Skip to content

Commit

Permalink
cancel summon when no procedure (#636)
Browse files Browse the repository at this point in the history
* cancel summon when no procedure

* edit comment

* fix field::filter_inrange_cards()

* class field: check playerid
  • Loading branch information
salix5 authored Oct 9, 2024
1 parent a6b5357 commit 41e51eb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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<card_vector*> cvec;
uint16 range = peffect->s_range;
Expand Down Expand Up @@ -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<card_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)
Expand All @@ -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);
}
}
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 41e51eb

Please sign in to comment.