Skip to content

Commit

Permalink
reference in field::destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
salix5 committed Nov 22, 2024
1 parent b28973f commit ca69f72
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion field.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion libduel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
23 changes: 11 additions & 12 deletions operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit ca69f72

Please sign in to comment.