Commit 9605c451 authored by salix5's avatar salix5

update std container erase

parent cca6e870
......@@ -1995,18 +1995,21 @@ void card::reset(uint32 id, uint32 reset_type) {
}
if(id & RESET_DISABLE) {
for(auto cmit = counters.begin(); cmit != counters.end();) {
auto rm = cmit++;
if(rm->second[1] > 0) {
if(cmit->second[1] > 0) {
pduel->write_buffer8(MSG_REMOVE_COUNTER);
pduel->write_buffer16(rm->first);
pduel->write_buffer16(cmit->first);
pduel->write_buffer8(current.controler);
pduel->write_buffer8(current.location);
pduel->write_buffer8(current.sequence);
pduel->write_buffer16(rm->second[1]);
rm->second[1] = 0;
if(rm->second[0] == 0)
counters.erase(rm);
pduel->write_buffer16(cmit->second[1]);
cmit->second[1] = 0;
if(cmit->second[0] == 0)
cmit = counters.erase(cmit);
else
++cmit;
}
else
++cmit;
}
}
if(id & RESET_TURN_SET) {
......
......@@ -1281,15 +1281,16 @@ void field::remove_effect(effect* peffect) {
}
void field::remove_oath_effect(effect* reason_effect) {
for(auto oeit = effects.oath.begin(); oeit != effects.oath.end();) {
auto rm = oeit++;
if(rm->second == reason_effect) {
effect* peffect = rm->first;
effects.oath.erase(rm);
if(oeit->second == reason_effect) {
effect* peffect = oeit->first;
oeit = effects.oath.erase(oeit);
if(peffect->is_flag(EFFECT_FLAG_FIELD_ONLY))
remove_effect(peffect);
else
peffect->handler->remove_effect(peffect);
}
else
++oeit;
}
}
void field::release_oath_relation(effect* reason_effect) {
......
......@@ -3599,7 +3599,7 @@ int32 field::destroy(uint16 step, group * targets, effect * reason_effect, uint3
if((*cit)->current.reason & REASON_REPLACE)
cit = core.operated_set.erase(cit);
else
cit++;
++cit;
}
returns.ivalue[0] = (int32)core.operated_set.size();
pduel->delete_group(targets);
......@@ -3754,8 +3754,7 @@ int32 field::release(uint16 step, group * targets, effect * reason_effect, uint3
switch (step) {
case 0: {
for (auto cit = targets->container.begin(); cit != targets->container.end();) {
auto rm = cit++;
card* pcard = *rm;
card* pcard = *cit;
if (pcard->get_status(STATUS_SUMMONING | STATUS_SPSUMMON_STEP)
|| ((reason & REASON_SUMMON) && !pcard->is_releasable_by_summon(reason_player, pcard->current.reason_card))
|| (!(pcard->current.reason & (REASON_RULE | REASON_SUMMON | REASON_COST))
......@@ -3763,9 +3762,10 @@ int32 field::release(uint16 step, group * targets, effect * reason_effect, uint3
pcard->current.reason = pcard->temp.reason;
pcard->current.reason_effect = pcard->temp.reason_effect;
pcard->current.reason_player = pcard->temp.reason_player;
targets->container.erase(rm);
continue;
cit = targets->container.erase(cit);
}
else
++cit;
}
if(reason & REASON_RULE)
return FALSE;
......@@ -3857,8 +3857,7 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
switch(step) {
case 0: {
for(auto cit = targets->container.begin(); cit != targets->container.end();) {
auto rm = cit++;
card* pcard = *rm;
card* pcard = *cit;
uint8 dest = pcard->sendto_param.location;
if(!(reason & REASON_RULE) &&
(pcard->get_status(STATUS_SUMMONING | STATUS_SPSUMMON_STEP)
......@@ -3871,9 +3870,10 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
pcard->current.reason = pcard->temp.reason;
pcard->current.reason_player = pcard->temp.reason_player;
pcard->current.reason_effect = pcard->temp.reason_effect;
targets->container.erase(rm);
continue;
cit = targets->container.erase(cit);
}
else
++cit;
}
if(reason & REASON_RULE)
return FALSE;
......@@ -5037,15 +5037,16 @@ int32 field::operation_replace(uint16 step, effect* replace_effect, group* targe
case 6: {
if (returns.ivalue[0]) {
for (auto cit = targets->container.begin(); cit != targets->container.end();) {
auto rm = cit++;
if(replace_effect->get_value(*rm) && !((*rm)->current.reason_effect && (*rm)->current.reason_effect->is_self_destroy_related())) {
(*rm)->current.reason = (*rm)->temp.reason;
(*rm)->current.reason_effect = (*rm)->temp.reason_effect;
(*rm)->current.reason_player = (*rm)->temp.reason_player;
if(replace_effect->get_value(*cit) && !((*cit)->current.reason_effect && (*cit)->current.reason_effect->is_self_destroy_related())) {
(*cit)->current.reason = (*cit)->temp.reason;
(*cit)->current.reason_effect = (*cit)->temp.reason_effect;
(*cit)->current.reason_player = (*cit)->temp.reason_player;
if(is_destroy)
core.destroy_canceled.insert(*rm);
targets->container.erase(rm);
core.destroy_canceled.insert(*cit);
cit = targets->container.erase(cit);
}
else
++cit;
}
replace_effect->dec_count(replace_effect->get_handler_player());
} else
......@@ -5148,15 +5149,16 @@ int32 field::operation_replace(uint16 step, effect* replace_effect, group* targe
case 13: {
if (returns.ivalue[0]) {
for (auto cit = targets->container.begin(); cit != targets->container.end();) {
auto rm = cit++;
if (replace_effect->get_value(*rm)) {
(*rm)->current.reason = (*rm)->temp.reason;
(*rm)->current.reason_effect = (*rm)->temp.reason_effect;
(*rm)->current.reason_player = (*rm)->temp.reason_player;
if (replace_effect->get_value(*cit)) {
(*cit)->current.reason = (*cit)->temp.reason;
(*cit)->current.reason_effect = (*cit)->temp.reason_effect;
(*cit)->current.reason_player = (*cit)->temp.reason_player;
if(is_destroy)
core.destroy_canceled.insert(*rm);
targets->container.erase(rm);
core.destroy_canceled.insert(*cit);
cit = targets->container.erase(cit);
}
else
++cit;
}
replace_effect->dec_count(replace_effect->get_handler_player());
core.desrep_chain.push_back(core.continuous_chain.front());
......
......@@ -3136,9 +3136,10 @@ int32 field::process_battle_command(uint16 step) {
group* des = core.units.begin()->ptarget;
if(des) {
for(auto cit = des->container.begin(); cit != des->container.end();) {
auto rm = cit++;
if((*rm)->current.location != LOCATION_MZONE || ((*rm)->fieldid_r != core.pre_field[0] && (*rm)->fieldid_r != core.pre_field[1]))
des->container.erase(rm);
if ((*cit)->current.location != LOCATION_MZONE || ((*cit)->fieldid_r != core.pre_field[0] && (*cit)->fieldid_r != core.pre_field[1]))
cit = des->container.erase(cit);
else
++cit;
}
add_process(PROCESSOR_DESTROY, 3, 0, des, REASON_BATTLE, PLAYER_NONE);
}
......@@ -4478,9 +4479,10 @@ int32 field::solve_chain(uint16 step, uint32 chainend_arg1, uint32 chainend_arg2
}
case 11: {
for(auto cit = core.leave_confirmed.begin(); cit != core.leave_confirmed.end();) {
auto rm = cit++;
if(!(*rm)->is_status(STATUS_LEAVE_CONFIRMED))
core.leave_confirmed.erase(rm);
if(!(*cit)->is_status(STATUS_LEAVE_CONFIRMED))
cit = core.leave_confirmed.erase(cit);
else
++cit;
}
if(core.leave_confirmed.size())
send_to(&core.leave_confirmed, 0, REASON_RULE, PLAYER_NONE, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP);
......@@ -4518,17 +4520,18 @@ int32 field::break_effect() {
core.hint_timing[0] &= TIMING_DAMAGE_STEP | TIMING_DAMAGE_CAL;
core.hint_timing[1] &= TIMING_DAMAGE_STEP | TIMING_DAMAGE_CAL;
for (auto chit = core.new_ochain.begin(); chit != core.new_ochain.end();) {
auto rm = chit++;
effect* peffect = rm->triggering_effect;
effect* peffect = chit->triggering_effect;
if (!peffect->is_flag(EFFECT_FLAG_DELAY)) {
if (peffect->is_flag(EFFECT_FLAG_FIELD_ONLY)
|| !(peffect->type & EFFECT_TYPE_FIELD) || peffect->in_range(*rm)) {
|| !(peffect->type & EFFECT_TYPE_FIELD) || peffect->in_range(*chit)) {
pduel->write_buffer8(MSG_MISSED_EFFECT);
pduel->write_buffer32(peffect->get_handler()->get_info_location());
pduel->write_buffer32(peffect->get_handler()->data.code);
}
core.new_ochain.erase(rm);
chit = core.new_ochain.erase(chit);
}
else
++chit;
}
core.used_event.splice(core.used_event.end(), core.instant_event);
adjust_instant();
......
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