Commit 15b29e41 authored by nanahira's avatar nanahira

update get_cards_in_zone

parent 13e0a39e
...@@ -1214,7 +1214,6 @@ void card::get_linked_cards(card_set* cset) { ...@@ -1214,7 +1214,6 @@ void card::get_linked_cards(card_set* cset) {
int32 p = current.controler; int32 p = current.controler;
uint32 linked_zone = get_linked_zone(); uint32 linked_zone = get_linked_zone();
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);
} }
uint32 card::get_mutual_linked_zone() { uint32 card::get_mutual_linked_zone() {
if(!(data.type & TYPE_LINK) || current.location != LOCATION_MZONE) if(!(data.type & TYPE_LINK) || current.location != LOCATION_MZONE)
...@@ -1353,7 +1352,6 @@ void card::get_mutual_linked_cards(card_set* cset) { ...@@ -1353,7 +1352,6 @@ void card::get_mutual_linked_cards(card_set* cset) {
int32 p = current.controler; int32 p = current.controler;
uint32 mutual_linked_zone = get_mutual_linked_zone(); uint32 mutual_linked_zone = get_mutual_linked_zone();
pduel->game_field->get_cards_in_zone(cset, mutual_linked_zone, p, LOCATION_MZONE); pduel->game_field->get_cards_in_zone(cset, mutual_linked_zone, p, LOCATION_MZONE);
pduel->game_field->get_cards_in_zone(cset, mutual_linked_zone >> 16, 1 - p, LOCATION_MZONE);
} }
int32 card::is_link_state() { int32 card::is_link_state() {
if(current.location != LOCATION_MZONE) if(current.location != LOCATION_MZONE)
...@@ -1489,9 +1487,6 @@ void card::get_column_cards(card_set* cset, int32 left, int32 right) { ...@@ -1489,9 +1487,6 @@ void card::get_column_cards(card_set* cset, int32 left, int32 right) {
uint32 column_mzone = get_column_zone(LOCATION_MZONE, left, right); uint32 column_mzone = get_column_zone(LOCATION_MZONE, left, right);
uint32 column_szone = get_column_zone(LOCATION_SZONE, left, right); uint32 column_szone = get_column_zone(LOCATION_SZONE, left, right);
pduel->game_field->get_cards_in_zone(cset, column_mzone, p, LOCATION_MZONE); pduel->game_field->get_cards_in_zone(cset, column_mzone, p, LOCATION_MZONE);
pduel->game_field->get_cards_in_zone(cset, column_mzone >> 16, 1 - p, LOCATION_MZONE);
pduel->game_field->get_cards_in_zone(cset, column_szone, p, LOCATION_SZONE);
pduel->game_field->get_cards_in_zone(cset, column_szone >> 16, 1 - p, LOCATION_SZONE);
} }
int32 card::is_all_column() { int32 card::is_all_column() {
if(!(current.location & LOCATION_ONFIELD)) if(!(current.location & LOCATION_ONFIELD))
......
...@@ -813,7 +813,7 @@ void field::get_linked_cards(uint8 self, uint8 s, uint8 o, card_set* cset) { ...@@ -813,7 +813,7 @@ void field::get_linked_cards(uint8 self, uint8 s, uint8 o, card_set* cset) {
uint8 c = s; uint8 c = s;
for(int32 p = 0; p < 2; ++p) { for(int32 p = 0; p < 2; ++p) {
if(c) { if(c) {
uint32 linked_zone = get_linked_zone(self); uint32 linked_zone = get_linked_zone(self) & 0xffff;
get_cards_in_zone(cset, linked_zone, self, LOCATION_MZONE); get_cards_in_zone(cset, linked_zone, self, LOCATION_MZONE);
} }
self = 1 - self; self = 1 - self;
...@@ -880,9 +880,11 @@ int32 field::check_extra_link(int32 playerid, card* pcard, int32 sequence) { ...@@ -880,9 +880,11 @@ int32 field::check_extra_link(int32 playerid, card* pcard, int32 sequence) {
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) {
if(!(location & LOCATION_ONFIELD)) if(!(location & LOCATION_ONFIELD))
return; return;
card_vector& svector = (location == LOCATION_MZONE) ? player[playerid].list_mzone : player[playerid].list_szone; uint32 icheck;
uint32 icheck = 0x1; if(location & LOCATION_MZONE) {
for(auto it = svector.begin(); it != svector.end(); ++it) { card_vector& svector_s = player[playerid].list_mzone;
icheck = 0x1;
for(auto it = svector_s.begin(); it != svector_s.end(); ++it) {
if(zone & icheck) { if(zone & icheck) {
card* pcard = *it; card* pcard = *it;
if(pcard) if(pcard)
...@@ -890,6 +892,39 @@ void field::get_cards_in_zone(card_set* cset, uint32 zone, int32 playerid, int32 ...@@ -890,6 +892,39 @@ void field::get_cards_in_zone(card_set* cset, uint32 zone, int32 playerid, int32
} }
icheck <<= 1; 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);
}
icheck <<= 1;
}
}
if(location & LOCATION_SZONE) {
card_vector& svector_s = player[playerid].list_szone;
icheck = 0x100;
for(auto it = svector_s.begin(); it != svector_s.end(); ++it) {
if(zone & icheck) {
card* pcard = *it;
if(pcard)
cset->insert(pcard);
}
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);
}
icheck <<= 1;
}
}
} }
void field::shuffle(uint8 playerid, uint8 location) { void field::shuffle(uint8 playerid, uint8 location) {
if(!(location & (LOCATION_HAND | LOCATION_DECK | LOCATION_EXTRA))) if(!(location & (LOCATION_HAND | LOCATION_DECK | LOCATION_EXTRA)))
...@@ -2600,7 +2635,7 @@ int32 field::check_tuner_material(card* pcard, card* tuner, int32 findex1, int32 ...@@ -2600,7 +2635,7 @@ int32 field::check_tuner_material(card* pcard, card* tuner, int32 findex1, int32
card_set linked_cards; card_set linked_cards;
if(ct <= 0) { if(ct <= 0) {
uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f; uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f;
get_cards_in_zone(&linked_cards, linked_zone, playerid, LOCATION_MZONE); get_cards_in_zone(&linked_cards, linked_zone & 0xffff, playerid, LOCATION_MZONE);
if(linked_cards.find(tuner) != linked_cards.end()) if(linked_cards.find(tuner) != linked_cards.end())
ct++; ct++;
} }
...@@ -2898,7 +2933,7 @@ int32 field::check_xyz_material(card* scard, int32 findex, int32 lv, int32 min, ...@@ -2898,7 +2933,7 @@ int32 field::check_xyz_material(card* scard, int32 findex, int32 lv, int32 min,
if(ct <= 0) { if(ct <= 0) {
int32 ft = ct; int32 ft = ct;
uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f; uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f;
get_cards_in_zone(&linked_cards, linked_zone, playerid, LOCATION_MZONE); get_cards_in_zone(&linked_cards, linked_zone & 0xffff, playerid, LOCATION_MZONE);
for(auto cit = core.xmaterial_lst.begin(); cit != core.xmaterial_lst.end(); ++cit) { for(auto cit = core.xmaterial_lst.begin(); cit != core.xmaterial_lst.end(); ++cit) {
card* pcard = cit->second; card* pcard = cit->second;
if(linked_cards.find(pcard) != linked_cards.end()) if(linked_cards.find(pcard) != linked_cards.end())
......
...@@ -374,7 +374,7 @@ public: ...@@ -374,7 +374,7 @@ public:
void get_linked_cards(uint8 self, uint8 s, uint8 o, card_set* cset); 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);
int32 check_extra_link(int32 playerid, card* pcard, int32 sequence); int32 check_extra_link(int32 playerid, card* pcard, int32 sequence);
void get_cards_in_zone(card_set* cset, uint32 zone, int32 playerid, int32 location); void get_cards_in_zone(card_set* cset, uint32 zone, int32 playerid, int32 location = 0xc);
void shuffle(uint8 playerid, uint8 location); void shuffle(uint8 playerid, uint8 location);
void reset_sequence(uint8 playerid, uint8 location); void reset_sequence(uint8 playerid, uint8 location);
void swap_deck_and_grave(uint8 playerid); void swap_deck_and_grave(uint8 playerid);
......
...@@ -5067,7 +5067,7 @@ int32 field::select_synchro_material(int16 step, uint8 playerid, card* pcard, in ...@@ -5067,7 +5067,7 @@ int32 field::select_synchro_material(int16 step, uint8 playerid, card* pcard, in
} }
card_set linked_cards; card_set linked_cards;
uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f; uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f;
get_cards_in_zone(&linked_cards, linked_zone, playerid, LOCATION_MZONE); get_cards_in_zone(&linked_cards, linked_zone & 0xffff, playerid, LOCATION_MZONE);
if(linked_cards.find(tuner) != linked_cards.end()) if(linked_cards.find(tuner) != linked_cards.end())
ct++; ct++;
if(smat && linked_cards.find(smat) != linked_cards.end()) 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 ...@@ -5296,7 +5296,7 @@ int32 field::select_xyz_material(int16 step, uint8 playerid, uint32 lv, card* sc
card_set linked_cards; card_set linked_cards;
if(ct <= 0) { if(ct <= 0) {
uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f; uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f;
get_cards_in_zone(&linked_cards, linked_zone, playerid, LOCATION_MZONE); get_cards_in_zone(&linked_cards, linked_zone & 0xffff, playerid, LOCATION_MZONE);
} }
for(auto mit = core.operated_set.begin(); mit != core.operated_set.end(); ++mit) { for(auto mit = core.operated_set.begin(); mit != core.operated_set.end(); ++mit) {
card* pcard = *mit; card* pcard = *mit;
...@@ -5382,7 +5382,7 @@ int32 field::select_xyz_material(int16 step, uint8 playerid, uint32 lv, card* sc ...@@ -5382,7 +5382,7 @@ int32 field::select_xyz_material(int16 step, uint8 playerid, uint32 lv, card* sc
} }
card_set linked_cards; card_set linked_cards;
uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f; uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f;
get_cards_in_zone(&linked_cards, linked_zone, playerid, LOCATION_MZONE); get_cards_in_zone(&linked_cards, linked_zone & 0xffff, playerid, LOCATION_MZONE);
int32 ft = ct + std::count_if(core.operated_set.begin(), core.operated_set.end(), int32 ft = ct + std::count_if(core.operated_set.begin(), core.operated_set.end(),
[=](card* pcard) { return linked_cards.find(pcard) != linked_cards.end(); }); [=](card* pcard) { return linked_cards.find(pcard) != linked_cards.end(); });
if(ft > 0) { if(ft > 0) {
...@@ -5565,7 +5565,7 @@ int32 field::select_xyz_material(int16 step, uint8 playerid, uint32 lv, card* sc ...@@ -5565,7 +5565,7 @@ int32 field::select_xyz_material(int16 step, uint8 playerid, uint32 lv, card* sc
return FALSE; return FALSE;
card_set linked_cards; card_set linked_cards;
uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f; uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f;
get_cards_in_zone(&linked_cards, linked_zone, playerid, LOCATION_MZONE); get_cards_in_zone(&linked_cards, linked_zone & 0xffff, playerid, LOCATION_MZONE);
int32 ft = ct + std::count_if(core.operated_set.begin(), core.operated_set.end(), int32 ft = ct + std::count_if(core.operated_set.begin(), core.operated_set.end(),
[=](card* pcard) { return linked_cards.find(pcard) != linked_cards.end(); }); [=](card* pcard) { return linked_cards.find(pcard) != linked_cards.end(); });
if(ft > 0) 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