server crash fix
This commit is contained in:
parent
9c4264b491
commit
3714e1cbf5
3 changed files with 19 additions and 2 deletions
|
@ -17,6 +17,9 @@ Server_Player::Server_Player(Server_Game *_game, int _playerId, const QString &_
|
|||
Server_Player::~Server_Player()
|
||||
{
|
||||
delete deck;
|
||||
|
||||
if (handler)
|
||||
handler->playerRemovedFromGame(game);
|
||||
}
|
||||
|
||||
int Server_Player::newCardId()
|
||||
|
|
|
@ -45,7 +45,13 @@ Server_ProtocolHandler::~Server_ProtocolHandler()
|
|||
chatChannelIterator.next().value()->removeClient(this);
|
||||
}
|
||||
|
||||
void Server_ProtocolHandler::processCommand(Command *command)
|
||||
void Server_ProtocolHandler::playerRemovedFromGame(Server_Game *game)
|
||||
{
|
||||
qDebug() << "Server_ProtocolHandler::playerRemovedFromGame(): gameId =" << game->getGameId();
|
||||
games.remove(game->getGameId());
|
||||
}
|
||||
|
||||
void Server_ProtocolHandler::processCommandHelper(Command *command)
|
||||
{
|
||||
lastCommandTime = QDateTime::currentDateTime();
|
||||
|
||||
|
@ -77,6 +83,7 @@ void Server_ProtocolHandler::processCommand(Command *command)
|
|||
}
|
||||
|
||||
if (!games.contains(gameCommand->getGameId())) {
|
||||
qDebug() << "invalid game";
|
||||
sendProtocolItem(new ProtocolResponse(gameCommand->getCmdId(), RespNameNotFound));
|
||||
return;
|
||||
}
|
||||
|
@ -128,6 +135,11 @@ void Server_ProtocolHandler::processCommand(Command *command)
|
|||
}
|
||||
if (response != RespNothing)
|
||||
sendProtocolItem(new ProtocolResponse(command->getCmdId(), response));
|
||||
}
|
||||
|
||||
void Server_ProtocolHandler::processCommand(Command *command)
|
||||
{
|
||||
processCommandHelper(command);
|
||||
|
||||
delete command;
|
||||
|
||||
|
@ -293,7 +305,6 @@ ResponseCode Server_ProtocolHandler::cmdJoinGame(Command_JoinGame *cmd)
|
|||
|
||||
ResponseCode Server_ProtocolHandler::cmdLeaveGame(Command_LeaveGame * /*cmd*/, Server_Game *game, Server_Player *player)
|
||||
{
|
||||
games.remove(game->getGameId());
|
||||
game->removePlayer(player);
|
||||
return RespOk;
|
||||
}
|
||||
|
|
|
@ -72,11 +72,14 @@ private:
|
|||
ResponseCode cmdSetActivePhase(Command_SetActivePhase *cmd, Server_Game *game, Server_Player *player);
|
||||
ResponseCode cmdDumpZone(Command_DumpZone *cmd, Server_Game *game, Server_Player *player);
|
||||
ResponseCode cmdStopDumpZone(Command_StopDumpZone *cmd, Server_Game *game, Server_Player *player);
|
||||
|
||||
void processCommandHelper(Command *command);
|
||||
private slots:
|
||||
void pingClockTimeout();
|
||||
public:
|
||||
Server_ProtocolHandler(Server *_server, QObject *parent = 0);
|
||||
~Server_ProtocolHandler();
|
||||
void playerRemovedFromGame(Server_Game *game);
|
||||
|
||||
bool getAcceptsGameListChanges() const { return acceptsGameListChanges; }
|
||||
bool getAcceptsChatChannelListChanges() const { return acceptsChatChannelListChanges; }
|
||||
|
|
Loading…
Reference in a new issue