Commit acb48d40 authored by salix5's avatar salix5

fix

parent 5e90b8dc
...@@ -1416,8 +1416,8 @@ void field::CheckCounter(card* pcard, int32 counter_type, int32 playerid) { ...@@ -1416,8 +1416,8 @@ void field::CheckCounter(card* pcard, int32 counter_type, int32 playerid) {
(counter_type == 2) ? core.normalsummon_counter : (counter_type == 2) ? core.normalsummon_counter :
(counter_type == 3) ? core.spsummon_counter : (counter_type == 3) ? core.spsummon_counter :
(counter_type == 4) ? core.flipsummon_counter : core.attack_counter; (counter_type == 4) ? core.flipsummon_counter : core.attack_counter;
for(auto& iter : counter_map) { for(auto iter = counter_map.begin();iter!=counter_map.end();++iter) {
auto& info = iter.second; auto& info = iter->second;
if(info.first) { if(info.first) {
pduel->lua->add_param(pcard, PARAM_TYPE_CARD); pduel->lua->add_param(pcard, PARAM_TYPE_CARD);
if(!pduel->lua->check_condition(info.first, 1)) { if(!pduel->lua->check_condition(info.first, 1)) {
...@@ -1705,9 +1705,9 @@ int32 field::check_xyz_material(card* scard, int32 findex, int32 lv, int32 min, ...@@ -1705,9 +1705,9 @@ int32 field::check_xyz_material(card* scard, int32 findex, int32 lv, int32 min,
if(mg) { if(mg) {
uint32 xyz_level; uint32 xyz_level;
core.xmaterial_lst.clear(); core.xmaterial_lst.clear();
for (auto cit : mg->container) { for (auto cit = mg->container.begin(); cit!=mg->container.end(); ++cit) {
if((xyz_level = cit->check_xyz_level(scard, lv)) && (findex == 0 || pduel->lua->check_matching(cit, findex, 0))) if((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.insert(std::make_pair((xyz_level >> 12) & 0xf, *cit));
} }
if(core.global_flag & GLOBALFLAG_XMAT_COUNT_LIMIT) { if(core.global_flag & GLOBALFLAG_XMAT_COUNT_LIMIT) {
auto iter = core.xmaterial_lst.begin(); auto iter = core.xmaterial_lst.begin();
......
...@@ -180,6 +180,7 @@ struct processor { ...@@ -180,6 +180,7 @@ struct processor {
chain_list new_ochain_b; chain_list new_ochain_b;
chain_list new_ochain_h; chain_list new_ochain_h;
chain_list new_chains; chain_list new_chains;
chain_list tmp_chain;
delayed_effect_collection delayed_quick_tmp; delayed_effect_collection delayed_quick_tmp;
delayed_effect_collection delayed_quick_break; delayed_effect_collection delayed_quick_break;
delayed_effect_collection delayed_quick; delayed_effect_collection delayed_quick;
...@@ -270,6 +271,7 @@ struct processor { ...@@ -270,6 +271,7 @@ struct processor {
uint8 battle_phase_count[2]; uint8 battle_phase_count[2];
uint8 phase_action; uint8 phase_action;
uint32 hint_timing[2]; uint32 hint_timing[2];
uint8 current_player;
std::unordered_map<uint32, std::pair<uint32, uint32> > summon_counter; std::unordered_map<uint32, std::pair<uint32, uint32> > summon_counter;
std::unordered_map<uint32, std::pair<uint32, uint32> > normalsummon_counter; std::unordered_map<uint32, std::pair<uint32, uint32> > normalsummon_counter;
std::unordered_map<uint32, std::pair<uint32, uint32> > spsummon_counter; std::unordered_map<uint32, std::pair<uint32, uint32> > spsummon_counter;
......
...@@ -1727,6 +1727,7 @@ int32 field::process_point_event(int16 step, int32 special, int32 skip_new) { ...@@ -1727,6 +1727,7 @@ int32 field::process_point_event(int16 step, int32 special, int32 skip_new) {
core.ntpchain.clear(); core.ntpchain.clear();
core.delayed_quick.clear(); core.delayed_quick.clear();
core.delayed_quick_break.swap(core.delayed_quick); core.delayed_quick_break.swap(core.delayed_quick);
core.current_player = infos.turn_player;
core.units.begin()->step = 1; core.units.begin()->step = 1;
return FALSE; return FALSE;
} }
...@@ -1775,18 +1776,30 @@ int32 field::process_point_event(int16 step, int32 special, int32 skip_new) { ...@@ -1775,18 +1776,30 @@ int32 field::process_point_event(int16 step, int32 special, int32 skip_new) {
peffect->dec_count(tp); peffect->dec_count(tp);
} }
} }
core.new_fchain_s.clear();
if(core.current_player == infos.turn_player){
if(core.tpchain.size() > 1) if(core.tpchain.size() > 1)
add_process(PROCESSOR_SORT_CHAIN, 0, 0, 0, 1, infos.turn_player); add_process(PROCESSOR_SORT_CHAIN, 0, 0, 0, 1, infos.turn_player);
}
else{
if(core.ntpchain.size() > 1) if(core.ntpchain.size() > 1)
add_process(PROCESSOR_SORT_CHAIN, 0, 0, 0, 0, infos.turn_player); add_process(PROCESSOR_SORT_CHAIN, 0, 0, 0, 0, infos.turn_player);
core.new_fchain_s.clear(); }
return FALSE; return FALSE;
} }
case 3: { case 3: {
if(core.current_player == infos.turn_player){
core.new_chains.splice(core.new_chains.end(), core.tpchain); core.new_chains.splice(core.new_chains.end(), core.tpchain);
if(core.new_chains.size())
add_process(PROCESSOR_ADD_CHAIN, 0, 0, 0, 0, 0);
core.current_player = 1-infos.turn_player;
core.units.begin()->step = 1;
}
else{
core.new_chains.splice(core.new_chains.end(), core.ntpchain); core.new_chains.splice(core.new_chains.end(), core.ntpchain);
if(core.new_chains.size()) if(core.new_chains.size())
add_process(PROCESSOR_ADD_CHAIN, 0, 0, 0, 0, 0); add_process(PROCESSOR_ADD_CHAIN, 0, 0, 0, 0, 0);
}
return FALSE; return FALSE;
} }
case 4: { case 4: {
...@@ -1816,14 +1829,21 @@ int32 field::process_point_event(int16 step, int32 special, int32 skip_new) { ...@@ -1816,14 +1829,21 @@ int32 field::process_point_event(int16 step, int32 special, int32 skip_new) {
core.new_ochain_s.splice(core.new_ochain_s.end(), core.tpchain); core.new_ochain_s.splice(core.new_ochain_s.end(), core.tpchain);
core.new_ochain_s.splice(core.new_ochain_s.end(), core.ntpchain); core.new_ochain_s.splice(core.new_ochain_s.end(), core.ntpchain);
core.new_ochain_h.clear(); core.new_ochain_h.clear();
core.tmp_chain.clear();
core.current_player = infos.turn_player;
return FALSE; return FALSE;
} }
case 5: { case 5: {
if(core.new_ochain_s.size() == 0) { if(core.new_ochain_s.size() == 0) {
if(core.current_player == infos.turn_player){
if(core.tpchain.size() > 1) if(core.tpchain.size() > 1)
add_process(PROCESSOR_SORT_CHAIN, 0, 0, 0, 1, infos.turn_player); add_process(PROCESSOR_SORT_CHAIN, 0, 0, 0, 1, infos.turn_player);
core.new_ochain_s.splice(core.new_ochain_s.end(), core.tmp_chain);
}
else{
if(core.ntpchain.size() > 1) if(core.ntpchain.size() > 1)
add_process(PROCESSOR_SORT_CHAIN, 0, 0, 0, 0, infos.turn_player); add_process(PROCESSOR_SORT_CHAIN, 0, 0, 0, 0, infos.turn_player);
}
core.units.begin()->step = 6; core.units.begin()->step = 6;
return FALSE; return FALSE;
} }
...@@ -1861,8 +1881,14 @@ int32 field::process_point_event(int16 step, int32 special, int32 skip_new) { ...@@ -1861,8 +1881,14 @@ int32 field::process_point_event(int16 step, int32 special, int32 skip_new) {
} else } else
act = false; act = false;
} else act = false; } else act = false;
if(act) if(act){
if(tp == core.current_player)
add_process(PROCESSOR_SELECT_EFFECTYN, 0, 0, (group*)peffect->handler, tp, 0); add_process(PROCESSOR_SELECT_EFFECTYN, 0, 0, (group*)peffect->handler, tp, 0);
else{
core.tmp_chain.push_back(*clit);
returns.ivalue[0] = FALSE;
}
}
else returns.ivalue[0] = FALSE; else returns.ivalue[0] = FALSE;
return FALSE; return FALSE;
} }
...@@ -1941,10 +1967,18 @@ int32 field::process_point_event(int16 step, int32 special, int32 skip_new) { ...@@ -1941,10 +1967,18 @@ int32 field::process_point_event(int16 step, int32 special, int32 skip_new) {
return FALSE; return FALSE;
} }
case 7: { case 7: {
if(core.current_player == infos.turn_player){
core.new_chains.splice(core.new_chains.end(), core.tpchain); core.new_chains.splice(core.new_chains.end(), core.tpchain);
if(core.new_chains.size())
add_process(PROCESSOR_ADD_CHAIN, 0, 0, 0, 0, 0);
core.current_player = 1-infos.turn_player;
core.units.begin()->step = 4;
}
else{
core.new_chains.splice(core.new_chains.end(), core.ntpchain); core.new_chains.splice(core.new_chains.end(), core.ntpchain);
if(core.new_chains.size()) if(core.new_chains.size())
add_process(PROCESSOR_ADD_CHAIN, 0, 0, 0, 0, 0); add_process(PROCESSOR_ADD_CHAIN, 0, 0, 0, 0, 0);
}
return FALSE; return FALSE;
} }
case 8: { case 8: {
...@@ -4001,16 +4035,16 @@ int32 field::process_turn(uint16 step, uint8 turn_player) { ...@@ -4001,16 +4035,16 @@ int32 field::process_turn(uint16 step, uint8 turn_player) {
for(auto rit = effects.rechargeable.begin(); rit != effects.rechargeable.end(); ++rit) for(auto rit = effects.rechargeable.begin(); rit != effects.rechargeable.end(); ++rit)
if(!((*rit)->flag & EFFECT_FLAG_NO_TURN_RESET)) if(!((*rit)->flag & EFFECT_FLAG_NO_TURN_RESET))
(*rit)->recharge(); (*rit)->recharge();
for(auto& iter : core.summon_counter) for(auto iter=core.summon_counter.begin();iter!=core.summon_counter.end();++iter)
iter.second.second = 0; iter->second.second = 0;
for(auto& iter : core.normalsummon_counter) for(auto iter=core.normalsummon_counter.begin();iter!=core.normalsummon_counter.end();++iter)
iter.second.second = 0; iter->second.second = 0;
for(auto& iter : core.spsummon_counter) for(auto iter=core.spsummon_counter.begin();iter!=core.spsummon_counter.end();++iter)
iter.second.second = 0; iter->second.second = 0;
for(auto& iter : core.flipsummon_counter) for(auto iter=core.flipsummon_counter.begin();iter!=core.flipsummon_counter.end();++iter)
iter.second.second = 0; iter->second.second = 0;
for(auto& iter : core.attack_counter) for(auto iter=core.attack_counter.begin();iter!=core.attack_counter.end();++iter)
iter.second.second = 0; iter->second.second = 0;
infos.turn_id++; infos.turn_id++;
infos.turn_player = turn_player; infos.turn_player = turn_player;
pduel->write_buffer8(MSG_NEW_TURN); pduel->write_buffer8(MSG_NEW_TURN);
......
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