From 63dc8f0d4ce8ce352ae038cf8b570efbc4736f7c Mon Sep 17 00:00:00 2001 From: salix5 Date: Wed, 16 Oct 2024 10:14:31 +0800 Subject: [PATCH] fix field::add_effect avoid duplicate entries like card::add_effect --- field.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/field.cpp b/field.cpp index b4b53bf0f..b7e02f51c 100644 --- a/field.cpp +++ b/field.cpp @@ -1161,13 +1161,8 @@ void field::tag_swap(uint8 playerid) { pduel->write_buffer32(pcard->data.code | (pcard->is_position(POS_FACEUP) ? 0x80000000 : 0)); } void field::add_effect(effect* peffect, uint8 owner_player) { - if (!peffect->handler) { - peffect->flag[0] |= EFFECT_FLAG_FIELD_ONLY; - peffect->handler = peffect->owner; - peffect->effect_owner = owner_player; - peffect->id = infos.field_id++; - } - peffect->card_type = peffect->owner->data.type; + if (effects.indexer.find(peffect) != effects.indexer.end()) + return; effect_container::iterator it; if (!(peffect->type & EFFECT_TYPE_ACTIONS)) { it = effects.aura_effect.emplace(peffect->code, peffect); @@ -1178,9 +1173,9 @@ void field::add_effect(effect* peffect, uint8 owner_player) { } else { if (peffect->type & EFFECT_TYPE_IGNITION) it = effects.ignition_effect.emplace(peffect->code, peffect); - else if (peffect->type & EFFECT_TYPE_TRIGGER_O && peffect->type & EFFECT_TYPE_FIELD) + else if (peffect->type & EFFECT_TYPE_TRIGGER_O) it = effects.trigger_o_effect.emplace(peffect->code, peffect); - else if (peffect->type & EFFECT_TYPE_TRIGGER_F && peffect->type & EFFECT_TYPE_FIELD) + else if (peffect->type & EFFECT_TYPE_TRIGGER_F) it = effects.trigger_f_effect.emplace(peffect->code, peffect); else if (peffect->type & EFFECT_TYPE_QUICK_O) it = effects.quick_o_effect.emplace(peffect->code, peffect); @@ -1190,7 +1185,16 @@ void field::add_effect(effect* peffect, uint8 owner_player) { it = effects.activate_effect.emplace(peffect->code, peffect); else if (peffect->type & EFFECT_TYPE_CONTINUOUS) it = effects.continuous_effect.emplace(peffect->code, peffect); + else + return; } + if (!peffect->handler) { + peffect->flag[0] |= EFFECT_FLAG_FIELD_ONLY; + peffect->handler = peffect->owner; + peffect->effect_owner = owner_player; + peffect->id = infos.field_id++; + } + peffect->card_type = peffect->owner->data.type; effects.indexer.emplace(peffect, it); if(peffect->is_flag(EFFECT_FLAG_FIELD_ONLY)) { if(peffect->is_disable_related())