diff --git a/card.cpp b/card.cpp index 493e6a39e..c5ffb8b81 100644 --- a/card.cpp +++ b/card.cpp @@ -1569,12 +1569,11 @@ int32 card::get_old_union_count() { } return count; } -void card::xyz_overlay(card_set* materials) { - if(materials->empty()) +void card::xyz_overlay(const card_set& materials) { + if(materials.empty()) return; card_set des, leave_grave, leave_deck; - card_vector cv; - cv.assign(materials->begin(), materials->end()); + card_vector cv(materials.begin(), materials.end()); std::sort(cv.begin(), cv.end(), card::card_operation_sort); if(pduel->game_field->core.global_flag & GLOBALFLAG_DECK_REVERSE_CHECK) { int32 d0 = (int32)pduel->game_field->player[0].list_main.size() - 1, s0 = d0; @@ -1659,7 +1658,7 @@ void card::xyz_overlay(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/card.h b/card.h index 9114770a7..1b52ec92b 100644 --- a/card.h +++ b/card.h @@ -285,7 +285,7 @@ class card { void unequip(); int32 get_union_count(); int32 get_old_union_count(); - void xyz_overlay(card_set* materials); + void xyz_overlay(const card_set& materials); void xyz_add(card* mat); void xyz_remove(card* mat); void apply_field_effect(); diff --git a/field.cpp b/field.cpp index 4ce5e2320..63a19520a 100644 --- a/field.cpp +++ b/field.cpp @@ -1927,11 +1927,11 @@ void field::get_fusion_material(uint8 playerid, card_set* material_all, card_set } material_all->insert(material_base->begin(), material_base->end()); } -void field::ritual_release(card_set* material) { +void field::ritual_release(const card_set& material) { card_set rel; card_set rem; card_set tgy; - for(auto& pcard : *material) { + for(const auto& pcard : material) { if(pcard->current.location == LOCATION_GRAVE) rem.insert(pcard); else if(pcard->current.location == LOCATION_OVERLAY || pcard->current.location == LOCATION_EXTRA) @@ -1939,9 +1939,9 @@ void field::ritual_release(card_set* material) { else rel.insert(pcard); } - send_to(&tgy, core.reason_effect, REASON_RITUAL + REASON_EFFECT + REASON_MATERIAL, core.reason_player, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP); - release(&rel, core.reason_effect, REASON_RITUAL + REASON_EFFECT + REASON_MATERIAL, core.reason_player); - send_to(&rem, core.reason_effect, REASON_RITUAL + REASON_EFFECT + REASON_MATERIAL, core.reason_player, PLAYER_NONE, LOCATION_REMOVED, 0, POS_FACEUP); + send_to(tgy, core.reason_effect, REASON_RITUAL + REASON_EFFECT + REASON_MATERIAL, core.reason_player, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP); + release(rel, core.reason_effect, REASON_RITUAL + REASON_EFFECT + REASON_MATERIAL, core.reason_player); + send_to(rem, core.reason_effect, REASON_RITUAL + REASON_EFFECT + REASON_MATERIAL, core.reason_player, PLAYER_NONE, LOCATION_REMOVED, 0, POS_FACEUP); } void field::get_xyz_material(lua_State* L, card* scard, int32 findex, uint32 lv, int32 maxc, group* mg) { core.xmaterial_lst.clear(); diff --git a/field.h b/field.h index cf7eb68b2..4e3107138 100644 --- a/field.h +++ b/field.h @@ -441,7 +441,7 @@ class field { int32 get_draw_count(uint8 playerid); void get_ritual_material(uint8 playerid, effect* peffect, card_set* material, uint8 no_level = FALSE); void get_fusion_material(uint8 playerid, card_set* material_all, card_set* material_base, uint32 location); - void ritual_release(card_set* material); + void ritual_release(const card_set& material); void get_xyz_material(lua_State* L, card* scard, int32 findex, uint32 lv, int32 maxc, group* mg); void get_overlay_group(uint8 self, uint8 s, uint8 o, card_set* pset); int32 get_overlay_count(uint8 self, uint8 s, uint8 o); @@ -564,9 +564,9 @@ class field { void change_target_param(uint8 chaincount, int32 param); void remove_counter(uint32 reason, card* pcard, uint32 rplayer, uint32 s, uint32 o, uint32 countertype, uint32 count); void remove_overlay_card(uint32 reason, card* pcard, uint32 rplayer, uint32 s, uint32 o, uint16 min, uint16 max); - void get_control(card_set* targets, effect* reason_effect, uint32 reason_player, uint32 playerid, uint32 reset_phase, uint32 reset_count, uint32 zone); + void get_control(const card_set& targets, effect* reason_effect, uint32 reason_player, uint32 playerid, uint32 reset_phase, uint32 reset_count, uint32 zone); void get_control(card* target, effect* reason_effect, uint32 reason_player, uint32 playerid, uint32 reset_phase, uint32 reset_count, uint32 zone); - void swap_control(effect* reason_effect, uint32 reason_player, card_set* targets1, card_set* targets2, uint32 reset_phase, uint32 reset_count); + void swap_control(effect* reason_effect, uint32 reason_player, const card_set& targets1, const card_set& targets2, uint32 reset_phase, uint32 reset_count); void swap_control(effect* reason_effect, uint32 reason_player, card* pcard1, card* pcard2, uint32 reset_phase, uint32 reset_count); void equip(uint32 equip_player, card* equip_card, card* target, uint32 up, uint32 is_step); void draw(effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, int32 count); @@ -575,17 +575,17 @@ class field { void summon(uint32 sumplayer, card* target, effect* proc, uint32 ignore_count, uint32 min_tribute, uint32 zone = 0x1f, uint32 action_type = SUMMON_IN_IDLE); void mset(uint32 setplayer, card* target, effect* proc, uint32 ignore_count, uint32 min_tribute, uint32 zone = 0x1f, uint32 action_type = SUMMON_IN_IDLE); void special_summon_rule(uint32 sumplayer, card* target, uint32 summon_type, uint32 action_type = SUMMON_IN_IDLE); - void special_summon(card_set* target, uint32 sumtype, uint32 sumplayer, uint32 playerid, uint32 nocheck, uint32 nolimit, uint32 positions, uint32 zone); + 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(card_set* targets, effect* reason_effect, uint32 reason, uint32 reason_player); + 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); - void send_to(card_set* targets, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence, uint32 position, uint8 send_activating = FALSE); + void send_to(const card_set& targets, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence, uint32 position, uint8 send_activating = FALSE); void send_to(card* target, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence, uint32 position, uint8 send_activating = FALSE); void move_to_field(card* target, uint32 move_player, uint32 playerid, uint32 destination, uint32 positions, uint32 enable = FALSE, uint32 ret = 0, uint32 pzone = FALSE, uint32 zone = 0xff); - void change_position(card_set* targets, effect* reason_effect, uint32 reason_player, uint32 au, uint32 ad, uint32 du, uint32 dd, uint32 flag, uint32 enable = FALSE); + void change_position(const card_set& targets, effect* reason_effect, uint32 reason_player, uint32 au, uint32 ad, uint32 du, uint32 dd, uint32 flag, uint32 enable = FALSE); void change_position(card* target, effect* reason_effect, uint32 reason_player, uint32 npos, uint32 flag, uint32 enable = FALSE); void operation_replace(int32 type, int32 step, group* targets); void select_tribute_cards(card* target, uint8 playerid, uint8 cancelable, int32 min, int32 max, uint8 toplayer, uint32 zone); diff --git a/libduel.cpp b/libduel.cpp index 211311800..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]); @@ -240,7 +240,7 @@ int32 scriptlib::duel_remove(lua_State *L) { if(pcard) pduel->game_field->send_to(pcard, pduel->game_field->core.reason_effect, reason, reason_player, PLAYER_NONE, LOCATION_REMOVED, 0, pos); else - pduel->game_field->send_to(&(pgroup->container), pduel->game_field->core.reason_effect, reason, reason_player, PLAYER_NONE, LOCATION_REMOVED, 0, pos); + pduel->game_field->send_to(pgroup->container, pduel->game_field->core.reason_effect, reason, reason_player, PLAYER_NONE, LOCATION_REMOVED, 0, pos); 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]); @@ -268,7 +268,7 @@ int32 scriptlib::duel_sendto_grave(lua_State *L) { if(pcard) pduel->game_field->send_to(pcard, pduel->game_field->core.reason_effect, reason, reason_player, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP); else - pduel->game_field->send_to(&(pgroup->container), pduel->game_field->core.reason_effect, reason, reason_player, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP); + pduel->game_field->send_to(pgroup->container, pduel->game_field->core.reason_effect, reason, reason_player, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP); 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]); @@ -577,11 +577,10 @@ int32 scriptlib::duel_special_summon(lua_State *L) { if(lua_gettop(L) >= 8) zone = (uint32)lua_tointeger(L, 8); if(pcard) { - card_set cset; - cset.insert(pcard); - pduel->game_field->special_summon(&cset, sumtype, sumplayer, playerid, nocheck, nolimit, positions, zone); + card_set cset{ pcard }; + pduel->game_field->special_summon(cset, sumtype, sumplayer, playerid, nocheck, nolimit, positions, zone); } else - pduel->game_field->special_summon(&(pgroup->container), sumtype, sumplayer, playerid, nocheck, nolimit, positions, zone); + pduel->game_field->special_summon(pgroup->container, sumtype, sumplayer, playerid, nocheck, nolimit, positions, zone); 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]); @@ -644,7 +643,7 @@ int32 scriptlib::duel_sendto_hand(lua_State *L) { if(pcard) pduel->game_field->send_to(pcard, pduel->game_field->core.reason_effect, reason, reason_player, playerid, LOCATION_HAND, 0, POS_FACEUP); else - pduel->game_field->send_to(&(pgroup->container), pduel->game_field->core.reason_effect, reason, reason_player, playerid, LOCATION_HAND, 0, POS_FACEUP); + pduel->game_field->send_to(pgroup->container, pduel->game_field->core.reason_effect, reason, reason_player, playerid, LOCATION_HAND, 0, POS_FACEUP); 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]); @@ -679,7 +678,7 @@ int32 scriptlib::duel_sendto_deck(lua_State *L) { if (pcard) pduel->game_field->send_to(pcard, pduel->game_field->core.reason_effect, reason, reason_player, playerid, LOCATION_DECK, sequence, POS_FACEUP, send_activating); else - pduel->game_field->send_to(&(pgroup->container), pduel->game_field->core.reason_effect, reason, reason_player, playerid, LOCATION_DECK, sequence, POS_FACEUP, send_activating); + pduel->game_field->send_to(pgroup->container, pduel->game_field->core.reason_effect, reason, reason_player, playerid, LOCATION_DECK, sequence, POS_FACEUP, send_activating); 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]); @@ -707,7 +706,7 @@ int32 scriptlib::duel_sendto_extra(lua_State *L) { if(pcard) pduel->game_field->send_to(pcard, pduel->game_field->core.reason_effect, reason, pduel->game_field->core.reason_player, playerid, LOCATION_EXTRA, 0, POS_FACEUP); else - pduel->game_field->send_to(&(pgroup->container), pduel->game_field->core.reason_effect, reason, pduel->game_field->core.reason_player, playerid, LOCATION_EXTRA, 0, POS_FACEUP); + pduel->game_field->send_to(pgroup->container, pduel->game_field->core.reason_effect, reason, pduel->game_field->core.reason_player, playerid, LOCATION_EXTRA, 0, POS_FACEUP); 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]); @@ -807,11 +806,10 @@ int32 scriptlib::duel_change_form(lua_State *L) { if(top > 4) dd = (uint32)lua_tointeger(L, 5); if(top > 5 && lua_toboolean(L, 6)) flag |= NO_FLIP_EFFECT; if(pcard) { - card_set cset; - cset.insert(pcard); - pduel->game_field->change_position(&cset, pduel->game_field->core.reason_effect, pduel->game_field->core.reason_player, au, ad, du, dd, flag, TRUE); + card_set cset{ pcard }; + pduel->game_field->change_position(cset, pduel->game_field->core.reason_effect, pduel->game_field->core.reason_player, au, ad, du, dd, flag, TRUE); } else - pduel->game_field->change_position(&(pgroup->container), pduel->game_field->core.reason_effect, pduel->game_field->core.reason_player, au, ad, du, dd, flag, TRUE); + pduel->game_field->change_position(pgroup->container, pduel->game_field->core.reason_effect, pduel->game_field->core.reason_player, au, ad, du, dd, flag, TRUE); 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]); @@ -839,7 +837,7 @@ int32 scriptlib::duel_release(lua_State *L) { if(pcard) pduel->game_field->release(pcard, pduel->game_field->core.reason_effect, reason, reason_player); else - pduel->game_field->release(&(pgroup->container), pduel->game_field->core.reason_effect, reason, reason_player); + pduel->game_field->release(pgroup->container, pduel->game_field->core.reason_effect, reason, reason_player); 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]); @@ -1410,7 +1408,7 @@ int32 scriptlib::duel_get_control(lua_State *L) { if(pcard) pduel->game_field->get_control(pcard, pduel->game_field->core.reason_effect, pduel->game_field->core.reason_player, playerid, reset_phase, reset_count, zone); else - pduel->game_field->get_control(&pgroup->container, pduel->game_field->core.reason_effect, pduel->game_field->core.reason_player, playerid, reset_phase, reset_count, zone); + pduel->game_field->get_control(pgroup->container, pduel->game_field->core.reason_effect, pduel->game_field->core.reason_player, playerid, reset_phase, reset_count, zone); 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]); @@ -1444,7 +1442,7 @@ int32 scriptlib::duel_swap_control(lua_State *L) { if(pcard1) pduel->game_field->swap_control(pduel->game_field->core.reason_effect, pduel->game_field->core.reason_player, pcard1, pcard2, reset_phase, reset_count); else - pduel->game_field->swap_control(pduel->game_field->core.reason_effect, pduel->game_field->core.reason_player, &pgroup1->container, &pgroup2->container, reset_phase, reset_count); + pduel->game_field->swap_control(pduel->game_field->core.reason_effect, pduel->game_field->core.reason_player, pgroup1->container, pgroup2->container, reset_phase, reset_count); return lua_yieldk(L, 0, (lua_KContext)pduel, [](lua_State *L, int32 status, lua_KContext ctx) { duel* pduel = (duel*)ctx; lua_pushboolean(L, pduel->game_field->returns.ivalue[0]); @@ -3346,7 +3344,7 @@ int32 scriptlib::duel_release_ritual_material(lua_State *L) { check_param_count(L, 1); check_param(L, PARAM_TYPE_GROUP, 1); group* pgroup = *(group**) lua_touserdata(L, 1); - pgroup->pduel->game_field->ritual_release(&pgroup->container); + pgroup->pduel->game_field->ritual_release(pgroup->container); return lua_yield(L, 0); } int32 scriptlib::duel_get_fusion_material(lua_State *L) { @@ -3631,11 +3629,10 @@ int32 scriptlib::duel_overlay(lua_State *L) { } else return luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 2); if(pcard) { - card_set cset; - cset.insert(pcard); - target->xyz_overlay(&cset); + card_set cset{ pcard }; + target->xyz_overlay(cset); } else - target->xyz_overlay(&pgroup->container); + target->xyz_overlay(pgroup->container); uint32 adjust = TRUE; if(lua_gettop(L) > 2) { adjust = lua_toboolean(L, 3); diff --git a/operations.cpp b/operations.cpp index ddc3564a0..d7ee229a8 100644 --- a/operations.cpp +++ b/operations.cpp @@ -112,29 +112,26 @@ void field::remove_counter(uint32 reason, card* pcard, uint32 rplayer, uint32 s, void field::remove_overlay_card(uint32 reason, card* pcard, uint32 rplayer, uint32 s, uint32 o, uint16 min, uint16 max) { add_process(PROCESSOR_REMOVE_OVERLAY, 0, nullptr, (group*)pcard, (rplayer << 16) + (s << 8) + o, (max << 16) + min, reason); } -void field::get_control(card_set* targets, effect* reason_effect, uint32 reason_player, uint32 playerid, uint32 reset_phase, uint32 reset_count, uint32 zone) { - group* ng = pduel->new_group(*targets); +void field::get_control(const card_set& targets, effect* reason_effect, uint32 reason_player, uint32 playerid, uint32 reset_phase, uint32 reset_count, uint32 zone) { + group* ng = pduel->new_group(targets); ng->is_readonly = GTYPE_READ_ONLY; add_process(PROCESSOR_GET_CONTROL, 0, reason_effect, ng, 0, (reason_player << 28) + (playerid << 24) + (reset_phase << 8) + reset_count, zone); } void field::get_control(card* target, effect* reason_effect, uint32 reason_player, uint32 playerid, uint32 reset_phase, uint32 reset_count, uint32 zone) { - card_set tset; - tset.insert(target); - get_control(&tset, reason_effect, reason_player, playerid, reset_phase, reset_count, zone); + card_set tset{ target }; + get_control(tset, reason_effect, reason_player, playerid, reset_phase, reset_count, zone); } -void field::swap_control(effect* reason_effect, uint32 reason_player, card_set* targets1, card_set* targets2, uint32 reset_phase, uint32 reset_count) { - group* ng1 = pduel->new_group(*targets1); +void field::swap_control(effect* reason_effect, uint32 reason_player, const card_set& targets1, const card_set& targets2, uint32 reset_phase, uint32 reset_count) { + group* ng1 = pduel->new_group(targets1); ng1->is_readonly = GTYPE_READ_ONLY; - group* ng2 = pduel->new_group(*targets2); + group* ng2 = pduel->new_group(targets2); ng2->is_readonly = GTYPE_READ_ONLY; add_process(PROCESSOR_SWAP_CONTROL, 0, reason_effect, ng1, reason_player, reset_phase, reset_count, 0, ng2); } void field::swap_control(effect* reason_effect, uint32 reason_player, card* pcard1, card* pcard2, uint32 reset_phase, uint32 reset_count) { - card_set tset1; - tset1.insert(pcard1); - card_set tset2; - tset2.insert(pcard2); - swap_control(reason_effect, reason_player, &tset1, &tset2, reset_phase, reset_count); + card_set tset1{ pcard1 }; + card_set tset2{ pcard2 }; + swap_control(reason_effect, reason_player, tset1, tset2, reset_phase, reset_count); } void field::equip(uint32 equip_player, card* equip_card, card* target, uint32 up, uint32 is_step) { add_process(PROCESSOR_EQUIP, 0, nullptr, (group*)target, 0, equip_player + (up << 16) + (is_step << 24), 0, 0, equip_card); @@ -161,10 +158,10 @@ void field::mset(uint32 setplayer, card* target, effect* proc, uint32 ignore_cou void field::special_summon_rule(uint32 sumplayer, card* target, uint32 summon_type, uint32 action_type) { add_process(PROCESSOR_SPSUMMON_RULE, 0, 0, (group*)target, sumplayer, summon_type, action_type); } -void field::special_summon(card_set* target, uint32 sumtype, uint32 sumplayer, uint32 playerid, uint32 nocheck, uint32 nolimit, uint32 positions, uint32 zone) { +void field::special_summon(const card_set& target, uint32 sumtype, uint32 sumplayer, uint32 playerid, uint32 nocheck, uint32 nolimit, uint32 positions, uint32 zone) { if((positions & POS_FACEDOWN) && is_player_affected_by_effect(sumplayer, EFFECT_DIVINE_LIGHT)) positions = (positions & POS_FACEUP) | ((positions & POS_FACEDOWN) >> 1); - for(auto& pcard : *target) { + for(auto& pcard : target) { pcard->temp.reason = pcard->current.reason; pcard->temp.reason_effect = pcard->current.reason_effect; pcard->temp.reason_player = pcard->current.reason_player; @@ -175,7 +172,7 @@ void field::special_summon(card_set* target, uint32 sumtype, uint32 sumplayer, u pcard->current.reason_player = core.reason_player; pcard->spsummon_param = (playerid << 24) + (nocheck << 16) + (nolimit << 8) + positions; } - group* pgroup = pduel->new_group(*target); + group* pgroup = pduel->new_group(target); pgroup->is_readonly = GTYPE_READ_ONLY; add_process(PROCESSOR_SPSUMMON, 0, core.reason_effect, pgroup, core.reason_player, zone); } @@ -200,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; @@ -227,17 +224,16 @@ 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(card_set* targets, effect* reason_effect, uint32 reason, uint32 reason_player) { - for(auto& pcard : *targets) { +void field::release(const card_set& targets, effect* reason_effect, uint32 reason, uint32 reason_player) { + for(auto& pcard : targets) { pcard->temp.reason = pcard->current.reason; pcard->temp.reason_effect = pcard->current.reason_effect; pcard->temp.reason_player = pcard->current.reason_player; @@ -246,19 +242,18 @@ void field::release(card_set* targets, effect* reason_effect, uint32 reason, uin pcard->current.reason_player = reason_player; pcard->sendto_param.set(pcard->owner, POS_FACEUP, LOCATION_GRAVE); } - group* ng = pduel->new_group(*targets); + group* ng = pduel->new_group(targets); ng->is_readonly = GTYPE_READ_ONLY; add_process(PROCESSOR_RELEASE, 0, reason_effect, ng, reason, reason_player); } void field::release(card* target, effect* reason_effect, uint32 reason, uint32 reason_player) { - card_set tset; - tset.insert(target); - release(&tset, reason_effect, reason, reason_player); + card_set tset{ target }; + release(tset, reason_effect, reason, reason_player); } -void field::send_to(card_set* targets, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence, uint32 position, uint8 send_activating) { +void field::send_to(const card_set& targets, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence, uint32 position, uint8 send_activating) { if(destination & LOCATION_ONFIELD) return; - for(auto& pcard : *targets) { + for(auto& pcard : targets) { pcard->temp.reason = pcard->current.reason; pcard->current.reason = reason; if(reason_player != PLAYER_SELFDES) { @@ -282,14 +277,13 @@ void field::send_to(card_set* targets, effect* reason_effect, uint32 reason, uin pos = pcard->current.position; pcard->sendto_param.set(p, pos, destination, sequence); } - group* ng = pduel->new_group(*targets); + group* ng = pduel->new_group(targets); ng->is_readonly = GTYPE_READ_ONLY; add_process(PROCESSOR_SENDTO, 0, reason_effect, ng, reason, reason_player, send_activating); } void field::send_to(card* target, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence, uint32 position, uint8 send_activating) { - card_set tset; - tset.insert(target); - send_to(&tset, reason_effect, reason, reason_player, playerid, destination, sequence, position, send_activating); + card_set tset{ target }; + send_to(tset, reason_effect, reason, reason_player, playerid, destination, sequence, position, send_activating); } void field::move_to_field(card* target, uint32 move_player, uint32 playerid, uint32 destination, uint32 positions, uint32 enable, uint32 ret, uint32 pzone, uint32 zone) { if(!(destination & LOCATION_ONFIELD) || !positions) @@ -299,10 +293,10 @@ void field::move_to_field(card* target, uint32 move_player, uint32 playerid, uin target->to_field_param = (move_player << 24) + (playerid << 16) + (destination << 8) + positions; add_process(PROCESSOR_MOVETOFIELD, 0, 0, (group*)target, enable, ret + (pzone << 8), zone); } -void field::change_position(card_set* targets, effect* reason_effect, uint32 reason_player, uint32 au, uint32 ad, uint32 du, uint32 dd, uint32 flag, uint32 enable) { - group* ng = pduel->new_group(*targets); +void field::change_position(const card_set& targets, effect* reason_effect, uint32 reason_player, uint32 au, uint32 ad, uint32 du, uint32 dd, uint32 flag, uint32 enable) { + group* ng = pduel->new_group(targets); ng->is_readonly = GTYPE_READ_ONLY; - for(auto& pcard : *targets) { + for(auto& pcard : targets) { if(pcard->current.position == POS_FACEUP_ATTACK) pcard->position_param = au; else if(pcard->current.position == POS_FACEDOWN_DEFENSE) @@ -859,7 +853,7 @@ int32 field::remove_overlay_card(uint16 step, uint32 reason, card* pcard, uint8 card_set cset; for(int32 i = 0; i < returns.bvalue[0]; ++i) cset.insert(core.select_cards[returns.bvalue[i + 1]]); - send_to(&cset, core.reason_effect, reason, rplayer, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP); + send_to(cset, core.reason_effect, reason, rplayer, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP); return FALSE; } case 4: { @@ -981,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; } @@ -1230,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: { @@ -1353,7 +1347,7 @@ int32 field::trap_monster_adjust(uint16 step) { } if(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); + send_to(*to_grave_set, 0, REASON_RULE, PLAYER_NONE, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP); delete to_grave_set; } return TRUE; @@ -1747,7 +1741,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card* target, effect* proc, ui for(auto& pcard : *tributes) pcard->current.reason_card = target; target->set_material(tributes); - release(tributes, 0, REASON_SUMMON | REASON_MATERIAL, sumplayer); + release(*tributes, 0, REASON_SUMMON | REASON_MATERIAL, sumplayer); target->summon_info = SUMMON_TYPE_NORMAL | SUMMON_TYPE_ADVANCE | (LOCATION_HAND << 16); delete tributes; core.units.begin()->peffect = 0; @@ -2338,7 +2332,7 @@ int32 field::mset(uint16 step, uint8 setplayer, card* target, effect* proc, uint for(auto& pcard : *tributes) pcard->current.reason_card = target; target->set_material(tributes); - release(tributes, 0, REASON_SUMMON | REASON_MATERIAL, setplayer); + release(*tributes, 0, REASON_SUMMON | REASON_MATERIAL, setplayer); target->summon_info = SUMMON_TYPE_NORMAL | SUMMON_TYPE_ADVANCE | (LOCATION_HAND << 16); delete tributes; core.units.begin()->peffect = 0; @@ -2618,7 +2612,7 @@ int32 field::sset_g(uint16 step, uint8 setplayer, uint8 toplayer, group* ptarget } case 5: { if(core.unable_tofield_set.size()) - send_to(&core.unable_tofield_set, 0, REASON_RULE, PLAYER_NONE, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP); + send_to(core.unable_tofield_set, 0, REASON_RULE, PLAYER_NONE, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP); return FALSE; } case 6: { @@ -3110,7 +3104,7 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card* target, uin ++cit; } if(cset.size()) { - send_to(&cset, 0, REASON_RULE, PLAYER_NONE, sumplayer, LOCATION_GRAVE, 0, 0); + send_to(cset, 0, REASON_RULE, PLAYER_NONE, sumplayer, LOCATION_GRAVE, 0, 0); adjust_instant(); } if(pgroup->container.size() == 0) { @@ -3326,7 +3320,7 @@ int32 field::special_summon(uint16 step, effect* reason_effect, uint8 reason_pla } case 1: { if(core.unable_tofield_set.size()) - send_to(&core.unable_tofield_set, 0, REASON_RULE, PLAYER_NONE, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP); + send_to(core.unable_tofield_set, 0, REASON_RULE, PLAYER_NONE, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP); return FALSE; } case 2: { @@ -4390,9 +4384,9 @@ 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); + send_to(overlays, 0, REASON_RULE + REASON_LOST_OVERLAY, PLAYER_NONE, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP); adjust_instant(); return FALSE; } @@ -4704,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(); @@ -4712,9 +4706,8 @@ int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret, } if(target->xyz_materials.size()) { target->xyz_materials_previous_count_onfield = (int32)target->xyz_materials.size(); - card_set overlays; - overlays.insert(target->xyz_materials.begin(), target->xyz_materials.end()); - send_to(&overlays, 0, REASON_LOST_OVERLAY + REASON_RULE, PLAYER_NONE, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP); + card_set overlays(target->xyz_materials.begin(), target->xyz_materials.end()); + send_to(overlays, 0, REASON_LOST_OVERLAY + REASON_RULE, PLAYER_NONE, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP); } else { target->xyz_materials_previous_count_onfield = 0; } @@ -4972,10 +4965,10 @@ 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); + send_to(*to_grave_set, 0, REASON_RULE, PLAYER_NONE, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP); } delete to_grave_set; return FALSE; diff --git a/processor.cpp b/processor.cpp index 115a94f77..baf1bc06d 100644 --- a/processor.cpp +++ b/processor.cpp @@ -644,7 +644,7 @@ uint32 field::process() { cset.insert(pcard); } if(cset.size()) - send_to(&cset, core.reason_effect, it->arg3, core.reason_player, it->arg1, LOCATION_GRAVE, 0, POS_FACEUP); + send_to(cset, core.reason_effect, it->arg3, core.reason_player, it->arg1, LOCATION_GRAVE, 0, POS_FACEUP); else returns.ivalue[0] = 0; ++it->step; @@ -1253,7 +1253,7 @@ int32 field::process_phase_event(int16 step, int32 phase) { card_set cset; for(int32 i = 0; i < returns.bvalue[0]; ++i) cset.insert(core.select_cards[returns.bvalue[i + 1]]); - send_to(&cset, 0, REASON_RULE + REASON_DISCARD + REASON_ADJUST, infos.turn_player, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP); + send_to(cset, 0, REASON_RULE + REASON_DISCARD + REASON_ADJUST, infos.turn_player, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP); return FALSE; } case 22: { @@ -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(); @@ -4531,7 +4531,7 @@ int32 field::solve_chain(uint16 step, uint32 chainend_arg1, uint32 chainend_arg2 ++cit; } if(core.leave_confirmed.size()) - send_to(&core.leave_confirmed, 0, REASON_RULE, PLAYER_NONE, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP); + send_to(core.leave_confirmed, 0, REASON_RULE, PLAYER_NONE, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP); return FALSE; } case 12: { @@ -4896,8 +4896,8 @@ int32 field::adjust_step(uint16 step) { } if(core.control_adjust_set[0].size() || core.control_adjust_set[1].size()) { core.re_adjust = TRUE; - get_control(&core.control_adjust_set[1 - infos.turn_player], 0, PLAYER_NONE, infos.turn_player, 0, 0, 0xff); - get_control(&core.control_adjust_set[infos.turn_player], 0, PLAYER_NONE, 1 - infos.turn_player, 0, 0, 0xff); + get_control(core.control_adjust_set[1 - infos.turn_player], 0, PLAYER_NONE, infos.turn_player, 0, 0, 0xff); + get_control(core.control_adjust_set[infos.turn_player], 0, PLAYER_NONE, 1 - infos.turn_player, 0, 0, 0xff); for(auto& rcard : reason_cards) { ++core.readjust_map[rcard]; if(core.readjust_map[rcard] > 3) @@ -4936,8 +4936,8 @@ int32 field::adjust_step(uint16 step) { core.remove_brainwashing = res; if(core.control_adjust_set[0].size() || core.control_adjust_set[1].size()) { core.re_adjust = TRUE; - get_control(&core.control_adjust_set[1 - infos.turn_player], 0, PLAYER_NONE, infos.turn_player, 0, 0, 0xff); - get_control(&core.control_adjust_set[infos.turn_player], 0, PLAYER_NONE, 1 - infos.turn_player, 0, 0, 0xff); + get_control(core.control_adjust_set[1 - infos.turn_player], 0, PLAYER_NONE, infos.turn_player, 0, 0, 0xff); + get_control(core.control_adjust_set[infos.turn_player], 0, PLAYER_NONE, 1 - infos.turn_player, 0, 0, 0xff); } } core.units.begin()->step = 7; @@ -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; }