diff --git a/card.cpp b/card.cpp index f5e68d2ce..493e6a39e 100644 --- a/card.cpp +++ b/card.cpp @@ -1650,10 +1650,10 @@ void card::xyz_overlay(card_set* materials) { } if(leave_grave.size() || leave_deck.size()) { if(leave_grave.size()) { - pduel->game_field->raise_event(&leave_grave, EVENT_LEAVE_GRAVE, pduel->game_field->core.reason_effect, REASON_XYZ + REASON_MATERIAL, pduel->game_field->core.reason_player, 0, 0); + pduel->game_field->raise_event(leave_grave, EVENT_LEAVE_GRAVE, pduel->game_field->core.reason_effect, REASON_XYZ + REASON_MATERIAL, pduel->game_field->core.reason_player, 0, 0); } if(leave_deck.size()) { - pduel->game_field->raise_event(&leave_deck, EVENT_LEAVE_DECK, pduel->game_field->core.reason_effect, REASON_XYZ + REASON_MATERIAL, pduel->game_field->core.reason_player, 0, 0); + pduel->game_field->raise_event(leave_deck, EVENT_LEAVE_DECK, pduel->game_field->core.reason_effect, REASON_XYZ + REASON_MATERIAL, pduel->game_field->core.reason_player, 0, 0); } pduel->game_field->process_single_event(); pduel->game_field->process_instant_event(); diff --git a/field.h b/field.h index 7e74c9a76..cf7eb68b2 100644 --- a/field.h +++ b/field.h @@ -527,7 +527,7 @@ class field { int32 execute_operation(uint16 step, effect* peffect, uint8 triggering_player); int32 execute_target(uint16 step, effect* peffect, uint8 triggering_player); void raise_event(card* event_card, uint32 event_code, effect* reason_effect, uint32 reason, uint8 reason_player, uint8 event_player, uint32 event_value); - void raise_event(card_set* event_cards, uint32 event_code, effect* reason_effect, uint32 reason, uint8 reason_player, uint8 event_player, uint32 event_value); + void raise_event(const card_set& event_cards, uint32 event_code, effect* reason_effect, uint32 reason, uint8 reason_player, uint8 event_player, uint32 event_value); void raise_single_event(card* trigger_card, card_set* event_cards, uint32 event_code, effect* reason_effect, uint32 reason, uint8 reason_player, uint8 event_player, uint32 event_value); int32 check_event(uint32 code, tevent* pe = nullptr); int32 check_event_c(effect* peffect, uint8 playerid, int32 neglect_con, int32 neglect_cost, int32 copy_info, tevent* pe = nullptr); diff --git a/libduel.cpp b/libduel.cpp index 01dff5801..93aa4a92e 100644 --- a/libduel.cpp +++ b/libduel.cpp @@ -939,7 +939,7 @@ int32 scriptlib::duel_swap_sequence(lua_State *L) { swapped.insert(pcard2); pduel->game_field->raise_single_event(pcard1, 0, EVENT_MOVE, pduel->game_field->core.reason_effect, 0, pduel->game_field->core.reason_player, player, 0); pduel->game_field->raise_single_event(pcard2, 0, EVENT_MOVE, pduel->game_field->core.reason_effect, 0, pduel->game_field->core.reason_player, player, 0); - pduel->game_field->raise_event(&swapped, EVENT_MOVE, pduel->game_field->core.reason_effect, 0, pduel->game_field->core.reason_player, player, 0); + pduel->game_field->raise_event(swapped, EVENT_MOVE, pduel->game_field->core.reason_effect, 0, pduel->game_field->core.reason_player, player, 0); pduel->game_field->process_single_event(); pduel->game_field->process_instant_event(); } @@ -1147,7 +1147,7 @@ int32 scriptlib::duel_raise_event(lua_State *L) { if(pcard) pduel->game_field->raise_event(pcard, code, peffect, r, rp, ep, ev); else - pduel->game_field->raise_event(&pgroup->container, code, peffect, r, rp, ep, ev); + pduel->game_field->raise_event(pgroup->container, code, peffect, r, rp, ep, ev); pduel->game_field->process_instant_event(); return lua_yield(L, 0); } @@ -1373,7 +1373,7 @@ int32 scriptlib::duel_equip_complete(lua_State *L) { for(auto& equip_target : etargets) pduel->game_field->raise_single_event(equip_target, &pduel->game_field->core.equiping_cards, EVENT_EQUIP, pduel->game_field->core.reason_effect, 0, pduel->game_field->core.reason_player, PLAYER_NONE, 0); - pduel->game_field->raise_event(&pduel->game_field->core.equiping_cards, EVENT_EQUIP, + pduel->game_field->raise_event(pduel->game_field->core.equiping_cards, EVENT_EQUIP, pduel->game_field->core.reason_effect, 0, pduel->game_field->core.reason_player, PLAYER_NONE, 0); pduel->game_field->core.hint_timing[0] |= TIMING_EQUIP; pduel->game_field->core.hint_timing[1] |= TIMING_EQUIP; @@ -1620,7 +1620,7 @@ int32 scriptlib::duel_shuffle_setcard(lua_State *L) { pcard->current.sequence = seq[i]; pduel->game_field->raise_single_event(pcard, 0, EVENT_MOVE, pcard->current.reason_effect, pcard->current.reason, pcard->current.reason_player, tp, 0); } - pduel->game_field->raise_event(&pgroup->container, EVENT_MOVE, pduel->game_field->core.reason_effect, 0, pduel->game_field->core.reason_player, tp, 0); + pduel->game_field->raise_event(pgroup->container, EVENT_MOVE, pduel->game_field->core.reason_effect, 0, pduel->game_field->core.reason_player, tp, 0); pduel->game_field->process_single_event(); pduel->game_field->process_instant_event(); for(int32 i = 0; i < ct; ++i) { @@ -1778,7 +1778,7 @@ int32 scriptlib::duel_break_effect(lua_State *L) { check_action_permission(L); duel* pduel = interpreter::get_duel_info(L); pduel->game_field->break_effect(); - pduel->game_field->raise_event((card*)0, EVENT_BREAK_EFFECT, 0, 0, PLAYER_NONE, PLAYER_NONE, 0); + pduel->game_field->raise_event(nullptr, EVENT_BREAK_EFFECT, 0, 0, PLAYER_NONE, PLAYER_NONE, 0); pduel->game_field->process_instant_event(); return lua_yield(L, 0); } @@ -1908,7 +1908,7 @@ int32 scriptlib::duel_disable_summon(lua_State *L) { if(pcard) pduel->game_field->raise_event(pcard, event_code, reason_effect, REASON_EFFECT, reason_player, sumplayer, 0); else - pduel->game_field->raise_event(&pgroup->container, event_code, reason_effect, REASON_EFFECT, reason_player, sumplayer, 0); + pduel->game_field->raise_event(pgroup->container, event_code, reason_effect, REASON_EFFECT, reason_player, sumplayer, 0); pduel->game_field->process_instant_event(); return 0; } diff --git a/operations.cpp b/operations.cpp index 8c14b8568..ddc3564a0 100644 --- a/operations.cpp +++ b/operations.cpp @@ -344,7 +344,6 @@ int32 field::draw(uint16 step, effect* reason_effect, uint32 reason, uint8 reaso switch(step) { case 0: { card_vector cv; - uint32 drawed = 0; uint32 public_count = 0; if(!(reason & REASON_RULE) && !is_player_can_draw(playerid)) { returns.ivalue[0] = 0; @@ -352,11 +351,10 @@ int32 field::draw(uint16 step, effect* reason_effect, uint32 reason, uint8 reaso } core.overdraw[playerid] = FALSE; for(int32 i = 0; i < count; ++i) { - if(player[playerid].list_main.size() == 0) { + if(player[playerid].list_main.empty()) { core.overdraw[playerid] = TRUE; break; } - ++drawed; card* pcard = player[playerid].list_main.back(); pcard->enable_field_effect(false); pcard->cancel_field_effect(); @@ -384,18 +382,17 @@ int32 field::draw(uint16 step, effect* reason_effect, uint32 reason, uint8 reaso adjust_instant(); if(core.overdraw[playerid] && (reason & REASON_RULE)) adjust_all(); - core.units.begin()->arg2 = (core.units.begin()->arg2 & 0xff000000) + drawed; - card_set* drawed_set = new card_set; - core.units.begin()->ptarget = (group*)drawed_set; - drawed_set->insert(cv.begin(), cv.end()); - if(drawed) { + core.units.begin()->arg2 = (core.units.begin()->arg2 & 0xff000000) | (uint32)cv.size(); + card_set* drawed_set = new card_set(cv.begin(), cv.end()); + core.units.begin()->ptr1 = drawed_set; + if(cv.size()) { if(core.global_flag & GLOBALFLAG_DECK_REVERSE_CHECK) { if(player[playerid].list_main.size()) { card* ptop = player[playerid].list_main.back(); if(core.deck_reversed || (ptop->current.position == POS_FACEUP_DEFENSE)) { pduel->write_buffer8(MSG_DECK_TOP); pduel->write_buffer8(playerid); - pduel->write_buffer8(drawed); + pduel->write_buffer8((uint8)cv.size()); if(ptop->current.position != POS_FACEUP_DEFENSE) pduel->write_buffer32(ptop->data.code); else @@ -405,14 +402,14 @@ int32 field::draw(uint16 step, effect* reason_effect, uint32 reason, uint8 reaso } pduel->write_buffer8(MSG_DRAW); pduel->write_buffer8(playerid); - pduel->write_buffer8(drawed); - for(uint32 i = 0; i < drawed; ++i) - pduel->write_buffer32(cv[i]->data.code | (cv[i]->is_position(POS_FACEUP) ? 0x80000000 : 0)); - if(core.deck_reversed && (public_count < drawed)) { + pduel->write_buffer8((uint8)cv.size()); + for (const auto& pcard : cv) + pduel->write_buffer32(pcard->data.code | (pcard->is_position(POS_FACEUP) ? 0x80000000 : 0)); + if(core.deck_reversed && (public_count < cv.size())) { pduel->write_buffer8(MSG_CONFIRM_CARDS); pduel->write_buffer8(1 - playerid); pduel->write_buffer8((uint8)drawed_set->size()); - for(auto& pcard : *drawed_set) { + for(const auto& pcard : *drawed_set) { pduel->write_buffer32(pcard->data.code); pduel->write_buffer8(pcard->current.controler); pduel->write_buffer8(pcard->current.location); @@ -436,15 +433,15 @@ int32 field::draw(uint16 step, effect* reason_effect, uint32 reason, uint8 reaso raise_single_event(pcard, 0, EVENT_MOVE, reason_effect, reason, reason_player, playerid, 0); } process_single_event(); - raise_event(drawed_set, EVENT_DRAW, reason_effect, reason, reason_player, playerid, drawed); - raise_event(drawed_set, EVENT_TO_HAND, reason_effect, reason, reason_player, playerid, drawed); - raise_event(drawed_set, EVENT_MOVE, reason_effect, reason, reason_player, playerid, drawed); + raise_event(*drawed_set, EVENT_DRAW, reason_effect, reason, reason_player, playerid, (uint32)cv.size()); + raise_event(*drawed_set, EVENT_TO_HAND, reason_effect, reason, reason_player, playerid, (uint32)cv.size()); + raise_event(*drawed_set, EVENT_MOVE, reason_effect, reason, reason_player, playerid, (uint32)cv.size()); process_instant_event(); } return FALSE; } case 1: { - card_set* drawed_set = (card_set*)core.units.begin()->ptarget; + card_set* drawed_set = (card_set*)core.units.begin()->ptr1; core.operated_set.swap(*drawed_set); delete drawed_set; returns.ivalue[0] = (int32)core.operated_set.size(); @@ -603,7 +600,7 @@ int32 field::recover(uint16 step, effect* reason_effect, uint32 reason, uint8 re pduel->write_buffer8(MSG_RECOVER); pduel->write_buffer8(playerid); pduel->write_buffer32(val); - raise_event((card*)0, EVENT_RECOVER, reason_effect, reason, reason_player, playerid, amount); + raise_event(nullptr, EVENT_RECOVER, reason_effect, reason, reason_player, playerid, amount); process_instant_event(); return FALSE; } @@ -682,7 +679,7 @@ int32 field::pay_lp_cost(uint32 step, uint8 playerid, uint32 cost, uint32 must_p pduel->write_buffer8(MSG_PAY_LPCOST); pduel->write_buffer8(playerid); pduel->write_buffer32(cost); - raise_event((card*)0, EVENT_PAY_LPCOST, core.reason_effect, 0, playerid, playerid, cost); + raise_event(nullptr, EVENT_PAY_LPCOST, core.reason_effect, 0, playerid, playerid, cost); process_instant_event(); return TRUE; } @@ -768,7 +765,7 @@ int32 field::remove_counter(uint16 step, uint32 reason, card* pcard, uint8 rplay return FALSE; } case 3: { - raise_event((card*)0, EVENT_REMOVE_COUNTER + countertype, core.reason_effect, reason, rplayer, rplayer, count); + raise_event(nullptr, EVENT_REMOVE_COUNTER + countertype, core.reason_effect, reason, rplayer, rplayer, count); process_instant_event(); return FALSE; } @@ -974,8 +971,8 @@ int32 field::get_control(uint16 step, effect* reason_effect, uint8 reason_player ++cit; } if(targets->container.size()) { - raise_event(&targets->container, EVENT_CONTROL_CHANGED, reason_effect, REASON_EFFECT, reason_player, playerid, 0); - raise_event(&targets->container, EVENT_MOVE, reason_effect, REASON_EFFECT, reason_player, playerid, 0); + raise_event(targets->container, EVENT_CONTROL_CHANGED, reason_effect, REASON_EFFECT, reason_player, playerid, 0); + raise_event(targets->container, EVENT_MOVE, reason_effect, REASON_EFFECT, reason_player, playerid, 0); } process_single_event(); process_instant_event(); @@ -1141,8 +1138,8 @@ int32 field::swap_control(uint16 step, effect* reason_effect, uint8 reason_playe raise_single_event(pcard, 0, EVENT_CONTROL_CHANGED, reason_effect, REASON_EFFECT, reason_player, pcard->current.controler, 0); raise_single_event(pcard, 0, EVENT_MOVE, reason_effect, REASON_EFFECT, reason_player, pcard->current.controler, 0); } - raise_event(&targets1->container, EVENT_CONTROL_CHANGED, reason_effect, REASON_EFFECT, reason_player, 0, 0); - raise_event(&targets1->container, EVENT_MOVE, reason_effect, REASON_EFFECT, reason_player, 0, 0); + raise_event(targets1->container, EVENT_CONTROL_CHANGED, reason_effect, REASON_EFFECT, reason_player, 0, 0); + raise_event(targets1->container, EVENT_MOVE, reason_effect, REASON_EFFECT, reason_player, 0, 0); process_single_event(); process_instant_event(); return FALSE; @@ -1432,7 +1429,7 @@ int32 field::equip(uint16 step, uint8 equip_player, card * equip_card, card * ta card_set cset; cset.insert(equip_card); raise_single_event(target, &cset, EVENT_EQUIP, core.reason_effect, 0, core.reason_player, PLAYER_NONE, 0); - raise_event(&cset, EVENT_EQUIP, core.reason_effect, 0, core.reason_player, PLAYER_NONE, 0); + raise_event(cset, EVENT_EQUIP, core.reason_effect, 0, core.reason_player, PLAYER_NONE, 0); core.hint_timing[target->current.controler] |= TIMING_EQUIP; process_single_event(); process_instant_event(); @@ -1881,7 +1878,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card* target, effect* proc, ui if (target->material_cards.size()) { for (auto& mcard : target->material_cards) raise_single_event(mcard, 0, EVENT_BE_PRE_MATERIAL, proc, REASON_SUMMON, sumplayer, sumplayer, 0); - raise_event(&target->material_cards, EVENT_BE_PRE_MATERIAL, proc, REASON_SUMMON, sumplayer, sumplayer, 0); + raise_event(target->material_cards, EVENT_BE_PRE_MATERIAL, proc, REASON_SUMMON, sumplayer, sumplayer, 0); } process_single_event(); process_instant_event(); @@ -1958,7 +1955,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card* target, effect* proc, ui if(target->material_cards.size()) { for(auto& mcard : target->material_cards) raise_single_event(mcard, 0, EVENT_BE_MATERIAL, proc, REASON_SUMMON, sumplayer, sumplayer, 0); - raise_event(&target->material_cards, EVENT_BE_MATERIAL, proc, REASON_SUMMON, sumplayer, sumplayer, 0); + raise_event(target->material_cards, EVENT_BE_MATERIAL, proc, REASON_SUMMON, sumplayer, sumplayer, 0); } process_single_event(); process_instant_event(); @@ -2674,7 +2671,7 @@ int32 field::sset_g(uint16 step, uint8 setplayer, uint8 toplayer, group* ptarget } case 8: { adjust_instant(); - raise_event(&core.operated_set, EVENT_SSET, reason_effect, 0, setplayer, setplayer, 0); + raise_event(core.operated_set, EVENT_SSET, reason_effect, 0, setplayer, setplayer, 0); process_instant_event(); if(core.current_chain.size() == 0) { adjust_all(); @@ -2881,7 +2878,7 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card* target, uin for (auto& mcard : target->material_cards) raise_single_event(mcard, 0, EVENT_BE_PRE_MATERIAL, proc, matreason, sumplayer, sumplayer, 0); } - raise_event(&target->material_cards, EVENT_BE_PRE_MATERIAL, proc, matreason, sumplayer, sumplayer, 0); + raise_event(target->material_cards, EVENT_BE_PRE_MATERIAL, proc, matreason, sumplayer, sumplayer, 0); process_single_event(); process_instant_event(); return FALSE; @@ -2958,7 +2955,7 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card* target, uin for(auto& mcard : target->material_cards) raise_single_event(mcard, 0, EVENT_BE_MATERIAL, proc, matreason, sumplayer, sumplayer, 0); } - raise_event(&target->material_cards, EVENT_BE_MATERIAL, proc, matreason, sumplayer, sumplayer, 0); + raise_event(target->material_cards, EVENT_BE_MATERIAL, proc, matreason, sumplayer, sumplayer, 0); process_single_event(); process_instant_event(); return FALSE; @@ -3093,7 +3090,7 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card* target, uin } } if(cset.size()) { - raise_event(&cset, EVENT_SPSUMMON, core.units.begin()->peffect, 0, sumplayer, sumplayer, 0); + raise_event(cset, EVENT_SPSUMMON, core.units.begin()->peffect, 0, sumplayer, sumplayer, 0); process_instant_event(); add_process(PROCESSOR_POINT_EVENT, 0, 0, 0, 0x101, TRUE); } @@ -3153,7 +3150,7 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card* target, uin } case 28: { group * pgroup = core.units.begin()->ptarget; - raise_event(&pgroup->container, EVENT_SPSUMMON_SUCCESS_G_P, core.units.begin()->peffect, 0, sumplayer, sumplayer, 0); + raise_event(pgroup->container, EVENT_SPSUMMON_SUCCESS_G_P, core.units.begin()->peffect, 0, sumplayer, sumplayer, 0); process_instant_event(); adjust_all(); return FALSE; @@ -3175,7 +3172,7 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card* target, uin for(auto& pcard : pgroup->container) raise_single_event(pcard, 0, EVENT_SPSUMMON_SUCCESS, peffect, 0, sumplayer, pcard->summon_player, 0); process_single_event(); - raise_event(&pgroup->container, EVENT_SPSUMMON_SUCCESS, peffect, 0, sumplayer, sumplayer, 0); + raise_event(pgroup->container, EVENT_SPSUMMON_SUCCESS, peffect, 0, sumplayer, sumplayer, 0); process_instant_event(); if(action_type == SUMMON_IN_IDLE) { adjust_all(); @@ -3388,7 +3385,7 @@ int32 field::special_summon(uint16 step, effect* reason_effect, uint8 reason_pla matreason = REASON_LINK; for(auto& mcard : pcard->material_cards) raise_single_event(mcard, &targets->container, EVENT_BE_MATERIAL, reason_effect, matreason, reason_player, pcard->summon_player, 0); - raise_event(&(pcard->material_cards), EVENT_BE_MATERIAL, reason_effect, matreason, reason_player, pcard->summon_player, 0); + raise_event(pcard->material_cards, EVENT_BE_MATERIAL, reason_effect, matreason, reason_player, pcard->summon_player, 0); } } process_single_event(); @@ -3396,7 +3393,7 @@ int32 field::special_summon(uint16 step, effect* reason_effect, uint8 reason_pla return FALSE; } case 4: { - raise_event(&targets->container, EVENT_SPSUMMON_SUCCESS, reason_effect, 0, reason_player, PLAYER_NONE, 0); + raise_event(targets->container, EVENT_SPSUMMON_SUCCESS, reason_effect, 0, reason_player, PLAYER_NONE, 0); process_instant_event(); return FALSE; } @@ -3619,7 +3616,7 @@ int32 field::destroy(uint16 step, group * targets, effect * reason_effect, uint3 } adjust_instant(); process_single_event(); - raise_event(&targets->container, EVENT_DESTROY, reason_effect, reason, reason_player, 0, 0); + raise_event(targets->container, EVENT_DESTROY, reason_effect, reason, reason_player, 0, 0); process_instant_event(); return FALSE; } @@ -3982,7 +3979,7 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3 } } if(leave_p.size()) - raise_event(&leave_p, EVENT_LEAVE_FIELD_P, reason_effect, reason, reason_player, 0, 0); + raise_event(leave_p, EVENT_LEAVE_FIELD_P, reason_effect, reason, reason_player, 0, 0); process_single_event(); process_instant_event(); return FALSE; @@ -4295,13 +4292,13 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3 } process_single_event(); if(param->leave_field.size()) - raise_event(¶m->leave_field, EVENT_LEAVE_FIELD, reason_effect, reason, reason_player, 0, 0); + raise_event(param->leave_field, EVENT_LEAVE_FIELD, reason_effect, reason, reason_player, 0, 0); if(param->leave_grave.size()) - raise_event(¶m->leave_grave, EVENT_LEAVE_GRAVE, reason_effect, reason, reason_player, 0, 0); + raise_event(param->leave_grave, EVENT_LEAVE_GRAVE, reason_effect, reason, reason_player, 0, 0); if(param->leave_deck.size()) - raise_event(¶m->leave_deck, EVENT_LEAVE_DECK, reason_effect, reason, reason_player, 0, 0); + raise_event(param->leave_deck, EVENT_LEAVE_DECK, reason_effect, reason, reason_player, 0, 0); if((core.global_flag & GLOBALFLAG_DETACH_EVENT) && param->detach.size()) - raise_event(¶m->detach, EVENT_DETACH_MATERIAL, reason_effect, reason, reason_player, 0, 0); + raise_event(param->detach, EVENT_DETACH_MATERIAL, reason_effect, reason, reason_player, 0, 0); process_instant_event(); adjust_instant(); return FALSE; @@ -4376,20 +4373,20 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3 raise_single_event(pcard, 0, EVENT_MOVE, pcard->current.reason_effect, pcard->current.reason, pcard->current.reason_player, 0, 0); } if(tohand.size()) - raise_event(&tohand, EVENT_TO_HAND, reason_effect, reason, reason_player, 0, 0); + raise_event(tohand, EVENT_TO_HAND, reason_effect, reason, reason_player, 0, 0); if(todeck.size()) - raise_event(&todeck, EVENT_TO_DECK, reason_effect, reason, reason_player, 0, 0); + raise_event(todeck, EVENT_TO_DECK, reason_effect, reason, reason_player, 0, 0); if(tograve.size()) - raise_event(&tograve, EVENT_TO_GRAVE, reason_effect, reason, reason_player, 0, 0); + raise_event(tograve, EVENT_TO_GRAVE, reason_effect, reason, reason_player, 0, 0); if(remove.size()) - raise_event(&remove, EVENT_REMOVE, reason_effect, reason, reason_player, 0, 0); + raise_event(remove, EVENT_REMOVE, reason_effect, reason, reason_player, 0, 0); if(discard.size()) - raise_event(&discard, EVENT_DISCARD, reason_effect, reason, reason_player, 0, 0); + raise_event(discard, EVENT_DISCARD, reason_effect, reason, reason_player, 0, 0); if(released.size()) - raise_event(&released, EVENT_RELEASE, reason_effect, reason, reason_player, 0, 0); + raise_event(released, EVENT_RELEASE, reason_effect, reason, reason_player, 0, 0); if(destroyed.size()) - raise_event(&destroyed, EVENT_DESTROYED, reason_effect, reason, reason_player, 0, 0); - raise_event(&targets->container, EVENT_MOVE, reason_effect, reason, reason_player, 0, 0); + raise_event(destroyed, EVENT_DESTROYED, reason_effect, reason, reason_player, 0, 0); + raise_event(targets->container, EVENT_MOVE, reason_effect, reason, reason_player, 0, 0); process_single_event(); process_instant_event(); if(equipings.size()) @@ -4518,14 +4515,14 @@ int32 field::discard_deck(uint16 step, uint8 playerid, uint8 count, uint32 reaso core.discarded_set.insert(pcard); } if(tohand.size()) - raise_event(&tohand, EVENT_TO_HAND, core.reason_effect, reason, core.reason_player, 0, 0); + raise_event(tohand, EVENT_TO_HAND, core.reason_effect, reason, core.reason_player, 0, 0); if(todeck.size()) - raise_event(&todeck, EVENT_TO_DECK, core.reason_effect, reason, core.reason_player, 0, 0); + raise_event(todeck, EVENT_TO_DECK, core.reason_effect, reason, core.reason_player, 0, 0); if(tograve.size()) - raise_event(&tograve, EVENT_TO_GRAVE, core.reason_effect, reason, core.reason_player, 0, 0); + raise_event(tograve, EVENT_TO_GRAVE, core.reason_effect, reason, core.reason_player, 0, 0); if(remove.size()) - raise_event(&remove, EVENT_REMOVE, core.reason_effect, reason, core.reason_player, 0, 0); - raise_event(&core.discarded_set, EVENT_MOVE, core.reason_effect, reason, core.reason_player, 0, 0); + raise_event(remove, EVENT_REMOVE, core.reason_effect, reason, core.reason_player, 0, 0); + raise_event(core.discarded_set, EVENT_MOVE, core.reason_effect, reason, core.reason_player, 0, 0); process_single_event(); process_instant_event(); adjust_instant(); @@ -4968,11 +4965,11 @@ int32 field::change_position(uint16 step, group * targets, effect * reason_effec adjust_instant(); process_single_event(); if(flips.size()) - raise_event(&flips, EVENT_FLIP, reason_effect, 0, reason_player, 0, 0); + raise_event(flips, EVENT_FLIP, reason_effect, 0, reason_player, 0, 0); if(ssets.size()) - raise_event(&ssets, EVENT_SSET, reason_effect, 0, reason_player, 0, 0); + raise_event(ssets, EVENT_SSET, reason_effect, 0, reason_player, 0, 0); if(pos_changed.size()) - raise_event(&pos_changed, EVENT_CHANGE_POS, reason_effect, 0, reason_player, 0, 0); + 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); @@ -6435,7 +6432,7 @@ int32 field::toss_coin(uint16 step, effect * reason_effect, uint8 reason_player, pduel->write_buffer8(core.coin_result[i]); } } - raise_event((card*)0, EVENT_TOSS_COIN_NEGATE, reason_effect, 0, reason_player, playerid, count); + raise_event(nullptr, EVENT_TOSS_COIN_NEGATE, reason_effect, 0, reason_player, playerid, count); process_instant_event(); } else { solve_continuous(peffect->get_handler_player(), peffect, e); @@ -6445,7 +6442,7 @@ int32 field::toss_coin(uint16 step, effect * reason_effect, uint8 reason_player, return FALSE; } case 1: { - raise_event((card*)0, EVENT_TOSS_COIN, reason_effect, 0, reason_player, playerid, core.coin_count); + raise_event(nullptr, EVENT_TOSS_COIN, reason_effect, 0, reason_player, playerid, core.coin_count); process_instant_event(); return TRUE; } @@ -6492,7 +6489,7 @@ int32 field::toss_dice(uint16 step, effect * reason_effect, uint8 reason_player, pduel->write_buffer8(core.dice_result[count1 + i]); } } - raise_event((card*)0, EVENT_TOSS_DICE_NEGATE, reason_effect, 0, reason_player, playerid, count1 + (count2 << 16)); + raise_event(nullptr, EVENT_TOSS_DICE_NEGATE, reason_effect, 0, reason_player, playerid, count1 + (count2 << 16)); process_instant_event(); } else { solve_continuous(peffect->get_handler_player(), peffect, e); @@ -6502,7 +6499,7 @@ int32 field::toss_dice(uint16 step, effect * reason_effect, uint8 reason_player, return FALSE; } case 1: { - raise_event((card*)0, EVENT_TOSS_DICE, reason_effect, 0, reason_player, playerid, count1 + (count2 << 16)); + raise_event(nullptr, EVENT_TOSS_DICE, reason_effect, 0, reason_player, playerid, count1 + (count2 << 16)); process_instant_event(); return TRUE; } diff --git a/processor.cpp b/processor.cpp index 45e5665b9..115a94f77 100644 --- a/processor.cpp +++ b/processor.cpp @@ -897,7 +897,7 @@ void field::raise_event(card* event_card, uint32 event_code, effect* reason_effe pgroup->is_readonly = GTYPE_READ_ONLY; new_event.event_cards = pgroup; } else - new_event.event_cards = 0; + new_event.event_cards = nullptr; new_event.event_code = event_code; new_event.reason_effect = reason_effect; new_event.reason = reason; @@ -906,15 +906,12 @@ void field::raise_event(card* event_card, uint32 event_code, effect* reason_effe new_event.event_value = event_value; core.queue_event.push_back(new_event); } -void field::raise_event(card_set* event_cards, uint32 event_code, effect* reason_effect, uint32 reason, uint8 reason_player, uint8 event_player, uint32 event_value) { +void field::raise_event(const card_set& event_cards, uint32 event_code, effect* reason_effect, uint32 reason, uint8 reason_player, uint8 event_player, uint32 event_value) { tevent new_event; new_event.trigger_card = 0; - if (event_cards) { - group* pgroup = pduel->new_group(*event_cards); - pgroup->is_readonly = GTYPE_READ_ONLY; - new_event.event_cards = pgroup; - } else - new_event.event_cards = 0; + group* pgroup = pduel->new_group(event_cards); + pgroup->is_readonly = GTYPE_READ_ONLY; + new_event.event_cards = pgroup; new_event.event_code = event_code; new_event.reason_effect = reason_effect; new_event.reason = reason; @@ -931,7 +928,7 @@ void field::raise_single_event(card* trigger_card, card_set* event_cards, uint32 pgroup->is_readonly = GTYPE_READ_ONLY; new_event.event_cards = pgroup; } else - new_event.event_cards = 0; + new_event.event_cards = nullptr; new_event.event_code = event_code; new_event.reason_effect = reason_effect; new_event.reason = reason; @@ -2816,7 +2813,7 @@ int32 field::process_battle_command(uint16 step) { if(core.attack_target) { raise_single_event(core.attack_target, 0, EVENT_BATTLE_START, 0, 0, 0, 0, 1); } - raise_event((card*)0, EVENT_BATTLE_START, 0, 0, 0, 0, 0); + raise_event(nullptr, EVENT_BATTLE_START, 0, 0, 0, 0, 0); process_single_event(); process_instant_event(); pduel->write_buffer8(MSG_HINT); @@ -2853,7 +2850,7 @@ int32 field::process_battle_command(uint16 step) { core.pre_field[1] = core.attack_target->fieldid_r; raise_single_event(core.attack_target, 0, EVENT_BATTLE_CONFIRM, 0, 0, 0, 0, 1); } - raise_event((card*)0, EVENT_BATTLE_CONFIRM, 0, 0, 0, 0, 0); + raise_event(nullptr, EVENT_BATTLE_CONFIRM, 0, 0, 0, 0, 0); process_single_event(); process_instant_event(); pduel->write_buffer8(MSG_HINT); @@ -2883,7 +2880,7 @@ int32 field::process_battle_command(uint16 step) { raise_single_event(core.attacker, 0, EVENT_PRE_DAMAGE_CALCULATE, 0, 0, 0, 0, 0); if(core.attack_target) raise_single_event(core.attack_target, 0, EVENT_PRE_DAMAGE_CALCULATE, 0, 0, 0, 0, 1); - raise_event((card*)0, EVENT_PRE_DAMAGE_CALCULATE, 0, 0, 0, 0, 0); + raise_event(nullptr, EVENT_PRE_DAMAGE_CALCULATE, 0, 0, 0, 0, 0); process_single_event(); process_instant_event(); pduel->write_buffer8(MSG_HINT); @@ -3121,7 +3118,7 @@ int32 field::process_battle_command(uint16 step) { raise_single_event(core.attacker, 0, EVENT_BATTLED, 0, 0, PLAYER_NONE, 0, 0); if(core.attack_target) raise_single_event(core.attack_target, 0, EVENT_BATTLED, 0, 0, PLAYER_NONE, 0, 1); - raise_event((card*)0, EVENT_BATTLED, 0, 0, PLAYER_NONE, 0, 0); + raise_event(nullptr, EVENT_BATTLED, 0, 0, PLAYER_NONE, 0, 0); process_single_event(); process_instant_event(); if(core.effect_damage_step) { @@ -3183,15 +3180,15 @@ int32 field::process_battle_command(uint16 step) { ed.insert(core.attack_target); } if(ing.size()) - raise_event(&ing, EVENT_BATTLE_DESTROYING, 0, 0, 0, 0, 0); + raise_event(ing, EVENT_BATTLE_DESTROYING, 0, 0, 0, 0, 0); if(ed.size()) { - raise_event(&ed, EVENT_BATTLE_DESTROYED, 0, 0, 0, 0, 0); - raise_event(&ed, EVENT_DESTROYED, 0, 0, 0, 0, 0); + raise_event(ed, EVENT_BATTLE_DESTROYED, 0, 0, 0, 0, 0); + raise_event(ed, EVENT_DESTROYED, 0, 0, 0, 0, 0); } raise_single_event(core.attacker, 0, EVENT_DAMAGE_STEP_END, 0, 0, 0, 0, 0); if(core.attack_target) raise_single_event(core.attack_target, 0, EVENT_DAMAGE_STEP_END, 0, 0, 0, 0, 1); - raise_event((card*)0, EVENT_DAMAGE_STEP_END, 0, 0, 0, 0, 0); + raise_event(nullptr, EVENT_DAMAGE_STEP_END, 0, 0, 0, 0, 0); process_single_event(); process_instant_event(); core.attacker->set_status(STATUS_BATTLE_DESTROYED, FALSE); @@ -3745,7 +3742,7 @@ int32 field::process_turn(uint16 step, uint8 turn_player) { infos.phase = PHASE_DRAW; core.phase_action = FALSE; core.hand_adjusted = FALSE; - raise_event((card*)0, EVENT_PHASE_START + PHASE_DRAW, 0, 0, 0, turn_player, 0); + raise_event(nullptr, EVENT_PHASE_START + PHASE_DRAW, 0, 0, 0, turn_player, 0); process_instant_event(); adjust_all(); return FALSE; @@ -3763,7 +3760,7 @@ int32 field::process_turn(uint16 step, uint8 turn_player) { } pduel->write_buffer8(MSG_NEW_PHASE); pduel->write_buffer16(infos.phase); - raise_event((card*)0, EVENT_PREDRAW, 0, 0, 0, turn_player, 0); + raise_event(nullptr, EVENT_PREDRAW, 0, 0, 0, turn_player, 0); process_instant_event(); pduel->write_buffer8(MSG_HINT); pduel->write_buffer8(HINT_EVENT); @@ -3805,7 +3802,7 @@ int32 field::process_turn(uint16 step, uint8 turn_player) { } pduel->write_buffer8(MSG_NEW_PHASE); pduel->write_buffer16(infos.phase); - raise_event((card*)0, EVENT_PHASE_START + PHASE_STANDBY, 0, 0, 0, turn_player, 0); + raise_event(nullptr, EVENT_PHASE_START + PHASE_STANDBY, 0, 0, 0, turn_player, 0); process_instant_event(); return FALSE; } @@ -3820,7 +3817,7 @@ int32 field::process_turn(uint16 step, uint8 turn_player) { //Main1 infos.phase = PHASE_MAIN1; core.phase_action = FALSE; - raise_event((card*)0, EVENT_PHASE_START + PHASE_MAIN1, 0, 0, 0, turn_player, 0); + raise_event(nullptr, EVENT_PHASE_START + PHASE_MAIN1, 0, 0, 0, turn_player, 0); process_instant_event(); adjust_all(); return FALSE; @@ -3861,7 +3858,7 @@ int32 field::process_turn(uint16 step, uint8 turn_player) { adjust_all(); return FALSE; } - raise_event((card*)0, EVENT_PHASE_START + PHASE_BATTLE_START, 0, 0, 0, turn_player, 0); + raise_event(nullptr, EVENT_PHASE_START + PHASE_BATTLE_START, 0, 0, 0, turn_player, 0); process_instant_event(); adjust_all(); return FALSE; @@ -3908,7 +3905,7 @@ int32 field::process_turn(uint16 step, uint8 turn_player) { //Main2 infos.phase = PHASE_MAIN2; core.phase_action = FALSE; - raise_event((card*)0, EVENT_PHASE_START + PHASE_MAIN2, 0, 0, 0, turn_player, 0); + raise_event(nullptr, EVENT_PHASE_START + PHASE_MAIN2, 0, 0, 0, turn_player, 0); process_instant_event(); adjust_all(); return FALSE; @@ -3941,7 +3938,7 @@ int32 field::process_turn(uint16 step, uint8 turn_player) { } pduel->write_buffer8(MSG_NEW_PHASE); pduel->write_buffer16(infos.phase); - raise_event((card*)0, EVENT_PHASE_START + PHASE_END, 0, 0, 0, turn_player, 0); + raise_event(nullptr, EVENT_PHASE_START + PHASE_END, 0, 0, 0, turn_player, 0); process_instant_event(); adjust_all(); return FALSE; @@ -3960,7 +3957,7 @@ int32 field::process_turn(uint16 step, uint8 turn_player) { return FALSE; } case 18: { - raise_event((card*)0, EVENT_TURN_END, 0, 0, 0, turn_player, 0); + raise_event(nullptr, EVENT_TURN_END, 0, 0, 0, turn_player, 0); process_instant_event(); adjust_all(); return FALSE; @@ -4232,7 +4229,7 @@ int32 field::add_chain(uint16 step) { raise_single_event(pcard, 0, EVENT_BECOME_TARGET, peffect, 0, clit.triggering_player, 0, clit.chain_count); process_single_event(); if(clit.target_cards->container.size()) - raise_event(&clit.target_cards->container, EVENT_BECOME_TARGET, peffect, 0, clit.triggering_player, clit.triggering_player, clit.chain_count); + raise_event(clit.target_cards->container, EVENT_BECOME_TARGET, peffect, 0, clit.triggering_player, clit.triggering_player, clit.chain_count); } } if(peffect->type & EFFECT_TYPE_ACTIVATE) { @@ -4367,7 +4364,7 @@ int32 field::solve_chain(uint16 step, uint32 chainend_arg1, uint32 chainend_arg2 pduel->write_buffer8(cait->chain_count); add_to_disable_check_list(cait->triggering_effect->get_handler()); adjust_instant(); - raise_event((card*)0, EVENT_CHAIN_ACTIVATING, cait->triggering_effect, 0, cait->triggering_player, cait->triggering_player, cait->chain_count); + raise_event(nullptr, EVENT_CHAIN_ACTIVATING, cait->triggering_effect, 0, cait->triggering_player, cait->triggering_player, cait->chain_count); process_instant_event(); return FALSE; } @@ -4381,7 +4378,7 @@ int32 field::solve_chain(uint16 step, uint32 chainend_arg1, uint32 chainend_arg2 check_chain_counter(peffect, cait->triggering_player, cait->chain_count, true); core.new_fchain.remove_if([chaincount = cait->chain_count](chain ch) { return ch.evt.event_code == EVENT_CHAINING && ch.evt.event_value == chaincount; }); core.new_ochain.remove_if([chaincount = cait->chain_count](chain ch) { return ch.evt.event_code == EVENT_CHAINING && ch.evt.event_value == chaincount; }); - raise_event((card*)0, EVENT_CHAIN_NEGATED, peffect, 0, cait->triggering_player, cait->triggering_player, cait->chain_count); + raise_event(nullptr, EVENT_CHAIN_NEGATED, peffect, 0, cait->triggering_player, cait->triggering_player, cait->chain_count); process_instant_event(); core.units.begin()->step = 9; return FALSE; @@ -4389,7 +4386,7 @@ int32 field::solve_chain(uint16 step, uint32 chainend_arg1, uint32 chainend_arg2 release_oath_relation(peffect); break_effect(); core.chain_solving = TRUE; - raise_event((card*)0, EVENT_CHAIN_SOLVING, peffect, 0, cait->triggering_player, cait->triggering_player, cait->chain_count); + raise_event(nullptr, EVENT_CHAIN_SOLVING, peffect, 0, cait->triggering_player, cait->triggering_player, cait->chain_count); process_instant_event(); return FALSE; } @@ -4419,7 +4416,7 @@ int32 field::solve_chain(uint16 step, uint32 chainend_arg1, uint32 chainend_arg2 pduel->write_buffer8(MSG_CHAIN_DISABLED); pduel->write_buffer8(cait->chain_count); } - raise_event((card*)0, EVENT_CHAIN_DISABLED, peffect, 0, cait->triggering_player, cait->triggering_player, cait->chain_count); + raise_event(nullptr, EVENT_CHAIN_DISABLED, peffect, 0, cait->triggering_player, cait->triggering_player, cait->chain_count); process_instant_event(); core.units.begin()->step = 3; return FALSE; @@ -4469,7 +4466,7 @@ int32 field::solve_chain(uint16 step, uint32 chainend_arg1, uint32 chainend_arg2 core.conti_player = PLAYER_NONE; pduel->write_buffer8(MSG_CHAIN_SOLVED); pduel->write_buffer8(cait->chain_count); - raise_event((card*)0, EVENT_CHAIN_SOLVED, cait->triggering_effect, 0, cait->triggering_player, cait->triggering_player, cait->chain_count); + raise_event(nullptr, EVENT_CHAIN_SOLVED, cait->triggering_effect, 0, cait->triggering_player, cait->triggering_player, cait->chain_count); adjust_disable_check_list(); process_instant_event(); core.units.begin()->step = 9; @@ -4553,7 +4550,7 @@ int32 field::solve_chain(uint16 step, uint32 chainend_arg1, uint32 chainend_arg2 return FALSE; } case 13: { - raise_event((card*)0, EVENT_CHAIN_END, 0, 0, 0, 0, 0); + raise_event(nullptr, EVENT_CHAIN_END, 0, 0, 0, 0, 0); process_instant_event(); adjust_all(); if(chainend_arg1 != 0x101 || chainend_arg2 != TRUE) { @@ -5107,7 +5104,7 @@ int32 field::adjust_step(uint16 step) { return FALSE; } case 15: { - raise_event((card*)0, EVENT_ADJUST, 0, 0, PLAYER_NONE, PLAYER_NONE, 0); + raise_event(nullptr, EVENT_ADJUST, 0, 0, PLAYER_NONE, PLAYER_NONE, 0); process_instant_event(); return FALSE; }