Commit 05481fe5 authored by salix5's avatar salix5

PHASE_BATTLE_START

parent a2ddc3df
...@@ -71,14 +71,16 @@ private: ...@@ -71,14 +71,16 @@ private:
#define PLAYER_NONE 2 // #define PLAYER_NONE 2 //
#define PLAYER_ALL 3 // #define PLAYER_ALL 3 //
//Phase //Phase
#define PHASE_DRAW 0x01 // #define PHASE_DRAW 0x01
#define PHASE_STANDBY 0x02 // #define PHASE_STANDBY 0x02
#define PHASE_MAIN1 0x04 // #define PHASE_MAIN1 0x04
#define PHASE_BATTLE 0x08 // #define PHASE_BATTLE_START 0x08
#define PHASE_DAMAGE 0x10 // #define PHASE_BATTLE_STEP 0x10
#define PHASE_DAMAGE_CAL 0x20 // #define PHASE_DAMAGE 0x20
#define PHASE_MAIN2 0x40 // #define PHASE_DAMAGE_CAL 0x40
#define PHASE_END 0x80 // #define PHASE_BATTLE 0x80
#define PHASE_MAIN2 0x100
#define PHASE_END 0x200
//Options //Options
#define DUEL_TEST_MODE 0x01 #define DUEL_TEST_MODE 0x01
#define DUEL_ATTACK_FIRST_TURN 0x02 #define DUEL_ATTACK_FIRST_TURN 0x02
......
...@@ -104,18 +104,10 @@ public: ...@@ -104,18 +104,10 @@ public:
#define EFFECT_COUNT_CODE_DUEL 0x20000000 #define EFFECT_COUNT_CODE_DUEL 0x20000000
//========== Reset ========== //========== Reset ==========
#define RESET_DRAW PHASE_DRAW #define RESET_SELF_TURN 0x10000000
#define RESET_STANDBY PHASE_STANDBY #define RESET_OPPO_TURN 0x20000000
#define RESET_MAIN1 PHASE_MAIN1 #define RESET_PHASE 0x40000000
#define RESET_BATTLE PHASE_BATTLE #define RESET_CHAIN 0x80000000
#define RESET_DAMAGE PHASE_DAMAGE
#define RESET_DAMAGE_CAL PHASE_DAMAGE_CAL
#define RESET_MAIN2 PHASE_MAIN2
#define RESET_END PHASE_END
#define RESET_SELF_TURN 0x0100
#define RESET_OPPO_TURN 0x0200
#define RESET_PHASE 0x0400
#define RESET_CHAIN 0x0800
#define RESET_EVENT 0x1000 #define RESET_EVENT 0x1000
#define RESET_CARD 0x2000 #define RESET_CARD 0x2000
#define RESET_CODE 0x4000 #define RESET_CODE 0x4000
...@@ -469,7 +461,6 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2) ...@@ -469,7 +461,6 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2)
#define EVENT_TURN_END 1210 #define EVENT_TURN_END 1210
#define EVENT_PHASE 0x1000 #define EVENT_PHASE 0x1000
#define EVENT_PHASE_START 0x2000 #define EVENT_PHASE_START 0x2000
#define EVENT_PHASE_PRESTART 0x2100
#define EVENT_ADD_COUNTER 0x10000 #define EVENT_ADD_COUNTER 0x10000
#define EVENT_REMOVE_COUNTER 0x20000 #define EVENT_REMOVE_COUNTER 0x20000
......
...@@ -113,7 +113,7 @@ struct field_info { ...@@ -113,7 +113,7 @@ struct field_info {
int16 copy_id; int16 copy_id;
int16 turn_id; int16 turn_id;
int16 card_id; int16 card_id;
uint8 phase; uint16 phase;
uint8 turn_player; uint8 turn_player;
uint8 priorities[2]; uint8 priorities[2];
uint8 can_shuffle; uint8 can_shuffle;
......
...@@ -86,7 +86,7 @@ int32 scriptlib::effect_set_description(lua_State *L) { ...@@ -86,7 +86,7 @@ int32 scriptlib::effect_set_description(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
int32 v = lua_tointeger(L, 2); uint32 v = lua_tounsigned(L, 2);
peffect->description = v; peffect->description = v;
return 0; return 0;
} }
...@@ -94,7 +94,7 @@ int32 scriptlib::effect_set_code(lua_State *L) { ...@@ -94,7 +94,7 @@ int32 scriptlib::effect_set_code(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
int32 v = lua_tointeger(L, 2); uint32 v = lua_tounsigned(L, 2);
peffect->code = v; peffect->code = v;
return 0; return 0;
} }
...@@ -102,7 +102,7 @@ int32 scriptlib::effect_set_range(lua_State *L) { ...@@ -102,7 +102,7 @@ int32 scriptlib::effect_set_range(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
int32 v = lua_tointeger(L, 2); uint32 v = lua_tounsigned(L, 2);
peffect->range = v; peffect->range = v;
return 0; return 0;
} }
...@@ -110,8 +110,8 @@ int32 scriptlib::effect_set_target_range(lua_State *L) { ...@@ -110,8 +110,8 @@ int32 scriptlib::effect_set_target_range(lua_State *L) {
check_param_count(L, 3); check_param_count(L, 3);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
int32 s = lua_tointeger(L, 2); uint32 s = lua_tounsigned(L, 2);
int32 o = lua_tointeger(L, 3); uint32 o = lua_tounsigned(L, 3);
peffect->s_range = s; peffect->s_range = s;
peffect->o_range = o; peffect->o_range = o;
peffect->flag[0] &= ~EFFECT_FLAG_ABSOLUTE_TARGET; peffect->flag[0] &= ~EFFECT_FLAG_ABSOLUTE_TARGET;
...@@ -121,9 +121,9 @@ int32 scriptlib::effect_set_absolute_range(lua_State *L) { ...@@ -121,9 +121,9 @@ int32 scriptlib::effect_set_absolute_range(lua_State *L) {
check_param_count(L, 4); check_param_count(L, 4);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
int32 playerid = lua_tointeger(L, 2); uint32 playerid = lua_tounsigned(L, 2);
int32 s = lua_tointeger(L, 3); uint32 s = lua_tounsigned(L, 3);
int32 o = lua_tointeger(L, 4); uint32 o = lua_tounsigned(L, 4);
if(playerid == 0) { if(playerid == 0) {
peffect->s_range = s; peffect->s_range = s;
peffect->o_range = o; peffect->o_range = o;
...@@ -138,10 +138,10 @@ int32 scriptlib::effect_set_count_limit(lua_State *L) { ...@@ -138,10 +138,10 @@ int32 scriptlib::effect_set_count_limit(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
int32 v = lua_tointeger(L, 2); uint32 v = lua_tounsigned(L, 2);
uint32 code = 0; uint32 code = 0;
if(lua_gettop(L) >= 3) if(lua_gettop(L) >= 3)
code = lua_tointeger(L, 3); code = lua_tounsigned(L, 3);
if(v == 0) if(v == 0)
v = 1; v = 1;
peffect->flag[0] |= EFFECT_FLAG_COUNT_LIMIT; peffect->flag[0] |= EFFECT_FLAG_COUNT_LIMIT;
...@@ -153,8 +153,8 @@ int32 scriptlib::effect_set_reset(lua_State *L) { ...@@ -153,8 +153,8 @@ int32 scriptlib::effect_set_reset(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
int32 v = lua_tointeger(L, 2); uint32 v = lua_tounsigned(L, 2);
int32 c = lua_tointeger(L, 3); uint32 c = lua_tounsigned(L, 3);
if(c == 0) if(c == 0)
c = 1; c = 1;
if(v & (RESET_PHASE) && !(v & (RESET_SELF_TURN | RESET_OPPO_TURN))) if(v & (RESET_PHASE) && !(v & (RESET_SELF_TURN | RESET_OPPO_TURN)))
...@@ -167,7 +167,7 @@ int32 scriptlib::effect_set_type(lua_State *L) { ...@@ -167,7 +167,7 @@ int32 scriptlib::effect_set_type(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
int32 v = lua_tointeger(L, 2); uint32 v = lua_tounsigned(L, 2);
if (v & 0x0ff0) if (v & 0x0ff0)
v |= EFFECT_TYPE_ACTIONS; v |= EFFECT_TYPE_ACTIONS;
else else
...@@ -198,7 +198,7 @@ int32 scriptlib::effect_set_label(lua_State *L) { ...@@ -198,7 +198,7 @@ int32 scriptlib::effect_set_label(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
int32 v = lua_tointeger(L, 2); uint32 v = lua_tounsigned(L, 2);
peffect->label = v; peffect->label = v;
return 0; return 0;
} }
...@@ -220,7 +220,7 @@ int32 scriptlib::effect_set_category(lua_State *L) { ...@@ -220,7 +220,7 @@ int32 scriptlib::effect_set_category(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
int32 v = lua_tointeger(L, 2); uint32 v = lua_tounsigned(L, 2);
peffect->category = v; peffect->category = v;
return 0; return 0;
} }
...@@ -228,10 +228,10 @@ int32 scriptlib::effect_set_hint_timing(lua_State *L) { ...@@ -228,10 +228,10 @@ int32 scriptlib::effect_set_hint_timing(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
int32 vs = lua_tointeger(L, 2); uint32 vs = lua_tounsigned(L, 2);
int32 vo = vs; uint32 vo = vs;
if(lua_gettop(L) >= 3) if(lua_gettop(L) >= 3)
vo = lua_tointeger(L, 3); vo = lua_tounsigned(L, 3);
peffect->hint_timing[0] = vs; peffect->hint_timing[0] = vs;
peffect->hint_timing[1] = vo; peffect->hint_timing[1] = vo;
return 0; return 0;
...@@ -301,7 +301,7 @@ int32 scriptlib::effect_set_owner_player(lua_State *L) { ...@@ -301,7 +301,7 @@ int32 scriptlib::effect_set_owner_player(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
int32 p = lua_tointeger(L, 2); uint32 p = lua_tounsigned(L, 2);
if(p != 0 && p != 1) if(p != 0 && p != 1)
return 0; return 0;
peffect->effect_owner = p; peffect->effect_owner = p;
......
...@@ -1316,7 +1316,8 @@ int32 field::process_phase_event(int16 step, int32 phase) { ...@@ -1316,7 +1316,8 @@ int32 field::process_phase_event(int16 step, int32 phase) {
switch(step) { switch(step) {
case 0: { case 0: {
if((phase == PHASE_DRAW && is_player_affected_by_effect(infos.turn_player, EFFECT_SKIP_DP)) if((phase == PHASE_DRAW && is_player_affected_by_effect(infos.turn_player, EFFECT_SKIP_DP))
|| (phase == PHASE_STANDBY && is_player_affected_by_effect(infos.turn_player, EFFECT_SKIP_SP))) { || (phase == PHASE_STANDBY && is_player_affected_by_effect(infos.turn_player, EFFECT_SKIP_SP))
|| (phase == PHASE_BATTLE_START && is_player_affected_by_effect(infos.turn_player, EFFECT_SKIP_BP))) {
core.units.begin()->step = 24; core.units.begin()->step = 24;
return FALSE; return FALSE;
} }
...@@ -1390,9 +1391,12 @@ int32 field::process_phase_event(int16 step, int32 phase) { ...@@ -1390,9 +1391,12 @@ int32 field::process_phase_event(int16 step, int32 phase) {
core.hint_timing[infos.turn_player] = TIMING_DRAW_PHASE; core.hint_timing[infos.turn_player] = TIMING_DRAW_PHASE;
else if(phase == PHASE_STANDBY) else if(phase == PHASE_STANDBY)
core.hint_timing[infos.turn_player] = TIMING_STANDBY_PHASE; core.hint_timing[infos.turn_player] = TIMING_STANDBY_PHASE;
else if(phase == PHASE_BATTLE_START)
core.hint_timing[infos.turn_player] = TIMING_BATTLE_START;
else if(phase == PHASE_BATTLE) else if(phase == PHASE_BATTLE)
core.hint_timing[infos.turn_player] = TIMING_BATTLE_END; core.hint_timing[infos.turn_player] = TIMING_BATTLE_END;
else core.hint_timing[infos.turn_player] = TIMING_END_PHASE; else
core.hint_timing[infos.turn_player] = TIMING_END_PHASE;
pr = effects.activate_effect.equal_range(EVENT_FREE_CHAIN); pr = effects.activate_effect.equal_range(EVENT_FREE_CHAIN);
for(; pr.first != pr.second; ++pr.first) { for(; pr.first != pr.second; ++pr.first) {
peffect = pr.first->second; peffect = pr.first->second;
...@@ -1441,6 +1445,8 @@ int32 field::process_phase_event(int16 step, int32 phase) { ...@@ -1441,6 +1445,8 @@ int32 field::process_phase_event(int16 step, int32 phase) {
pduel->write_buffer32(20); pduel->write_buffer32(20);
else if(infos.phase == PHASE_STANDBY) else if(infos.phase == PHASE_STANDBY)
pduel->write_buffer32(21); pduel->write_buffer32(21);
else if(infos.phase == PHASE_BATTLE_START)
pduel->write_buffer32(28);
else if(infos.phase == PHASE_BATTLE) else if(infos.phase == PHASE_BATTLE)
pduel->write_buffer32(25); pduel->write_buffer32(25);
else else
...@@ -3948,7 +3954,7 @@ int32 field::process_turn(uint16 step, uint8 turn_player) { ...@@ -3948,7 +3954,7 @@ int32 field::process_turn(uint16 step, uint8 turn_player) {
return FALSE; return FALSE;
} }
pduel->write_buffer8(MSG_NEW_PHASE); pduel->write_buffer8(MSG_NEW_PHASE);
pduel->write_buffer8(infos.phase); pduel->write_buffer16(infos.phase);
raise_event((card*)0, EVENT_PREDRAW, 0, 0, 0, turn_player, 0); raise_event((card*)0, EVENT_PREDRAW, 0, 0, 0, turn_player, 0);
process_instant_event(); process_instant_event();
if(core.new_fchain.size() || core.new_ochain.size()) if(core.new_fchain.size() || core.new_ochain.size())
...@@ -3968,15 +3974,13 @@ int32 field::process_turn(uint16 step, uint8 turn_player) { ...@@ -3968,15 +3974,13 @@ int32 field::process_turn(uint16 step, uint8 turn_player) {
return FALSE; return FALSE;
} }
case 3: { case 3: {
//Standby Phase // EVENT_PHASE_PRESTART is removed
infos.phase = PHASE_STANDBY;
core.phase_action = FALSE;
raise_event((card*)0, EVENT_PHASE_PRESTART + PHASE_STANDBY, 0, 0, 0, turn_player, 0);
process_instant_event();
adjust_all();
return FALSE; return FALSE;
} }
case 4: { case 4: {
//Standby Phase
infos.phase = PHASE_STANDBY;
core.phase_action = FALSE;
core.new_fchain.clear(); core.new_fchain.clear();
core.new_ochain.clear(); core.new_ochain.clear();
core.quick_f_chain.clear(); core.quick_f_chain.clear();
...@@ -3988,13 +3992,13 @@ int32 field::process_turn(uint16 step, uint8 turn_player) { ...@@ -3988,13 +3992,13 @@ int32 field::process_turn(uint16 step, uint8 turn_player) {
return FALSE; return FALSE;
} }
pduel->write_buffer8(MSG_NEW_PHASE); pduel->write_buffer8(MSG_NEW_PHASE);
pduel->write_buffer8(infos.phase); pduel->write_buffer16(infos.phase);
raise_event((card*)0, EVENT_PHASE_START + PHASE_STANDBY, 0, 0, 0, turn_player, 0); raise_event((card*)0, EVENT_PHASE_START + PHASE_STANDBY, 0, 0, 0, turn_player, 0);
process_instant_event(); process_instant_event();
return FALSE; return FALSE;
} }
case 5: { case 5: {
if(core.new_fchain.size() || core.new_ochain.size() || core.instant_event.back().event_code != EVENT_PHASE_START + PHASE_STANDBY) if(core.new_fchain.size() || core.new_ochain.size() || core.instant_event.size())
add_process(PROCESSOR_POINT_EVENT, 0, 0, 0, 0, 0); add_process(PROCESSOR_POINT_EVENT, 0, 0, 0, 0, 0);
add_process(PROCESSOR_PHASE_EVENT, 0, 0, 0, PHASE_STANDBY, 0); add_process(PROCESSOR_PHASE_EVENT, 0, 0, 0, PHASE_STANDBY, 0);
return FALSE; return FALSE;
...@@ -4019,8 +4023,7 @@ int32 field::process_turn(uint16 step, uint8 turn_player) { ...@@ -4019,8 +4023,7 @@ int32 field::process_turn(uint16 step, uint8 turn_player) {
core.quick_f_chain.clear(); core.quick_f_chain.clear();
core.delayed_quick_tmp.clear(); core.delayed_quick_tmp.clear();
pduel->write_buffer8(MSG_NEW_PHASE); pduel->write_buffer8(MSG_NEW_PHASE);
pduel->write_buffer8(infos.phase); pduel->write_buffer16(infos.phase);
add_process(PROCESSOR_IDLE_COMMAND, 0, 0, 0, 0, 0); add_process(PROCESSOR_IDLE_COMMAND, 0, 0, 0, 0, 0);
return FALSE; return FALSE;
} }
...@@ -4034,23 +4037,16 @@ int32 field::process_turn(uint16 step, uint8 turn_player) { ...@@ -4034,23 +4037,16 @@ int32 field::process_turn(uint16 step, uint8 turn_player) {
core.battle_phase_action = FALSE; core.battle_phase_action = FALSE;
core.battle_phase_count[infos.turn_player]++; core.battle_phase_count[infos.turn_player]++;
pduel->write_buffer8(MSG_NEW_PHASE); pduel->write_buffer8(MSG_NEW_PHASE);
pduel->write_buffer8(infos.phase); pduel->write_buffer16(infos.phase);
pduel->write_buffer8(MSG_HINT);
pduel->write_buffer8(HINT_EVENT);
pduel->write_buffer8(infos.turn_player);
pduel->write_buffer32(28);
pduel->write_buffer8(MSG_HINT);
pduel->write_buffer8(HINT_EVENT);
pduel->write_buffer8(1 - infos.turn_player);
pduel->write_buffer32(28);
raise_event((card*)0, EVENT_PHASE_START + PHASE_BATTLE, 0, 0, 0, turn_player, 0); raise_event((card*)0, EVENT_PHASE_START + PHASE_BATTLE, 0, 0, 0, turn_player, 0);
process_instant_event(); process_instant_event();
adjust_all(); adjust_all();
return FALSE; return FALSE;
} }
case 10: { case 10: {
core.hint_timing[infos.turn_player] = TIMING_BATTLE_START; if(core.new_fchain.size() || core.new_ochain.size() || core.instant_event.size())
add_process(PROCESSOR_POINT_EVENT, 0, 0, 0, 0, 0); add_process(PROCESSOR_POINT_EVENT, 0, 0, 0, 0, 0);
add_process(PROCESSOR_PHASE_EVENT, 0, 0, 0, PHASE_BATTLE_START, 0);
return FALSE; return FALSE;
} }
case 11: { case 11: {
...@@ -4103,7 +4099,7 @@ int32 field::process_turn(uint16 step, uint8 turn_player) { ...@@ -4103,7 +4099,7 @@ int32 field::process_turn(uint16 step, uint8 turn_player) {
core.quick_f_chain.clear(); core.quick_f_chain.clear();
core.delayed_quick_tmp.clear(); core.delayed_quick_tmp.clear();
pduel->write_buffer8(MSG_NEW_PHASE); pduel->write_buffer8(MSG_NEW_PHASE);
pduel->write_buffer8(infos.phase); pduel->write_buffer16(infos.phase);
infos.can_shuffle = TRUE; infos.can_shuffle = TRUE;
add_process(PROCESSOR_IDLE_COMMAND, 0, 0, 0, 0, 0); add_process(PROCESSOR_IDLE_COMMAND, 0, 0, 0, 0, 0);
return FALSE; return FALSE;
...@@ -4113,7 +4109,7 @@ int32 field::process_turn(uint16 step, uint8 turn_player) { ...@@ -4113,7 +4109,7 @@ int32 field::process_turn(uint16 step, uint8 turn_player) {
infos.phase = PHASE_END; infos.phase = PHASE_END;
core.phase_action = FALSE; core.phase_action = FALSE;
pduel->write_buffer8(MSG_NEW_PHASE); pduel->write_buffer8(MSG_NEW_PHASE);
pduel->write_buffer8(infos.phase); pduel->write_buffer16(infos.phase);
raise_event((card*)0, EVENT_PHASE_START + PHASE_END, 0, 0, 0, turn_player, 0); raise_event((card*)0, EVENT_PHASE_START + PHASE_END, 0, 0, 0, turn_player, 0);
process_instant_event(); process_instant_event();
adjust_all(); adjust_all();
......
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