Commit 5ba3e298 authored by VanillaSalt's avatar VanillaSalt

fix

parent b62ac6b3
...@@ -72,7 +72,6 @@ card::card(duel* pd) { ...@@ -72,7 +72,6 @@ card::card(duel* pd) {
assume_type = 0; assume_type = 0;
assume_value = 0; assume_value = 0;
spsummon_code = 0; spsummon_code = 0;
relate_effect_outside = 0;
current.controler = PLAYER_NONE; current.controler = PLAYER_NONE;
} }
card::~card() { card::~card() {
...@@ -1438,48 +1437,44 @@ void card::release_relation(card* target) { ...@@ -1438,48 +1437,44 @@ void card::release_relation(card* target) {
return; return;
relations.erase(target); relations.erase(target);
} }
void card::create_relation(uint16 chain_id) { void card::create_relation(const chain& ch) {
relate_effect.insert(chain_id); relate_effect.insert(std::make_pair(ch.triggering_effect, ch.chain_id));
} }
int32 card::is_has_relation(uint16 chain_id) { int32 card::is_has_relation(const chain& ch) {
if (relate_effect.find(chain_id) != relate_effect.end()) if (relate_effect.find(std::make_pair(ch.triggering_effect, ch.chain_id)) != relate_effect.end())
return TRUE; return TRUE;
return FALSE; return FALSE;
} }
void card::release_relation(uint16 chain_id) { void card::release_relation(const chain& ch) {
relate_effect.erase(chain_id); relate_effect.erase(std::make_pair(ch.triggering_effect, ch.chain_id));
} }
void card::clear_relate_effect() { void card::clear_relate_effect() {
relate_effect.clear(); relate_effect.clear();
relate_effect_outside = 0;
} }
void card::create_relation(effect* peffect) { void card::create_relation(effect* peffect) {
for(auto it = pduel->game_field->core.current_chain.rbegin(); it != pduel->game_field->core.current_chain.rend(); ++it) { for(auto it = pduel->game_field->core.current_chain.rbegin(); it != pduel->game_field->core.current_chain.rend(); ++it) {
if(it->triggering_effect == peffect) { if(it->triggering_effect == peffect) {
create_relation(it->chain_id); create_relation(*it);
return; return;
} }
} }
relate_effect_outside = peffect; relate_effect.insert(std::make_pair(peffect, (uint16)0));
} }
int32 card::is_has_relation(effect* peffect) { int32 card::is_has_relation(effect* peffect) {
for(auto it = pduel->game_field->core.current_chain.rbegin(); it != pduel->game_field->core.current_chain.rend(); ++it) { for(auto it = relate_effect.begin(); it != relate_effect.end(); ++it) {
if(it->triggering_effect == peffect) if(it->first == peffect)
return is_has_relation(it->chain_id);
}
if(relate_effect_outside == peffect)
return TRUE; return TRUE;
}
return FALSE; return FALSE;
} }
void card::release_relation(effect* peffect) { void card::release_relation(effect* peffect) {
for(auto it = pduel->game_field->core.current_chain.rbegin(); it != pduel->game_field->core.current_chain.rend(); ++it) { for(auto it = pduel->game_field->core.current_chain.rbegin(); it != pduel->game_field->core.current_chain.rend(); ++it) {
if(it->triggering_effect == peffect) { if(it->triggering_effect == peffect) {
release_relation(it->chain_id); release_relation(*it);
return; return;
} }
} }
if(relate_effect_outside == peffect) relate_effect.erase(std::make_pair(peffect, (uint16)0));
relate_effect_outside = 0;
} }
int32 card::leave_field_redirect(uint32 reason) { int32 card::leave_field_redirect(uint32 reason) {
effect_set es; effect_set es;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#define CARD_H_ #define CARD_H_
#include "common.h" #include "common.h"
#include "effect.h"
#include "effectset.h" #include "effectset.h"
#include <set> #include <set>
#include <map> #include <map>
...@@ -17,7 +18,6 @@ ...@@ -17,7 +18,6 @@
class card; class card;
class duel; class duel;
class effect;
class group; class group;
struct card_data { struct card_data {
...@@ -79,11 +79,16 @@ struct query_cache { ...@@ -79,11 +79,16 @@ struct query_cache {
class card { class card {
public: public:
struct effect_relation_hash {
inline std::size_t operator()(const std::pair<effect*, uint16>& v) const {
return std::hash<uint16>()(v.second);
}
};
typedef std::vector<card*> card_vector; typedef std::vector<card*> card_vector;
typedef std::multimap<uint32, effect*> effect_container; typedef std::multimap<uint32, effect*> effect_container;
typedef std::set<card*, card_sort> card_set; typedef std::set<card*, card_sort> card_set;
typedef std::unordered_map<effect*, effect_container::iterator> effect_indexer; typedef std::unordered_map<effect*, effect_container::iterator> effect_indexer;
typedef std::unordered_set<uint16> effect_relation; typedef std::unordered_set<std::pair<effect*, uint16>, effect_relation_hash> effect_relation;
typedef std::unordered_map<card*, uint32> relation_map; typedef std::unordered_map<card*, uint32> relation_map;
typedef std::map<uint16, std::array<uint16, 2> > counter_map; typedef std::map<uint16, std::array<uint16, 2> > counter_map;
class attacker_map : public std::unordered_map<uint16, std::pair<card*, uint32> > { class attacker_map : public std::unordered_map<uint16, std::pair<card*, uint32> > {
...@@ -195,9 +200,9 @@ public: ...@@ -195,9 +200,9 @@ public:
void create_relation(card* target, uint32 reset); void create_relation(card* target, uint32 reset);
int32 is_has_relation(card* target); int32 is_has_relation(card* target);
void release_relation(card* target); void release_relation(card* target);
void create_relation(uint16 chain_id); void create_relation(const chain& ch);
int32 is_has_relation(uint16 chain_id); int32 is_has_relation(const chain& ch);
void release_relation(uint16 chain_id); void release_relation(const chain& ch);
void clear_relate_effect(); void clear_relate_effect();
void create_relation(effect* peffect); void create_relation(effect* peffect);
int32 is_has_relation(effect* peffect); int32 is_has_relation(effect* peffect);
......
...@@ -1153,8 +1153,7 @@ int32 scriptlib::card_is_relate_to_chain(lua_State *L) { ...@@ -1153,8 +1153,7 @@ int32 scriptlib::card_is_relate_to_chain(lua_State *L) {
duel* pduel = pcard->pduel; duel* pduel = pcard->pduel;
if(chain_count > pduel->game_field->core.current_chain.size() || chain_count < 1) if(chain_count > pduel->game_field->core.current_chain.size() || chain_count < 1)
chain_count = pduel->game_field->core.current_chain.size(); chain_count = pduel->game_field->core.current_chain.size();
uint16 chain_id = pduel->game_field->core.current_chain[chain_count - 1].chain_id; if(pcard && pcard->is_has_relation(pduel->game_field->core.current_chain[chain_count - 1]))
if(pcard && pcard->is_has_relation(chain_id))
lua_pushboolean(L, 1); lua_pushboolean(L, 1);
else else
lua_pushboolean(L, 0); lua_pushboolean(L, 0);
......
...@@ -69,12 +69,11 @@ void field::change_target(uint8 chaincount, group* targets) { ...@@ -69,12 +69,11 @@ void field::change_target(uint8 chaincount, group* targets) {
group* ot = core.current_chain[chaincount - 1].target_cards; group* ot = core.current_chain[chaincount - 1].target_cards;
if(ot) { if(ot) {
effect* te = core.current_chain[chaincount - 1].triggering_effect; effect* te = core.current_chain[chaincount - 1].triggering_effect;
uint16 chain_id = core.current_chain[chaincount - 1].chain_id;
for(auto cit = ot->container.begin(); cit != ot->container.end(); ++cit) for(auto cit = ot->container.begin(); cit != ot->container.end(); ++cit)
(*cit)->release_relation(chain_id); (*cit)->release_relation(core.current_chain[chaincount - 1]);
ot->container = targets->container; ot->container = targets->container;
for(auto cit = ot->container.begin(); cit != ot->container.end(); ++cit) for(auto cit = ot->container.begin(); cit != ot->container.end(); ++cit)
(*cit)->create_relation(chain_id); (*cit)->create_relation(core.current_chain[chaincount - 1]);
if(te->is_flag(EFFECT_FLAG_CARD_TARGET)) { if(te->is_flag(EFFECT_FLAG_CARD_TARGET)) {
for(auto cit = ot->container.begin(); cit != ot->container.end(); ++cit) { for(auto cit = ot->container.begin(); cit != ot->container.end(); ++cit) {
if((*cit)->current.location & 0x30) if((*cit)->current.location & 0x30)
......
...@@ -737,9 +737,8 @@ int32 field::process() { ...@@ -737,9 +737,8 @@ int32 field::process() {
pduel->write_buffer32(pcard->get_info_location()); pduel->write_buffer32(pcard->get_info_location());
} }
} }
uint16 chain_id = core.current_chain.rbegin()->chain_id;
for(auto cit = pret->container.begin(); cit != pret->container.end(); ++cit) for(auto cit = pret->container.begin(); cit != pret->container.end(); ++cit)
(*cit)->create_relation(chain_id); (*cit)->create_relation(core.current_chain.back());
pduel->lua->add_param(pret, PARAM_TYPE_GROUP); pduel->lua->add_param(pret, PARAM_TYPE_GROUP);
} }
core.units.pop_front(); core.units.pop_front();
...@@ -1611,7 +1610,7 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free ...@@ -1611,7 +1610,7 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free
//forced trigger //forced trigger
for (auto clit = core.new_fchain_s.begin(); clit != core.new_fchain_s.end(); ++clit) { for (auto clit = core.new_fchain_s.begin(); clit != core.new_fchain_s.end(); ++clit) {
effect* peffect = clit->triggering_effect; effect* peffect = clit->triggering_effect;
if(!peffect->is_flag(EFFECT_FLAG_EVENT_PLAYER | EFFECT_FLAG_BOTH_SIDE) && peffect->handler->is_has_relation(clit->chain_id)) { if(!peffect->is_flag(EFFECT_FLAG_EVENT_PLAYER | EFFECT_FLAG_BOTH_SIDE) && peffect->handler->is_has_relation(*clit)) {
clit->triggering_player = peffect->handler->current.controler; clit->triggering_player = peffect->handler->current.controler;
clit->triggering_controler = peffect->handler->current.controler; clit->triggering_controler = peffect->handler->current.controler;
clit->triggering_location = peffect->handler->current.location; clit->triggering_location = peffect->handler->current.location;
...@@ -1684,11 +1683,11 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free ...@@ -1684,11 +1683,11 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free
} }
for (auto clit = core.new_ochain_s.begin(); clit != core.new_ochain_s.end(); ++clit) { for (auto clit = core.new_ochain_s.begin(); clit != core.new_ochain_s.end(); ++clit) {
effect* peffect = clit->triggering_effect; effect* peffect = clit->triggering_effect;
if((!peffect->is_flag(EFFECT_FLAG_EVENT_PLAYER | EFFECT_FLAG_BOTH_SIDE) && peffect->handler->is_has_relation(clit->chain_id)) if((!peffect->is_flag(EFFECT_FLAG_EVENT_PLAYER | EFFECT_FLAG_BOTH_SIDE) && peffect->handler->is_has_relation(*clit))
|| (!(peffect->is_flag(EFFECT_FLAG_FIELD_ONLY)) && (peffect->type & EFFECT_TYPE_FIELD) || (!(peffect->is_flag(EFFECT_FLAG_FIELD_ONLY)) && (peffect->type & EFFECT_TYPE_FIELD)
&& (peffect->range & LOCATION_HAND) && peffect->handler->current.location == LOCATION_HAND)) { && (peffect->range & LOCATION_HAND) && peffect->handler->current.location == LOCATION_HAND)) {
if(!peffect->handler->is_has_relation(clit->chain_id)) if(!peffect->handler->is_has_relation(*clit))
peffect->handler->create_relation(clit->chain_id); peffect->handler->create_relation(*clit);
clit->triggering_player = peffect->handler->current.controler; clit->triggering_player = peffect->handler->current.controler;
clit->triggering_controler = peffect->handler->current.controler; clit->triggering_controler = peffect->handler->current.controler;
clit->triggering_location = peffect->handler->current.location; clit->triggering_location = peffect->handler->current.location;
...@@ -1728,7 +1727,7 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free ...@@ -1728,7 +1727,7 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free
&& (peffect->code == EVENT_FLIP && infos.phase == PHASE_DAMAGE || (clit->triggering_location & 0x43) && (peffect->code == EVENT_FLIP && infos.phase == PHASE_DAMAGE || (clit->triggering_location & 0x43)
|| !(peffect->handler->current.location & 0x43) || peffect->handler->is_position(POS_FACEUP))) { || !(peffect->handler->current.location & 0x43) || peffect->handler->is_position(POS_FACEUP))) {
if(!(peffect->is_flag(EFFECT_FLAG_FIELD_ONLY)) && clit->triggering_location == LOCATION_HAND if(!(peffect->is_flag(EFFECT_FLAG_FIELD_ONLY)) && clit->triggering_location == LOCATION_HAND
&& (((peffect->type & EFFECT_TYPE_SINGLE) && !(peffect->is_flag(EFFECT_FLAG_SINGLE_RANGE)) && peffect->handler->is_has_relation(clit->chain_id)) && (((peffect->type & EFFECT_TYPE_SINGLE) && !(peffect->is_flag(EFFECT_FLAG_SINGLE_RANGE)) && peffect->handler->is_has_relation(*clit))
|| (peffect->range & LOCATION_HAND))) { || (peffect->range & LOCATION_HAND))) {
core.new_ochain_h.push_back(*clit); core.new_ochain_h.push_back(*clit);
act = false; act = false;
...@@ -1789,7 +1788,7 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free ...@@ -1789,7 +1788,7 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free
&& (peffect->code == EVENT_FLIP && infos.phase == PHASE_DAMAGE || (clit->triggering_location & 0x43) && (peffect->code == EVENT_FLIP && infos.phase == PHASE_DAMAGE || (clit->triggering_location & 0x43)
|| !(peffect->handler->current.location & 0x43) || peffect->handler->is_position(POS_FACEUP))) { || !(peffect->handler->current.location & 0x43) || peffect->handler->is_position(POS_FACEUP))) {
if(!(peffect->is_flag(EFFECT_FLAG_FIELD_ONLY)) && clit->triggering_location == LOCATION_HAND if(!(peffect->is_flag(EFFECT_FLAG_FIELD_ONLY)) && clit->triggering_location == LOCATION_HAND
&& (((peffect->type & EFFECT_TYPE_SINGLE) && !(peffect->is_flag(EFFECT_FLAG_SINGLE_RANGE)) && peffect->handler->is_has_relation(clit->chain_id)) && (((peffect->type & EFFECT_TYPE_SINGLE) && !(peffect->is_flag(EFFECT_FLAG_SINGLE_RANGE)) && peffect->handler->is_has_relation(*clit))
|| (peffect->range & LOCATION_HAND))) { || (peffect->range & LOCATION_HAND))) {
continue; continue;
} else if((peffect->is_flag(EFFECT_FLAG_FIELD_ONLY)) || !(peffect->type & EFFECT_TYPE_FIELD) } else if((peffect->is_flag(EFFECT_FLAG_FIELD_ONLY)) || !(peffect->type & EFFECT_TYPE_FIELD)
...@@ -1952,7 +1951,7 @@ int32 field::process_quick_effect(int16 step, int32 skip_freechain, uint8 priori ...@@ -1952,7 +1951,7 @@ int32 field::process_quick_effect(int16 step, int32 skip_freechain, uint8 priori
for(auto ifit = core.quick_f_chain.begin(); ifit != core.quick_f_chain.end(); ++ifit) { for(auto ifit = core.quick_f_chain.begin(); ifit != core.quick_f_chain.end(); ++ifit) {
peffect = ifit->first; peffect = ifit->first;
if(peffect->is_chainable(ifit->second.triggering_player) && peffect->check_count_limit(ifit->second.triggering_player) if(peffect->is_chainable(ifit->second.triggering_player) && peffect->check_count_limit(ifit->second.triggering_player)
&& peffect->handler->is_has_relation(ifit->second.chain_id)) { && peffect->handler->is_has_relation(ifit->second)) {
if(ifit->second.triggering_player == infos.turn_player) { if(ifit->second.triggering_player == infos.turn_player) {
act = true; act = true;
if(peffect->is_flag(EFFECT_FLAG_CHAIN_UNIQUE)) { if(peffect->is_flag(EFFECT_FLAG_CHAIN_UNIQUE)) {
...@@ -2064,7 +2063,7 @@ int32 field::process_quick_effect(int16 step, int32 skip_freechain, uint8 priori ...@@ -2064,7 +2063,7 @@ int32 field::process_quick_effect(int16 step, int32 skip_freechain, uint8 priori
for(auto clit = core.new_ochain_h.begin(); clit != core.new_ochain_h.end(); ++clit) { for(auto clit = core.new_ochain_h.begin(); clit != core.new_ochain_h.end(); ++clit) {
peffect = clit->triggering_effect; peffect = clit->triggering_effect;
bool act = true; bool act = true;
if(clit->triggering_player == priority && !peffect->handler->is_status(STATUS_CHAINING) && peffect->handler->is_has_relation(clit->chain_id) if(clit->triggering_player == priority && !peffect->handler->is_status(STATUS_CHAINING) && peffect->handler->is_has_relation(*clit)
&& peffect->is_chainable(priority) && peffect->is_activateable(priority, clit->evt, TRUE)) { && peffect->is_chainable(priority) && peffect->is_activateable(priority, clit->evt, TRUE)) {
for(auto cait = core.current_chain.begin(); cait != core.current_chain.end(); ++cait) { for(auto cait = core.current_chain.begin(); cait != core.current_chain.end(); ++cait) {
if(cait->triggering_player == priority) { if(cait->triggering_player == priority) {
...@@ -2249,7 +2248,7 @@ int32 field::process_instant_event() { ...@@ -2249,7 +2248,7 @@ int32 field::process_instant_event() {
newchain.triggering_player = elit->event_player; newchain.triggering_player = elit->event_player;
else newchain.triggering_player = peffect->handler->current.controler; else newchain.triggering_player = peffect->handler->current.controler;
core.new_fchain.push_back(newchain); core.new_fchain.push_back(newchain);
peffect->handler->create_relation(newchain.chain_id); peffect->handler->create_relation(newchain);
} }
pr = effects.trigger_o_effect.equal_range(elit->event_code); pr = effects.trigger_o_effect.equal_range(elit->event_code);
for(; pr.first != pr.second; ++pr.first) { for(; pr.first != pr.second; ++pr.first) {
...@@ -2272,7 +2271,7 @@ int32 field::process_instant_event() { ...@@ -2272,7 +2271,7 @@ int32 field::process_instant_event() {
if((peffect->is_flag(EFFECT_FLAG_FIELD_ONLY)) if((peffect->is_flag(EFFECT_FLAG_FIELD_ONLY))
|| ((peffect->type & EFFECT_TYPE_SINGLE) && !(peffect->is_flag(EFFECT_FLAG_SINGLE_RANGE))) || ((peffect->type & EFFECT_TYPE_SINGLE) && !(peffect->is_flag(EFFECT_FLAG_SINGLE_RANGE)))
|| !(peffect->range & LOCATION_HAND) || (peffect->range & peffect->handler->current.location)) || !(peffect->range & LOCATION_HAND) || (peffect->range & peffect->handler->current.location))
peffect->handler->create_relation(newchain.chain_id); peffect->handler->create_relation(newchain);
} }
//instant_f //instant_f
pr = effects.quick_f_effect.equal_range(elit->event_code); pr = effects.quick_f_effect.equal_range(elit->event_code);
...@@ -2292,7 +2291,7 @@ int32 field::process_instant_event() { ...@@ -2292,7 +2291,7 @@ int32 field::process_instant_event() {
newchain.triggering_player = elit->event_player; newchain.triggering_player = elit->event_player;
else newchain.triggering_player = peffect->handler->current.controler; else newchain.triggering_player = peffect->handler->current.controler;
core.quick_f_chain[peffect] = newchain; core.quick_f_chain[peffect] = newchain;
peffect->handler->create_relation(newchain.chain_id); peffect->handler->create_relation(newchain);
} }
} }
if(!(core.global_flag & GLOBALFLAG_DELAYED_QUICKEFFECT)) if(!(core.global_flag & GLOBALFLAG_DELAYED_QUICKEFFECT))
...@@ -2394,7 +2393,7 @@ int32 field::process_single_event() { ...@@ -2394,7 +2393,7 @@ int32 field::process_single_event() {
else else
core.new_fchain.push_back(newchain); core.new_fchain.push_back(newchain);
} }
peffect->handler->create_relation(newchain.chain_id); peffect->handler->create_relation(newchain);
} }
} }
} }
...@@ -4287,12 +4286,12 @@ int32 field::add_chain(uint16 step) { ...@@ -4287,12 +4286,12 @@ int32 field::add_chain(uint16 step) {
check_chain_counter(peffect, clit.triggering_player, clit.chain_count); check_chain_counter(peffect, clit.triggering_player, clit.chain_count);
// triggered events which are not caused by RaiseEvent create relation with the handler // triggered events which are not caused by RaiseEvent create relation with the handler
if(!(peffect->is_flag(EFFECT_FLAG_FIELD_ONLY)) && (!(peffect->type & 0x2a0) || (peffect->code & EVENT_PHASE) == EVENT_PHASE)) { if(!(peffect->is_flag(EFFECT_FLAG_FIELD_ONLY)) && (!(peffect->type & 0x2a0) || (peffect->code & EVENT_PHASE) == EVENT_PHASE)) {
peffect->handler->create_relation(clit.chain_id); peffect->handler->create_relation(clit);
} }
peffect->effect_owner = clit.triggering_player; peffect->effect_owner = clit.triggering_player;
// DISABLE_CHAIN should be check before cost // DISABLE_CHAIN should be check before cost
effect* deffect; effect* deffect;
if(!(peffect->is_flag(EFFECT_FLAG_FIELD_ONLY)) && phandler->is_has_relation(clit.chain_id) && (deffect = phandler->is_affected_by_effect(EFFECT_DISABLE_EFFECT))) { if(!(peffect->is_flag(EFFECT_FLAG_FIELD_ONLY)) && phandler->is_has_relation(clit) && (deffect = phandler->is_affected_by_effect(EFFECT_DISABLE_EFFECT))) {
effect* negeff = pduel->new_effect(); effect* negeff = pduel->new_effect();
negeff->owner = deffect->owner; negeff->owner = deffect->owner;
negeff->type = EFFECT_TYPE_SINGLE; negeff->type = EFFECT_TYPE_SINGLE;
...@@ -4551,7 +4550,7 @@ int32 field::solve_chain(uint16 step, uint32 chainend_arg1, uint32 chainend_arg2 ...@@ -4551,7 +4550,7 @@ int32 field::solve_chain(uint16 step, uint32 chainend_arg1, uint32 chainend_arg2
break_effect(); break_effect();
core.chain_solving = TRUE; core.chain_solving = TRUE;
card* pcard = peffect->handler; card* pcard = peffect->handler;
if((peffect->type & EFFECT_TYPE_ACTIVATE) && pcard->is_has_relation(cait->chain_id)) { if((peffect->type & EFFECT_TYPE_ACTIVATE) && pcard->is_has_relation(*cait)) {
pcard->set_status(STATUS_ACTIVATED, TRUE); pcard->set_status(STATUS_ACTIVATED, TRUE);
pcard->enable_field_effect(TRUE); pcard->enable_field_effect(TRUE);
if(core.duel_options & DUEL_OBSOLETE_RULING) { if(core.duel_options & DUEL_OBSOLETE_RULING) {
...@@ -4574,7 +4573,7 @@ int32 field::solve_chain(uint16 step, uint32 chainend_arg1, uint32 chainend_arg2 ...@@ -4574,7 +4573,7 @@ int32 field::solve_chain(uint16 step, uint32 chainend_arg1, uint32 chainend_arg2
if(is_chain_disablable(cait->chain_count)) { if(is_chain_disablable(cait->chain_count)) {
if((cait->flag & CHAIN_DISABLE_EFFECT) || pcard->is_affected_by_effect(EFFECT_DISABLE_CHAIN) if((cait->flag & CHAIN_DISABLE_EFFECT) || pcard->is_affected_by_effect(EFFECT_DISABLE_CHAIN)
|| ((cait->triggering_location & LOCATION_ONFIELD) && pcard->is_affected_by_effect(EFFECT_DISABLE_CHAIN_FIELD)) || ((cait->triggering_location & LOCATION_ONFIELD) && pcard->is_affected_by_effect(EFFECT_DISABLE_CHAIN_FIELD))
|| (pcard->is_status(STATUS_DISABLED) && pcard->is_has_relation(cait->chain_id))) { || (pcard->is_status(STATUS_DISABLED) && pcard->is_has_relation(*cait))) {
if(!(cait->flag & CHAIN_DISABLE_EFFECT)) { if(!(cait->flag & CHAIN_DISABLE_EFFECT)) {
pduel->write_buffer8(MSG_CHAIN_DISABLED); pduel->write_buffer8(MSG_CHAIN_DISABLED);
pduel->write_buffer8(cait->chain_count); pduel->write_buffer8(cait->chain_count);
...@@ -4680,21 +4679,21 @@ int32 field::solve_chain(uint16 step, uint32 chainend_arg1, uint32 chainend_arg2 ...@@ -4680,21 +4679,21 @@ int32 field::solve_chain(uint16 step, uint32 chainend_arg1, uint32 chainend_arg2
shuffle(pcard->current.controler, LOCATION_HAND); shuffle(pcard->current.controler, LOCATION_HAND);
if(cait->target_cards && cait->target_cards->container.size()) { if(cait->target_cards && cait->target_cards->container.size()) {
for(auto cit = cait->target_cards->container.begin(); cit != cait->target_cards->container.end(); ++cit) for(auto cit = cait->target_cards->container.begin(); cit != cait->target_cards->container.end(); ++cit)
(*cit)->release_relation(cait->chain_id); (*cit)->release_relation(*cait);
} }
if((pcard->data.type & TYPE_EQUIP) && (peffect->type & EFFECT_TYPE_ACTIVATE) if((pcard->data.type & TYPE_EQUIP) && (peffect->type & EFFECT_TYPE_ACTIVATE)
&& !pcard->equiping_target && (pcard->current.location == LOCATION_SZONE)) && !pcard->equiping_target && (pcard->current.location == LOCATION_SZONE))
pcard->set_status(STATUS_LEAVE_CONFIRMED, TRUE); pcard->set_status(STATUS_LEAVE_CONFIRMED, TRUE);
if(core.duel_options & DUEL_OBSOLETE_RULING) { if(core.duel_options & DUEL_OBSOLETE_RULING) {
if((pcard->data.type & TYPE_FIELD) && (peffect->type & EFFECT_TYPE_ACTIVATE) if((pcard->data.type & TYPE_FIELD) && (peffect->type & EFFECT_TYPE_ACTIVATE)
&& !pcard->is_status(STATUS_LEAVE_CONFIRMED) && pcard->is_has_relation(cait->chain_id)) { && !pcard->is_status(STATUS_LEAVE_CONFIRMED) && pcard->is_has_relation(*cait)) {
card* fscard = player[1 - pcard->current.controler].list_szone[5]; card* fscard = player[1 - pcard->current.controler].list_szone[5];
if(fscard && fscard->is_position(POS_FACEUP)) if(fscard && fscard->is_position(POS_FACEUP))
destroy(fscard, 0, REASON_RULE, 1 - pcard->current.controler); destroy(fscard, 0, REASON_RULE, 1 - pcard->current.controler);
} }
} }
peffect->active_type = 0; peffect->active_type = 0;
pcard->release_relation(cait->chain_id); pcard->release_relation(*cait);
if(cait->target_cards) if(cait->target_cards)
pduel->delete_group(cait->target_cards); pduel->delete_group(cait->target_cards);
for(auto oit = cait->opinfos.begin(); oit != cait->opinfos.end(); ++oit) { for(auto oit = cait->opinfos.begin(); oit != cait->opinfos.end(); ++oit) {
......
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