Skip to content
This repository has been archived by the owner on Apr 6, 2018. It is now read-only.

Commit

Permalink
Merge branch 'master' into koishibuild
Browse files Browse the repository at this point in the history
  • Loading branch information
Smile-DK committed Mar 7, 2018
2 parents 1fc6151 + c85d4da commit 00e742b
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 122 deletions.
33 changes: 17 additions & 16 deletions ocgcore/card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ bool card::card_operation_sort(card* c1, card* c2) {
}
void card::attacker_map::addcard(card* pcard) {
uint16 fid = pcard ? pcard->fieldid_r : 0;
auto pr = insert(std::make_pair(fid, std::make_pair(pcard, 0)));
auto pr = emplace(fid, std::make_pair(pcard, 0));
pr.first->second.second++;
}
card::card(duel* pd) {
Expand Down Expand Up @@ -1693,21 +1693,21 @@ int32 card::add_effect(effect* peffect) {
remove_effect(rm->second);
}
}
eit = single_effect.insert(std::make_pair(peffect->code, peffect));
eit = single_effect.emplace(peffect->code, peffect);
} else if (peffect->type & EFFECT_TYPE_EQUIP) {
eit = equip_effect.insert(std::make_pair(peffect->code, peffect));
eit = equip_effect.emplace(peffect->code, peffect);
if (equiping_target)
check_target = equiping_target;
else
check_target = 0;
} else if (peffect->type & EFFECT_TYPE_XMATERIAL) {
eit = xmaterial_effect.insert(std::make_pair(peffect->code, peffect));
eit = xmaterial_effect.emplace(peffect->code, peffect);
if (overlay_target)
check_target = overlay_target;
else
check_target = 0;
} else if (peffect->type & EFFECT_TYPE_FIELD) {
eit = field_effect.insert(std::make_pair(peffect->code, peffect));
eit = field_effect.emplace(peffect->code, peffect);
} else
return 0;
peffect->id = pduel->game_field->infos.field_id++;
Expand All @@ -1726,7 +1726,7 @@ int32 card::add_effect(effect* peffect) {
if(peffect->reset_count > reason_effect->reset_count)
peffect->reset_count = reason_effect->reset_count;
}
indexer.insert(std::make_pair(peffect, eit));
indexer.emplace(peffect, eit);
peffect->handler = this;
if (peffect->in_range(this) && (peffect->type & EFFECT_TYPE_FIELD))
pduel->game_field->add_effect(peffect);
Expand All @@ -1735,7 +1735,7 @@ int32 card::add_effect(effect* peffect) {
pduel->game_field->add_to_disable_check_list(check_target);
}
if(peffect->is_flag(EFFECT_FLAG_OATH)) {
pduel->game_field->effects.oath.insert(std::make_pair(peffect, reason_effect));
pduel->game_field->effects.oath.emplace(peffect, reason_effect);
}
if(peffect->reset_flag & RESET_PHASE) {
pduel->game_field->effects.pheff.insert(peffect);
Expand Down Expand Up @@ -2080,7 +2080,7 @@ void card::release_relation(card* target) {
relations.erase(target);
}
void card::create_relation(const chain& ch) {
relate_effect.insert(std::make_pair(ch.triggering_effect, ch.chain_id));
relate_effect.emplace(ch.triggering_effect, ch.chain_id);
}
int32 card::is_has_relation(const chain& ch) {
if (relate_effect.find(std::make_pair(ch.triggering_effect, ch.chain_id)) != relate_effect.end())
Expand All @@ -2100,7 +2100,7 @@ void card::create_relation(effect* peffect) {
return;
}
}
relate_effect.insert(std::make_pair(peffect, (uint16)0));
relate_effect.emplace(peffect, (uint16)0);
}
int32 card::is_has_relation(effect* peffect) {
for(auto it = relate_effect.begin(); it != relate_effect.end(); ++it) {
Expand Down Expand Up @@ -2167,7 +2167,7 @@ int32 card::add_counter(uint8 playerid, uint16 countertype, uint16 count, uint8
if(!is_can_add_counter(playerid, countertype, count, singly, 0))
return FALSE;
uint16 cttype = countertype & ~COUNTER_NEED_ENABLE;
auto pr = counters.insert(std::make_pair(cttype, counter_map::mapped_type()));
auto pr = counters.emplace(cttype, counter_map::mapped_type());
auto cmit = pr.first;
if(pr.second) {
cmit->second[0] = 0;
Expand Down Expand Up @@ -2591,9 +2591,9 @@ void card::filter_spsummon_procedure(uint8 playerid, effect_set* peset, uint32 s
auto pr = field_effect.equal_range(EFFECT_SPSUMMON_PROC);
uint8 toplayer;
uint8 topos;
effect* peffect;
for(; pr.first != pr.second; ++pr.first) {
peffect = pr.first->second;
for(auto eit = pr.first; eit != pr.second;) {
effect* peffect = eit->second;
++eit;
if(peffect->is_flag(EFFECT_FLAG_SPSUM_PARAM)) {
topos = (uint8)peffect->s_range;
if(peffect->o_range == 0)
Expand All @@ -2618,8 +2618,9 @@ void card::filter_spsummon_procedure(uint8 playerid, effect_set* peset, uint32 s
}
void card::filter_spsummon_procedure_g(uint8 playerid, effect_set* peset) {
auto pr = field_effect.equal_range(EFFECT_SPSUMMON_PROC_G);
for(; pr.first != pr.second; ++pr.first) {
effect* peffect = pr.first->second;
for(auto eit = pr.first; eit != pr.second;) {
effect* peffect = eit->second;
++eit;
if(!peffect->is_available() || !peffect->check_count_limit(playerid))
continue;
if(current.controler != playerid && !peffect->is_flag(EFFECT_FLAG_BOTH_SIDE))
Expand Down Expand Up @@ -3247,7 +3248,7 @@ int32 card::is_destructable_by_effect(effect* peffect, uint8 playerid) {
pduel->lua->add_param(playerid, PARAM_TYPE_INT);
int32 ct;
if(ct = eset[i]->get_value(3)) {
auto it = indestructable_effects.insert(std::make_pair(eset[i]->id, 0));
auto it = indestructable_effects.emplace(eset[i]->id, 0);
if(it.first->second + 1 <= ct) {
return FALSE;
break;
Expand Down
47 changes: 24 additions & 23 deletions ocgcore/field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1044,33 +1044,33 @@ void field::add_effect(effect* peffect, uint8 owner_player) {
peffect->card_type = peffect->owner->data.type;
effect_container::iterator it;
if (!(peffect->type & EFFECT_TYPE_ACTIONS)) {
it = effects.aura_effect.insert(std::make_pair(peffect->code, peffect));
it = effects.aura_effect.emplace(peffect->code, peffect);
if(peffect->code == EFFECT_SPSUMMON_COUNT_LIMIT)
effects.spsummon_count_eff.insert(peffect);
if(peffect->type & EFFECT_TYPE_GRANT)
effects.grant_effect.insert(std::make_pair(peffect, field_effect::gain_effects()));
effects.grant_effect.emplace(peffect, field_effect::gain_effects());
} else {
if (peffect->type & EFFECT_TYPE_IGNITION)
it = effects.ignition_effect.insert(std::make_pair(peffect->code, peffect));
it = effects.ignition_effect.emplace(peffect->code, peffect);
else if (peffect->type & EFFECT_TYPE_ACTIVATE)
it = effects.activate_effect.insert(std::make_pair(peffect->code, peffect));
it = effects.activate_effect.emplace(peffect->code, peffect);
else if (peffect->type & EFFECT_TYPE_TRIGGER_O && peffect->type & EFFECT_TYPE_FIELD)
it = effects.trigger_o_effect.insert(std::make_pair(peffect->code, peffect));
it = effects.trigger_o_effect.emplace(peffect->code, peffect);
else if (peffect->type & EFFECT_TYPE_TRIGGER_F && peffect->type & EFFECT_TYPE_FIELD)
it = effects.trigger_f_effect.insert(std::make_pair(peffect->code, peffect));
it = effects.trigger_f_effect.emplace(peffect->code, peffect);
else if (peffect->type & EFFECT_TYPE_QUICK_O)
it = effects.quick_o_effect.insert(std::make_pair(peffect->code, peffect));
it = effects.quick_o_effect.emplace(peffect->code, peffect);
else if (peffect->type & EFFECT_TYPE_QUICK_F)
it = effects.quick_f_effect.insert(std::make_pair(peffect->code, peffect));
it = effects.quick_f_effect.emplace(peffect->code, peffect);
else if (peffect->type & EFFECT_TYPE_CONTINUOUS)
it = effects.continuous_effect.insert(std::make_pair(peffect->code, peffect));
it = effects.continuous_effect.emplace(peffect->code, peffect);
}
effects.indexer.insert(std::make_pair(peffect, it));
effects.indexer.emplace(peffect, it);
if(peffect->is_flag(EFFECT_FLAG_FIELD_ONLY)) {
if(peffect->is_disable_related())
update_disable_check_list(peffect);
if(peffect->is_flag(EFFECT_FLAG_OATH))
effects.oath.insert(std::make_pair(peffect, core.reason_effect));
effects.oath.emplace(peffect, core.reason_effect);
if(peffect->reset_flag & RESET_PHASE)
effects.pheff.insert(peffect);
if(peffect->reset_flag & RESET_CHAIN)
Expand Down Expand Up @@ -1777,21 +1777,21 @@ void field::get_xyz_material(card* scard, int32 findex, uint32 lv, int32 maxc, g
for (auto cit = mg->container.begin(); cit != mg->container.end(); ++cit) {
if((*cit)->is_can_be_xyz_material(scard) && (xyz_level = (*cit)->check_xyz_level(scard, lv))
&& (findex == 0 || pduel->lua->check_matching(*cit, findex, 0)))
core.xmaterial_lst.insert(std::make_pair((xyz_level >> 12) & 0xf, *cit));
core.xmaterial_lst.emplace((xyz_level >> 12) & 0xf, *cit);
}
} else {
int32 playerid = scard->current.controler;
for(auto cit = player[playerid].list_mzone.begin(); cit != player[playerid].list_mzone.end(); ++cit) {
card* pcard = *cit;
if(pcard && pcard->is_position(POS_FACEUP) && pcard->is_can_be_xyz_material(scard) && (xyz_level = pcard->check_xyz_level(scard, lv))
&& (findex == 0 || pduel->lua->check_matching(pcard, findex, 0)))
core.xmaterial_lst.insert(std::make_pair((xyz_level >> 12) & 0xf, pcard));
core.xmaterial_lst.emplace((xyz_level >> 12) & 0xf, pcard);
}
for(auto cit = player[1 - playerid].list_mzone.begin(); cit != player[1 - playerid].list_mzone.end(); ++cit) {
card* pcard = *cit;
if(pcard && pcard->is_position(POS_FACEUP) && pcard->is_can_be_xyz_material(scard) && (xyz_level = pcard->check_xyz_level(scard, lv))
&& pcard->is_affected_by_effect(EFFECT_XYZ_MATERIAL) && (findex == 0 || pduel->lua->check_matching(pcard, findex, 0)))
core.xmaterial_lst.insert(std::make_pair((xyz_level >> 12) & 0xf, pcard));
core.xmaterial_lst.emplace((xyz_level >> 12) & 0xf, pcard);
}
}
if(core.global_flag & GLOBALFLAG_XMAT_COUNT_LIMIT) {
Expand Down Expand Up @@ -1974,7 +1974,7 @@ int32 field::adjust_grant_effect() {
effect* ceffect = geffect->clone();
ceffect->owner = pcard;
pcard->add_effect(ceffect);
eit->second.insert(std::make_pair(pcard, ceffect));
eit->second.emplace(pcard, ceffect);
}
for(auto cit = remove_set.begin(); cit != remove_set.end(); ++cit) {
card* pcard = *cit;
Expand Down Expand Up @@ -2187,8 +2187,9 @@ uint32 field::get_field_counter(uint8 self, uint8 s, uint8 o, uint16 countertype
}
int32 field::effect_replace_check(uint32 code, const tevent& e) {
auto pr = effects.continuous_effect.equal_range(code);
for (; pr.first != pr.second; ++pr.first) {
effect* peffect = pr.first->second;
for(auto eit = pr.first; eit != pr.second;) {
effect* peffect = eit->second;
++eit;
if(peffect->is_activateable(peffect->get_handler_player(), e))
return TRUE;
}
Expand Down Expand Up @@ -3160,16 +3161,16 @@ int32 field::is_player_can_remove_counter(uint8 playerid, card * pcard, uint8 s,
if((pcard && pcard->get_counter(countertype) >= count) || (!pcard && get_field_counter(playerid, s, o, countertype) >= count))
return TRUE;
auto pr = effects.continuous_effect.equal_range(EFFECT_RCOUNTER_REPLACE + countertype);
effect* peffect;
tevent e;
e.event_cards = 0;
e.event_player = playerid;
e.event_value = count;
e.reason = reason;
e.reason_effect = core.reason_effect;
e.reason_player = playerid;
for (; pr.first != pr.second; ++pr.first) {
peffect = pr.first->second;
for(auto eit = pr.first; eit != pr.second;) {
effect* peffect = eit->second;
++eit;
if(peffect->is_activateable(peffect->get_handler_player(), e))
return TRUE;
}
Expand All @@ -3179,16 +3180,16 @@ int32 field::is_player_can_remove_overlay_card(uint8 playerid, card * pcard, uin
if((pcard && pcard->xyz_materials.size() >= min) || (!pcard && get_overlay_count(playerid, s, o) >= min))
return TRUE;
auto pr = effects.continuous_effect.equal_range(EFFECT_OVERLAY_REMOVE_REPLACE);
effect* peffect;
tevent e;
e.event_cards = 0;
e.event_player = playerid;
e.event_value = min;
e.reason = reason;
e.reason_effect = core.reason_effect;
e.reason_player = playerid;
for (; pr.first != pr.second; ++pr.first) {
peffect = pr.first->second;
for(auto eit = pr.first; eit != pr.second;) {
effect* peffect = eit->second;
++eit;
if(peffect->is_activateable(peffect->get_handler_player(), e))
return TRUE;
}
Expand Down
10 changes: 5 additions & 5 deletions ocgcore/interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -746,15 +746,15 @@ int32 interpreter::load_card_script(uint32 code) {
}
void interpreter::add_param(void *param, int32 type, bool front) {
if(front)
params.push_front(std::make_pair(param, type));
params.emplace_front(param, type);
else
params.push_back(std::make_pair(param, type));
params.emplace_back(param, type);
}
void interpreter::add_param(ptr param, int32 type, bool front) {
if(front)
params.push_front(std::make_pair((void*)param, type));
params.emplace_front((void*)param, type);
else
params.push_back(std::make_pair((void*)param, type));
params.emplace_back((void*)param, type);
}
void interpreter::push_param(lua_State* L, bool is_coroutine) {
uint32 type;
Expand Down Expand Up @@ -1118,7 +1118,7 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va
return OPERATION_FAIL;
}
call_depth++;
coroutines.insert(std::make_pair(f, rthread));
coroutines.emplace(f, rthread);
} else {
rthread = it->second;
if(step == 0) {
Expand Down
3 changes: 2 additions & 1 deletion ocgcore/libcard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1360,8 +1360,9 @@ int32 scriptlib::card_check_activate_effect(lua_State *L) {
int32 copy_info = lua_toboolean(L, 4);
duel* pduel = pcard->pduel;
tevent pe;
for(auto eit = pcard->field_effect.begin(); eit != pcard->field_effect.end(); ++eit) {
for(auto eit = pcard->field_effect.begin(); eit != pcard->field_effect.end();) {
effect* peffect = eit->second;
++eit;
if((peffect->type & EFFECT_TYPE_ACTIVATE)
&& pduel->game_field->check_event_c(peffect, pduel->game_field->core.reason_player, neglect_con, neglect_cost, copy_info, &pe)) {
if(!copy_info || (peffect->code == EVENT_FREE_CHAIN)) {
Expand Down
2 changes: 1 addition & 1 deletion ocgcore/libdebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ int32 scriptlib::debug_pre_add_counter(lua_State *L) {
uint32 countertype = lua_tonumberint(L, 2);
uint32 count = lua_tonumberint(L, 3);
uint16 cttype = countertype & ~COUNTER_NEED_ENABLE;
auto pr = pcard->counters.insert(std::make_pair(cttype, card::counter_map::mapped_type()));
auto pr = pcard->counters.emplace(cttype, card::counter_map::mapped_type());
auto cmit = pr.first;
if(pr.second) {
cmit->second[0] = 0;
Expand Down
4 changes: 2 additions & 2 deletions ocgcore/libduel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -748,15 +748,15 @@ int32 scriptlib::duel_set_chain_limit(lua_State *L) {
check_param(L, PARAM_TYPE_FUNCTION, 1);
duel* pduel = interpreter::get_duel_info(L);
int32 f = interpreter::get_function_handle(L, 1);
pduel->game_field->core.chain_limit.push_back(processor::chain_limit_t(f, pduel->game_field->core.reason_player));
pduel->game_field->core.chain_limit.emplace_back(f, pduel->game_field->core.reason_player);
return 0;
}
int32 scriptlib::duel_set_chain_limit_p(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_FUNCTION, 1);
duel* pduel = interpreter::get_duel_info(L);
int32 f = interpreter::get_function_handle(L, 1);
pduel->game_field->core.chain_limit_p.push_back(processor::chain_limit_t(f, pduel->game_field->core.reason_player));
pduel->game_field->core.chain_limit_p.emplace_back(f, pduel->game_field->core.reason_player);
return 0;
}
int32 scriptlib::duel_get_chain_material(lua_State *L) {
Expand Down
26 changes: 14 additions & 12 deletions ocgcore/operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,9 @@ void field::operation_replace(int32 type, int32 step, group* targets) {
int32 is_destroy = (type == EFFECT_DESTROY_REPLACE) ? TRUE : FALSE;
auto pr = effects.continuous_effect.equal_range(type);
std::vector<effect*> opp_effects;
for(auto it = pr.first; it != pr.second; ++it) {
effect* reffect = it->second;
for(auto eit = pr.first; eit != pr.second;) {
effect* reffect = eit->second;
++eit;
if(reffect->get_handler_player() == infos.turn_player)
add_process(PROCESSOR_OPERATION_REPLACE, step, reffect, targets, is_destroy, 0);
else
Expand Down Expand Up @@ -623,8 +624,9 @@ int32 field::pay_lp_cost(uint32 step, uint8 playerid, uint32 cost) {
core.select_effects.push_back(0);
}
auto pr = effects.continuous_effect.equal_range(EFFECT_LPCOST_REPLACE);
for (; pr.first != pr.second; ++pr.first) {
effect* peffect = pr.first->second;
for(auto eit = pr.first; eit != pr.second;) {
effect* peffect = eit->second;
++eit;
if(peffect->is_activateable(peffect->get_handler_player(), e)) {
core.select_options.push_back(peffect->description);
core.select_effects.push_back(peffect);
Expand Down Expand Up @@ -679,16 +681,16 @@ int32 field::remove_counter(uint16 step, uint32 reason, card* pcard, uint8 rplay
core.select_effects.push_back(0);
}
auto pr = effects.continuous_effect.equal_range(EFFECT_RCOUNTER_REPLACE + countertype);
effect* peffect;
tevent e;
e.event_cards = 0;
e.event_player = rplayer;
e.event_value = count;
e.reason = reason;
e.reason_effect = core.reason_effect;
e.reason_player = rplayer;
for (; pr.first != pr.second; ++pr.first) {
peffect = pr.first->second;
for(auto eit = pr.first; eit != pr.second;) {
effect* peffect = eit->second;
++eit;
if(peffect->is_activateable(peffect->get_handler_player(), e)) {
core.select_options.push_back(peffect->description);
core.select_effects.push_back(peffect);
Expand Down Expand Up @@ -756,16 +758,16 @@ int32 field::remove_overlay_card(uint16 step, uint32 reason, card* pcard, uint8
core.select_effects.push_back(0);
}
auto pr = effects.continuous_effect.equal_range(EFFECT_OVERLAY_REMOVE_REPLACE);
effect* peffect;
tevent e;
e.event_cards = 0;
e.event_player = rplayer;
e.event_value = min;
e.reason = reason;
e.reason_effect = core.reason_effect;
e.reason_player = rplayer;
for (; pr.first != pr.second; ++pr.first) {
peffect = pr.first->second;
for(auto eit = pr.first; eit != pr.second;) {
effect* peffect = eit->second;
++eit;
if(peffect->is_activateable(peffect->get_handler_player(), e)) {
core.select_options.push_back(peffect->description);
core.select_effects.push_back(peffect);
Expand Down Expand Up @@ -3137,7 +3139,7 @@ int32 field::destroy(uint16 step, group * targets, effect * reason_effect, uint3
pduel->lua->add_param(pcard->current.reason_player, PARAM_TYPE_INT);
int32 ct;
if(ct = eset[i]->get_value(3)) {
auto it = pcard->indestructable_effects.insert(std::make_pair(eset[i]->id, 0));
auto it = pcard->indestructable_effects.emplace(eset[i]->id, 0);
if(++it.first->second <= ct) {
indestructable_effect_set.insert(eset[i]);
is_destructable = false;
Expand Down Expand Up @@ -3340,7 +3342,7 @@ int32 field::destroy(uint16 step, group * targets, effect * reason_effect, uint3
pduel->lua->add_param(pcard->current.reason_player, PARAM_TYPE_INT);
int32 ct;
if(ct = eset[i]->get_value(3)) {
auto it = pcard->indestructable_effects.insert(std::make_pair(eset[i]->id, 0));
auto it = pcard->indestructable_effects.emplace(eset[i]->id, 0);
if(++it.first->second <= ct) {
pduel->write_buffer8(MSG_HINT);
pduel->write_buffer8(HINT_CARD);
Expand Down
Loading

0 comments on commit 00e742b

Please sign in to comment.