Commit 504ff1fa authored by VanillaSalt's avatar VanillaSalt

fix

parent 838f354c
......@@ -1154,25 +1154,9 @@ void card::get_linked_cards(card_set* cset) {
if(!(data.type & TYPE_LINK) || current.location != LOCATION_MZONE)
return;
int32 p = current.controler;
uint32 zones = get_linked_zone();
uint32 icheck = 0x1;
for(auto it = pduel->game_field->player[p].list_mzone.begin(); it != pduel->game_field->player[p].list_mzone.end(); ++it) {
if(zones & icheck) {
card* pcard = *it;
if(pcard)
cset->insert(pcard);
}
icheck <<= 1;
}
icheck = 0x10000;
for(auto it = pduel->game_field->player[1 - p].list_mzone.begin(); it != pduel->game_field->player[1 - p].list_mzone.end(); ++it) {
if(zones & icheck) {
card* pcard = *it;
if(pcard)
cset->insert(pcard);
}
icheck <<= 1;
}
uint32 linked_zone = get_linked_zone();
pduel->game_field->get_cards_in_zone(cset, linked_zone, p);
pduel->game_field->get_cards_in_zone(cset, linked_zone >> 16, 1 - p);
}
uint32 card::get_mutual_linked_zone() {
if(!(data.type & TYPE_LINK) || current.location != LOCATION_MZONE)
......
......@@ -679,19 +679,13 @@ uint8 effect::get_handler_player() {
return effect_owner;
return get_handler()->current.controler;
}
int32 effect::in_range(int32 loc, int32 seq) {
int32 effect::in_range(card* pcard) {
if(type & EFFECT_TYPE_XMATERIAL)
return handler->overlay_target ? TRUE : FALSE;
if(loc != LOCATION_SZONE)
return range & loc;
if(seq < 5)
return range & LOCATION_SZONE;
if(seq == 5)
return range & (LOCATION_SZONE | LOCATION_FZONE);
return range & LOCATION_PZONE;
return pcard->current.is_location(range);
}
int32 effect::in_range(card* pcard) {
int32 effect::in_range(const chain& ch) {
if(type & EFFECT_TYPE_XMATERIAL)
return handler->overlay_target ? TRUE : FALSE;
return pcard->current.is_location(range);
return range & ch.triggering_location;
}
......@@ -89,8 +89,8 @@ public:
uint8 get_owner_player();
card* get_handler() const;
uint8 get_handler_player();
int32 in_range(int32 loc, int32 seq);
int32 in_range(card* pcard);
int32 in_range(const chain& ch);
bool is_flag(effect_flag flag) const {
return !!(this->flag[0] & flag);
}
......
......@@ -20,6 +20,16 @@ int32 field::field_used_count[32] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3
bool chain::chain_operation_sort(const chain& c1, const chain& c2) {
return c1.triggering_effect->id < c2.triggering_effect->id;
}
void chain::set_triggering_place(card* pcard) {
triggering_controler = pcard->current.controler;
if(pcard->current.is_location(LOCATION_FZONE))
triggering_location = LOCATION_SZONE | LOCATION_FZONE;
else if(pcard->current.is_location(LOCATION_PZONE))
triggering_location = LOCATION_SZONE | LOCATION_PZONE;
else
triggering_location = pcard->current.location;
triggering_sequence = pcard->current.sequence;
}
bool tevent::operator< (const tevent& v) const {
return memcmp(this, &v, sizeof(tevent)) < 0;
}
......@@ -139,7 +149,7 @@ void field::reload_field_info() {
pduel->write_buffer32(peffect->get_handler()->data.code);
pduel->write_buffer32(peffect->get_handler()->get_info_location());
pduel->write_buffer8(chit->triggering_controler);
pduel->write_buffer8(chit->triggering_location);
pduel->write_buffer8((uint8)chit->triggering_location);
pduel->write_buffer8(chit->triggering_sequence);
pduel->write_buffer32(peffect->description);
}
......@@ -719,6 +729,17 @@ 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) {
uint32 icheck = 0x1;
for(auto it = player[playerid].list_mzone.begin(); it != player[playerid].list_mzone.end(); ++it) {
if(zone & icheck) {
card* pcard = *it;
if(pcard)
cset->insert(pcard);
}
icheck <<= 1;
}
}
void field::shuffle(uint8 playerid, uint8 location) {
if(!(location & (LOCATION_HAND | LOCATION_DECK)))
return;
......@@ -2372,17 +2393,8 @@ int32 field::check_tuner_material(card* pcard, card* tuner, int32 findex1, int32
int32 ct = get_useable_count(pcard, playerid, LOCATION_MZONE, playerid, LOCATION_REASON_TOFIELD);
card_set linked_cards;
if(ct <= 0) {
uint32 linked_zone = get_linked_zone(playerid);
linked_zone |= (1u << 5) | (1u << 6);
uint32 icheck = 0x1;
for(auto it = player[playerid].list_mzone.begin(); it != player[playerid].list_mzone.end(); ++it) {
if(linked_zone & icheck) {
card* pcard = *it;
if(pcard)
linked_cards.insert(pcard);
}
icheck <<= 1;
}
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);
if(linked_cards.find(tuner) != linked_cards.end())
ct++;
}
......
......@@ -49,7 +49,7 @@ struct chain {
uint8 chain_count;
uint8 triggering_player;
uint8 triggering_controler;
uint8 triggering_location;
uint16 triggering_location;
uint8 triggering_sequence;
effect* triggering_effect;
group* target_cards;
......@@ -62,6 +62,7 @@ struct chain {
opmap opinfos;
uint32 flag;
static bool chain_operation_sort(const chain& c1, const chain& c2);
void set_triggering_place(card* pcard);
};
struct player_info {
......@@ -347,6 +348,7 @@ public:
uint32 get_linked_zone(int32 playerid);
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);
void shuffle(uint8 playerid, uint8 location);
void reset_sequence(uint8 playerid, uint8 location);
void swap_deck_and_grave(uint8 playerid);
......
......@@ -335,7 +335,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(ptr pduel, byte* buf) {
*((int*)(buf)) = peffect->get_handler()->get_info_location();
buf += 4;
*buf++ = chit->triggering_controler;
*buf++ = chit->triggering_location;
*buf++ = (uint8)chit->triggering_location;
*buf++ = chit->triggering_sequence;
*((int*)(buf)) = peffect->description;
buf += 4;
......
......@@ -4681,17 +4681,8 @@ int32 field::select_synchro_material(int16 step, uint8 playerid, card* pcard, in
int32 ct = get_useable_count(pcard, playerid, LOCATION_MZONE, playerid, LOCATION_REASON_TOFIELD);
if(ct <= 0) {
card_set linked_cards;
uint32 linked_zone = get_linked_zone(playerid);
linked_zone |= (1u << 5) | (1u << 6);
uint32 icheck = 0x1;
for(auto it = player[playerid].list_mzone.begin(); it != player[playerid].list_mzone.end(); ++it) {
if(linked_zone & icheck) {
card* pcard = *it;
if(pcard)
linked_cards.insert(pcard);
}
icheck <<= 1;
}
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);
if(linked_cards.find(tuner) != linked_cards.end())
ct++;
if(smat) {
......@@ -4707,17 +4698,8 @@ int32 field::select_synchro_material(int16 step, uint8 playerid, card* pcard, in
int32 lv = pcard->get_level();
int32 playerid = pcard->current.controler;
card_set linked_cards;
uint32 linked_zone = get_linked_zone(playerid);
linked_zone |= (1u << 5) | (1u << 6);
uint32 icheck = 0x1;
for(auto it = player[playerid].list_mzone.begin(); it != player[playerid].list_mzone.end(); ++it) {
if(linked_zone & icheck) {
card* pcard = *it;
if(pcard)
linked_cards.insert(pcard);
}
icheck <<= 1;
}
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);
card_vector* select_cards = new card_vector;
select_cards->swap(core.select_cards);
card_vector* must_select_cards = new card_vector;
......
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