Commit 26d9b67a authored by fallenstardust's avatar fallenstardust

sync ocgcore

parent 8df34f94
...@@ -28,6 +28,28 @@ bool card_state::is_location(int32 loc) const { ...@@ -28,6 +28,28 @@ bool card_state::is_location(int32 loc) const {
return true; return true;
return false; return false;
} }
void card_state::init_state() {
code = 0xffffffff;
code2 = 0xffffffff;
type = 0xffffffff;
level = 0xffffffff;
rank = 0xffffffff;
link = 0xffffffff;
lscale = 0xffffffff;
rscale = 0xffffffff;
attribute = 0xffffffff;
race = 0xffffffff;
attack = 0xffffffff;
defense = 0xffffffff;
base_attack = 0xffffffff;
base_defense = 0xffffffff;
controler = 0xff;
location = 0xff;
sequence = 0xff;
position = 0xff;
reason = 0xffffffff;
reason_player = 0xff;
}
bool card::card_operation_sort(card* c1, card* c2) { bool card::card_operation_sort(card* c1, card* c2) {
duel* pduel = c1->pduel; duel* pduel = c1->pduel;
int32 cp1 = c1->overlay_target ? c1->overlay_target->current.controler : c1->current.controler; int32 cp1 = c1->overlay_target ? c1->overlay_target->current.controler : c1->current.controler;
...@@ -87,9 +109,9 @@ card::card(duel* pd) { ...@@ -87,9 +109,9 @@ card::card(duel* pd) {
equiping_target = 0; equiping_target = 0;
pre_equip_target = 0; pre_equip_target = 0;
overlay_target = 0; overlay_target = 0;
std::memset(&current, 0, sizeof(card_state)); current = {};
std::memset(&previous, 0, sizeof(card_state)); previous = {};
std::memset(&temp, 0xff, sizeof(card_state)); temp.init_state();
unique_pos[0] = unique_pos[1] = 0; unique_pos[0] = unique_pos[1] = 0;
spsummon_counter[0] = spsummon_counter[1] = 0; spsummon_counter[0] = spsummon_counter[1] = 0;
unique_code = 0; unique_code = 0;
...@@ -380,9 +402,10 @@ int32 card::is_pre_set_card(uint32 set_code) { ...@@ -380,9 +402,10 @@ int32 card::is_pre_set_card(uint32 set_code) {
setcode = setcode >> 16; setcode = setcode >> 16;
} }
//add set code //add set code
setcode = previous.setcode; for(auto& presetcode : previous.setcode) {
if (setcode && (setcode & 0xfff) == settype && (setcode & 0xf000 & setsubtype) == setsubtype) if (presetcode && (presetcode & 0xfff) == settype && (presetcode & 0xf000 & setsubtype) == setsubtype)
return TRUE; return TRUE;
}
//another code //another code
uint32 code2 = previous.code2; uint32 code2 = previous.code2;
uint64 setcode2; uint64 setcode2;
...@@ -1575,7 +1598,7 @@ int32 card::add_effect(effect* peffect) { ...@@ -1575,7 +1598,7 @@ int32 card::add_effect(effect* peffect) {
if (peffect->type & EFFECT_TYPE_SINGLE && !peffect->is_flag(EFFECT_FLAG_SINGLE_RANGE) && peffect->owner == this if (peffect->type & EFFECT_TYPE_SINGLE && !peffect->is_flag(EFFECT_FLAG_SINGLE_RANGE) && peffect->owner == this
&& get_status(STATUS_DISABLED) && (peffect->reset_flag & RESET_DISABLE)) && get_status(STATUS_DISABLED) && (peffect->reset_flag & RESET_DISABLE))
return 0; return 0;
if (!(peffect->type & EFFECT_TYPE_CONTINUOUS) && is_continuous_event(peffect->code)) if (peffect->type & EFFECT_TYPES_TRIGGER_LIKE && is_continuous_event(peffect->code))
return 0; return 0;
// the trigger effect in phase is "once per turn" by default // the trigger effect in phase is "once per turn" by default
if (peffect->get_code_type() == CODE_PHASE && peffect->code & (PHASE_DRAW | PHASE_STANDBY | PHASE_END) && peffect->type & (EFFECT_TYPE_TRIGGER_O | EFFECT_TYPE_TRIGGER_F) if (peffect->get_code_type() == CODE_PHASE && peffect->code & (PHASE_DRAW | PHASE_STANDBY | PHASE_END) && peffect->type & (EFFECT_TYPE_TRIGGER_O | EFFECT_TYPE_TRIGGER_F)
......
...@@ -41,12 +41,12 @@ struct card_data { ...@@ -41,12 +41,12 @@ struct card_data {
struct card_state { struct card_state {
card_state() card_state()
: code(0), code2(0), setcode(0), type(0), level(0), rank(0), link(0), lscale(0), rscale(0), attribute(0), race(0), attack(0), defense(0), base_attack(0), base_defense(0), : code(0), code2(0), type(0), level(0), rank(0), link(0), lscale(0), rscale(0), attribute(0), race(0), attack(0), defense(0), base_attack(0), base_defense(0),
controler(PLAYER_NONE), location(0), sequence(0), position(0), reason(0), pzone(false), reason_card(nullptr), reason_player(PLAYER_NONE), reason_effect(nullptr) {} controler(PLAYER_NONE), location(0), sequence(0), position(0), reason(0), pzone(false), reason_card(nullptr), reason_player(PLAYER_NONE), reason_effect(nullptr) {}
uint32 code; uint32 code;
uint32 code2; uint32 code2;
uint16 setcode; std::vector<uint32> setcode;
uint32 type; uint32 type;
uint32 level; uint32 level;
uint32 rank; uint32 rank;
...@@ -69,6 +69,7 @@ struct card_state { ...@@ -69,6 +69,7 @@ struct card_state {
uint8 reason_player; uint8 reason_player;
effect* reason_effect; effect* reason_effect;
bool is_location(int32 loc) const; bool is_location(int32 loc) const;
void init_state();
}; };
struct query_cache { struct query_cache {
......
...@@ -166,6 +166,8 @@ public: ...@@ -166,6 +166,8 @@ public:
#define EFFECT_TYPE_GRANT 0x2000 // #define EFFECT_TYPE_GRANT 0x2000 //
#define EFFECT_TYPE_TARGET 0x4000 // #define EFFECT_TYPE_TARGET 0x4000 //
#define EFFECT_TYPES_TRIGGER_LIKE (EFFECT_TYPE_ACTIVATE | EFFECT_TYPE_TRIGGER_O | EFFECT_TYPE_TRIGGER_F | EFFECT_TYPE_QUICK_O | EFFECT_TYPE_QUICK_F)
//========== Flags ========== //========== Flags ==========
enum effect_flag : uint32 { enum effect_flag : uint32 {
EFFECT_FLAG_INITIAL = 0x0001, EFFECT_FLAG_INITIAL = 0x0001,
...@@ -466,7 +468,7 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2) ...@@ -466,7 +468,7 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2)
#define EFFECT_ACTIVATION_COUNT_LIMIT 367 #define EFFECT_ACTIVATION_COUNT_LIMIT 367
#define EFFECT_LIMIT_SPECIAL_SUMMON_POSITION 368 #define EFFECT_LIMIT_SPECIAL_SUMMON_POSITION 368
#define EVENT_STARTUP 1000 //#define EVENT_STARTUP 1000
#define EVENT_FLIP 1001 #define EVENT_FLIP 1001
#define EVENT_FREE_CHAIN 1002 #define EVENT_FREE_CHAIN 1002
#define EVENT_DESTROY 1010 #define EVENT_DESTROY 1010
...@@ -543,7 +545,7 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2) ...@@ -543,7 +545,7 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2)
#define DOUBLE_DAMAGE 0x80000000 #define DOUBLE_DAMAGE 0x80000000
#define HALF_DAMAGE 0x80000001 #define HALF_DAMAGE 0x80000001
// The type of bit field in code // The type of event in code
#define CODE_CUSTOM 1 // header + id (28 bits) #define CODE_CUSTOM 1 // header + id (28 bits)
#define CODE_COUNTER 2 // header + counter_id (16 bits) #define CODE_COUNTER 2 // header + counter_id (16 bits)
#define CODE_PHASE 3 // header + phase_id (12 bits) #define CODE_PHASE 3 // header + phase_id (12 bits)
......
...@@ -3692,7 +3692,16 @@ int32 scriptlib::duel_select_field(lua_State* L) { ...@@ -3692,7 +3692,16 @@ int32 scriptlib::duel_select_field(lua_State* L) {
uint32 location1 = (uint32)lua_tointeger(L, 3); uint32 location1 = (uint32)lua_tointeger(L, 3);
uint32 location2 = (uint32)lua_tointeger(L, 4); uint32 location2 = (uint32)lua_tointeger(L, 4);
uint32 filter = (uint32)lua_tointeger(L, 5); uint32 filter = (uint32)lua_tointeger(L, 5);
uint16 type = PROCESSOR_SELECT_DISFIELD;
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
if(lua_gettop(L) >= 6) {
type = PROCESSOR_SELECT_PLACE;
uint32 code = (uint32)lua_tointeger(L, 6);
pduel->write_buffer8(MSG_HINT);
pduel->write_buffer8(HINT_SELECTMSG);
pduel->write_buffer8(playerid);
pduel->write_buffer32(code);
}
uint32 flag = 0xffffffff; uint32 flag = 0xffffffff;
if(location1 & LOCATION_MZONE) { if(location1 & LOCATION_MZONE) {
flag &= 0xffffffe0; flag &= 0xffffffe0;
...@@ -3710,7 +3719,7 @@ int32 scriptlib::duel_select_field(lua_State* L) { ...@@ -3710,7 +3719,7 @@ int32 scriptlib::duel_select_field(lua_State* L) {
flag &= 0xffffff9f; flag &= 0xffffff9f;
} }
flag |= filter | 0x00800080; flag |= filter | 0x00800080;
pduel->game_field->add_process(PROCESSOR_SELECT_DISFIELD, 0, 0, 0, playerid, flag, count); pduel->game_field->add_process(type, 0, 0, 0, playerid, flag, count);
return lua_yieldk(L, 0, (lua_KContext)pduel, [](lua_State* L, int32 status, lua_KContext ctx) { return lua_yieldk(L, 0, (lua_KContext)pduel, [](lua_State* L, int32 status, lua_KContext ctx) {
duel* pduel = (duel*)ctx; duel* pduel = (duel*)ctx;
int32 playerid = (int32)lua_tointeger(L, 1); int32 playerid = (int32)lua_tointeger(L, 1);
......
...@@ -18,7 +18,7 @@ int32 field::negate_chain(uint8 chaincount) { ...@@ -18,7 +18,7 @@ int32 field::negate_chain(uint8 chaincount) {
if(chaincount > core.current_chain.size() || chaincount < 1) if(chaincount > core.current_chain.size() || chaincount < 1)
chaincount = (uint8)core.current_chain.size(); chaincount = (uint8)core.current_chain.size();
chain& pchain = core.current_chain[chaincount - 1]; chain& pchain = core.current_chain[chaincount - 1];
card* phandler = pchain.triggering_effect->handler; card* phandler = pchain.triggering_effect->get_handler();
if(!(pchain.flag & CHAIN_DISABLE_ACTIVATE) && is_chain_negatable(pchain.chain_count) if(!(pchain.flag & CHAIN_DISABLE_ACTIVATE) && is_chain_negatable(pchain.chain_count)
&& (!phandler->is_has_relation(pchain) || phandler->is_affect_by_effect(core.reason_effect))) { && (!phandler->is_has_relation(pchain) || phandler->is_affect_by_effect(core.reason_effect))) {
pchain.flag |= CHAIN_DISABLE_ACTIVATE; pchain.flag |= CHAIN_DISABLE_ACTIVATE;
...@@ -43,7 +43,7 @@ int32 field::disable_chain(uint8 chaincount, uint8 forced) { ...@@ -43,7 +43,7 @@ int32 field::disable_chain(uint8 chaincount, uint8 forced) {
if(chaincount > core.current_chain.size() || chaincount < 1) if(chaincount > core.current_chain.size() || chaincount < 1)
chaincount = (uint8)core.current_chain.size(); chaincount = (uint8)core.current_chain.size();
chain& pchain = core.current_chain[chaincount - 1]; chain& pchain = core.current_chain[chaincount - 1];
card* phandler = pchain.triggering_effect->handler; card* phandler = pchain.triggering_effect->get_handler();
if(!(pchain.flag & CHAIN_DISABLE_EFFECT) && is_chain_disablable(pchain.chain_count) if(!(pchain.flag & CHAIN_DISABLE_EFFECT) && is_chain_disablable(pchain.chain_count)
&& (!phandler->is_has_relation(pchain) || phandler->is_affect_by_effect(core.reason_effect)) && (!phandler->is_has_relation(pchain) || phandler->is_affect_by_effect(core.reason_effect))
&& !(phandler->is_has_relation(pchain) && phandler->is_status(STATUS_DISABLED) && !forced)) { && !(phandler->is_has_relation(pchain) && phandler->is_status(STATUS_DISABLED) && !forced)) {
...@@ -3865,12 +3865,12 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -3865,12 +3865,12 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
pcard->previous.attack = pcard->data.attack; pcard->previous.attack = pcard->data.attack;
pcard->previous.defense = pcard->data.defense; pcard->previous.defense = pcard->data.defense;
} }
pcard->previous.setcode.clear();
effect_set eset; effect_set eset;
pcard->filter_effect(EFFECT_ADD_SETCODE, &eset); pcard->filter_effect(EFFECT_ADD_SETCODE, &eset);
if(eset.size()) for(int32 i = 0; i < eset.size(); ++i) {
pcard->previous.setcode = eset.get_last()->get_value(pcard); pcard->previous.setcode.push_back((uint32)eset[i]->get_value(pcard));
else }
pcard->previous.setcode = 0;
} }
} }
if(leave_p.size()) if(leave_p.size())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment