Commit 44070585 authored by mercury233's avatar mercury233

fix time_compensator

parent 50e2fa1a
......@@ -629,7 +629,8 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
if(host_info.time_limit) {
time_elapsed = 0;
#ifdef YGOPRO_SERVER_MODE
time_compensator = host_info.time_limit;
time_compensator[0] = host_info.time_limit;
time_compensator[1] = host_info.time_limit;
#endif
timeval timeout = { 1, 0 };
event_add(etimer, &timeout);
......@@ -1143,6 +1144,10 @@ int SingleDuel::Analyze(char* msgbuffer, unsigned int len) {
#endif
time_limit[0] = host_info.time_limit;
time_limit[1] = host_info.time_limit;
#ifdef YGOPRO_SERVER_MODE
time_compensator[0] = host_info.time_limit;
time_compensator[1] = host_info.time_limit;
#endif
NetServer::SendBufferToPlayer(players[0], STOC_GAME_MSG, offset, pbuf - offset);
NetServer::ReSendToPlayer(players[1]);
for(auto oit = observers.begin(); oit != observers.end(); ++oit)
......@@ -1880,8 +1885,8 @@ void SingleDuel::TimeConfirm(DuelPlayer* dp) {
return;
players[last_response]->state = CTOS_RESPONSE;
#ifdef YGOPRO_SERVER_MODE
if(time_elapsed < 10 && time_elapsed <= time_compensator){
time_compensator -= time_elapsed;
if(time_elapsed < 10 && time_elapsed <= time_compensator[dp->type]){
time_compensator[dp->type] -= time_elapsed;
time_elapsed = 0;
}
#else
......
......@@ -77,7 +77,7 @@ protected:
unsigned short time_limit[2];
unsigned short time_elapsed;
#ifdef YGOPRO_SERVER_MODE
unsigned short time_compensator;
unsigned short time_compensator[2];
#endif
};
......
......@@ -634,7 +634,8 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
if(host_info.time_limit) {
time_elapsed = 0;
#ifdef YGOPRO_SERVER_MODE
time_compensator = host_info.time_limit;
time_compensator[0] = host_info.time_limit;
time_compensator[1] = host_info.time_limit;
#endif
timeval timeout = { 1, 0 };
event_add(etimer, &timeout);
......@@ -1087,6 +1088,10 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) {
#endif
time_limit[0] = host_info.time_limit;
time_limit[1] = host_info.time_limit;
#ifdef YGOPRO_SERVER_MODE
time_compensator[0] = host_info.time_limit;
time_compensator[1] = host_info.time_limit;
#endif
NetServer::SendBufferToPlayer(players[0], STOC_GAME_MSG, offset, pbuf - offset);
NetServer::ReSendToPlayer(players[1]);
NetServer::ReSendToPlayer(players[2]);
......@@ -1959,8 +1964,8 @@ void TagDuel::TimeConfirm(DuelPlayer* dp) {
return;
cur_player[last_response]->state = CTOS_RESPONSE;
#ifdef YGOPRO_SERVER_MODE
if(time_elapsed < 10 && time_elapsed <= time_compensator){
time_compensator -= time_elapsed;
if(time_elapsed < 10 && time_elapsed <= time_compensator[dp->type]){
time_compensator[dp->type] -= time_elapsed;
time_elapsed = 0;
}
#else
......
......@@ -74,7 +74,7 @@ protected:
unsigned short time_limit[2];
unsigned short time_elapsed;
#ifdef YGOPRO_SERVER_MODE
unsigned short time_compensator;
unsigned short time_compensator[2];
#endif
};
......
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