From ca69f7264b4f4028328801bdefb7848da7464527 Mon Sep 17 00:00:00 2001 From: salix5 Date: Fri, 22 Nov 2024 18:54:40 +0800 Subject: [PATCH] reference in field::destroy --- card.cpp | 2 +- field.h | 2 +- libduel.cpp | 2 +- operations.cpp | 23 +++++++++++------------ processor.cpp | 4 ++-- 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/card.cpp b/card.cpp index 18777c6fb..c5ffb8b81 100644 --- a/card.cpp +++ b/card.cpp @@ -1658,7 +1658,7 @@ void card::xyz_overlay(const card_set& materials) { pduel->game_field->process_instant_event(); } if(des.size()) - pduel->game_field->destroy(&des, 0, REASON_LOST_TARGET + REASON_RULE, PLAYER_NONE); + pduel->game_field->destroy(des, 0, REASON_LOST_TARGET + REASON_RULE, PLAYER_NONE); else pduel->game_field->adjust_instant(); } diff --git a/field.h b/field.h index 5e44ddb35..4e3107138 100644 --- a/field.h +++ b/field.h @@ -578,7 +578,7 @@ class field { void special_summon(const card_set& target, uint32 sumtype, uint32 sumplayer, uint32 playerid, uint32 nocheck, uint32 nolimit, uint32 positions, uint32 zone); void special_summon_step(card* target, uint32 sumtype, uint32 sumplayer, uint32 playerid, uint32 nocheck, uint32 nolimit, uint32 positions, uint32 zone); void special_summon_complete(effect* reason_effect, uint8 reason_player); - void destroy(card_set* targets, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid = 2, uint32 destination = 0, uint32 sequence = 0); + void destroy(card_set& targets, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid = 2, uint32 destination = 0, uint32 sequence = 0); void destroy(card* target, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid = 2, uint32 destination = 0, uint32 sequence = 0); void release(const card_set& targets, effect* reason_effect, uint32 reason, uint32 reason_player); void release(card* target, effect* reason_effect, uint32 reason, uint32 reason_player); diff --git a/libduel.cpp b/libduel.cpp index 2be3c744c..7136c6af6 100644 --- a/libduel.cpp +++ b/libduel.cpp @@ -211,7 +211,7 @@ int32 scriptlib::duel_destroy(lua_State *L) { if(pcard) pduel->game_field->destroy(pcard, pduel->game_field->core.reason_effect, reason, reason_player, PLAYER_NONE, dest, 0); else - pduel->game_field->destroy(&(pgroup->container), pduel->game_field->core.reason_effect, reason, reason_player, PLAYER_NONE, dest, 0); + pduel->game_field->destroy(pgroup->container, pduel->game_field->core.reason_effect, reason, reason_player, PLAYER_NONE, dest, 0); return lua_yieldk(L, 0, (lua_KContext)pduel, [](lua_State *L, int32 status, lua_KContext ctx) { duel* pduel = (duel*)ctx; lua_pushinteger(L, pduel->game_field->returns.ivalue[0]); diff --git a/operations.cpp b/operations.cpp index 1c418b731..d7ee229a8 100644 --- a/operations.cpp +++ b/operations.cpp @@ -197,11 +197,11 @@ void field::special_summon_complete(effect* reason_effect, uint8 reason_player) core.hint_timing[reason_player] |= TIMING_SPSUMMON; add_process(PROCESSOR_SPSUMMON, 1, reason_effect, ng, reason_player, 0); } -void field::destroy(card_set* targets, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence) { - for(auto cit = targets->begin(); cit != targets->end();) { +void field::destroy(card_set& targets, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence) { + for(auto cit = targets.begin(); cit != targets.end();) { card* pcard = *cit; if(pcard->is_status(STATUS_DESTROY_CONFIRMED) && core.destroy_canceled.find(pcard) == core.destroy_canceled.end()) { - cit = targets->erase(cit); + cit = targets.erase(cit); continue; } pcard->temp.reason = pcard->current.reason; @@ -224,14 +224,13 @@ void field::destroy(card_set* targets, effect* reason_effect, uint32 reason, uin pcard->sendto_param.set(p, POS_FACEUP, destination, sequence); ++cit; } - group* ng = pduel->new_group(*targets); + group* ng = pduel->new_group(targets); ng->is_readonly = GTYPE_READ_ONLY; add_process(PROCESSOR_DESTROY, 0, reason_effect, ng, reason, reason_player); } void field::destroy(card* target, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence) { - card_set tset; - tset.insert(target); - destroy(&tset, reason_effect, reason, reason_player, playerid, destination, sequence); + card_set tset{ target }; + destroy(tset, reason_effect, reason, reason_player, playerid, destination, sequence); } void field::release(const card_set& targets, effect* reason_effect, uint32 reason, uint32 reason_player) { for(auto& pcard : targets) { @@ -976,7 +975,7 @@ int32 field::get_control(uint16 step, effect* reason_effect, uint8 reason_player case 6: { card_set* destroy_set = (card_set*)core.units.begin()->ptr1; if(destroy_set->size()) - destroy(destroy_set, 0, REASON_RULE, PLAYER_NONE); + destroy(*destroy_set, 0, REASON_RULE, PLAYER_NONE); delete destroy_set; return FALSE; } @@ -1225,7 +1224,7 @@ int32 field::self_destroy(uint16 step, card* ucard, int32 p) { pcard->current.reason_effect = ucard->unique_effect; pcard->current.reason_player = ucard->current.controler; } - destroy(&cset, 0, REASON_RULE, PLAYER_SELFDES); + destroy(cset, 0, REASON_RULE, PLAYER_SELFDES); return FALSE; } case 2: { @@ -4385,7 +4384,7 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3 process_single_event(); process_instant_event(); if(equipings.size()) - destroy(&equipings, 0, REASON_RULE + REASON_LOST_TARGET, PLAYER_NONE); + destroy(equipings, 0, REASON_RULE + REASON_LOST_TARGET, PLAYER_NONE); if(overlays.size()) send_to(overlays, 0, REASON_RULE + REASON_LOST_OVERLAY, PLAYER_NONE, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP); adjust_instant(); @@ -4699,7 +4698,7 @@ int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret, pduel->write_buffer32(target->current.reason); if(target->current.location != LOCATION_MZONE) { if(target->equiping_cards.size()) { - destroy(&target->equiping_cards, 0, REASON_LOST_TARGET + REASON_RULE, PLAYER_NONE); + destroy(target->equiping_cards, 0, REASON_LOST_TARGET + REASON_RULE, PLAYER_NONE); for(auto csit = target->equiping_cards.begin(); csit != target->equiping_cards.end();) { auto rm = csit++; (*rm)->unequip(); @@ -4966,7 +4965,7 @@ int32 field::change_position(uint16 step, group * targets, effect * reason_effec raise_event(pos_changed, EVENT_CHANGE_POS, reason_effect, 0, reason_player, 0, 0); process_instant_event(); if(equipings.size()) - destroy(&equipings, 0, REASON_LOST_TARGET + REASON_RULE, PLAYER_NONE); + destroy(equipings, 0, REASON_LOST_TARGET + REASON_RULE, PLAYER_NONE); card_set* to_grave_set = (card_set*)core.units.begin()->ptr1; if(to_grave_set->size()) { send_to(*to_grave_set, 0, REASON_RULE, PLAYER_NONE, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP); diff --git a/processor.cpp b/processor.cpp index 84d36f810..baf1bc06d 100644 --- a/processor.cpp +++ b/processor.cpp @@ -3091,7 +3091,7 @@ int32 field::process_battle_command(uint16 step) { } case 29: { if(core.battle_destroy_rep.size()) - destroy(&core.battle_destroy_rep, 0, REASON_EFFECT | REASON_REPLACE, PLAYER_NONE); + destroy(core.battle_destroy_rep, 0, REASON_EFFECT | REASON_REPLACE, PLAYER_NONE); if(core.desrep_chain.size()) add_process(PROCESSOR_OPERATION_REPLACE, 15, nullptr, nullptr, 0, 0); adjust_all(); @@ -4971,7 +4971,7 @@ int32 field::adjust_step(uint16 step) { } if(destroy_set.size()) { core.re_adjust = TRUE; - destroy(&destroy_set, 0, REASON_RULE, PLAYER_NONE); + destroy(destroy_set, 0, REASON_RULE, PLAYER_NONE); } return FALSE; }