Commit f9ab9561 authored by VanillaSalt's avatar VanillaSalt

update

parent 0b4dded6
This diff is collapsed.
This diff is collapsed.
...@@ -24,6 +24,8 @@ class effect; ...@@ -24,6 +24,8 @@ class effect;
struct tevent; struct tevent;
struct effect_set; struct effect_set;
struct effect_set_v; struct effect_set_v;
enum effect_flag;
enum effect_flag2;
class effect { class effect {
public: public:
...@@ -35,7 +37,7 @@ public: ...@@ -35,7 +37,7 @@ public:
uint8 effect_owner; uint8 effect_owner;
uint32 description; uint32 description;
uint32 code; uint32 code;
uint32 flag; uint32 flag[2];
uint32 id; uint32 id;
uint16 type; uint16 type;
uint16 copy_id; uint16 copy_id;
...@@ -86,6 +88,12 @@ public: ...@@ -86,6 +88,12 @@ public:
uint8 get_owner_player(); uint8 get_owner_player();
uint8 get_handler_player(); uint8 get_handler_player();
int32 in_range(int32 loc, int32 seq); int32 in_range(int32 loc, int32 seq);
bool is_flag(effect_flag flag) const {
return !!(this->flag[0] & flag);
}
bool is_flag(effect_flag2 flag) const {
return !!(this->flag[1] & flag);
}
}; };
//special cards //special cards
...@@ -144,38 +152,48 @@ public: ...@@ -144,38 +152,48 @@ public:
#define EFFECT_TYPE_CONTINUOUS 0x0800 // #define EFFECT_TYPE_CONTINUOUS 0x0800 //
//========== Flags ========== //========== Flags ==========
#define EFFECT_FLAG_INITIAL 0x0001 // enum effect_flag {
#define EFFECT_FLAG_FUNC_VALUE 0x0002 // EFFECT_FLAG_INITIAL = 0x0001,
#define EFFECT_FLAG_COUNT_LIMIT 0x0004 // EFFECT_FLAG_FUNC_VALUE = 0x0002,
#define EFFECT_FLAG_FIELD_ONLY 0x0008 // EFFECT_FLAG_COUNT_LIMIT = 0x0004,
#define EFFECT_FLAG_CARD_TARGET 0x0010 // EFFECT_FLAG_FIELD_ONLY = 0x0008,
#define EFFECT_FLAG_IGNORE_RANGE 0x0020 // EFFECT_FLAG_CARD_TARGET = 0x0010,
#define EFFECT_FLAG_ABSOLUTE_TARGET 0x0040 // EFFECT_FLAG_IGNORE_RANGE = 0x0020,
#define EFFECT_FLAG_IGNORE_IMMUNE 0x0080 // EFFECT_FLAG_ABSOLUTE_TARGET = 0x0040,
#define EFFECT_FLAG_SET_AVAILABLE 0x0100 // EFFECT_FLAG_IGNORE_IMMUNE = 0x0080,
#define EFFECT_FLAG_CONTINUOUS 0x0200 // EFFECT_FLAG_SET_AVAILABLE = 0x0100,
#define EFFECT_FLAG_CANNOT_DISABLE 0x0400 // EFFECT_FLAG_CONTINUOUS = 0x0200,
#define EFFECT_FLAG_PLAYER_TARGET 0x0800 // EFFECT_FLAG_CANNOT_DISABLE = 0x0400,
#define EFFECT_FLAG_BOTH_SIDE 0x1000 // EFFECT_FLAG_PLAYER_TARGET = 0x0800,
#define EFFECT_FLAG_COPY_INHERIT 0x2000 // EFFECT_FLAG_BOTH_SIDE = 0x1000,
#define EFFECT_FLAG_DAMAGE_STEP 0x4000 // EFFECT_FLAG_COPY_INHERIT = 0x2000,
#define EFFECT_FLAG_DAMAGE_CAL 0x8000 // EFFECT_FLAG_DAMAGE_STEP = 0x4000,
#define EFFECT_FLAG_DELAY 0x10000 // EFFECT_FLAG_DAMAGE_CAL = 0x8000,
#define EFFECT_FLAG_SINGLE_RANGE 0x20000 // EFFECT_FLAG_DELAY = 0x10000,
#define EFFECT_FLAG_UNCOPYABLE 0x40000 // EFFECT_FLAG_SINGLE_RANGE = 0x20000,
#define EFFECT_FLAG_OATH 0x80000 // EFFECT_FLAG_UNCOPYABLE = 0x40000,
#define EFFECT_FLAG_SPSUM_PARAM 0x100000 // EFFECT_FLAG_OATH = 0x80000,
#define EFFECT_FLAG_REPEAT 0x200000 // EFFECT_FLAG_SPSUM_PARAM = 0x100000,
#define EFFECT_FLAG_NO_TURN_RESET 0x400000 // EFFECT_FLAG_REPEAT = 0x200000,
#define EFFECT_FLAG_EVENT_PLAYER 0x800000 // EFFECT_FLAG_NO_TURN_RESET = 0x400000,
#define EFFECT_FLAG_OWNER_RELATE 0x1000000 // EFFECT_FLAG_EVENT_PLAYER = 0x800000,
#define EFFECT_FLAG_AVAILABLE_BD 0x2000000 // EFFECT_FLAG_OWNER_RELATE = 0x1000000,
#define EFFECT_FLAG_CLIENT_HINT 0x4000000 // EFFECT_FLAG_AVAILABLE_BD = 0x2000000,
#define EFFECT_FLAG_CHAIN_UNIQUE 0x8000000 // EFFECT_FLAG_CLIENT_HINT = 0x4000000,
#define EFFECT_FLAG_NAGA 0x10000000 // EFFECT_FLAG_CHAIN_UNIQUE = 0x8000000,
#define EFFECT_FLAG_COF 0x20000000 // // EFFECT_FLAG_NAGA = 0x10000000,
#define EFFECT_FLAG_CVAL_CHECK 0x40000000 // // EFFECT_FLAG_COF = 0x20000000,
#define EFFECT_FLAG_IMMEDIATELY_APPLY 0x80000000 // EFFECT_FLAG_CVAL_CHECK = 0x40000000,
EFFECT_FLAG_IMMEDIATELY_APPLY = 0x80000000,
};
enum effect_flag2 {
EFFECT_FLAG2_NAGA = 0x0001,
EFFECT_FLAG2_COF = 0x0002,
};
inline effect_flag operator|(effect_flag flag1, effect_flag flag2)
{
return static_cast<effect_flag>(static_cast<uint32>(flag1) | static_cast<uint32>(flag2));
}
//========== Codes ========== //========== Codes ==========
#define EFFECT_IMMUNE_EFFECT 1 // #define EFFECT_IMMUNE_EFFECT 1 //
#define EFFECT_DISABLE 2 // #define EFFECT_DISABLE 2 //
......
...@@ -397,7 +397,7 @@ void field::set_control(card* pcard, uint8 playerid, uint16 reset_phase, uint8 r ...@@ -397,7 +397,7 @@ void field::set_control(card* pcard, uint8 playerid, uint16 reset_phase, uint8 r
peffect->type = EFFECT_TYPE_SINGLE; peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_SET_CONTROL; peffect->code = EFFECT_SET_CONTROL;
peffect->value = playerid; peffect->value = playerid;
peffect->flag = EFFECT_FLAG_CANNOT_DISABLE; peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT | 0xc6c0000; peffect->reset_flag = RESET_EVENT | 0xc6c0000;
if(reset_count) { if(reset_count) {
peffect->reset_flag |= RESET_PHASE | reset_phase; peffect->reset_flag |= RESET_PHASE | reset_phase;
...@@ -709,7 +709,7 @@ void field::tag_swap(uint8 playerid) { ...@@ -709,7 +709,7 @@ void field::tag_swap(uint8 playerid) {
} }
void field::add_effect(effect* peffect, uint8 owner_player) { void field::add_effect(effect* peffect, uint8 owner_player) {
if (!peffect->handler) { if (!peffect->handler) {
peffect->flag |= EFFECT_FLAG_FIELD_ONLY; peffect->flag[0] |= EFFECT_FLAG_FIELD_ONLY;
peffect->handler = peffect->owner; peffect->handler = peffect->owner;
peffect->effect_owner = owner_player; peffect->effect_owner = owner_player;
peffect->id = infos.field_id++; peffect->id = infos.field_id++;
...@@ -740,14 +740,14 @@ void field::add_effect(effect* peffect, uint8 owner_player) { ...@@ -740,14 +740,14 @@ void field::add_effect(effect* peffect, uint8 owner_player) {
it = effects.continuous_effect.insert(make_pair(peffect->code, peffect)); it = effects.continuous_effect.insert(make_pair(peffect->code, peffect));
} }
effects.indexer.insert(make_pair(peffect, it)); effects.indexer.insert(make_pair(peffect, it));
if((peffect->flag & EFFECT_FLAG_FIELD_ONLY)) { if((peffect->is_flag(EFFECT_FLAG_FIELD_ONLY))) {
if(peffect->flag & EFFECT_FLAG_OATH) if(peffect->is_flag(EFFECT_FLAG_OATH))
effects.oath.insert(make_pair(peffect, core.reason_effect)); effects.oath.insert(make_pair(peffect, core.reason_effect));
if(peffect->reset_flag & RESET_PHASE) if(peffect->reset_flag & RESET_PHASE)
effects.pheff.insert(peffect); effects.pheff.insert(peffect);
if(peffect->reset_flag & RESET_CHAIN) if(peffect->reset_flag & RESET_CHAIN)
effects.cheff.insert(peffect); effects.cheff.insert(peffect);
if(peffect->flag & EFFECT_FLAG_COUNT_LIMIT) if(peffect->is_flag(EFFECT_FLAG_COUNT_LIMIT))
effects.rechargeable.insert(peffect); effects.rechargeable.insert(peffect);
} }
} }
...@@ -777,14 +777,14 @@ void field::remove_effect(effect* peffect) { ...@@ -777,14 +777,14 @@ void field::remove_effect(effect* peffect) {
effects.continuous_effect.erase(it); effects.continuous_effect.erase(it);
} }
effects.indexer.erase(peffect); effects.indexer.erase(peffect);
if((peffect->flag & EFFECT_FLAG_FIELD_ONLY)) { if((peffect->is_flag(EFFECT_FLAG_FIELD_ONLY))) {
if(peffect->flag & EFFECT_FLAG_OATH) if(peffect->is_flag(EFFECT_FLAG_OATH))
effects.oath.erase(peffect); effects.oath.erase(peffect);
if(peffect->reset_flag & RESET_PHASE) if(peffect->reset_flag & RESET_PHASE)
effects.pheff.erase(peffect); effects.pheff.erase(peffect);
if(peffect->reset_flag & RESET_CHAIN) if(peffect->reset_flag & RESET_CHAIN)
effects.cheff.erase(peffect); effects.cheff.erase(peffect);
if(peffect->flag & EFFECT_FLAG_COUNT_LIMIT) if(peffect->is_flag(EFFECT_FLAG_COUNT_LIMIT))
effects.rechargeable.erase(peffect); effects.rechargeable.erase(peffect);
core.reseted_effects.insert(peffect); core.reseted_effects.insert(peffect);
} }
...@@ -795,7 +795,7 @@ void field::remove_oath_effect(effect* reason_effect) { ...@@ -795,7 +795,7 @@ void field::remove_oath_effect(effect* reason_effect) {
if(rm->second == reason_effect) { if(rm->second == reason_effect) {
effect* peffect = rm->first; effect* peffect = rm->first;
effects.oath.erase(rm); effects.oath.erase(rm);
if(peffect->flag & EFFECT_FLAG_FIELD_ONLY) if(peffect->is_flag(EFFECT_FLAG_FIELD_ONLY))
remove_effect(peffect); remove_effect(peffect);
else else
peffect->handler->remove_effect(peffect); peffect->handler->remove_effect(peffect);
...@@ -808,7 +808,7 @@ void field::reset_effect(uint32 id, uint32 reset_type) { ...@@ -808,7 +808,7 @@ void field::reset_effect(uint32 id, uint32 reset_type) {
auto rm = it++; auto rm = it++;
auto peffect = rm->first; auto peffect = rm->first;
auto pit = rm->second; auto pit = rm->second;
if (!(peffect->flag & EFFECT_FLAG_FIELD_ONLY)) if (!(peffect->is_flag(EFFECT_FLAG_FIELD_ONLY)))
continue; continue;
result = peffect->reset(id, reset_type); result = peffect->reset(id, reset_type);
if (result) { if (result) {
...@@ -841,7 +841,7 @@ void field::reset_phase(uint32 phase) { ...@@ -841,7 +841,7 @@ void field::reset_phase(uint32 phase) {
for(auto eit = effects.pheff.begin(); eit != effects.pheff.end();) { for(auto eit = effects.pheff.begin(); eit != effects.pheff.end();) {
auto rm = eit++; auto rm = eit++;
if((*rm)->reset(phase, RESET_PHASE)) { if((*rm)->reset(phase, RESET_PHASE)) {
if((*rm)->flag & EFFECT_FLAG_FIELD_ONLY) if((*rm)->is_flag(EFFECT_FLAG_FIELD_ONLY))
remove_effect((*rm)); remove_effect((*rm));
else else
(*rm)->handler->remove_effect((*rm)); (*rm)->handler->remove_effect((*rm));
...@@ -851,7 +851,7 @@ void field::reset_phase(uint32 phase) { ...@@ -851,7 +851,7 @@ void field::reset_phase(uint32 phase) {
void field::reset_chain() { void field::reset_chain() {
for(auto eit = effects.cheff.begin(); eit != effects.cheff.end();) { for(auto eit = effects.cheff.begin(); eit != effects.cheff.end();) {
auto rm = eit++; auto rm = eit++;
if((*rm)->flag & EFFECT_FLAG_FIELD_ONLY) if((*rm)->is_flag(EFFECT_FLAG_FIELD_ONLY))
remove_effect((*rm)); remove_effect((*rm));
else else
(*rm)->handler->remove_effect((*rm)); (*rm)->handler->remove_effect((*rm));
...@@ -889,7 +889,7 @@ void field::filter_field_effect(uint32 code, effect_set* eset, uint8 sort) { ...@@ -889,7 +889,7 @@ void field::filter_field_effect(uint32 code, effect_set* eset, uint8 sort) {
eset->sort(); eset->sort();
} }
void field::filter_affected_cards(effect* peffect, card_set* cset) { void field::filter_affected_cards(effect* peffect, card_set* cset) {
if ((peffect->type & EFFECT_TYPE_ACTIONS) || !(peffect->type & EFFECT_TYPE_FIELD) || (peffect->flag & EFFECT_FLAG_PLAYER_TARGET)) if ((peffect->type & EFFECT_TYPE_ACTIONS) || !(peffect->type & EFFECT_TYPE_FIELD) || (peffect->is_flag(EFFECT_FLAG_PLAYER_TARGET)))
return; return;
uint8 self = peffect->get_handler_player(); uint8 self = peffect->get_handler_player();
if(self == PLAYER_NONE) if(self == PLAYER_NONE)
...@@ -1252,7 +1252,7 @@ int32 field::get_summon_release_list(card* target, card_set* release_list, card_ ...@@ -1252,7 +1252,7 @@ int32 field::get_summon_release_list(card* target, card_set* release_list, card_
rcount += pcard->operation_param; rcount += pcard->operation_param;
} else { } else {
effect* peffect = pcard->is_affected_by_effect(EFFECT_EXTRA_RELEASE_SUM); effect* peffect = pcard->is_affected_by_effect(EFFECT_EXTRA_RELEASE_SUM);
if(!peffect || ((peffect->flag & EFFECT_FLAG_COUNT_LIMIT) && (peffect->reset_count & 0xf00) == 0)) if(!peffect || ((peffect->is_flag(EFFECT_FLAG_COUNT_LIMIT)) && (peffect->reset_count & 0xf00) == 0))
continue; continue;
if(ex_list_sum) if(ex_list_sum)
ex_list_sum->insert(pcard); ex_list_sum->insert(pcard);
...@@ -2236,9 +2236,9 @@ int32 field::is_chain_negatable(uint8 chaincount, uint8 naga_check) { ...@@ -2236,9 +2236,9 @@ int32 field::is_chain_negatable(uint8 chaincount, uint8 naga_check) {
peffect = core.current_chain.back().triggering_effect; peffect = core.current_chain.back().triggering_effect;
else else
peffect = core.current_chain[chaincount - 1].triggering_effect; peffect = core.current_chain[chaincount - 1].triggering_effect;
if(naga_check && peffect->flag & EFFECT_FLAG_NAGA) if(naga_check && peffect->is_flag(EFFECT_FLAG2_NAGA))
return FALSE; return FALSE;
if(peffect->flag & EFFECT_FLAG_CANNOT_DISABLE) if(peffect->is_flag(EFFECT_FLAG_CANNOT_DISABLE))
return FALSE; return FALSE;
filter_field_effect(EFFECT_CANNOT_INACTIVATE, &eset); filter_field_effect(EFFECT_CANNOT_INACTIVATE, &eset);
for(int32 i = 0; i < eset.size(); ++i) { for(int32 i = 0; i < eset.size(); ++i) {
...@@ -2257,9 +2257,9 @@ int32 field::is_chain_disablable(uint8 chaincount, uint8 naga_check) { ...@@ -2257,9 +2257,9 @@ int32 field::is_chain_disablable(uint8 chaincount, uint8 naga_check) {
peffect = core.current_chain.back().triggering_effect; peffect = core.current_chain.back().triggering_effect;
else else
peffect = core.current_chain[chaincount - 1].triggering_effect; peffect = core.current_chain[chaincount - 1].triggering_effect;
if(naga_check && peffect->flag & EFFECT_FLAG_NAGA) if(naga_check && peffect->is_flag(EFFECT_FLAG2_NAGA))
return FALSE; return FALSE;
if(peffect->flag & EFFECT_FLAG_CANNOT_DISABLE) if(peffect->is_flag(EFFECT_FLAG_CANNOT_DISABLE))
return FALSE; return FALSE;
filter_field_effect(EFFECT_CANNOT_DISEFFECT, &eset); filter_field_effect(EFFECT_CANNOT_DISEFFECT, &eset);
for(int32 i = 0; i < eset.size(); ++i) { for(int32 i = 0; i < eset.size(); ++i) {
...@@ -2279,7 +2279,7 @@ int32 field::check_chain_target(uint8 chaincount, card * pcard) { ...@@ -2279,7 +2279,7 @@ int32 field::check_chain_target(uint8 chaincount, card * pcard) {
pchain = &core.current_chain[chaincount - 1]; pchain = &core.current_chain[chaincount - 1];
effect* peffect = pchain->triggering_effect; effect* peffect = pchain->triggering_effect;
uint8 tp = pchain->triggering_player; uint8 tp = pchain->triggering_player;
if(!(peffect->flag & EFFECT_FLAG_CARD_TARGET) || !peffect->target) if(!(peffect->is_flag(EFFECT_FLAG_CARD_TARGET)) || !peffect->target)
return FALSE; return FALSE;
if(!pcard->is_capable_be_effect_target(peffect, tp)) if(!pcard->is_capable_be_effect_target(peffect, tp))
return false; return false;
......
...@@ -603,7 +603,7 @@ void interpreter::unregister_effect(effect *peffect) { ...@@ -603,7 +603,7 @@ void interpreter::unregister_effect(effect *peffect) {
luaL_unref(lua_state, LUA_REGISTRYINDEX, peffect->target); luaL_unref(lua_state, LUA_REGISTRYINDEX, peffect->target);
if(peffect->operation) if(peffect->operation)
luaL_unref(lua_state, LUA_REGISTRYINDEX, peffect->operation); luaL_unref(lua_state, LUA_REGISTRYINDEX, peffect->operation);
if(peffect->value && (peffect->flag & EFFECT_FLAG_FUNC_VALUE)) if(peffect->value && (peffect->is_flag(EFFECT_FLAG_FUNC_VALUE)))
luaL_unref(lua_state, LUA_REGISTRYINDEX, peffect->value); luaL_unref(lua_state, LUA_REGISTRYINDEX, peffect->value);
luaL_unref(lua_state, LUA_REGISTRYINDEX, peffect->ref_handle); luaL_unref(lua_state, LUA_REGISTRYINDEX, peffect->ref_handle);
peffect->ref_handle = 0; peffect->ref_handle = 0;
......
...@@ -591,7 +591,7 @@ int32 scriptlib::card_enable_dual_state(lua_State *L) { ...@@ -591,7 +591,7 @@ int32 scriptlib::card_enable_dual_state(lua_State *L) {
deffect->owner = pcard; deffect->owner = pcard;
deffect->code = EFFECT_DUAL_STATUS; deffect->code = EFFECT_DUAL_STATUS;
deffect->type = EFFECT_TYPE_SINGLE; deffect->type = EFFECT_TYPE_SINGLE;
deffect->flag = EFFECT_FLAG_CANNOT_DISABLE; deffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
deffect->reset_flag = RESET_EVENT + 0x1fe0000; deffect->reset_flag = RESET_EVENT + 0x1fe0000;
pcard->add_effect(deffect); pcard->add_effect(deffect);
return 0; return 0;
...@@ -987,7 +987,7 @@ int32 scriptlib::card_register_flag_effect(lua_State *L) { ...@@ -987,7 +987,7 @@ int32 scriptlib::card_register_flag_effect(lua_State *L) {
peffect->type = EFFECT_TYPE_SINGLE; peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = code; peffect->code = code;
peffect->reset_flag = reset; peffect->reset_flag = reset;
peffect->flag = flag | EFFECT_FLAG_CANNOT_DISABLE; peffect->flag[0] = flag | EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_count |= count & 0xff; peffect->reset_count |= count & 0xff;
peffect->label = lab; peffect->label = lab;
peffect->description = desc; peffect->description = desc;
...@@ -1141,7 +1141,7 @@ int32 scriptlib::card_enable_unsummonable(lua_State *L) { ...@@ -1141,7 +1141,7 @@ int32 scriptlib::card_enable_unsummonable(lua_State *L) {
peffect->owner = pcard; peffect->owner = pcard;
peffect->code = EFFECT_UNSUMMONABLE_CARD; peffect->code = EFFECT_UNSUMMONABLE_CARD;
peffect->type = EFFECT_TYPE_SINGLE; peffect->type = EFFECT_TYPE_SINGLE;
peffect->flag = EFFECT_FLAG_CANNOT_DISABLE | EFFECT_FLAG_UNCOPYABLE; peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE | EFFECT_FLAG_UNCOPYABLE;
pcard->add_effect(peffect); pcard->add_effect(peffect);
} }
return 0; return 0;
...@@ -1156,13 +1156,13 @@ int32 scriptlib::card_enable_revive_limit(lua_State *L) { ...@@ -1156,13 +1156,13 @@ int32 scriptlib::card_enable_revive_limit(lua_State *L) {
peffect1->owner = pcard; peffect1->owner = pcard;
peffect1->code = EFFECT_UNSUMMONABLE_CARD; peffect1->code = EFFECT_UNSUMMONABLE_CARD;
peffect1->type = EFFECT_TYPE_SINGLE; peffect1->type = EFFECT_TYPE_SINGLE;
peffect1->flag = EFFECT_FLAG_CANNOT_DISABLE | EFFECT_FLAG_UNCOPYABLE; peffect1->flag[0] = EFFECT_FLAG_CANNOT_DISABLE | EFFECT_FLAG_UNCOPYABLE;
pcard->add_effect(peffect1); pcard->add_effect(peffect1);
effect* peffect2 = pduel->new_effect(); effect* peffect2 = pduel->new_effect();
peffect2->owner = pcard; peffect2->owner = pcard;
peffect2->code = EFFECT_REVIVE_LIMIT; peffect2->code = EFFECT_REVIVE_LIMIT;
peffect2->type = EFFECT_TYPE_SINGLE; peffect2->type = EFFECT_TYPE_SINGLE;
peffect2->flag = EFFECT_FLAG_CANNOT_DISABLE | EFFECT_FLAG_UNCOPYABLE; peffect2->flag[0] = EFFECT_FLAG_CANNOT_DISABLE | EFFECT_FLAG_UNCOPYABLE;
pcard->add_effect(peffect2); pcard->add_effect(peffect2);
} }
return 0; return 0;
...@@ -1806,7 +1806,7 @@ int32 scriptlib::card_enable_counter_permit(lua_State *L) { ...@@ -1806,7 +1806,7 @@ int32 scriptlib::card_enable_counter_permit(lua_State *L) {
peffect->owner = pcard; peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE; peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_COUNTER_PERMIT | countertype; peffect->code = EFFECT_COUNTER_PERMIT | countertype;
peffect->flag = EFFECT_FLAG_SINGLE_RANGE; peffect->flag[0] = EFFECT_FLAG_SINGLE_RANGE;
peffect->range = prange; peffect->range = prange;
pcard->add_effect(peffect); pcard->add_effect(peffect);
return 0; return 0;
...@@ -1976,7 +1976,7 @@ int32 scriptlib::card_add_trap_monster_attribute(lua_State *L) { ...@@ -1976,7 +1976,7 @@ int32 scriptlib::card_add_trap_monster_attribute(lua_State *L) {
peffect->owner = pcard; peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE; peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_ADD_TYPE; peffect->code = EFFECT_ADD_TYPE;
peffect->flag = EFFECT_FLAG_CANNOT_DISABLE; peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x47e0000; peffect->reset_flag = RESET_EVENT + 0x47e0000;
peffect->value = TYPE_MONSTER | TYPE_TRAPMONSTER | extra_type; peffect->value = TYPE_MONSTER | TYPE_TRAPMONSTER | extra_type;
pcard->add_effect(peffect); pcard->add_effect(peffect);
...@@ -1985,7 +1985,7 @@ int32 scriptlib::card_add_trap_monster_attribute(lua_State *L) { ...@@ -1985,7 +1985,7 @@ int32 scriptlib::card_add_trap_monster_attribute(lua_State *L) {
peffect->owner = pcard; peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE; peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_ADD_ATTRIBUTE; peffect->code = EFFECT_ADD_ATTRIBUTE;
peffect->flag = EFFECT_FLAG_CANNOT_DISABLE; peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x47e0000; peffect->reset_flag = RESET_EVENT + 0x47e0000;
peffect->value = attribute; peffect->value = attribute;
pcard->add_effect(peffect); pcard->add_effect(peffect);
...@@ -1994,7 +1994,7 @@ int32 scriptlib::card_add_trap_monster_attribute(lua_State *L) { ...@@ -1994,7 +1994,7 @@ int32 scriptlib::card_add_trap_monster_attribute(lua_State *L) {
peffect->owner = pcard; peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE; peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_ADD_RACE; peffect->code = EFFECT_ADD_RACE;
peffect->flag = EFFECT_FLAG_CANNOT_DISABLE; peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x47e0000; peffect->reset_flag = RESET_EVENT + 0x47e0000;
peffect->value = race; peffect->value = race;
pcard->add_effect(peffect); pcard->add_effect(peffect);
...@@ -2003,7 +2003,7 @@ int32 scriptlib::card_add_trap_monster_attribute(lua_State *L) { ...@@ -2003,7 +2003,7 @@ int32 scriptlib::card_add_trap_monster_attribute(lua_State *L) {
peffect->owner = pcard; peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE; peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_CHANGE_LEVEL; peffect->code = EFFECT_CHANGE_LEVEL;
peffect->flag = EFFECT_FLAG_CANNOT_DISABLE; peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x47e0000; peffect->reset_flag = RESET_EVENT + 0x47e0000;
peffect->value = level; peffect->value = level;
pcard->add_effect(peffect); pcard->add_effect(peffect);
...@@ -2012,7 +2012,7 @@ int32 scriptlib::card_add_trap_monster_attribute(lua_State *L) { ...@@ -2012,7 +2012,7 @@ int32 scriptlib::card_add_trap_monster_attribute(lua_State *L) {
peffect->owner = pcard; peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE; peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_SET_BASE_ATTACK; peffect->code = EFFECT_SET_BASE_ATTACK;
peffect->flag = EFFECT_FLAG_CANNOT_DISABLE; peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x47e0000; peffect->reset_flag = RESET_EVENT + 0x47e0000;
peffect->value = atk; peffect->value = atk;
pcard->add_effect(peffect); pcard->add_effect(peffect);
...@@ -2021,7 +2021,7 @@ int32 scriptlib::card_add_trap_monster_attribute(lua_State *L) { ...@@ -2021,7 +2021,7 @@ int32 scriptlib::card_add_trap_monster_attribute(lua_State *L) {
peffect->owner = pcard; peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE; peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_SET_BASE_DEFENCE; peffect->code = EFFECT_SET_BASE_DEFENCE;
peffect->flag = EFFECT_FLAG_CANNOT_DISABLE; peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x47e0000; peffect->reset_flag = RESET_EVENT + 0x47e0000;
peffect->value = def; peffect->value = def;
pcard->add_effect(peffect); pcard->add_effect(peffect);
...@@ -2039,7 +2039,7 @@ int32 scriptlib::card_trap_monster_block(lua_State *L) { ...@@ -2039,7 +2039,7 @@ int32 scriptlib::card_trap_monster_block(lua_State *L) {
peffect->type = EFFECT_TYPE_FIELD; peffect->type = EFFECT_TYPE_FIELD;
peffect->range = LOCATION_MZONE; peffect->range = LOCATION_MZONE;
peffect->code = EFFECT_USE_EXTRA_SZONE; peffect->code = EFFECT_USE_EXTRA_SZONE;
peffect->flag = EFFECT_FLAG_CANNOT_DISABLE; peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x5fe0000; peffect->reset_flag = RESET_EVENT + 0x5fe0000;
peffect->value = 1 + (0x10000 << pcard->previous.sequence); peffect->value = 1 + (0x10000 << pcard->previous.sequence);
pcard->add_effect(peffect); pcard->add_effect(peffect);
...@@ -2136,7 +2136,7 @@ int32 scriptlib::card_set_unique_onfield(lua_State *L) { ...@@ -2136,7 +2136,7 @@ int32 scriptlib::card_set_unique_onfield(lua_State *L) {
peffect->owner = pcard; peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE; peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_UNIQUE_CHECK; peffect->code = EFFECT_UNIQUE_CHECK;
peffect->flag = EFFECT_FLAG_COPY_INHERIT; peffect->flag[0] = EFFECT_FLAG_COPY_INHERIT;
pcard->add_effect(peffect); pcard->add_effect(peffect);
pcard->unique_effect = peffect; pcard->unique_effect = peffect;
if(pcard->current.location & LOCATION_ONFIELD) if(pcard->current.location & LOCATION_ONFIELD)
......
...@@ -95,7 +95,7 @@ int32 scriptlib::duel_register_flag_effect(lua_State *L) { ...@@ -95,7 +95,7 @@ int32 scriptlib::duel_register_flag_effect(lua_State *L) {
peffect->type = EFFECT_TYPE_FIELD; peffect->type = EFFECT_TYPE_FIELD;
peffect->code = code; peffect->code = code;
peffect->reset_flag = reset; peffect->reset_flag = reset;
peffect->flag = flag | EFFECT_FLAG_CANNOT_DISABLE | EFFECT_FLAG_PLAYER_TARGET | EFFECT_FLAG_FIELD_ONLY; peffect->flag[0] = flag | EFFECT_FLAG_CANNOT_DISABLE | EFFECT_FLAG_PLAYER_TARGET | EFFECT_FLAG_FIELD_ONLY;
peffect->s_range = 1; peffect->s_range = 1;
peffect->o_range = 0; peffect->o_range = 0;
peffect->reset_count |= count & 0xff; peffect->reset_count |= count & 0xff;
...@@ -1521,7 +1521,7 @@ int32 scriptlib::duel_skip_phase(lua_State *L) { ...@@ -1521,7 +1521,7 @@ int32 scriptlib::duel_skip_phase(lua_State *L) {
peffect->type = EFFECT_TYPE_FIELD; peffect->type = EFFECT_TYPE_FIELD;
peffect->code = code; peffect->code = code;
peffect->reset_flag = (reset & 0xff) | RESET_PHASE | RESET_SELF_TURN; peffect->reset_flag = (reset & 0xff) | RESET_PHASE | RESET_SELF_TURN;
peffect->flag = EFFECT_FLAG_CANNOT_DISABLE | EFFECT_FLAG_PLAYER_TARGET; peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE | EFFECT_FLAG_PLAYER_TARGET;
peffect->s_range = 1; peffect->s_range = 1;
peffect->o_range = 0; peffect->o_range = 0;
peffect->reset_count |= count & 0xff; peffect->reset_count |= count & 0xff;
...@@ -2255,7 +2255,7 @@ int32 scriptlib::duel_set_target_card(lua_State *L) { ...@@ -2255,7 +2255,7 @@ int32 scriptlib::duel_set_target_card(lua_State *L) {
for(auto cit = pgroup->container.begin(); cit != pgroup->container.end(); ++cit) for(auto cit = pgroup->container.begin(); cit != pgroup->container.end(); ++cit)
(*cit)->create_relation(peffect); (*cit)->create_relation(peffect);
} }
if(peffect->flag & EFFECT_FLAG_CARD_TARGET) { if(peffect->is_flag(EFFECT_FLAG_CARD_TARGET)) {
if(pcard) { if(pcard) {
if(pcard->current.location & 0x30) if(pcard->current.location & 0x30)
pduel->game_field->move_card(pcard->current.controler, pcard, pcard->current.location, 0); pduel->game_field->move_card(pcard->current.controler, pcard, pcard->current.location, 0);
...@@ -3242,7 +3242,7 @@ int32 scriptlib::duel_venom_swamp_check(lua_State *L) { ...@@ -3242,7 +3242,7 @@ int32 scriptlib::duel_venom_swamp_check(lua_State *L) {
for (int32 i = 0; i < eset.size(); ++i) { for (int32 i = 0; i < eset.size(); ++i) {
switch (eset[i]->code) { switch (eset[i]->code) {
case EFFECT_UPDATE_ATTACK: { case EFFECT_UPDATE_ATTACK: {
if (eset[i]->type & EFFECT_TYPE_SINGLE && !(eset[i]->flag & EFFECT_FLAG_SINGLE_RANGE)) if (eset[i]->type & EFFECT_TYPE_SINGLE && !(eset[i]->is_flag(EFFECT_FLAG_SINGLE_RANGE)))
up += eset[i]->get_value(pcard); up += eset[i]->get_value(pcard);
else else
upc += eset[i]->get_value(pcard); upc += eset[i]->get_value(pcard);
...@@ -3252,11 +3252,11 @@ int32 scriptlib::duel_venom_swamp_check(lua_State *L) { ...@@ -3252,11 +3252,11 @@ int32 scriptlib::duel_venom_swamp_check(lua_State *L) {
} }
case EFFECT_SET_ATTACK: case EFFECT_SET_ATTACK:
base = eset[i]->get_value(pcard); base = eset[i]->get_value(pcard);
if (eset[i]->type & EFFECT_TYPE_SINGLE && !(eset[i]->flag & EFFECT_FLAG_SINGLE_RANGE)) if (eset[i]->type & EFFECT_TYPE_SINGLE && !(eset[i]->is_flag(EFFECT_FLAG_SINGLE_RANGE)))
up = 0; up = 0;
break; break;
case EFFECT_SET_ATTACK_FINAL: case EFFECT_SET_ATTACK_FINAL:
if (eset[i]->type & EFFECT_TYPE_SINGLE && !(eset[i]->flag & EFFECT_FLAG_SINGLE_RANGE)) { if (eset[i]->type & EFFECT_TYPE_SINGLE && !(eset[i]->is_flag(EFFECT_FLAG_SINGLE_RANGE))) {
base = eset[i]->get_value(pcard); base = eset[i]->get_value(pcard);
up = 0; up = 0;
upc = 0; upc = 0;
...@@ -3301,14 +3301,14 @@ int32 scriptlib::duel_majestic_copy(lua_State *L) { ...@@ -3301,14 +3301,14 @@ int32 scriptlib::duel_majestic_copy(lua_State *L) {
} }
effect* peffect = eit->second; effect* peffect = eit->second;
if(!(peffect->type & 0x7c)) continue; if(!(peffect->type & 0x7c)) continue;
if(!(peffect->flag & EFFECT_FLAG_INITIAL)) continue; if(!(peffect->is_flag(EFFECT_FLAG_INITIAL))) continue;
effect* ceffect = pduel->new_effect(); effect* ceffect = pduel->new_effect();
int32 ref = ceffect->ref_handle; int32 ref = ceffect->ref_handle;
*ceffect = *peffect; *ceffect = *peffect;
ceffect->ref_handle = ref; ceffect->ref_handle = ref;
ceffect->owner = pcard; ceffect->owner = pcard;
ceffect->handler = 0; ceffect->handler = 0;
ceffect->flag &= ~EFFECT_FLAG_INITIAL; ceffect->flag[0] &= ~EFFECT_FLAG_INITIAL;
ceffect->effect_owner = PLAYER_NONE; ceffect->effect_owner = PLAYER_NONE;
if(peffect->condition) { if(peffect->condition) {
lua_rawgeti(L, LUA_REGISTRYINDEX, peffect->condition); lua_rawgeti(L, LUA_REGISTRYINDEX, peffect->condition);
...@@ -3332,7 +3332,7 @@ int32 scriptlib::duel_majestic_copy(lua_State *L) { ...@@ -3332,7 +3332,7 @@ int32 scriptlib::duel_majestic_copy(lua_State *L) {
if(ceffect->type & EFFECT_TYPE_TRIGGER_F) { if(ceffect->type & EFFECT_TYPE_TRIGGER_F) {
ceffect->type &= ~EFFECT_TYPE_TRIGGER_F; ceffect->type &= ~EFFECT_TYPE_TRIGGER_F;
ceffect->type |= EFFECT_TYPE_TRIGGER_O; ceffect->type |= EFFECT_TYPE_TRIGGER_O;
ceffect->flag |= EFFECT_FLAG_DELAY; ceffect->flag[0] |= EFFECT_FLAG_DELAY;
} }
if(ceffect->type & EFFECT_TYPE_QUICK_F) { if(ceffect->type & EFFECT_TYPE_QUICK_F) {
ceffect->type &= ~EFFECT_TYPE_QUICK_F; ceffect->type &= ~EFFECT_TYPE_QUICK_F;
......
...@@ -57,7 +57,7 @@ int32 scriptlib::effect_clone(lua_State *L) { ...@@ -57,7 +57,7 @@ int32 scriptlib::effect_clone(lua_State *L) {
lua_rawgeti(L, LUA_REGISTRYINDEX, peffect->operation); lua_rawgeti(L, LUA_REGISTRYINDEX, peffect->operation);
ceffect->operation = luaL_ref(L, LUA_REGISTRYINDEX); ceffect->operation = luaL_ref(L, LUA_REGISTRYINDEX);
} }
if(peffect->value && (peffect->flag & EFFECT_FLAG_FUNC_VALUE)) { if(peffect->value && (peffect->is_flag(EFFECT_FLAG_FUNC_VALUE))) {
lua_rawgeti(L, LUA_REGISTRYINDEX, peffect->value); lua_rawgeti(L, LUA_REGISTRYINDEX, peffect->value);
ceffect->value = luaL_ref(L, LUA_REGISTRYINDEX); ceffect->value = luaL_ref(L, LUA_REGISTRYINDEX);
} }
...@@ -70,7 +70,7 @@ int32 scriptlib::effect_reset(lua_State *L) { ...@@ -70,7 +70,7 @@ int32 scriptlib::effect_reset(lua_State *L) {
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
if(peffect->owner == 0) if(peffect->owner == 0)
return 0; return 0;
if(peffect->flag & EFFECT_FLAG_FIELD_ONLY) if(peffect->is_flag(EFFECT_FLAG_FIELD_ONLY))
peffect->pduel->game_field->remove_effect(peffect); peffect->pduel->game_field->remove_effect(peffect);
else else
peffect->handler->remove_effect(peffect); peffect->handler->remove_effect(peffect);
...@@ -115,7 +115,7 @@ int32 scriptlib::effect_set_target_range(lua_State *L) { ...@@ -115,7 +115,7 @@ int32 scriptlib::effect_set_target_range(lua_State *L) {
int32 o = lua_tointeger(L, 3); int32 o = lua_tointeger(L, 3);
peffect->s_range = s; peffect->s_range = s;
peffect->o_range = o; peffect->o_range = o;
peffect->flag &= ~EFFECT_FLAG_ABSOLUTE_TARGET; peffect->flag[0] &= ~EFFECT_FLAG_ABSOLUTE_TARGET;
return 0; return 0;
} }
int32 scriptlib::effect_set_absolute_range(lua_State *L) { int32 scriptlib::effect_set_absolute_range(lua_State *L) {
...@@ -132,7 +132,7 @@ int32 scriptlib::effect_set_absolute_range(lua_State *L) { ...@@ -132,7 +132,7 @@ int32 scriptlib::effect_set_absolute_range(lua_State *L) {
peffect->s_range = o; peffect->s_range = o;
peffect->o_range = s; peffect->o_range = s;
} }
peffect->flag |= EFFECT_FLAG_ABSOLUTE_TARGET; peffect->flag[0] |= EFFECT_FLAG_ABSOLUTE_TARGET;
return 0; return 0;
} }
int32 scriptlib::effect_set_count_limit(lua_State *L) { int32 scriptlib::effect_set_count_limit(lua_State *L) {
...@@ -145,7 +145,7 @@ int32 scriptlib::effect_set_count_limit(lua_State *L) { ...@@ -145,7 +145,7 @@ int32 scriptlib::effect_set_count_limit(lua_State *L) {
code = lua_tointeger(L, 3); code = lua_tointeger(L, 3);
if(v == 0) if(v == 0)
v = 1; v = 1;
peffect->flag |= EFFECT_FLAG_COUNT_LIMIT; peffect->flag[0] |= EFFECT_FLAG_COUNT_LIMIT;
peffect->reset_count |= ((v << 12) & 0xf000) | ((v << 8) & 0xf00); peffect->reset_count |= ((v << 12) & 0xf000) | ((v << 8) & 0xf00);
peffect->count_code = code; peffect->count_code = code;
return 0; return 0;
...@@ -189,8 +189,10 @@ int32 scriptlib::effect_set_property(lua_State *L) { ...@@ -189,8 +189,10 @@ int32 scriptlib::effect_set_property(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
uint32 v = lua_tounsigned(L, 2); uint32 v1 = lua_tounsigned(L, 2);
peffect->flag = (peffect->flag & 0x4f) | (v & ~0x4f); uint32 v2 = lua_tounsigned(L, 3);
peffect->flag[0] = (peffect->flag[0] & 0x4f) | (v1 & ~0x4f);
peffect->flag[1] = v2;
return 0; return 0;
} }
int32 scriptlib::effect_set_label(lua_State *L) { int32 scriptlib::effect_set_label(lua_State *L) {
...@@ -269,13 +271,13 @@ int32 scriptlib::effect_set_value(lua_State *L) { ...@@ -269,13 +271,13 @@ int32 scriptlib::effect_set_value(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
if(peffect->value && (peffect->flag & EFFECT_FLAG_FUNC_VALUE)) if(peffect->value && (peffect->is_flag(EFFECT_FLAG_FUNC_VALUE)))
luaL_unref(L, LUA_REGISTRYINDEX, peffect->value); luaL_unref(L, LUA_REGISTRYINDEX, peffect->value);
if (lua_isfunction(L, 2)) { if (lua_isfunction(L, 2)) {
peffect->value = interpreter::get_function_handle(L, 2); peffect->value = interpreter::get_function_handle(L, 2);
peffect->flag |= EFFECT_FLAG_FUNC_VALUE; peffect->flag[0] |= EFFECT_FLAG_FUNC_VALUE;
} else { } else {
peffect->flag &= ~EFFECT_FLAG_FUNC_VALUE; peffect->flag[0] &= ~EFFECT_FLAG_FUNC_VALUE;
if(lua_isboolean(L, 2)) if(lua_isboolean(L, 2))
peffect->value = lua_toboolean(L, 2); peffect->value = lua_toboolean(L, 2);
else else
...@@ -437,7 +439,7 @@ int32 scriptlib::effect_get_value(lua_State *L) { ...@@ -437,7 +439,7 @@ int32 scriptlib::effect_get_value(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
if(peffect->flag & EFFECT_FLAG_FUNC_VALUE) if(peffect->is_flag(EFFECT_FLAG_FUNC_VALUE))
interpreter::function2value(L, peffect->value); interpreter::function2value(L, peffect->value);
else else
lua_pushinteger(L, (int32)peffect->value); lua_pushinteger(L, (int32)peffect->value);
...@@ -489,8 +491,9 @@ int32 scriptlib::effect_is_has_property(lua_State *L) { ...@@ -489,8 +491,9 @@ int32 scriptlib::effect_is_has_property(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
uint32 tflag = lua_tounsigned(L, 2); uint32 tflag1 = lua_tounsigned(L, 2);
if (peffect && (peffect->flag & tflag)) uint32 tflag2 = lua_tounsigned(L, 3);
if (peffect && (!tflag1 || (peffect->flag[0] & tflag1)) && (!tflag2 || (peffect->flag[1] & tflag2)))
lua_pushboolean(L, 1); lua_pushboolean(L, 1);
else else
lua_pushboolean(L, 0); lua_pushboolean(L, 0);
......
...@@ -29,7 +29,7 @@ int32 field::negate_chain(uint8 chaincount) { ...@@ -29,7 +29,7 @@ int32 field::negate_chain(uint8 chaincount) {
} }
pduel->write_buffer8(MSG_CHAIN_NEGATED); pduel->write_buffer8(MSG_CHAIN_NEGATED);
pduel->write_buffer8(chaincount); pduel->write_buffer8(chaincount);
if(pchain.triggering_effect->flag & EFFECT_FLAG_NAGA) if(pchain.triggering_effect->is_flag(EFFECT_FLAG2_NAGA))
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
...@@ -48,7 +48,7 @@ int32 field::disable_chain(uint8 chaincount) { ...@@ -48,7 +48,7 @@ int32 field::disable_chain(uint8 chaincount) {
core.current_chain[chaincount - 1].disable_player = core.reason_player; core.current_chain[chaincount - 1].disable_player = core.reason_player;
pduel->write_buffer8(MSG_CHAIN_DISABLED); pduel->write_buffer8(MSG_CHAIN_DISABLED);
pduel->write_buffer8(chaincount); pduel->write_buffer8(chaincount);
if(pchain.triggering_effect->flag & EFFECT_FLAG_NAGA) if(pchain.triggering_effect->is_flag(EFFECT_FLAG2_NAGA))
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
...@@ -74,7 +74,7 @@ void field::change_target(uint8 chaincount, group* targets) { ...@@ -74,7 +74,7 @@ void field::change_target(uint8 chaincount, group* targets) {
ot->container = targets->container; ot->container = targets->container;
for(auto cit = ot->container.begin(); cit != ot->container.end(); ++cit) for(auto cit = ot->container.begin(); cit != ot->container.end(); ++cit)
(*cit)->create_relation(te); (*cit)->create_relation(te);
if(te->flag & EFFECT_FLAG_CARD_TARGET) { if(te->is_flag(EFFECT_FLAG_CARD_TARGET)) {
for(auto cit = ot->container.begin(); cit != ot->container.end(); ++cit) { for(auto cit = ot->container.begin(); cit != ot->container.end(); ++cit) {
if((*cit)->current.location & 0x30) if((*cit)->current.location & 0x30)
move_card((*cit)->current.controler, (*cit), (*cit)->current.location, 0); move_card((*cit)->current.controler, (*cit), (*cit)->current.location, 0);
...@@ -1132,7 +1132,7 @@ int32 field::equip(uint16 step, uint8 equip_player, card * equip_card, card * ta ...@@ -1132,7 +1132,7 @@ int32 field::equip(uint16 step, uint8 equip_player, card * equip_card, card * ta
peffect->value = TYPE_EQUIP + TYPE_SPELL + TYPE_UNION; peffect->value = TYPE_EQUIP + TYPE_SPELL + TYPE_UNION;
else else
peffect->value = TYPE_EQUIP + TYPE_SPELL; peffect->value = TYPE_EQUIP + TYPE_SPELL;
peffect->flag = EFFECT_FLAG_CANNOT_DISABLE; peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x17e0000; peffect->reset_flag = RESET_EVENT + 0x17e0000;
equip_card->add_effect(peffect); equip_card->add_effect(peffect);
} }
...@@ -1183,7 +1183,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc, ...@@ -1183,7 +1183,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc,
} else { } else {
if(!ignore_count && !core.extra_summon[sumplayer] && core.summon_count[sumplayer] >= get_summon_count_limit(sumplayer)) { if(!ignore_count && !core.extra_summon[sumplayer] && core.summon_count[sumplayer] >= get_summon_count_limit(sumplayer)) {
effect* pextra = target->is_affected_by_effect(EFFECT_EXTRA_SUMMON_COUNT); effect* pextra = target->is_affected_by_effect(EFFECT_EXTRA_SUMMON_COUNT);
if(pextra && !(pextra->flag & EFFECT_FLAG_FUNC_VALUE)) { if(pextra && !(pextra->is_flag(EFFECT_FLAG_FUNC_VALUE))) {
int32 count = pextra->get_value(); int32 count = pextra->get_value();
if(min_tribute < count) { if(min_tribute < count) {
min_tribute = count; min_tribute = count;
...@@ -1335,7 +1335,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc, ...@@ -1335,7 +1335,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc,
int32 minul = 0; int32 minul = 0;
effect* pdec = 0; effect* pdec = 0;
for(int32 i = 0; i < eset.size(); ++i) { for(int32 i = 0; i < eset.size(); ++i) {
if(!(eset[i]->flag & EFFECT_FLAG_COUNT_LIMIT)) { if(!(eset[i]->is_flag(EFFECT_FLAG_COUNT_LIMIT))) {
int32 dec = eset[i]->get_value(target); int32 dec = eset[i]->get_value(target);
if(minul < (dec & 0xffff)) { if(minul < (dec & 0xffff)) {
minul = dec & 0xffff; minul = dec & 0xffff;
...@@ -1351,7 +1351,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc, ...@@ -1351,7 +1351,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc,
pduel->write_buffer32(pdec->handler->data.code); pduel->write_buffer32(pdec->handler->data.code);
} }
for(int32 i = 0; i < eset.size() && min > 0; ++i) { for(int32 i = 0; i < eset.size() && min > 0; ++i) {
if((eset[i]->flag & EFFECT_FLAG_COUNT_LIMIT) && (eset[i]->reset_count & 0xf00) > 0 && eset[i]->target) { if((eset[i]->is_flag(EFFECT_FLAG_COUNT_LIMIT)) && (eset[i]->reset_count & 0xf00) > 0 && eset[i]->target) {
int32 dec = eset[i]->get_value(target); int32 dec = eset[i]->get_value(target);
min -= dec & 0xffff; min -= dec & 0xffff;
eset[i]->dec_count(); eset[i]->dec_count();
...@@ -1362,7 +1362,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc, ...@@ -1362,7 +1362,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc,
} }
} }
for(int32 i = 0; i < eset.size() && min > 0; ++i) { for(int32 i = 0; i < eset.size() && min > 0; ++i) {
if((eset[i]->flag & EFFECT_FLAG_COUNT_LIMIT) && (eset[i]->reset_count & 0xf00) > 0 && !eset[i]->target) { if((eset[i]->is_flag(EFFECT_FLAG_COUNT_LIMIT)) && (eset[i]->reset_count & 0xf00) > 0 && !eset[i]->target) {
int32 dec = eset[i]->get_value(target); int32 dec = eset[i]->get_value(target);
min -= dec & 0xffff; min -= dec & 0xffff;
eset[i]->dec_count(); eset[i]->dec_count();
...@@ -1418,9 +1418,9 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc, ...@@ -1418,9 +1418,9 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc,
returns.ivalue[0] = FALSE; returns.ivalue[0] = FALSE;
effect* pextra = (effect*)core.temp_var[0]; effect* pextra = (effect*)core.temp_var[0];
if(pextra) { if(pextra) {
if((pextra->flag & EFFECT_FLAG_FUNC_VALUE) && (core.summon_count[sumplayer] < get_summon_count_limit(sumplayer))) if((pextra->is_flag(EFFECT_FLAG_FUNC_VALUE)) && (core.summon_count[sumplayer] < get_summon_count_limit(sumplayer)))
add_process(PROCESSOR_SELECT_YESNO, 0, 0, 0, sumplayer, 91); add_process(PROCESSOR_SELECT_YESNO, 0, 0, 0, sumplayer, 91);
else if(!(pextra->flag & EFFECT_FLAG_FUNC_VALUE) && ((int32)target->material_cards.size() < pextra->get_value())) else if(!(pextra->is_flag(EFFECT_FLAG_FUNC_VALUE)) && ((int32)target->material_cards.size() < pextra->get_value()))
core.temp_var[0] = 0; core.temp_var[0] = 0;
else else
returns.ivalue[0] = TRUE; returns.ivalue[0] = TRUE;
...@@ -1445,7 +1445,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc, ...@@ -1445,7 +1445,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc,
uint8 positions = POS_FACEUP_ATTACK; uint8 positions = POS_FACEUP_ATTACK;
if(is_player_affected_by_effect(sumplayer, EFFECT_DEVINE_LIGHT)) if(is_player_affected_by_effect(sumplayer, EFFECT_DEVINE_LIGHT))
positions = POS_FACEUP; positions = POS_FACEUP;
if(proc && (proc->flag & EFFECT_FLAG_SPSUM_PARAM)) { if(proc && (proc->is_flag(EFFECT_FLAG_SPSUM_PARAM))) {
positions = proc->s_range; positions = proc->s_range;
if(proc->o_range) if(proc->o_range)
targetplayer = 1 - sumplayer; targetplayer = 1 - sumplayer;
...@@ -1467,7 +1467,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc, ...@@ -1467,7 +1467,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc,
deffect->owner = target; deffect->owner = target;
deffect->code = EFFECT_DUAL_STATUS; deffect->code = EFFECT_DUAL_STATUS;
deffect->type = EFFECT_TYPE_SINGLE; deffect->type = EFFECT_TYPE_SINGLE;
deffect->flag = EFFECT_FLAG_CANNOT_DISABLE | EFFECT_FLAG_CLIENT_HINT; deffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE | EFFECT_FLAG_CLIENT_HINT;
deffect->description = 64; deffect->description = 64;
deffect->reset_flag = RESET_EVENT + 0x1fe0000; deffect->reset_flag = RESET_EVENT + 0x1fe0000;
target->add_effect(deffect); target->add_effect(deffect);
...@@ -1477,7 +1477,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc, ...@@ -1477,7 +1477,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc,
effect* pextra = core.extra_summon[sumplayer] ? 0 : target->is_affected_by_effect(EFFECT_EXTRA_SUMMON_COUNT); effect* pextra = core.extra_summon[sumplayer] ? 0 : target->is_affected_by_effect(EFFECT_EXTRA_SUMMON_COUNT);
if(pextra) { if(pextra) {
core.temp_var[0] = (ptr)pextra; core.temp_var[0] = (ptr)pextra;
if((pextra->flag & EFFECT_FLAG_FUNC_VALUE) && (core.summon_count[sumplayer] < get_summon_count_limit(sumplayer))) if((pextra->is_flag(EFFECT_FLAG_FUNC_VALUE)) && (core.summon_count[sumplayer] < get_summon_count_limit(sumplayer)))
add_process(PROCESSOR_SELECT_YESNO, 0, 0, 0, sumplayer, 91); add_process(PROCESSOR_SELECT_YESNO, 0, 0, 0, sumplayer, 91);
else else
returns.ivalue[0] = TRUE; returns.ivalue[0] = TRUE;
...@@ -1704,7 +1704,7 @@ int32 field::mset(uint16 step, uint8 setplayer, card * target, effect * proc, ui ...@@ -1704,7 +1704,7 @@ int32 field::mset(uint16 step, uint8 setplayer, card * target, effect * proc, ui
return TRUE; return TRUE;
if(!ignore_count && !core.extra_summon[setplayer] && core.summon_count[setplayer] >= get_summon_count_limit(setplayer)) { if(!ignore_count && !core.extra_summon[setplayer] && core.summon_count[setplayer] >= get_summon_count_limit(setplayer)) {
effect* pextra = target->is_affected_by_effect(EFFECT_EXTRA_SET_COUNT); effect* pextra = target->is_affected_by_effect(EFFECT_EXTRA_SET_COUNT);
if(pextra && !(pextra->flag & EFFECT_FLAG_FUNC_VALUE)) { if(pextra && !(pextra->is_flag(EFFECT_FLAG_FUNC_VALUE))) {
int32 count = pextra->get_value(); int32 count = pextra->get_value();
if(min_tribute < count) { if(min_tribute < count) {
min_tribute = count; min_tribute = count;
...@@ -1868,9 +1868,9 @@ int32 field::mset(uint16 step, uint8 setplayer, card * target, effect * proc, ui ...@@ -1868,9 +1868,9 @@ int32 field::mset(uint16 step, uint8 setplayer, card * target, effect * proc, ui
returns.ivalue[0] = FALSE; returns.ivalue[0] = FALSE;
effect* pextra = (effect*)core.temp_var[0]; effect* pextra = (effect*)core.temp_var[0];
if(pextra) { if(pextra) {
if((pextra->flag & EFFECT_FLAG_FUNC_VALUE) && (core.summon_count[setplayer] < get_summon_count_limit(setplayer))) if((pextra->is_flag(EFFECT_FLAG_FUNC_VALUE)) && (core.summon_count[setplayer] < get_summon_count_limit(setplayer)))
add_process(PROCESSOR_SELECT_YESNO, 0, 0, 0, setplayer, 91); add_process(PROCESSOR_SELECT_YESNO, 0, 0, 0, setplayer, 91);
else if(!(pextra->flag & EFFECT_FLAG_FUNC_VALUE) && ((int32)target->material_cards.size() < pextra->get_value())) else if(!(pextra->is_flag(EFFECT_FLAG_FUNC_VALUE)) && ((int32)target->material_cards.size() < pextra->get_value()))
core.temp_var[0] = 0; core.temp_var[0] = 0;
else else
returns.ivalue[0] = TRUE; returns.ivalue[0] = TRUE;
...@@ -1893,7 +1893,7 @@ int32 field::mset(uint16 step, uint8 setplayer, card * target, effect * proc, ui ...@@ -1893,7 +1893,7 @@ int32 field::mset(uint16 step, uint8 setplayer, card * target, effect * proc, ui
} }
uint8 targetplayer = setplayer; uint8 targetplayer = setplayer;
uint8 positions = POS_FACEDOWN_DEFENCE; uint8 positions = POS_FACEDOWN_DEFENCE;
if(proc && (proc->flag & EFFECT_FLAG_SPSUM_PARAM)) { if(proc && (proc->is_flag(EFFECT_FLAG_SPSUM_PARAM))) {
positions = proc->s_range; positions = proc->s_range;
if(proc->o_range) if(proc->o_range)
targetplayer = 1 - setplayer; targetplayer = 1 - setplayer;
...@@ -2151,7 +2151,7 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card * target, ui ...@@ -2151,7 +2151,7 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card * target, ui
effect* peffect = core.units.begin()->peffect; effect* peffect = core.units.begin()->peffect;
uint8 targetplayer = sumplayer; uint8 targetplayer = sumplayer;
uint8 positions = POS_FACEUP; uint8 positions = POS_FACEUP;
if(peffect->flag & EFFECT_FLAG_SPSUM_PARAM) { if(peffect->is_flag(EFFECT_FLAG_SPSUM_PARAM)) {
positions = peffect->s_range; positions = peffect->s_range;
if(peffect->o_range == 0) if(peffect->o_range == 0)
targetplayer = sumplayer; targetplayer = sumplayer;
...@@ -2653,7 +2653,7 @@ int32 field::destroy(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -2653,7 +2653,7 @@ int32 field::destroy(uint16 step, group * targets, effect * reason_effect, uint3
if (eset.size()) { if (eset.size()) {
bool is_destructable = true; bool is_destructable = true;
for (int32 i = 0; i < eset.size(); ++i) { for (int32 i = 0; i < eset.size(); ++i) {
if(!(eset[i]->flag & EFFECT_FLAG_COUNT_LIMIT) || (eset[i]->reset_count & 0xf00) == 0) if(!(eset[i]->is_flag(EFFECT_FLAG_COUNT_LIMIT)) || (eset[i]->reset_count & 0xf00) == 0)
continue; continue;
pduel->lua->add_param(pcard->current.reason_effect, PARAM_TYPE_EFFECT); pduel->lua->add_param(pcard->current.reason_effect, PARAM_TYPE_EFFECT);
pduel->lua->add_param(pcard->current.reason, PARAM_TYPE_INT); pduel->lua->add_param(pcard->current.reason, PARAM_TYPE_INT);
...@@ -2820,7 +2820,7 @@ int32 field::destroy(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -2820,7 +2820,7 @@ int32 field::destroy(uint16 step, group * targets, effect * reason_effect, uint3
if (eset.size()) { if (eset.size()) {
bool indes = false; bool indes = false;
for (int32 i = 0; i < eset.size(); ++i) { for (int32 i = 0; i < eset.size(); ++i) {
if(!(eset[i]->flag & EFFECT_FLAG_COUNT_LIMIT) || (eset[i]->reset_count & 0xf00) == 0) if(!(eset[i]->is_flag(EFFECT_FLAG_COUNT_LIMIT)) || (eset[i]->reset_count & 0xf00) == 0)
continue; continue;
pduel->lua->add_param(pcard->current.reason_effect, PARAM_TYPE_EFFECT); pduel->lua->add_param(pcard->current.reason_effect, PARAM_TYPE_EFFECT);
pduel->lua->add_param(pcard->current.reason, PARAM_TYPE_INT); pduel->lua->add_param(pcard->current.reason, PARAM_TYPE_INT);
......
...@@ -309,7 +309,7 @@ int32 field::select_chain(uint16 step, uint8 playerid, uint8 spe_count, uint8 fo ...@@ -309,7 +309,7 @@ int32 field::select_chain(uint16 step, uint8 playerid, uint8 spe_count, uint8 fo
card* pcard = peffect->handler; card* pcard = peffect->handler;
if(!(peffect->type & EFFECT_TYPE_ACTIONS)) if(!(peffect->type & EFFECT_TYPE_ACTIONS))
pcard = peffect->owner; pcard = peffect->owner;
if(peffect->flag & EFFECT_FLAG_FIELD_ONLY) if(peffect->is_flag(EFFECT_FLAG_FIELD_ONLY))
pduel->write_buffer32(1000000000 + pcard->data.code); pduel->write_buffer32(1000000000 + pcard->data.code);
else else
pduel->write_buffer32(pcard->data.code); pduel->write_buffer32(pcard->data.code);
......
This diff is collapsed.
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