Commit db4198ec authored by fallenstardust's avatar fallenstardust

sync ocgcore

parent c0eb8727
...@@ -1276,18 +1276,18 @@ uint32 card::get_rscale() { ...@@ -1276,18 +1276,18 @@ uint32 card::get_rscale() {
temp.rscale = UINT32_MAX; temp.rscale = UINT32_MAX;
return rscale; return rscale;
} }
uint32 card::get_link_marker() { uint32 card::get_link_marker() const {
if(!(data.type & TYPE_LINK)) if(!(data.type & TYPE_LINK))
return 0; return 0;
return data.link_marker; return data.link_marker;
} }
int32 card::is_link_marker(uint32 dir) { uint32 card::is_link_marker(uint32 dir) const {
return (int32)(get_link_marker() & dir); return get_link_marker() & dir;
} }
uint32 card::get_linked_zone() { uint32 card::get_linked_zone() const {
if(!(data.type & TYPE_LINK) || current.location != LOCATION_MZONE || is_treated_as_not_on_field()) if(!(data.type & TYPE_LINK) || current.location != LOCATION_MZONE || is_treated_as_not_on_field())
return 0; return 0;
int32 zones = 0; uint32 zones = 0;
int32 s = current.sequence; int32 s = current.sequence;
if(s > 0 && s <= 4 && is_link_marker(LINK_MARKER_LEFT)) if(s > 0 && s <= 4 && is_link_marker(LINK_MARKER_LEFT))
zones |= 1u << (s - 1); zones |= 1u << (s - 1);
...@@ -1340,10 +1340,10 @@ void card::get_linked_cards(card_set* cset) { ...@@ -1340,10 +1340,10 @@ void card::get_linked_cards(card_set* cset) {
pduel->game_field->get_cards_in_zone(cset, linked_zone, p, LOCATION_MZONE); pduel->game_field->get_cards_in_zone(cset, linked_zone, p, LOCATION_MZONE);
pduel->game_field->get_cards_in_zone(cset, linked_zone >> 16, 1 - p, LOCATION_MZONE); pduel->game_field->get_cards_in_zone(cset, linked_zone >> 16, 1 - p, LOCATION_MZONE);
} }
uint32 card::get_mutual_linked_zone() { uint32 card::get_mutual_linked_zone() const {
if(!(data.type & TYPE_LINK) || current.location != LOCATION_MZONE || is_treated_as_not_on_field()) if(!(data.type & TYPE_LINK) || current.location != LOCATION_MZONE || is_treated_as_not_on_field())
return 0; return 0;
int32 zones = 0; uint32 zones = 0;
int32 p = current.controler; int32 p = current.controler;
int32 s = current.sequence; int32 s = current.sequence;
uint32 linked_zone = get_linked_zone(); uint32 linked_zone = get_linked_zone();
...@@ -1351,15 +1351,15 @@ uint32 card::get_mutual_linked_zone() { ...@@ -1351,15 +1351,15 @@ uint32 card::get_mutual_linked_zone() {
for(int32 i = 0; i < 7; ++i, icheck <<= 1) { for(int32 i = 0; i < 7; ++i, icheck <<= 1) {
if(icheck & linked_zone) { if(icheck & linked_zone) {
card* pcard = pduel->game_field->player[p].list_mzone[i]; card* pcard = pduel->game_field->player[p].list_mzone[i];
if(pcard && (pcard->get_linked_zone() & (1u << s))) if(pcard && (pcard->get_linked_zone() & (0x1u << s)))
zones |= icheck; zones |= icheck;
} }
} }
icheck = 0x10000; icheck = 0x10000U;
for(uint32 i = 0; i < 7; ++i, icheck <<= 1) { for(uint32 i = 0; i < 7; ++i, icheck <<= 1) {
if(icheck & linked_zone) { if(icheck & linked_zone) {
card* pcard = pduel->game_field->player[1 - p].list_mzone[i]; card* pcard = pduel->game_field->player[1 - p].list_mzone[i];
if(pcard && (pcard->get_linked_zone() & (1u << (s + 16)))) if(pcard && (pcard->get_linked_zone() & (0x1u << (s + 16))))
zones |= icheck; zones |= icheck;
} }
} }
...@@ -1383,28 +1383,28 @@ int32 card::is_link_state() { ...@@ -1383,28 +1383,28 @@ int32 card::is_link_state() {
return TRUE; return TRUE;
int32 p = current.controler; int32 p = current.controler;
uint32 linked_zone = pduel->game_field->get_linked_zone(p); uint32 linked_zone = pduel->game_field->get_linked_zone(p);
if((linked_zone >> current.sequence) & 1) if((linked_zone >> current.sequence) & 0x1U)
return TRUE; return TRUE;
return FALSE; return FALSE;
} }
int32 card::is_extra_link_state() { int32 card::is_extra_link_state() {
if(current.location != LOCATION_MZONE) if(current.location != LOCATION_MZONE)
return FALSE; return FALSE;
uint32 checked = 1u << current.sequence; uint32 checked = 0x1U << current.sequence;
uint32 linked_zone = get_mutual_linked_zone(); uint32 linked_zone = get_mutual_linked_zone();
const auto& list_mzone0 = pduel->game_field->player[current.controler].list_mzone; const auto& list_mzone0 = pduel->game_field->player[current.controler].list_mzone;
const auto& list_mzone1 = pduel->game_field->player[1 - current.controler].list_mzone; const auto& list_mzone1 = pduel->game_field->player[1 - current.controler].list_mzone;
while(true) { while(true) {
if(((linked_zone >> 5) | (linked_zone >> (16 + 6))) & ((linked_zone >> 6) | (linked_zone >> (16 + 5))) & 1) if(((linked_zone >> 5) | (linked_zone >> (16 + 6))) & ((linked_zone >> 6) | (linked_zone >> (16 + 5))) & 0x1U)
return TRUE; return TRUE;
int32 checking = (int32)(linked_zone & ~checked); uint32 checking = linked_zone & ~checked;
if(!checking) if(!checking)
return FALSE; return FALSE;
int32 rightmost = checking & (-checking); uint32 rightmost = checking & (-checking);
checked |= (uint32)rightmost; checked |= rightmost;
if(rightmost < 0x10000) { if(rightmost < 0x10000U) {
for(int32 i = 0; i < 7; ++i) { for(int32 i = 0; i < 7; ++i) {
if(rightmost & 1) { if(rightmost & 0x1U) {
card* pcard = list_mzone0[i]; card* pcard = list_mzone0[i];
linked_zone |= pcard->get_mutual_linked_zone(); linked_zone |= pcard->get_mutual_linked_zone();
break; break;
...@@ -1414,7 +1414,7 @@ int32 card::is_extra_link_state() { ...@@ -1414,7 +1414,7 @@ int32 card::is_extra_link_state() {
} else { } else {
rightmost >>= 16; rightmost >>= 16;
for(int32 i = 0; i < 7; ++i) { for(int32 i = 0; i < 7; ++i) {
if(rightmost & 1) { if(rightmost & 0x1U) {
card* pcard = list_mzone1[i]; card* pcard = list_mzone1[i];
uint32 zone = pcard->get_mutual_linked_zone(); uint32 zone = pcard->get_mutual_linked_zone();
linked_zone |= (zone << 16) | (zone >> 16); linked_zone |= (zone << 16) | (zone >> 16);
...@@ -1426,7 +1426,7 @@ int32 card::is_extra_link_state() { ...@@ -1426,7 +1426,7 @@ int32 card::is_extra_link_state() {
} }
return FALSE; return FALSE;
} }
int32 card::is_position(int32 pos) { int32 card::is_position(uint32 pos) const {
return current.position & pos; return current.position & pos;
} }
void card::set_status(uint32 x, int32 enabled) { void card::set_status(uint32 x, int32 enabled) {
...@@ -1522,7 +1522,7 @@ uint32 card::get_select_info_location(uint8 *deck_seq_pointer) { ...@@ -1522,7 +1522,7 @@ uint32 card::get_select_info_location(uint8 *deck_seq_pointer) {
return get_info_location(); return get_info_location();
} }
} }
int32 card::is_treated_as_not_on_field() { int32 card::is_treated_as_not_on_field() const {
return get_status(STATUS_SUMMONING | STATUS_SUMMON_DISABLED | STATUS_ACTIVATE_DISABLED | STATUS_SPSUMMON_STEP); return get_status(STATUS_SUMMONING | STATUS_SUMMON_DISABLED | STATUS_ACTIVATE_DISABLED | STATUS_SPSUMMON_STEP);
} }
void card::equip(card* target, uint32 send_msg) { void card::equip(card* target, uint32 send_msg) {
...@@ -1569,12 +1569,11 @@ int32 card::get_old_union_count() { ...@@ -1569,12 +1569,11 @@ int32 card::get_old_union_count() {
} }
return count; return count;
} }
void card::xyz_overlay(card_set* materials) { void card::xyz_overlay(const card_set& materials) {
if(materials->empty()) if(materials.empty())
return; return;
card_set des, leave_grave, leave_deck; card_set des, leave_grave, leave_deck;
card_vector cv; card_vector cv(materials.begin(), materials.end());
cv.assign(materials->begin(), materials->end());
std::sort(cv.begin(), cv.end(), card::card_operation_sort); std::sort(cv.begin(), cv.end(), card::card_operation_sort);
if(pduel->game_field->core.global_flag & GLOBALFLAG_DECK_REVERSE_CHECK) { if(pduel->game_field->core.global_flag & GLOBALFLAG_DECK_REVERSE_CHECK) {
int32 d0 = (int32)pduel->game_field->player[0].list_main.size() - 1, s0 = d0; int32 d0 = (int32)pduel->game_field->player[0].list_main.size() - 1, s0 = d0;
...@@ -1650,16 +1649,16 @@ void card::xyz_overlay(card_set* materials) { ...@@ -1650,16 +1649,16 @@ void card::xyz_overlay(card_set* materials) {
} }
if(leave_grave.size() || leave_deck.size()) { if(leave_grave.size() || leave_deck.size()) {
if(leave_grave.size()) { if(leave_grave.size()) {
pduel->game_field->raise_event(&leave_grave, EVENT_LEAVE_GRAVE, pduel->game_field->core.reason_effect, REASON_XYZ + REASON_MATERIAL, pduel->game_field->core.reason_player, 0, 0); pduel->game_field->raise_event(leave_grave, EVENT_LEAVE_GRAVE, pduel->game_field->core.reason_effect, REASON_XYZ + REASON_MATERIAL, pduel->game_field->core.reason_player, 0, 0);
} }
if(leave_deck.size()) { if(leave_deck.size()) {
pduel->game_field->raise_event(&leave_deck, EVENT_LEAVE_DECK, pduel->game_field->core.reason_effect, REASON_XYZ + REASON_MATERIAL, pduel->game_field->core.reason_player, 0, 0); pduel->game_field->raise_event(leave_deck, EVENT_LEAVE_DECK, pduel->game_field->core.reason_effect, REASON_XYZ + REASON_MATERIAL, pduel->game_field->core.reason_player, 0, 0);
} }
pduel->game_field->process_single_event(); pduel->game_field->process_single_event();
pduel->game_field->process_instant_event(); pduel->game_field->process_instant_event();
} }
if(des.size()) if(des.size())
pduel->game_field->destroy(&des, 0, REASON_LOST_TARGET + REASON_RULE, PLAYER_NONE); pduel->game_field->destroy(des, 0, REASON_LOST_TARGET + REASON_RULE, PLAYER_NONE);
else else
pduel->game_field->adjust_instant(); pduel->game_field->adjust_instant();
} }
...@@ -1959,6 +1958,7 @@ effect_indexer::iterator card::remove_effect(effect* peffect) { ...@@ -1959,6 +1958,7 @@ effect_indexer::iterator card::remove_effect(effect* peffect) {
pduel->game_field->update_disable_check_list(peffect); pduel->game_field->update_disable_check_list(peffect);
} }
field_effect.erase(it); field_effect.erase(it);
pduel->game_field->remove_effect(peffect);
} }
if ((current.controler != PLAYER_NONE) && !get_status(STATUS_DISABLED | STATUS_FORBIDDEN) && !check_target.empty()) { if ((current.controler != PLAYER_NONE) && !get_status(STATUS_DISABLED | STATUS_FORBIDDEN) && !check_target.empty()) {
if (peffect->is_disable_related()) { if (peffect->is_disable_related()) {
...@@ -2002,7 +2002,6 @@ effect_indexer::iterator card::remove_effect(effect* peffect) { ...@@ -2002,7 +2002,6 @@ effect_indexer::iterator card::remove_effect(effect* peffect) {
unique_pos[0] = unique_pos[1] = 0; unique_pos[0] = unique_pos[1] = 0;
unique_code = 0; unique_code = 0;
} }
pduel->game_field->remove_effect(peffect);
pduel->game_field->core.reseted_effects.insert(peffect); pduel->game_field->core.reseted_effects.insert(peffect);
return ret; return ret;
} }
......
...@@ -262,15 +262,15 @@ public: ...@@ -262,15 +262,15 @@ public:
uint32 get_grave_race(uint8 playerid); uint32 get_grave_race(uint8 playerid);
uint32 get_lscale(); uint32 get_lscale();
uint32 get_rscale(); uint32 get_rscale();
uint32 get_link_marker(); uint32 get_link_marker() const;
int32 is_link_marker(uint32 dir); uint32 is_link_marker(uint32 dir) const;
uint32 get_linked_zone(); uint32 get_linked_zone() const;
void get_linked_cards(card_set* cset); void get_linked_cards(card_set* cset);
uint32 get_mutual_linked_zone(); uint32 get_mutual_linked_zone() const;
void get_mutual_linked_cards(card_set * cset); void get_mutual_linked_cards(card_set * cset);
int32 is_link_state(); int32 is_link_state();
int32 is_extra_link_state(); int32 is_extra_link_state();
int32 is_position(int32 pos); int32 is_position(uint32 pos) const;
void set_status(uint32 status, int32 enabled); void set_status(uint32 status, int32 enabled);
int32 get_status(uint32 status) const; int32 get_status(uint32 status) const;
int32 is_status(uint32 status) const; int32 is_status(uint32 status) const;
...@@ -279,13 +279,13 @@ public: ...@@ -279,13 +279,13 @@ public:
int32 is_all_column(); int32 is_all_column();
uint8 get_select_sequence(uint8 *deck_seq_pointer); uint8 get_select_sequence(uint8 *deck_seq_pointer);
uint32 get_select_info_location(uint8 *deck_seq_pointer); uint32 get_select_info_location(uint8 *deck_seq_pointer);
int32 is_treated_as_not_on_field(); int32 is_treated_as_not_on_field() const;
void equip(card* target, uint32 send_msg = TRUE); void equip(card* target, uint32 send_msg = TRUE);
void unequip(); void unequip();
int32 get_union_count(); int32 get_union_count();
int32 get_old_union_count(); int32 get_old_union_count();
void xyz_overlay(card_set* materials); void xyz_overlay(const card_set& materials);
void xyz_add(card* mat); void xyz_add(card* mat);
void xyz_remove(card* mat); void xyz_remove(card* mat);
void apply_field_effect(); void apply_field_effect();
......
...@@ -863,7 +863,7 @@ uint32 effect::get_active_type(uint8 uselast) { ...@@ -863,7 +863,7 @@ uint32 effect::get_active_type(uint8 uselast) {
} else } else
return owner->get_type(); return owner->get_type();
} }
int32 effect::get_code_type() const { code_type effect::get_code_type() const {
// start from the highest bit // start from the highest bit
if (code & 0xf0000000) if (code & 0xf0000000)
return CODE_CUSTOM; return CODE_CUSTOM;
......
...@@ -20,8 +20,11 @@ class effect; ...@@ -20,8 +20,11 @@ class effect;
struct tevent; struct tevent;
struct effect_set; struct effect_set;
struct effect_set_v; struct effect_set_v;
enum effect_flag : uint32; enum effect_flag : uint64;
enum effect_flag2 : uint32; enum effect_flag2 : uint64;
enum code_type : int32;
bool is_continuous_event(uint32 code);
class effect { class effect {
public: public:
...@@ -32,7 +35,6 @@ public: ...@@ -32,7 +35,6 @@ public:
uint8 effect_owner{ PLAYER_NONE }; uint8 effect_owner{ PLAYER_NONE };
uint32 description{ 0 }; uint32 description{ 0 };
uint32 code{ 0 }; uint32 code{ 0 };
uint32 flag[2]{};
uint32 id{ 0 }; uint32 id{ 0 };
uint32 type{ 0 }; uint32 type{ 0 };
uint16 copy_id{ 0 }; uint16 copy_id{ 0 };
...@@ -41,18 +43,19 @@ public: ...@@ -41,18 +43,19 @@ public:
uint16 o_range{ 0 }; uint16 o_range{ 0 };
uint8 count_limit{ 0 }; uint8 count_limit{ 0 };
uint8 count_limit_max{ 0 }; uint8 count_limit_max{ 0 };
uint16 status{ 0 };
int32 reset_count{ 0 }; int32 reset_count{ 0 };
uint32 reset_flag{ 0 }; uint32 reset_flag{ 0 };
uint32 count_code{ 0 }; uint32 count_code{ 0 };
uint64 category{ 0 }; uint64 category{ 0 };
uint64 flag[2]{};
uint32 hint_timing[2]{}; uint32 hint_timing[2]{};
uint32 card_type{ 0 }; uint32 card_type{ 0 };
uint32 active_type{ 0 }; uint32 active_type{ 0 };
uint16 active_location{ 0 }; uint16 active_location{ 0 };
uint16 active_sequence{ 0 }; uint16 active_sequence{ 0 };
card* active_handler{ nullptr }; card* active_handler{ nullptr };
uint16 status{ 0 }; std::vector<lua_Integer> label;
std::vector<uint32> label;
int32 label_object{ 0 }; int32 label_object{ 0 };
int32 condition{ 0 }; int32 condition{ 0 };
int32 cost{ 0 }; int32 cost{ 0 };
...@@ -112,7 +115,7 @@ public: ...@@ -112,7 +115,7 @@ public:
void set_activate_location(); void set_activate_location();
void set_active_type(); void set_active_type();
uint32 get_active_type(uint8 uselast = TRUE); uint32 get_active_type(uint8 uselast = TRUE);
int32 get_code_type() const; code_type get_code_type() const;
bool is_flag(effect_flag x) const { bool is_flag(effect_flag x) const {
return !!(flag[0] & x); return !!(flag[0] & x);
...@@ -178,7 +181,7 @@ constexpr uint32 EFFECT_TYPES_TRIGGER_LIKE = EFFECT_TYPE_ACTIVATE | EFFECT_TYPE_ ...@@ -178,7 +181,7 @@ constexpr uint32 EFFECT_TYPES_TRIGGER_LIKE = EFFECT_TYPE_ACTIVATE | EFFECT_TYPE_
constexpr uint32 EFFECT_TYPES_CHAIN_LINK = EFFECT_TYPES_TRIGGER_LIKE | EFFECT_TYPE_FLIP | EFFECT_TYPE_IGNITION; constexpr uint32 EFFECT_TYPES_CHAIN_LINK = EFFECT_TYPES_TRIGGER_LIKE | EFFECT_TYPE_FLIP | EFFECT_TYPE_IGNITION;
//========== Flags ========== //========== Flags ==========
enum effect_flag : uint32 { enum effect_flag : uint64 {
EFFECT_FLAG_INITIAL = 0x0001, EFFECT_FLAG_INITIAL = 0x0001,
EFFECT_FLAG_FUNC_VALUE = 0x0002, EFFECT_FLAG_FUNC_VALUE = 0x0002,
EFFECT_FLAG_COUNT_LIMIT = 0x0004, EFFECT_FLAG_COUNT_LIMIT = 0x0004,
...@@ -212,7 +215,7 @@ enum effect_flag : uint32 { ...@@ -212,7 +215,7 @@ enum effect_flag : uint32 {
// EFFECT_FLAG_CVAL_CHECK = 0x40000000, // EFFECT_FLAG_CVAL_CHECK = 0x40000000,
EFFECT_FLAG_IMMEDIATELY_APPLY = 0x80000000, EFFECT_FLAG_IMMEDIATELY_APPLY = 0x80000000,
}; };
enum effect_flag2 : uint32 { enum effect_flag2 : uint64 {
EFFECT_FLAG2_REPEAT_UPDATE = 0x0001, EFFECT_FLAG2_REPEAT_UPDATE = 0x0001,
EFFECT_FLAG2_COF = 0x0002, EFFECT_FLAG2_COF = 0x0002,
EFFECT_FLAG2_WICKED = 0x0004, EFFECT_FLAG2_WICKED = 0x0004,
...@@ -564,10 +567,12 @@ constexpr int32 HALF_DAMAGE = 0x80000001; ...@@ -564,10 +567,12 @@ constexpr int32 HALF_DAMAGE = 0x80000001;
#define MAX_CARD_ID 0xfffffff #define MAX_CARD_ID 0xfffffff
// The type of effect code // The type of effect code
#define CODE_CUSTOM 1 // header + id (28 bits) enum code_type : int32 {
#define CODE_COUNTER 2 // header + counter_id (16 bits) CODE_CUSTOM = 1, // header + id (28 bits)
#define CODE_PHASE 3 // header + phase_id (12 bits) CODE_COUNTER, // header + counter_id (16 bits)
#define CODE_VALUE 4 // numeric value, max = 4095 CODE_PHASE, // header + phase_id (12 bits)
CODE_VALUE, // numeric value, max = 4095
};
const std::unordered_set<uint32> continuous_event{ const std::unordered_set<uint32> continuous_event{
EVENT_ADJUST, EVENT_ADJUST,
...@@ -576,7 +581,6 @@ const std::unordered_set<uint32> continuous_event{ ...@@ -576,7 +581,6 @@ const std::unordered_set<uint32> continuous_event{
EVENT_PRE_BATTLE_DAMAGE, EVENT_PRE_BATTLE_DAMAGE,
EVENT_SPSUMMON_SUCCESS_G_P, EVENT_SPSUMMON_SUCCESS_G_P,
}; };
bool is_continuous_event(uint32 code);
const std::unordered_set<uint32> affect_summoning_effect{ const std::unordered_set<uint32> affect_summoning_effect{
EFFECT_CANNOT_DISABLE_SUMMON, EFFECT_CANNOT_DISABLE_SUMMON,
......
...@@ -804,11 +804,11 @@ int32 field::get_szone_limit(uint8 playerid, uint8 uplayer, uint32 reason) { ...@@ -804,11 +804,11 @@ int32 field::get_szone_limit(uint8 playerid, uint8 uplayer, uint32 reason) {
} }
uint32 field::get_linked_zone(int32 playerid) { uint32 field::get_linked_zone(int32 playerid) {
uint32 zones = 0; uint32 zones = 0;
for(auto& pcard : player[playerid].list_mzone) { for(const auto& pcard : player[playerid].list_mzone) {
if(pcard) if(pcard)
zones |= pcard->get_linked_zone() & 0xff; zones |= pcard->get_linked_zone() & 0xffff;
} }
for(auto& pcard : player[1 - playerid].list_mzone) { for(const auto& pcard : player[1 - playerid].list_mzone) {
if(pcard) if(pcard)
zones |= pcard->get_linked_zone() >> 16; zones |= pcard->get_linked_zone() >> 16;
} }
...@@ -872,19 +872,19 @@ int32 field::check_extra_link(int32 playerid) { ...@@ -872,19 +872,19 @@ int32 field::check_extra_link(int32 playerid) {
if(!player[playerid].list_mzone[5] || !player[playerid].list_mzone[6]) if(!player[playerid].list_mzone[5] || !player[playerid].list_mzone[6])
return FALSE; return FALSE;
card* pcard = player[playerid].list_mzone[5]; card* pcard = player[playerid].list_mzone[5];
uint32 checked = 1u << 5; uint32 checked = 0x1u << 5;
uint32 linked_zone = pcard->get_mutual_linked_zone(); uint32 linked_zone = pcard->get_mutual_linked_zone();
while(true) { while(true) {
if((linked_zone >> 6) & 1) if((linked_zone >> 6) & 0x1U)
return TRUE; return TRUE;
int32 checking = (int32)(linked_zone & ~checked); uint32 checking = linked_zone & ~checked;
if(!checking) if(!checking)
return FALSE; return FALSE;
int32 rightmost = checking & (-checking); uint32 rightmost = checking & (-checking);
checked |= (uint32)rightmost; checked |= rightmost;
if(rightmost < 0x10000) { if(rightmost < 0x10000U) {
for(int32 i = 0; i < 7; ++i) { for(int32 i = 0; i < 7; ++i) {
if(rightmost & 1) { if(rightmost & 0x1U) {
pcard = player[playerid].list_mzone[i]; pcard = player[playerid].list_mzone[i];
linked_zone |= pcard->get_mutual_linked_zone(); linked_zone |= pcard->get_mutual_linked_zone();
break; break;
...@@ -894,7 +894,7 @@ int32 field::check_extra_link(int32 playerid) { ...@@ -894,7 +894,7 @@ int32 field::check_extra_link(int32 playerid) {
} else { } else {
rightmost >>= 16; rightmost >>= 16;
for(int32 i = 0; i < 7; ++i) { for(int32 i = 0; i < 7; ++i) {
if(rightmost & 1) { if(rightmost & 0x1U) {
pcard = player[1 - playerid].list_mzone[i]; pcard = player[1 - playerid].list_mzone[i];
uint32 zone = pcard->get_mutual_linked_zone(); uint32 zone = pcard->get_mutual_linked_zone();
linked_zone |= (zone << 16) | (zone >> 16); linked_zone |= (zone << 16) | (zone >> 16);
...@@ -1662,7 +1662,7 @@ int32 field::filter_field_card(uint8 self, uint32 location1, uint32 location2, g ...@@ -1662,7 +1662,7 @@ int32 field::filter_field_card(uint8 self, uint32 location1, uint32 location2, g
} }
if (pgroup) if (pgroup)
pgroup->container.insert(result.begin(), result.end()); pgroup->container.insert(result.begin(), result.end());
return result.size(); return (int32)result.size();
} }
effect* field::is_player_affected_by_effect(uint8 playerid, uint32 code) { effect* field::is_player_affected_by_effect(uint8 playerid, uint32 code) {
auto rg = effects.aura_effect.equal_range(code); auto rg = effects.aura_effect.equal_range(code);
...@@ -1927,11 +1927,11 @@ void field::get_fusion_material(uint8 playerid, card_set* material_all, card_set ...@@ -1927,11 +1927,11 @@ void field::get_fusion_material(uint8 playerid, card_set* material_all, card_set
} }
material_all->insert(material_base->begin(), material_base->end()); material_all->insert(material_base->begin(), material_base->end());
} }
void field::ritual_release(card_set* material) { void field::ritual_release(const card_set& material) {
card_set rel; card_set rel;
card_set rem; card_set rem;
card_set tgy; card_set tgy;
for(auto& pcard : *material) { for(const auto& pcard : material) {
if(pcard->current.location == LOCATION_GRAVE) if(pcard->current.location == LOCATION_GRAVE)
rem.insert(pcard); rem.insert(pcard);
else if(pcard->current.location == LOCATION_OVERLAY || pcard->current.location == LOCATION_EXTRA) else if(pcard->current.location == LOCATION_OVERLAY || pcard->current.location == LOCATION_EXTRA)
...@@ -1939,9 +1939,9 @@ void field::ritual_release(card_set* material) { ...@@ -1939,9 +1939,9 @@ void field::ritual_release(card_set* material) {
else else
rel.insert(pcard); rel.insert(pcard);
} }
send_to(&tgy, core.reason_effect, REASON_RITUAL + REASON_EFFECT + REASON_MATERIAL, core.reason_player, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP); send_to(tgy, core.reason_effect, REASON_RITUAL + REASON_EFFECT + REASON_MATERIAL, core.reason_player, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP);
release(&rel, core.reason_effect, REASON_RITUAL + REASON_EFFECT + REASON_MATERIAL, core.reason_player); release(rel, core.reason_effect, REASON_RITUAL + REASON_EFFECT + REASON_MATERIAL, core.reason_player);
send_to(&rem, core.reason_effect, REASON_RITUAL + REASON_EFFECT + REASON_MATERIAL, core.reason_player, PLAYER_NONE, LOCATION_REMOVED, 0, POS_FACEUP); send_to(rem, core.reason_effect, REASON_RITUAL + REASON_EFFECT + REASON_MATERIAL, core.reason_player, PLAYER_NONE, LOCATION_REMOVED, 0, POS_FACEUP);
} }
void field::get_xyz_material(lua_State* L, card* scard, int32 findex, uint32 lv, int32 maxc, group* mg) { void field::get_xyz_material(lua_State* L, card* scard, int32 findex, uint32 lv, int32 maxc, group* mg) {
core.xmaterial_lst.clear(); core.xmaterial_lst.clear();
...@@ -2124,6 +2124,8 @@ int32 field::adjust_grant_effect() { ...@@ -2124,6 +2124,8 @@ int32 field::adjust_grant_effect() {
effect* geffect = (effect*)peffect->get_label_object(); effect* geffect = (effect*)peffect->get_label_object();
if (geffect->type & EFFECT_TYPE_GRANT) if (geffect->type & EFFECT_TYPE_GRANT)
continue; continue;
if (geffect->code == EFFECT_UNIQUE_CHECK)
continue;
card_set cset; card_set cset;
if(peffect->is_available()) if(peffect->is_available())
filter_affected_cards(peffect, &cset); filter_affected_cards(peffect, &cset);
...@@ -2138,9 +2140,6 @@ int32 field::adjust_grant_effect() { ...@@ -2138,9 +2140,6 @@ int32 field::adjust_grant_effect() {
if(!pcard->is_affect_by_effect(peffect) || !cset.count(pcard)) if(!pcard->is_affect_by_effect(peffect) || !cset.count(pcard))
remove_set.insert(pcard); remove_set.insert(pcard);
} }
//X gains an effect from itself will break card::remove_effect
if (!peffect->is_flag(EFFECT_FLAG_FIELD_ONLY))
add_set.erase(peffect->handler);
for(auto& pcard : add_set) { for(auto& pcard : add_set) {
effect* ceffect = geffect->clone(); effect* ceffect = geffect->clone();
ceffect->owner = pcard; ceffect->owner = pcard;
......
...@@ -441,7 +441,7 @@ public: ...@@ -441,7 +441,7 @@ public:
int32 get_draw_count(uint8 playerid); int32 get_draw_count(uint8 playerid);
void get_ritual_material(uint8 playerid, effect* peffect, card_set* material, uint8 no_level = FALSE); void get_ritual_material(uint8 playerid, effect* peffect, card_set* material, uint8 no_level = FALSE);
void get_fusion_material(uint8 playerid, card_set* material_all, card_set* material_base, uint32 location); void get_fusion_material(uint8 playerid, card_set* material_all, card_set* material_base, uint32 location);
void ritual_release(card_set* material); void ritual_release(const card_set& material);
void get_xyz_material(lua_State* L, card* scard, int32 findex, uint32 lv, int32 maxc, group* mg); void get_xyz_material(lua_State* L, card* scard, int32 findex, uint32 lv, int32 maxc, group* mg);
void get_overlay_group(uint8 self, uint8 s, uint8 o, card_set* pset); void get_overlay_group(uint8 self, uint8 s, uint8 o, card_set* pset);
int32 get_overlay_count(uint8 self, uint8 s, uint8 o); int32 get_overlay_count(uint8 self, uint8 s, uint8 o);
...@@ -527,7 +527,7 @@ public: ...@@ -527,7 +527,7 @@ public:
int32 execute_operation(uint16 step, effect* peffect, uint8 triggering_player); int32 execute_operation(uint16 step, effect* peffect, uint8 triggering_player);
int32 execute_target(uint16 step, effect* peffect, uint8 triggering_player); int32 execute_target(uint16 step, effect* peffect, uint8 triggering_player);
void raise_event(card* event_card, uint32 event_code, effect* reason_effect, uint32 reason, uint8 reason_player, uint8 event_player, uint32 event_value); void raise_event(card* event_card, uint32 event_code, effect* reason_effect, uint32 reason, uint8 reason_player, uint8 event_player, uint32 event_value);
void raise_event(card_set* event_cards, uint32 event_code, effect* reason_effect, uint32 reason, uint8 reason_player, uint8 event_player, uint32 event_value); void raise_event(const card_set& event_cards, uint32 event_code, effect* reason_effect, uint32 reason, uint8 reason_player, uint8 event_player, uint32 event_value);
void raise_single_event(card* trigger_card, card_set* event_cards, uint32 event_code, effect* reason_effect, uint32 reason, uint8 reason_player, uint8 event_player, uint32 event_value); void raise_single_event(card* trigger_card, card_set* event_cards, uint32 event_code, effect* reason_effect, uint32 reason, uint8 reason_player, uint8 event_player, uint32 event_value);
int32 check_event(uint32 code, tevent* pe = nullptr); int32 check_event(uint32 code, tevent* pe = nullptr);
int32 check_event_c(effect* peffect, uint8 playerid, int32 neglect_con, int32 neglect_cost, int32 copy_info, tevent* pe = nullptr); int32 check_event_c(effect* peffect, uint8 playerid, int32 neglect_con, int32 neglect_cost, int32 copy_info, tevent* pe = nullptr);
...@@ -564,9 +564,9 @@ public: ...@@ -564,9 +564,9 @@ public:
void change_target_param(uint8 chaincount, int32 param); void change_target_param(uint8 chaincount, int32 param);
void remove_counter(uint32 reason, card* pcard, uint32 rplayer, uint32 s, uint32 o, uint32 countertype, uint32 count); void remove_counter(uint32 reason, card* pcard, uint32 rplayer, uint32 s, uint32 o, uint32 countertype, uint32 count);
void remove_overlay_card(uint32 reason, card* pcard, uint32 rplayer, uint32 s, uint32 o, uint16 min, uint16 max); void remove_overlay_card(uint32 reason, card* pcard, uint32 rplayer, uint32 s, uint32 o, uint16 min, uint16 max);
void get_control(card_set* targets, effect* reason_effect, uint32 reason_player, uint32 playerid, uint32 reset_phase, uint32 reset_count, uint32 zone); void get_control(const card_set& targets, effect* reason_effect, uint32 reason_player, uint32 playerid, uint32 reset_phase, uint32 reset_count, uint32 zone);
void get_control(card* target, effect* reason_effect, uint32 reason_player, uint32 playerid, uint32 reset_phase, uint32 reset_count, uint32 zone); void get_control(card* target, effect* reason_effect, uint32 reason_player, uint32 playerid, uint32 reset_phase, uint32 reset_count, uint32 zone);
void swap_control(effect* reason_effect, uint32 reason_player, card_set* targets1, card_set* targets2, uint32 reset_phase, uint32 reset_count); void swap_control(effect* reason_effect, uint32 reason_player, const card_set& targets1, const card_set& targets2, uint32 reset_phase, uint32 reset_count);
void swap_control(effect* reason_effect, uint32 reason_player, card* pcard1, card* pcard2, uint32 reset_phase, uint32 reset_count); void swap_control(effect* reason_effect, uint32 reason_player, card* pcard1, card* pcard2, uint32 reset_phase, uint32 reset_count);
void equip(uint32 equip_player, card* equip_card, card* target, uint32 up, uint32 is_step); void equip(uint32 equip_player, card* equip_card, card* target, uint32 up, uint32 is_step);
void draw(effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, int32 count); void draw(effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, int32 count);
...@@ -575,17 +575,17 @@ public: ...@@ -575,17 +575,17 @@ public:
void summon(uint32 sumplayer, card* target, effect* proc, uint32 ignore_count, uint32 min_tribute, uint32 zone = 0x1f, uint32 action_type = SUMMON_IN_IDLE); void summon(uint32 sumplayer, card* target, effect* proc, uint32 ignore_count, uint32 min_tribute, uint32 zone = 0x1f, uint32 action_type = SUMMON_IN_IDLE);
void mset(uint32 setplayer, card* target, effect* proc, uint32 ignore_count, uint32 min_tribute, uint32 zone = 0x1f, uint32 action_type = SUMMON_IN_IDLE); void mset(uint32 setplayer, card* target, effect* proc, uint32 ignore_count, uint32 min_tribute, uint32 zone = 0x1f, uint32 action_type = SUMMON_IN_IDLE);
void special_summon_rule(uint32 sumplayer, card* target, uint32 summon_type, uint32 action_type = SUMMON_IN_IDLE); void special_summon_rule(uint32 sumplayer, card* target, uint32 summon_type, uint32 action_type = SUMMON_IN_IDLE);
void special_summon(card_set* target, uint32 sumtype, uint32 sumplayer, uint32 playerid, uint32 nocheck, uint32 nolimit, uint32 positions, uint32 zone); void special_summon(const card_set& target, uint32 sumtype, uint32 sumplayer, uint32 playerid, uint32 nocheck, uint32 nolimit, uint32 positions, uint32 zone);
void special_summon_step(card* target, uint32 sumtype, uint32 sumplayer, uint32 playerid, uint32 nocheck, uint32 nolimit, uint32 positions, uint32 zone); void special_summon_step(card* target, uint32 sumtype, uint32 sumplayer, uint32 playerid, uint32 nocheck, uint32 nolimit, uint32 positions, uint32 zone);
void special_summon_complete(effect* reason_effect, uint8 reason_player); void special_summon_complete(effect* reason_effect, uint8 reason_player);
void destroy(card_set* targets, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid = 2, uint32 destination = 0, uint32 sequence = 0); void destroy(card_set& targets, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid = 2, uint32 destination = 0, uint32 sequence = 0);
void destroy(card* target, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid = 2, uint32 destination = 0, uint32 sequence = 0); void destroy(card* target, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid = 2, uint32 destination = 0, uint32 sequence = 0);
void release(card_set* targets, effect* reason_effect, uint32 reason, uint32 reason_player); void release(const card_set& targets, effect* reason_effect, uint32 reason, uint32 reason_player);
void release(card* target, effect* reason_effect, uint32 reason, uint32 reason_player); void release(card* target, effect* reason_effect, uint32 reason, uint32 reason_player);
void send_to(card_set* targets, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence, uint32 position, uint8 send_activating = FALSE); void send_to(const card_set& targets, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence, uint32 position, uint8 send_activating = FALSE);
void send_to(card* target, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence, uint32 position, uint8 send_activating = FALSE); void send_to(card* target, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence, uint32 position, uint8 send_activating = FALSE);
void move_to_field(card* target, uint32 move_player, uint32 playerid, uint32 destination, uint32 positions, uint32 enable = FALSE, uint32 ret = 0, uint32 pzone = FALSE, uint32 zone = 0xff); void move_to_field(card* target, uint32 move_player, uint32 playerid, uint32 destination, uint32 positions, uint32 enable = FALSE, uint32 ret = 0, uint32 pzone = FALSE, uint32 zone = 0xff);
void change_position(card_set* targets, effect* reason_effect, uint32 reason_player, uint32 au, uint32 ad, uint32 du, uint32 dd, uint32 flag, uint32 enable = FALSE); void change_position(const card_set& targets, effect* reason_effect, uint32 reason_player, uint32 au, uint32 ad, uint32 du, uint32 dd, uint32 flag, uint32 enable = FALSE);
void change_position(card* target, effect* reason_effect, uint32 reason_player, uint32 npos, uint32 flag, uint32 enable = FALSE); void change_position(card* target, effect* reason_effect, uint32 reason_player, uint32 npos, uint32 flag, uint32 enable = FALSE);
void operation_replace(int32 type, int32 step, group* targets); void operation_replace(int32 type, int32 step, group* targets);
void select_tribute_cards(card* target, uint8 playerid, uint8 cancelable, int32 min, int32 max, uint8 toplayer, uint32 zone); void select_tribute_cards(card* target, uint8 playerid, uint8 cancelable, int32 min, int32 max, uint8 toplayer, uint32 zone);
......
...@@ -1893,10 +1893,10 @@ int32 scriptlib::card_register_flag_effect(lua_State *L) { ...@@ -1893,10 +1893,10 @@ int32 scriptlib::card_register_flag_effect(lua_State *L) {
int32 reset = (int32)lua_tointeger(L, 3); int32 reset = (int32)lua_tointeger(L, 3);
uint32 flag = (uint32)lua_tointeger(L, 4); uint32 flag = (uint32)lua_tointeger(L, 4);
int32 count = (int32)lua_tointeger(L, 5); int32 count = (int32)lua_tointeger(L, 5);
int32 lab = 0; lua_Integer lab = 0;
int32 desc = 0; int32 desc = 0;
if(lua_gettop(L) >= 6) if(lua_gettop(L) >= 6)
lab = (int32)lua_tointeger(L, 6); lab = lua_tointeger(L, 6);
if(lua_gettop(L) >= 7) if(lua_gettop(L) >= 7)
desc = (int32)lua_tointeger(L, 7); desc = (int32)lua_tointeger(L, 7);
if(count == 0) if(count == 0)
...@@ -1940,7 +1940,7 @@ int32 scriptlib::card_set_flag_effect_label(lua_State *L) { ...@@ -1940,7 +1940,7 @@ int32 scriptlib::card_set_flag_effect_label(lua_State *L) {
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1); card* pcard = *(card**) lua_touserdata(L, 1);
uint32 code = (lua_tointeger(L, 2) & MAX_CARD_ID) | EFFECT_FLAG_EFFECT; uint32 code = (lua_tointeger(L, 2) & MAX_CARD_ID) | EFFECT_FLAG_EFFECT;
int32 lab = (int32)lua_tointeger(L, 3); auto lab = lua_tointeger(L, 3);
auto eit = pcard->single_effect.find(code); auto eit = pcard->single_effect.find(code);
if(eit == pcard->single_effect.end()) if(eit == pcard->single_effect.end())
lua_pushboolean(L, FALSE); lua_pushboolean(L, FALSE);
......
This diff is collapsed.
...@@ -238,8 +238,7 @@ int32 scriptlib::effect_set_label(lua_State *L) { ...@@ -238,8 +238,7 @@ int32 scriptlib::effect_set_label(lua_State *L) {
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
peffect->label.clear(); peffect->label.clear();
for(int32 i = 2; i <= lua_gettop(L); ++i) { for(int32 i = 2; i <= lua_gettop(L); ++i) {
uint32 v = (uint32)lua_tointeger(L, i); peffect->label.push_back(lua_tointeger(L, i));
peffect->label.push_back(v);
} }
return 0; return 0;
} }
...@@ -507,8 +506,8 @@ int32 scriptlib::effect_is_has_property(lua_State *L) { ...@@ -507,8 +506,8 @@ 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 tflag1 = (uint32)lua_tointeger(L, 2); uint64 tflag1 = lua_tointeger(L, 2);
uint32 tflag2 = (uint32)lua_tointeger(L, 3); uint64 tflag2 = lua_tointeger(L, 3);
if (peffect && (!tflag1 || (peffect->flag[0] & tflag1)) && (!tflag2 || (peffect->flag[1] & tflag2))) if (peffect && (!tflag1 || (peffect->flag[0] & tflag1)) && (!tflag2 || (peffect->flag[1] & tflag2)))
lua_pushboolean(L, 1); lua_pushboolean(L, 1);
else else
......
This diff is collapsed.
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