Commit 7beac3d0 authored by salix5's avatar salix5

group: use default member initializer

parent 673d4af0
...@@ -10,21 +10,15 @@ ...@@ -10,21 +10,15 @@
#include "duel.h" #include "duel.h"
group::group(duel* pd) { group::group(duel* pd) {
ref_handle = 0;
pduel = pd; pduel = pd;
is_readonly = FALSE;
it = container.begin(); it = container.begin();
} }
group::group(duel* pd, card* pcard) { group::group(duel* pd, card* pcard) {
container.insert(pcard); container.insert(pcard);
ref_handle = 0;
pduel = pd; pduel = pd;
is_readonly = FALSE;
it = container.begin(); it = container.begin();
} }
group::group(duel* pd, const card_set& cset): container(cset) { group::group(duel* pd, const card_set& cset): container(cset) {
ref_handle = 0;
pduel = pd; pduel = pd;
is_readonly = FALSE;
it = container.begin(); it = container.begin();
} }
...@@ -18,11 +18,11 @@ class duel; ...@@ -18,11 +18,11 @@ class duel;
class group { class group {
public: public:
using card_set = std::set<card*, card_sort>; using card_set = std::set<card*, card_sort>;
int32 ref_handle;
duel* pduel; duel* pduel;
card_set container; card_set container;
card_set::iterator it; card_set::iterator it;
uint32 is_readonly; int32 ref_handle{ 0 };
uint32 is_readonly{ 0 };
inline bool has_card(card* c) { inline bool has_card(card* c) {
return container.find(c) != container.end(); return container.find(c) != container.end();
......
...@@ -352,7 +352,7 @@ int32 scriptlib::duel_synchro_summon(lua_State *L) { ...@@ -352,7 +352,7 @@ int32 scriptlib::duel_synchro_summon(lua_State *L) {
check_param(L, PARAM_TYPE_GROUP, 4); check_param(L, PARAM_TYPE_GROUP, 4);
group* pgroup = *(group**) lua_touserdata(L, 4); group* pgroup = *(group**) lua_touserdata(L, 4);
mg = pduel->new_group(pgroup->container); mg = pduel->new_group(pgroup->container);
mg->is_readonly = TRUE; mg->is_readonly = 1;
} }
} }
int32 minc = 0; int32 minc = 0;
...@@ -390,7 +390,7 @@ int32 scriptlib::duel_xyz_summon(lua_State *L) { ...@@ -390,7 +390,7 @@ int32 scriptlib::duel_xyz_summon(lua_State *L) {
check_param(L, PARAM_TYPE_GROUP, 3); check_param(L, PARAM_TYPE_GROUP, 3);
group* pgroup = *(group**)lua_touserdata(L, 3); group* pgroup = *(group**)lua_touserdata(L, 3);
materials = pduel->new_group(pgroup->container); materials = pduel->new_group(pgroup->container);
materials->is_readonly = TRUE; materials->is_readonly = 1;
} }
int32 minc = 0; int32 minc = 0;
if(lua_gettop(L) >= 4) if(lua_gettop(L) >= 4)
...@@ -427,7 +427,7 @@ int32 scriptlib::duel_link_summon(lua_State *L) { ...@@ -427,7 +427,7 @@ int32 scriptlib::duel_link_summon(lua_State *L) {
check_param(L, PARAM_TYPE_GROUP, 3); check_param(L, PARAM_TYPE_GROUP, 3);
group* pgroup = *(group**)lua_touserdata(L, 3); group* pgroup = *(group**)lua_touserdata(L, 3);
materials = pduel->new_group(pgroup->container); materials = pduel->new_group(pgroup->container);
materials->is_readonly = TRUE; materials->is_readonly = 1;
} }
if(lua_gettop(L) >= 4) { if(lua_gettop(L) >= 4) {
if(!lua_isnil(L, 4)) { if(!lua_isnil(L, 4)) {
...@@ -2970,7 +2970,7 @@ int32 scriptlib::duel_select_target(lua_State *L) { ...@@ -2970,7 +2970,7 @@ int32 scriptlib::duel_select_target(lua_State *L) {
return 0; return 0;
if(!ch->target_cards) { if(!ch->target_cards) {
ch->target_cards = pduel->new_group(); ch->target_cards = pduel->new_group();
ch->target_cards->is_readonly = TRUE; ch->target_cards->is_readonly = 1;
} }
group* tg = ch->target_cards; group* tg = ch->target_cards;
effect* peffect = ch->triggering_effect; effect* peffect = ch->triggering_effect;
...@@ -3027,10 +3027,10 @@ int32 scriptlib::duel_check_must_material(lua_State *L) { ...@@ -3027,10 +3027,10 @@ int32 scriptlib::duel_check_must_material(lua_State *L) {
pduel = interpreter::get_duel_info(L); pduel = interpreter::get_duel_info(L);
if(mgroup) { if(mgroup) {
pgroup = pduel->new_group(mgroup->container); pgroup = pduel->new_group(mgroup->container);
pgroup->is_readonly = TRUE; pgroup->is_readonly = 1;
} else if(mcard) { } else if(mcard) {
pgroup = pduel->new_group(mcard); pgroup = pduel->new_group(mcard);
pgroup->is_readonly = TRUE; pgroup->is_readonly = 1;
} else } else
pgroup = 0; pgroup = 0;
uint32 limit = (uint32)lua_tointeger(L, 3); uint32 limit = (uint32)lua_tointeger(L, 3);
...@@ -3306,7 +3306,7 @@ int32 scriptlib::duel_set_target_card(lua_State *L) { ...@@ -3306,7 +3306,7 @@ int32 scriptlib::duel_set_target_card(lua_State *L) {
return 0; return 0;
if(!ch->target_cards) { if(!ch->target_cards) {
ch->target_cards = pduel->new_group(); ch->target_cards = pduel->new_group();
ch->target_cards->is_readonly = TRUE; ch->target_cards->is_readonly = 1;
} }
group* targets = ch->target_cards; group* targets = ch->target_cards;
effect* peffect = ch->triggering_effect; effect* peffect = ch->triggering_effect;
...@@ -3397,12 +3397,12 @@ int32 scriptlib::duel_set_operation_info(lua_State *L) { ...@@ -3397,12 +3397,12 @@ int32 scriptlib::duel_set_operation_info(lua_State *L) {
return 0; return 0;
if(pgroup) { if(pgroup) {
pg = pduel->new_group(pgroup->container); pg = pduel->new_group(pgroup->container);
pg->is_readonly = TRUE; pg->is_readonly = 1;
} else if(pcard) { } else if(pcard) {
pg = pduel->new_group(pcard); pg = pduel->new_group(pcard);
pg->is_readonly = TRUE; pg->is_readonly = 1;
} else } else
pg = 0; pg = nullptr;
optarget opt; optarget opt;
opt.op_cards = pg; opt.op_cards = pg;
opt.op_count = count; opt.op_count = count;
......
...@@ -114,7 +114,7 @@ void field::remove_overlay_card(uint32 reason, card* pcard, uint32 rplayer, uint ...@@ -114,7 +114,7 @@ void field::remove_overlay_card(uint32 reason, card* pcard, uint32 rplayer, uint
} }
void field::get_control(card_set* targets, effect* reason_effect, uint32 reason_player, uint32 playerid, uint32 reset_phase, uint32 reset_count, uint32 zone) { 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); group* ng = pduel->new_group(*targets);
ng->is_readonly = TRUE; ng->is_readonly = 1;
add_process(PROCESSOR_GET_CONTROL, 0, reason_effect, ng, 0, (reason_player << 28) + (playerid << 24) + (reset_phase << 8) + reset_count, zone); 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) { void field::get_control(card* target, effect* reason_effect, uint32 reason_player, uint32 playerid, uint32 reset_phase, uint32 reset_count, uint32 zone) {
...@@ -124,9 +124,9 @@ void field::get_control(card* target, effect* reason_effect, uint32 reason_playe ...@@ -124,9 +124,9 @@ void field::get_control(card* target, effect* reason_effect, uint32 reason_playe
} }
void field::swap_control(effect* reason_effect, uint32 reason_player, card_set* targets1, card_set* targets2, uint32 reset_phase, uint32 reset_count) { 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); group* ng1 = pduel->new_group(*targets1);
ng1->is_readonly = TRUE; ng1->is_readonly = 1;
group* ng2 = pduel->new_group(*targets2); group* ng2 = pduel->new_group(*targets2);
ng2->is_readonly = TRUE; ng2->is_readonly = 1;
add_process(PROCESSOR_SWAP_CONTROL, 0, reason_effect, ng1, reason_player, reset_phase, reset_count, 0, ng2); 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) { void field::swap_control(effect* reason_effect, uint32 reason_player, card* pcard1, card* pcard2, uint32 reset_phase, uint32 reset_count) {
...@@ -176,7 +176,7 @@ void field::special_summon(card_set* target, uint32 sumtype, uint32 sumplayer, u ...@@ -176,7 +176,7 @@ void field::special_summon(card_set* target, uint32 sumtype, uint32 sumplayer, u
pcard->spsummon_param = (playerid << 24) + (nocheck << 16) + (nolimit << 8) + positions; 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 = TRUE; pgroup->is_readonly = 1;
add_process(PROCESSOR_SPSUMMON, 0, core.reason_effect, pgroup, core.reason_player, zone); add_process(PROCESSOR_SPSUMMON, 0, core.reason_effect, pgroup, core.reason_player, zone);
} }
void field::special_summon_step(card* target, uint32 sumtype, uint32 sumplayer, uint32 playerid, uint32 nocheck, uint32 nolimit, uint32 positions, uint32 zone) { void field::special_summon_step(card* target, uint32 sumtype, uint32 sumplayer, uint32 playerid, uint32 nocheck, uint32 nolimit, uint32 positions, uint32 zone) {
...@@ -196,7 +196,7 @@ void field::special_summon_step(card* target, uint32 sumtype, uint32 sumplayer, ...@@ -196,7 +196,7 @@ void field::special_summon_step(card* target, uint32 sumtype, uint32 sumplayer,
void field::special_summon_complete(effect* reason_effect, uint8 reason_player) { void field::special_summon_complete(effect* reason_effect, uint8 reason_player) {
group* ng = pduel->new_group(); group* ng = pduel->new_group();
ng->container.swap(core.special_summoning); ng->container.swap(core.special_summoning);
ng->is_readonly = TRUE; ng->is_readonly = 1;
core.hint_timing[reason_player] |= TIMING_SPSUMMON; core.hint_timing[reason_player] |= TIMING_SPSUMMON;
add_process(PROCESSOR_SPSUMMON, 1, reason_effect, ng, reason_player, 0); add_process(PROCESSOR_SPSUMMON, 1, reason_effect, ng, reason_player, 0);
} }
...@@ -228,7 +228,7 @@ void field::destroy(card_set* targets, effect* reason_effect, uint32 reason, uin ...@@ -228,7 +228,7 @@ void field::destroy(card_set* targets, effect* reason_effect, uint32 reason, uin
++cit; ++cit;
} }
group* ng = pduel->new_group(*targets); group* ng = pduel->new_group(*targets);
ng->is_readonly = TRUE; ng->is_readonly = 1;
add_process(PROCESSOR_DESTROY, 0, reason_effect, ng, reason, reason_player); 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) { void field::destroy(card* target, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence) {
...@@ -247,7 +247,7 @@ void field::release(card_set* targets, effect* reason_effect, uint32 reason, uin ...@@ -247,7 +247,7 @@ void field::release(card_set* targets, effect* reason_effect, uint32 reason, uin
pcard->sendto_param.set(pcard->owner, POS_FACEUP, LOCATION_GRAVE); 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 = TRUE; ng->is_readonly = 1;
add_process(PROCESSOR_RELEASE, 0, reason_effect, ng, reason, reason_player); add_process(PROCESSOR_RELEASE, 0, reason_effect, ng, reason, reason_player);
} }
void field::release(card* target, effect* reason_effect, uint32 reason, uint32 reason_player) { void field::release(card* target, effect* reason_effect, uint32 reason, uint32 reason_player) {
...@@ -281,7 +281,7 @@ void field::send_to(card_set* targets, effect* reason_effect, uint32 reason, uin ...@@ -281,7 +281,7 @@ void field::send_to(card_set* targets, effect* reason_effect, uint32 reason, uin
pcard->sendto_param.set(p, pos, destination, sequence); pcard->sendto_param.set(p, pos, destination, sequence);
} }
group* ng = pduel->new_group(*targets); group* ng = pduel->new_group(*targets);
ng->is_readonly = TRUE; ng->is_readonly = 1;
add_process(PROCESSOR_SENDTO, 0, reason_effect, ng, reason, reason_player); add_process(PROCESSOR_SENDTO, 0, reason_effect, ng, reason, reason_player);
} }
void field::send_to(card* target, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence, uint32 position) { void field::send_to(card* target, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence, uint32 position) {
...@@ -299,7 +299,7 @@ void field::move_to_field(card* target, uint32 move_player, uint32 playerid, uin ...@@ -299,7 +299,7 @@ void field::move_to_field(card* target, uint32 move_player, uint32 playerid, uin
} }
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) { 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); group* ng = pduel->new_group(*targets);
ng->is_readonly = TRUE; ng->is_readonly = 1;
for(auto& pcard : *targets) { for(auto& pcard : *targets) {
if(pcard->current.position == POS_FACEUP_ATTACK) if(pcard->current.position == POS_FACEUP_ATTACK)
pcard->position_param = au; pcard->position_param = au;
...@@ -315,7 +315,7 @@ void field::change_position(card_set* targets, effect* reason_effect, uint32 rea ...@@ -315,7 +315,7 @@ void field::change_position(card_set* targets, effect* reason_effect, uint32 rea
} }
void field::change_position(card* target, effect* reason_effect, uint32 reason_player, uint32 npos, uint32 flag, uint32 enable) { void field::change_position(card* target, effect* reason_effect, uint32 reason_player, uint32 npos, uint32 flag, uint32 enable) {
group* ng = pduel->new_group(target); group* ng = pduel->new_group(target);
ng->is_readonly = TRUE; ng->is_readonly = 1;
target->position_param = npos; target->position_param = npos;
target->position_param |= flag; target->position_param |= flag;
add_process(PROCESSOR_CHANGEPOS, 0, reason_effect, ng, reason_player, enable); add_process(PROCESSOR_CHANGEPOS, 0, reason_effect, ng, reason_player, enable);
...@@ -3588,7 +3588,7 @@ int32 field::destroy(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -3588,7 +3588,7 @@ int32 field::destroy(uint16 step, group * targets, effect * reason_effect, uint3
} }
case 4: { case 4: {
group* sendtargets = pduel->new_group(targets->container); group* sendtargets = pduel->new_group(targets->container);
sendtargets->is_readonly = TRUE; sendtargets->is_readonly = 1;
for(auto& pcard : sendtargets->container) { for(auto& pcard : sendtargets->container) {
pcard->set_status(STATUS_DESTROY_CONFIRMED, FALSE); pcard->set_status(STATUS_DESTROY_CONFIRMED, FALSE);
uint32 dest = pcard->sendto_param.location; uint32 dest = pcard->sendto_param.location;
...@@ -3815,7 +3815,7 @@ int32 field::release(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -3815,7 +3815,7 @@ int32 field::release(uint16 step, group * targets, effect * reason_effect, uint3
} }
case 3: { case 3: {
group* sendtargets = pduel->new_group(targets->container); group* sendtargets = pduel->new_group(targets->container);
sendtargets->is_readonly = TRUE; sendtargets->is_readonly = 1;
operation_replace(EFFECT_SEND_REPLACE, 5, sendtargets); operation_replace(EFFECT_SEND_REPLACE, 5, sendtargets);
add_process(PROCESSOR_SENDTO, 1, reason_effect, sendtargets, reason | REASON_RELEASE, reason_player); add_process(PROCESSOR_SENDTO, 1, reason_effect, sendtargets, reason | REASON_RELEASE, reason_player);
return FALSE; return FALSE;
......
...@@ -894,7 +894,7 @@ void field::raise_event(card* event_card, uint32 event_code, effect* reason_effe ...@@ -894,7 +894,7 @@ void field::raise_event(card* event_card, uint32 event_code, effect* reason_effe
new_event.trigger_card = 0; new_event.trigger_card = 0;
if (event_card) { if (event_card) {
group* pgroup = pduel->new_group(event_card); group* pgroup = pduel->new_group(event_card);
pgroup->is_readonly = TRUE; pgroup->is_readonly = 1;
new_event.event_cards = pgroup; new_event.event_cards = pgroup;
} else } else
new_event.event_cards = 0; new_event.event_cards = 0;
...@@ -911,7 +911,7 @@ void field::raise_event(card_set* event_cards, uint32 event_code, effect* reason ...@@ -911,7 +911,7 @@ void field::raise_event(card_set* event_cards, uint32 event_code, effect* reason
new_event.trigger_card = 0; new_event.trigger_card = 0;
if (event_cards) { if (event_cards) {
group* pgroup = pduel->new_group(*event_cards); group* pgroup = pduel->new_group(*event_cards);
pgroup->is_readonly = TRUE; pgroup->is_readonly = 1;
new_event.event_cards = pgroup; new_event.event_cards = pgroup;
} else } else
new_event.event_cards = 0; new_event.event_cards = 0;
...@@ -928,7 +928,7 @@ void field::raise_single_event(card* trigger_card, card_set* event_cards, uint32 ...@@ -928,7 +928,7 @@ void field::raise_single_event(card* trigger_card, card_set* event_cards, uint32
new_event.trigger_card = trigger_card; new_event.trigger_card = trigger_card;
if (event_cards) { if (event_cards) {
group* pgroup = pduel->new_group(*event_cards); group* pgroup = pduel->new_group(*event_cards);
pgroup->is_readonly = TRUE; pgroup->is_readonly = 1;
new_event.event_cards = pgroup; new_event.event_cards = pgroup;
} else } else
new_event.event_cards = 0; new_event.event_cards = 0;
...@@ -3073,7 +3073,7 @@ int32 field::process_battle_command(uint16 step) { ...@@ -3073,7 +3073,7 @@ int32 field::process_battle_command(uint16 step) {
if(des.size()) { if(des.size()) {
group* ng = pduel->new_group(); group* ng = pduel->new_group();
ng->container.swap(des); ng->container.swap(des);
ng->is_readonly = TRUE; ng->is_readonly = 1;
add_process(PROCESSOR_DESTROY, 10, 0, ng, REASON_BATTLE, PLAYER_NONE); add_process(PROCESSOR_DESTROY, 10, 0, ng, REASON_BATTLE, PLAYER_NONE);
core.units.begin()->ptarget = ng; core.units.begin()->ptarget = ng;
} }
...@@ -4958,7 +4958,7 @@ int32 field::adjust_step(uint16 step) { ...@@ -4958,7 +4958,7 @@ int32 field::adjust_step(uint16 step) {
core.re_adjust = TRUE; core.re_adjust = TRUE;
group* ng = pduel->new_group(); group* ng = pduel->new_group();
ng->container.swap(pos_adjust); ng->container.swap(pos_adjust);
ng->is_readonly = TRUE; ng->is_readonly = 1;
add_process(PROCESSOR_CHANGEPOS, 0, 0, ng, PLAYER_NONE, TRUE); add_process(PROCESSOR_CHANGEPOS, 0, 0, ng, PLAYER_NONE, TRUE);
} }
return FALSE; return FALSE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment