Commit 7a7e2ebe authored by nanahira's avatar nanahira

Merge branch 'master' of github.com:Fluorohydride/ygopro

parents 15b78091 1cfa1a1c
......@@ -780,7 +780,7 @@ void Game::DrawGUI() {
while (imageLoading.size()) {
auto mit = imageLoading.cbegin();
mit->first->setImage(imageManager.GetTexture(mit->second));
imageLoading.erase(imageLoading.begin());
imageLoading.erase(mit);
}
for(auto fit = fadingList.begin(); fit != fadingList.end();) {
auto fthis = fit++;
......
......@@ -488,6 +488,11 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
RefreshExtra(0);
RefreshExtra(1);
start_duel(pduel, opt);
if(host_info.time_limit) {
time_elapsed = 0;
timeval timeout = { 1, 0 };
event_add(etimer, &timeout);
}
Process();
}
void SingleDuel::Process() {
......@@ -1429,7 +1434,7 @@ void SingleDuel::GetResponse(DuelPlayer* dp, void* pdata, unsigned int len) {
if(time_limit[dp->type] >= time_elapsed)
time_limit[dp->type] -= time_elapsed;
else time_limit[dp->type] = 0;
event_del(etimer);
time_elapsed = 0;
}
Process();
}
......@@ -1446,6 +1451,7 @@ void SingleDuel::EndDuel() {
for(auto oit = observers.begin(); oit != observers.end(); ++oit)
NetServer::ReSendToPlayer(*oit);
end_duel(pduel);
event_del(etimer);
pduel = 0;
}
void SingleDuel::WaitforResponse(int playerid) {
......@@ -1468,9 +1474,8 @@ void SingleDuel::TimeConfirm(DuelPlayer* dp) {
if(dp->type != last_response)
return;
players[last_response]->state = CTOS_RESPONSE;
time_elapsed = 0;
timeval timeout = {1, 0};
event_add(etimer, &timeout);
if(time_elapsed < 10)
time_elapsed = 0;
}
void SingleDuel::RefreshMzone(int player, int flag, int use_cache) {
char query_buffer[0x2000];
......@@ -1590,7 +1595,7 @@ int SingleDuel::MessageHandler(intptr_t fduel, int type) {
void SingleDuel::SingleTimer(evutil_socket_t fd, short events, void* arg) {
SingleDuel* sd = static_cast<SingleDuel*>(arg);
sd->time_elapsed++;
if(sd->time_elapsed >= sd->time_limit[sd->last_response]) {
if(sd->time_elapsed >= sd->time_limit[sd->last_response] || sd->time_limit[sd->last_response] <= 0) {
unsigned char wbuf[3];
uint32 player = sd->last_response;
wbuf[0] = MSG_WIN;
......@@ -1610,7 +1615,10 @@ void SingleDuel::SingleTimer(evutil_socket_t fd, short events, void* arg) {
sd->EndDuel();
sd->DuelEndProc();
event_del(sd->etimer);
return;
}
timeval timeout = { 1, 0 };
event_add(sd->etimer, &timeout);
}
}
......@@ -56,8 +56,8 @@ protected:
unsigned char duel_count;
unsigned char tp_player;
unsigned char match_result[3];
unsigned short time_limit[2];
unsigned short time_elapsed;
short time_limit[2];
short time_elapsed;
};
}
......
......@@ -484,6 +484,11 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
RefreshExtra(0);
RefreshExtra(1);
start_duel(pduel, opt);
if(host_info.time_limit) {
time_elapsed = 0;
timeval timeout = { 1, 0 };
event_add(etimer, &timeout);
}
Process();
}
void TagDuel::Process() {
......@@ -1527,7 +1532,7 @@ void TagDuel::GetResponse(DuelPlayer* dp, void* pdata, unsigned int len) {
if(time_limit[resp_type] >= time_elapsed)
time_limit[resp_type] -= time_elapsed;
else time_limit[resp_type] = 0;
event_del(etimer);
time_elapsed = 0;
}
Process();
}
......@@ -1546,6 +1551,7 @@ void TagDuel::EndDuel() {
for(auto oit = observers.begin(); oit != observers.end(); ++oit)
NetServer::ReSendToPlayer(*oit);
end_duel(pduel);
event_del(etimer);
pduel = 0;
}
void TagDuel::WaitforResponse(int playerid) {
......@@ -1572,9 +1578,8 @@ void TagDuel::TimeConfirm(DuelPlayer* dp) {
if(dp != cur_player[last_response])
return;
cur_player[last_response]->state = CTOS_RESPONSE;
time_elapsed = 0;
timeval timeout = {1, 0};
event_add(etimer, &timeout);
if(time_elapsed < 10)
time_elapsed = 0;
}
void TagDuel::RefreshMzone(int player, int flag, int use_cache) {
char query_buffer[0x4000];
......@@ -1723,7 +1728,7 @@ int TagDuel::MessageHandler(intptr_t fduel, int type) {
void TagDuel::TagTimer(evutil_socket_t fd, short events, void* arg) {
TagDuel* sd = static_cast<TagDuel*>(arg);
sd->time_elapsed++;
if(sd->time_elapsed >= sd->time_limit[sd->last_response]) {
if(sd->time_elapsed >= sd->time_limit[sd->last_response] || sd->time_limit[sd->last_response] <= 0) {
unsigned char wbuf[3];
uint32 player = sd->last_response;
wbuf[0] = MSG_WIN;
......@@ -1736,7 +1741,10 @@ void TagDuel::TagTimer(evutil_socket_t fd, short events, void* arg) {
sd->EndDuel();
sd->DuelEndProc();
event_del(sd->etimer);
return;
}
timeval timeout = { 1, 0 };
event_add(sd->etimer, &timeout);
}
}
......@@ -53,8 +53,8 @@ protected:
unsigned char last_response;
Replay last_replay;
unsigned char turn_count;
unsigned short time_limit[2];
unsigned short time_elapsed;
short time_limit[2];
short time_elapsed;
};
}
......
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