Commit 4218cf36 authored by mercury233's avatar mercury233

update tag timer

parent fd4817f5
...@@ -492,6 +492,11 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) { ...@@ -492,6 +492,11 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
RefreshExtra(0); RefreshExtra(0);
RefreshExtra(1); RefreshExtra(1);
start_duel(pduel, opt); start_duel(pduel, opt);
if(host_info.time_limit) {
time_elapsed = 0;
timeval timeout = { 1, 0 };
event_add(etimer, &timeout);
}
Process(); Process();
} }
void TagDuel::Process() { void TagDuel::Process() {
...@@ -1503,7 +1508,7 @@ void TagDuel::GetResponse(DuelPlayer* dp, void* pdata, unsigned int len) { ...@@ -1503,7 +1508,7 @@ void TagDuel::GetResponse(DuelPlayer* dp, void* pdata, unsigned int len) {
if(time_limit[resp_type] >= time_elapsed) if(time_limit[resp_type] >= time_elapsed)
time_limit[resp_type] -= time_elapsed; time_limit[resp_type] -= time_elapsed;
else time_limit[resp_type] = 0; else time_limit[resp_type] = 0;
event_del(etimer); time_elapsed = 0;
} }
Process(); Process();
} }
...@@ -1522,6 +1527,7 @@ void TagDuel::EndDuel() { ...@@ -1522,6 +1527,7 @@ void TagDuel::EndDuel() {
for(auto oit = observers.begin(); oit != observers.end(); ++oit) for(auto oit = observers.begin(); oit != observers.end(); ++oit)
NetServer::ReSendToPlayer(*oit); NetServer::ReSendToPlayer(*oit);
end_duel(pduel); end_duel(pduel);
event_del(etimer);
pduel = 0; pduel = 0;
} }
void TagDuel::WaitforResponse(int playerid) { void TagDuel::WaitforResponse(int playerid) {
...@@ -1548,9 +1554,8 @@ void TagDuel::TimeConfirm(DuelPlayer* dp) { ...@@ -1548,9 +1554,8 @@ void TagDuel::TimeConfirm(DuelPlayer* dp) {
if(dp != cur_player[last_response]) if(dp != cur_player[last_response])
return; return;
cur_player[last_response]->state = CTOS_RESPONSE; cur_player[last_response]->state = CTOS_RESPONSE;
time_elapsed = 0; if(time_elapsed < 10)
timeval timeout = {1, 0}; time_elapsed = 0;
event_add(etimer, &timeout);
} }
void TagDuel::RefreshMzone(int player, int flag, int use_cache) { void TagDuel::RefreshMzone(int player, int flag, int use_cache) {
char query_buffer[0x4000]; char query_buffer[0x4000];
...@@ -1712,7 +1717,10 @@ void TagDuel::TagTimer(evutil_socket_t fd, short events, void* arg) { ...@@ -1712,7 +1717,10 @@ void TagDuel::TagTimer(evutil_socket_t fd, short events, void* arg) {
sd->EndDuel(); sd->EndDuel();
sd->DuelEndProc(); sd->DuelEndProc();
event_del(sd->etimer); event_del(sd->etimer);
return;
} }
timeval timeout = { 1, 0 };
event_add(sd->etimer, &timeout);
} }
} }
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