Commit 3bb24b93 authored by DailyShana's avatar DailyShana

update EVENT_LEAVE_FIELD

parent 8520696d
...@@ -1560,6 +1560,7 @@ void card::xyz_overlay(card_set* materials) { ...@@ -1560,6 +1560,7 @@ void card::xyz_overlay(card_set* materials) {
pduel->game_field->remove_unique_card(pcard); pduel->game_field->remove_unique_card(pcard);
if(pcard->equiping_target) if(pcard->equiping_target)
pcard->unequip(); pcard->unequip();
pcard->clear_card_target();
xyz_add(pcard, &des); xyz_add(pcard, &des);
} else { } else {
field::card_vector cv; field::card_vector cv;
...@@ -1572,6 +1573,7 @@ void card::xyz_overlay(card_set* materials) { ...@@ -1572,6 +1573,7 @@ void card::xyz_overlay(card_set* materials) {
pduel->game_field->remove_unique_card(*cvit); pduel->game_field->remove_unique_card(*cvit);
if((*cvit)->equiping_target) if((*cvit)->equiping_target)
(*cvit)->unequip(); (*cvit)->unequip();
(*cvit)->clear_card_target();
xyz_add(*cvit, &des); xyz_add(*cvit, &des);
} }
} }
...@@ -1989,20 +1991,6 @@ void card::reset(uint32 id, uint32 reset_type) { ...@@ -1989,20 +1991,6 @@ void card::reset(uint32 id, uint32 reset_type) {
} }
if(id & 0xd7e0000) { if(id & 0xd7e0000) {
counters.clear(); counters.clear();
for(auto cit = effect_target_owner.begin(); cit != effect_target_owner.end(); ++cit)
(*cit)->effect_target_cards.erase(this);
for(auto cit = effect_target_cards.begin(); cit != effect_target_cards.end(); ++cit) {
card* pcard = *cit;
pcard->effect_target_owner.erase(this);
for(auto it = pcard->single_effect.begin(); it != pcard->single_effect.end();) {
auto rm = it++;
effect* peffect = rm->second;
if((peffect->owner == this) && peffect->is_flag(EFFECT_FLAG_OWNER_RELATE))
pcard->remove_effect(peffect, rm);
}
}
effect_target_owner.clear();
effect_target_cards.clear();
} }
if(id & 0x3fe0000) { if(id & 0x3fe0000) {
auto pr = field_effect.equal_range(EFFECT_USE_EXTRA_MZONE); auto pr = field_effect.equal_range(EFFECT_USE_EXTRA_MZONE);
...@@ -2338,6 +2326,22 @@ void card::cancel_card_target(card* pcard) { ...@@ -2338,6 +2326,22 @@ void card::cancel_card_target(card* pcard) {
pduel->write_buffer32(pcard->get_info_location()); pduel->write_buffer32(pcard->get_info_location());
} }
} }
void card::clear_card_target() {
for(auto cit = effect_target_owner.begin(); cit != effect_target_owner.end(); ++cit)
(*cit)->effect_target_cards.erase(this);
for(auto cit = effect_target_cards.begin(); cit != effect_target_cards.end(); ++cit) {
card* pcard = *cit;
pcard->effect_target_owner.erase(this);
for(auto it = pcard->single_effect.begin(); it != pcard->single_effect.end();) {
auto rm = it++;
effect* peffect = rm->second;
if((peffect->owner == this) && peffect->is_flag(EFFECT_FLAG_OWNER_RELATE))
pcard->remove_effect(peffect, rm);
}
}
effect_target_owner.clear();
effect_target_cards.clear();
}
void card::filter_effect(int32 code, effect_set* eset, uint8 sort) { void card::filter_effect(int32 code, effect_set* eset, uint8 sort) {
effect* peffect; effect* peffect;
auto rg = single_effect.equal_range(code); auto rg = single_effect.equal_range(code);
......
...@@ -277,6 +277,7 @@ public: ...@@ -277,6 +277,7 @@ public:
void set_material(card_set* materials); void set_material(card_set* materials);
void add_card_target(card* pcard); void add_card_target(card* pcard);
void cancel_card_target(card* pcard); void cancel_card_target(card* pcard);
void clear_card_target();
void filter_effect(int32 code, effect_set* eset, uint8 sort = TRUE); void filter_effect(int32 code, effect_set* eset, uint8 sort = TRUE);
void filter_single_effect(int32 code, effect_set* eset, uint8 sort = TRUE); void filter_single_effect(int32 code, effect_set* eset, uint8 sort = TRUE);
......
...@@ -3933,6 +3933,7 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -3933,6 +3933,7 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
pcard->previous.location = 0; pcard->previous.location = 0;
} else if(oloc & LOCATION_ONFIELD) { } else if(oloc & LOCATION_ONFIELD) {
pcard->reset(RESET_LEAVE + RESET_MSCHANGE, RESET_EVENT); pcard->reset(RESET_LEAVE + RESET_MSCHANGE, RESET_EVENT);
pcard->clear_card_target();
param->leave.insert(pcard); param->leave.insert(pcard);
} }
if(param->predirect->operation) { if(param->predirect->operation) {
...@@ -3974,6 +3975,22 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -3974,6 +3975,22 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
pduel->write_buffer32(ptop->data.code | 0x80000000); pduel->write_buffer32(ptop->data.code | 0x80000000);
} }
} }
for(auto cit = param->targets->container.begin(); cit != param->targets->container.end(); ++cit) {
card* pcard = *cit;
uint8 nloc = pcard->current.location;
if(nloc == LOCATION_HAND)
pcard->reset(RESET_TOHAND, RESET_EVENT);
else if(nloc == LOCATION_DECK || nloc == LOCATION_EXTRA)
pcard->reset(RESET_TODECK, RESET_EVENT);
else if(nloc == LOCATION_GRAVE)
pcard->reset(RESET_TOGRAVE, RESET_EVENT);
if(nloc == LOCATION_REMOVED || ((pcard->data.type & TYPE_TOKEN) && pcard->sendto_param.location == LOCATION_REMOVED)) {
if(pcard->current.reason & REASON_TEMPORARY)
pcard->reset(RESET_TEMP_REMOVE, RESET_EVENT);
else
pcard->reset(RESET_REMOVE, RESET_EVENT);
}
}
for(auto iter = param->leave.begin(); iter != param->leave.end(); ++iter) for(auto iter = param->leave.begin(); iter != param->leave.end(); ++iter)
raise_single_event(*iter, 0, EVENT_LEAVE_FIELD, (*iter)->current.reason_effect, (*iter)->current.reason, (*iter)->current.reason_player, 0, 0); raise_single_event(*iter, 0, EVENT_LEAVE_FIELD, (*iter)->current.reason_effect, (*iter)->current.reason, (*iter)->current.reason_player, 0, 0);
if((core.global_flag & GLOBALFLAG_DETACH_EVENT) && param->detach.size()) { if((core.global_flag & GLOBALFLAG_DETACH_EVENT) && param->detach.size()) {
...@@ -4011,18 +4028,16 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -4011,18 +4028,16 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
equipings.insert(equipc); equipings.insert(equipc);
} }
} }
pcard->clear_card_target();
if(!(pcard->data.type & TYPE_TOKEN)) { if(!(pcard->data.type & TYPE_TOKEN)) {
pcard->enable_field_effect(true); pcard->enable_field_effect(true);
if(nloc == LOCATION_HAND) { if(nloc == LOCATION_HAND) {
tohand.insert(pcard); tohand.insert(pcard);
pcard->reset(RESET_TOHAND, RESET_EVENT);
raise_single_event(pcard, 0, EVENT_TO_HAND, pcard->current.reason_effect, pcard->current.reason, pcard->current.reason_player, 0, 0); raise_single_event(pcard, 0, EVENT_TO_HAND, pcard->current.reason_effect, pcard->current.reason, pcard->current.reason_player, 0, 0);
} else if(nloc == LOCATION_DECK || nloc == LOCATION_EXTRA) { } else if(nloc == LOCATION_DECK || nloc == LOCATION_EXTRA) {
todeck.insert(pcard); todeck.insert(pcard);
pcard->reset(RESET_TODECK, RESET_EVENT);
raise_single_event(pcard, 0, EVENT_TO_DECK, pcard->current.reason_effect, pcard->current.reason, pcard->current.reason_player, 0, 0); raise_single_event(pcard, 0, EVENT_TO_DECK, pcard->current.reason_effect, pcard->current.reason, pcard->current.reason_player, 0, 0);
} else if(nloc == LOCATION_GRAVE) { } else if(nloc == LOCATION_GRAVE) {
pcard->reset(RESET_TOGRAVE, RESET_EVENT);
if(pcard->current.reason & REASON_RETURN) { if(pcard->current.reason & REASON_RETURN) {
retgrave.insert(pcard); retgrave.insert(pcard);
raise_single_event(pcard, 0, EVENT_RETURN_TO_GRAVE, pcard->current.reason_effect, pcard->current.reason, pcard->current.reason_player, 0, 0); raise_single_event(pcard, 0, EVENT_RETURN_TO_GRAVE, pcard->current.reason_effect, pcard->current.reason, pcard->current.reason_player, 0, 0);
...@@ -4034,10 +4049,6 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -4034,10 +4049,6 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
} }
if(nloc == LOCATION_REMOVED || ((pcard->data.type & TYPE_TOKEN) && pcard->sendto_param.location == LOCATION_REMOVED)) { if(nloc == LOCATION_REMOVED || ((pcard->data.type & TYPE_TOKEN) && pcard->sendto_param.location == LOCATION_REMOVED)) {
remove.insert(pcard); remove.insert(pcard);
if(pcard->current.reason & REASON_TEMPORARY)
pcard->reset(RESET_TEMP_REMOVE, RESET_EVENT);
else
pcard->reset(RESET_REMOVE, RESET_EVENT);
raise_single_event(pcard, 0, EVENT_REMOVE, pcard->current.reason_effect, pcard->current.reason, pcard->current.reason_player, 0, 0); raise_single_event(pcard, 0, EVENT_REMOVE, pcard->current.reason_effect, pcard->current.reason, pcard->current.reason_player, 0, 0);
} }
if(pcard->current.reason & REASON_DISCARD) { if(pcard->current.reason & REASON_DISCARD) {
...@@ -4386,6 +4397,7 @@ int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret, ...@@ -4386,6 +4397,7 @@ int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret,
} }
if((target->previous.location == LOCATION_SZONE) && target->equiping_target) if((target->previous.location == LOCATION_SZONE) && target->equiping_target)
target->unequip(); target->unequip();
target->clear_card_target();
if(target->current.location == LOCATION_MZONE) { if(target->current.location == LOCATION_MZONE) {
effect_set eset; effect_set eset;
filter_player_effect(0, EFFECT_MUST_USE_MZONE, &eset, FALSE); filter_player_effect(0, EFFECT_MUST_USE_MZONE, &eset, FALSE);
...@@ -4499,6 +4511,7 @@ int32 field::change_position(uint16 step, group * targets, effect * reason_effec ...@@ -4499,6 +4511,7 @@ int32 field::change_position(uint16 step, group * targets, effect * reason_effec
if(pcard->status & (STATUS_SUMMON_DISABLED | STATUS_ACTIVATE_DISABLED)) if(pcard->status & (STATUS_SUMMON_DISABLED | STATUS_ACTIVATE_DISABLED))
pcard->set_status(STATUS_SUMMON_DISABLED | STATUS_ACTIVATE_DISABLED, FALSE); pcard->set_status(STATUS_SUMMON_DISABLED | STATUS_ACTIVATE_DISABLED, FALSE);
pcard->reset(RESET_TURN_SET, RESET_EVENT); pcard->reset(RESET_TURN_SET, RESET_EVENT);
pcard->clear_card_target();
pcard->set_status(STATUS_SET_TURN, TRUE); pcard->set_status(STATUS_SET_TURN, TRUE);
pcard->enable_field_effect(false); pcard->enable_field_effect(false);
pcard->summon_info &= 0xdf00ffff; pcard->summon_info &= 0xdf00ffff;
......
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