Commit 38d6ca31 authored by nanahira's avatar nanahira

say goodbye to &0xffff

parent 13590a51
......@@ -813,8 +813,8 @@ void field::get_linked_cards(uint8 self, uint8 s, uint8 o, card_set* cset) {
uint8 c = s;
for(int32 p = 0; p < 2; ++p) {
if(c) {
uint32 linked_zone = get_linked_zone(self) & 0xffff;
get_cards_in_zone(cset, linked_zone, self, LOCATION_MZONE);
uint32 linked_zone = get_linked_zone(self);
get_cards_in_zone(cset, linked_zone, self, LOCATION_MZONE, false);
}
self = 1 - self;
c = o;
......@@ -877,7 +877,7 @@ int32 field::check_extra_link(int32 playerid, card* pcard, int32 sequence) {
pcard->current.sequence = cur_sequence;
return ret;
}
void field::get_cards_in_zone(card_set* cset, uint32 zone, int32 playerid, int32 location) {
void field::get_cards_in_zone(card_set* cset, uint32 zone, int32 playerid, int32 location, bool oppo) {
if(!(location & LOCATION_ONFIELD))
return;
uint32 icheck;
......@@ -892,15 +892,17 @@ void field::get_cards_in_zone(card_set* cset, uint32 zone, int32 playerid, int32
}
icheck <<= 1;
}
card_vector& svector_o = player[1 - playerid].list_mzone;
icheck = 0x10000;
for(auto it = svector_o.begin(); it != svector_o.end(); ++it) {
if(zone & icheck) {
card* pcard = *it;
if(pcard)
cset->insert(pcard);
if(oppo) {
card_vector& svector_o = player[1 - playerid].list_mzone;
icheck = 0x10000;
for(auto it = svector_o.begin(); it != svector_o.end(); ++it) {
if(zone & icheck) {
card* pcard = *it;
if(pcard)
cset->insert(pcard);
}
icheck <<= 1;
}
icheck <<= 1;
}
}
if(location & LOCATION_SZONE) {
......@@ -914,15 +916,17 @@ void field::get_cards_in_zone(card_set* cset, uint32 zone, int32 playerid, int32
}
icheck <<= 1;
}
card_vector& svector_o = player[1 - playerid].list_szone;
icheck = 0x1000000;
for(auto it = svector_o.begin(); it != svector_o.end(); ++it) {
if(zone & icheck) {
card* pcard = *it;
if(pcard)
cset->insert(pcard);
if(oppo) {
card_vector& svector_o = player[1 - playerid].list_szone;
icheck = 0x1000000;
for(auto it = svector_o.begin(); it != svector_o.end(); ++it) {
if(zone & icheck) {
card* pcard = *it;
if(pcard)
cset->insert(pcard);
}
icheck <<= 1;
}
icheck <<= 1;
}
}
}
......@@ -2635,7 +2639,7 @@ int32 field::check_tuner_material(card* pcard, card* tuner, int32 findex1, int32
card_set linked_cards;
if(ct <= 0) {
uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f;
get_cards_in_zone(&linked_cards, linked_zone & 0xffff, playerid, LOCATION_MZONE);
get_cards_in_zone(&linked_cards, linked_zone, playerid, LOCATION_MZONE, false);
if(linked_cards.find(tuner) != linked_cards.end())
ct++;
}
......@@ -2933,7 +2937,7 @@ int32 field::check_xyz_material(card* scard, int32 findex, int32 lv, int32 min,
if(ct <= 0) {
int32 ft = ct;
uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f;
get_cards_in_zone(&linked_cards, linked_zone & 0xffff, playerid, LOCATION_MZONE);
get_cards_in_zone(&linked_cards, linked_zone, playerid, LOCATION_MZONE, false);
for(auto cit = core.xmaterial_lst.begin(); cit != core.xmaterial_lst.end(); ++cit) {
card* pcard = cit->second;
if(linked_cards.find(pcard) != linked_cards.end())
......
......@@ -374,7 +374,7 @@ public:
void get_linked_cards(uint8 self, uint8 s, uint8 o, card_set* cset);
int32 check_extra_link(int32 playerid);
int32 check_extra_link(int32 playerid, card* pcard, int32 sequence);
void get_cards_in_zone(card_set* cset, uint32 zone, int32 playerid, int32 location = 0xc);
void get_cards_in_zone(card_set* cset, uint32 zone, int32 playerid, int32 location = 0xc, bool oppo = true);
void shuffle(uint8 playerid, uint8 location);
void reset_sequence(uint8 playerid, uint8 location);
void swap_deck_and_grave(uint8 playerid);
......
......@@ -5067,7 +5067,7 @@ int32 field::select_synchro_material(int16 step, uint8 playerid, card* pcard, in
}
card_set linked_cards;
uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f;
get_cards_in_zone(&linked_cards, linked_zone & 0xffff, playerid, LOCATION_MZONE);
get_cards_in_zone(&linked_cards, linked_zone, playerid, LOCATION_MZONE, false);
if(linked_cards.find(tuner) != linked_cards.end())
ct++;
if(smat && linked_cards.find(smat) != linked_cards.end())
......@@ -5296,7 +5296,7 @@ int32 field::select_xyz_material(int16 step, uint8 playerid, uint32 lv, card* sc
card_set linked_cards;
if(ct <= 0) {
uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f;
get_cards_in_zone(&linked_cards, linked_zone & 0xffff, playerid, LOCATION_MZONE);
get_cards_in_zone(&linked_cards, linked_zone, playerid, LOCATION_MZONE, false);
}
for(auto mit = core.operated_set.begin(); mit != core.operated_set.end(); ++mit) {
card* pcard = *mit;
......@@ -5382,7 +5382,7 @@ int32 field::select_xyz_material(int16 step, uint8 playerid, uint32 lv, card* sc
}
card_set linked_cards;
uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f;
get_cards_in_zone(&linked_cards, linked_zone & 0xffff, playerid, LOCATION_MZONE);
get_cards_in_zone(&linked_cards, linked_zone, playerid, LOCATION_MZONE, false);
int32 ft = ct + std::count_if(core.operated_set.begin(), core.operated_set.end(),
[=](card* pcard) { return linked_cards.find(pcard) != linked_cards.end(); });
if(ft > 0) {
......@@ -5565,7 +5565,7 @@ int32 field::select_xyz_material(int16 step, uint8 playerid, uint32 lv, card* sc
return FALSE;
card_set linked_cards;
uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f;
get_cards_in_zone(&linked_cards, linked_zone & 0xffff, playerid, LOCATION_MZONE);
get_cards_in_zone(&linked_cards, linked_zone, playerid, LOCATION_MZONE, false);
int32 ft = ct + std::count_if(core.operated_set.begin(), core.operated_set.end(),
[=](card* pcard) { return linked_cards.find(pcard) != linked_cards.end(); });
if(ft > 0)
......
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