From 41e51eb838c0f6e873f991b72dad8f45ba1aed52 Mon Sep 17 00:00:00 2001 From: salix5 Date: Wed, 9 Oct 2024 21:34:20 +0800 Subject: [PATCH] cancel summon when no procedure (#636) * cancel summon when no procedure * edit comment * fix field::filter_inrange_cards() * class field: check playerid --- card.cpp | 4 ++-- field.cpp | 12 ++++++------ operations.cpp | 4 +++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/card.cpp b/card.cpp index 07009dfcf..c05717d78 100644 --- a/card.cpp +++ b/card.cpp @@ -2720,8 +2720,8 @@ void card::filter_disable_related_cards() { // return value: // -2 = this has a EFFECT_LIMIT_SUMMON_PROC, 0 available // -1 = this has a EFFECT_LIMIT_SUMMON_PROC, at least 1 available -// 0 = no EFFECT_LIMIT_SUMMON_PROC, and ordinary summon ia not available -// 1 = no EFFECT_LIMIT_SUMMON_PROC, and ordinary summon ia available +// 0 = no EFFECT_LIMIT_SUMMON_PROC, and ordinary summon is not available +// 1 = no EFFECT_LIMIT_SUMMON_PROC, and ordinary summon is available int32 card::filter_summon_procedure(uint8 playerid, effect_set* peset, uint8 ignore_count, uint8 min_tribute, uint32 zone) { effect_set eset; filter_effect(EFFECT_LIMIT_SUMMON_PROC, &eset); diff --git a/field.cpp b/field.cpp index 0ac36c89f..a62b367b2 100644 --- a/field.cpp +++ b/field.cpp @@ -192,7 +192,7 @@ void field::add_card(uint8 playerid, card* pcard, uint8 location, uint8 sequence refresh_player_info(playerid); } void field::remove_card(card* pcard) { - if (pcard->current.controler == PLAYER_NONE || pcard->current.location == 0) + if (!check_playerid(pcard->current.controler) || pcard->current.location == 0) return; uint8 playerid = pcard->current.controler; switch (pcard->current.location) { @@ -1371,7 +1371,7 @@ void field::filter_affected_cards(effect* peffect, card_set* cset) { || peffect->is_flag(EFFECT_FLAG_PLAYER_TARGET | EFFECT_FLAG_SPSUM_PARAM)) return; uint8 self = peffect->get_handler_player(); - if(self == PLAYER_NONE) + if (!check_playerid(self)) return; std::vector cvec; uint16 range = peffect->s_range; @@ -1404,11 +1404,11 @@ void field::filter_inrange_cards(effect* peffect, card_set* cset) { if(peffect->is_flag(EFFECT_FLAG_PLAYER_TARGET | EFFECT_FLAG_SPSUM_PARAM)) return; uint8 self = peffect->get_handler_player(); - if(self == PLAYER_NONE) + if (!check_playerid(self)) return; uint16 range = peffect->s_range; std::vector cvec; - for(uint32 p = 0; p < 2; ++p) { + for(int32 p = 0; p < 2; ++p) { if(range & LOCATION_MZONE) cvec.push_back(&player[self].list_mzone); if(range & LOCATION_SZONE) @@ -1428,7 +1428,7 @@ void field::filter_inrange_cards(effect* peffect, card_set* cset) { } for(auto& cvit : cvec) { for(auto& pcard : *cvit) { - if(pcard && peffect->is_fit_target_function(pcard)) + if (pcard && (!(pcard->current.location & LOCATION_ONFIELD) || !pcard->is_treated_as_not_on_field()) && peffect->is_fit_target_function(pcard)) cset->insert(pcard); } } @@ -2144,7 +2144,7 @@ void field::add_unique_card(card* pcard) { } void field::remove_unique_card(card* pcard) { uint8 con = pcard->current.controler; - if(con == PLAYER_NONE) + if (!check_playerid(con)) return; if(pcard->unique_pos[0]) core.unique_cards[con].erase(pcard); diff --git a/operations.cpp b/operations.cpp index 62480a742..29a9568e6 100644 --- a/operations.cpp +++ b/operations.cpp @@ -1489,13 +1489,15 @@ int32 field::summon(uint16 step, uint8 sumplayer, card* target, effect* proc, ui core.select_effects.clear(); core.select_options.clear(); if(res > 0) { - core.select_effects.push_back(0); + core.select_effects.push_back(nullptr); core.select_options.push_back(1); } for(int32 i = 0; i < eset.size(); ++i) { core.select_effects.push_back(eset[i]); core.select_options.push_back(eset[i]->description); } + if (core.select_options.empty()) + return TRUE; if(core.select_options.size() == 1) returns.ivalue[0] = 0; else