Commit 4e324d60 authored by mercury233's avatar mercury233

fix player quit when finger-guessing

parent c4222113
......@@ -10,6 +10,7 @@
namespace ygo {
SingleDuel::SingleDuel(bool is_match) {
game_started = false;
match_mode = is_match;
match_kill = 0;
for(int i = 0; i < 2; ++i) {
......@@ -145,7 +146,7 @@ void SingleDuel::LeaveGame(DuelPlayer* dp) {
NetServer::StopServer();
} else if(dp->type == NETPLAYER_TYPE_OBSERVER) {
observers.erase(dp);
if(!pduel) {
if(!game_started) {
STOC_HS_WatchChange scwc;
scwc.watch_count = observers.size();
if(players[0])
......@@ -157,7 +158,7 @@ void SingleDuel::LeaveGame(DuelPlayer* dp) {
}
NetServer::DisconnectPlayer(dp);
} else {
if(!pduel && duel_count == 0) {
if(!game_started && duel_count == 0) {
STOC_HS_PlayerChange scpc;
players[dp->type] = 0;
ready[dp->type] = false;
......@@ -170,7 +171,7 @@ void SingleDuel::LeaveGame(DuelPlayer* dp) {
NetServer::SendPacketToPlayer(*pit, STOC_HS_PLAYER_CHANGE, scpc);
NetServer::DisconnectPlayer(dp);
} else {
if(!pduel) {
if(!game_started) {
if(!ready[0])
NetServer::SendPacketToPlayer(players[0], STOC_DUEL_START);
if(!ready[1])
......@@ -310,6 +311,7 @@ void SingleDuel::StartDuel(DuelPlayer* dp) {
return;
NetServer::StopListen();
//NetServer::StopBroadcast();
game_started = true;
NetServer::SendPacketToPlayer(players[0], STOC_DUEL_START);
NetServer::ReSendToPlayer(players[1]);
for(auto oit = observers.begin(); oit != observers.end(); ++oit) {
......
......@@ -52,6 +52,7 @@ protected:
Replay last_replay;
bool match_mode;
int match_kill;
bool game_started;
unsigned char duel_count;
unsigned char tp_player;
unsigned char match_result[3];
......
......@@ -10,6 +10,7 @@
namespace ygo {
TagDuel::TagDuel() {
game_started = false;
for(int i = 0; i < 4; ++i) {
players[i] = 0;
ready[i] = false;
......@@ -119,7 +120,7 @@ void TagDuel::LeaveGame(DuelPlayer* dp) {
NetServer::StopServer();
} else if(dp->type == NETPLAYER_TYPE_OBSERVER) {
observers.erase(dp);
if(!pduel) {
if(!game_started) {
STOC_HS_WatchChange scwc;
scwc.watch_count = observers.size();
for(int i = 0; i < 4; ++i)
......@@ -130,7 +131,7 @@ void TagDuel::LeaveGame(DuelPlayer* dp) {
}
NetServer::DisconnectPlayer(dp);
} else {
if(!pduel) {
if(!game_started) {
STOC_HS_PlayerChange scpc;
players[dp->type] = 0;
ready[dp->type] = false;
......@@ -263,6 +264,7 @@ void TagDuel::StartDuel(DuelPlayer* dp) {
if(!ready[0] || !ready[1] || !ready[2] || !ready[3])
return;
NetServer::StopListen();
game_started = true;
//NetServer::StopBroadcast();
for(int i = 0; i < 4; ++i)
NetServer::SendPacketToPlayer(players[i], STOC_DUEL_START);
......
......@@ -51,6 +51,7 @@ protected:
unsigned char hand_result[2];
unsigned char last_response;
Replay last_replay;
bool game_started;
unsigned char turn_count;
unsigned short time_limit[2];
unsigned 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