mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-14 22:42:14 -07:00
create participant, move code
This commit is contained in:
parent
dc3d40d261
commit
cf6826dc00
11 changed files with 1084 additions and 669 deletions
|
|
@ -329,11 +329,11 @@ void Server::externalUserLeft(const QString &userName)
|
|||
continue;
|
||||
|
||||
QMutexLocker gameLocker(&game->gameMutex);
|
||||
Server_Player *player = game->getPlayers().value(userGamesIterator.value().second);
|
||||
if (!player)
|
||||
auto *participant = game->getParticipants().value(userGamesIterator.value().second);
|
||||
if (!participant)
|
||||
continue;
|
||||
|
||||
player->disconnectClient();
|
||||
participant->disconnectClient();
|
||||
}
|
||||
roomsLock.unlock();
|
||||
|
||||
|
|
@ -480,8 +480,8 @@ void Server::externalGameCommandContainerReceived(const CommandContainer &cont,
|
|||
}
|
||||
|
||||
QMutexLocker gameLocker(&game->gameMutex);
|
||||
Server_Player *player = game->getPlayers().value(playerId);
|
||||
if (!player) {
|
||||
auto *participant = game->getParticipants().value(playerId);
|
||||
if (!participant) {
|
||||
qDebug() << "externalGameCommandContainerReceived: player id=" << playerId << "not found";
|
||||
throw Response::RespNotInRoom;
|
||||
}
|
||||
|
|
@ -491,7 +491,7 @@ void Server::externalGameCommandContainerReceived(const CommandContainer &cont,
|
|||
const GameCommand &sc = cont.game_command(i);
|
||||
qDebug() << "[ISL]" << getSafeDebugString(sc);
|
||||
|
||||
Response::ResponseCode resp = player->processGameCommand(sc, responseContainer, ges);
|
||||
Response::ResponseCode resp = participant->processGameCommand(sc, responseContainer, ges);
|
||||
|
||||
if (resp != Response::RespOk)
|
||||
finalResponseCode = resp;
|
||||
|
|
@ -499,9 +499,7 @@ void Server::externalGameCommandContainerReceived(const CommandContainer &cont,
|
|||
ges.sendToGame(game);
|
||||
|
||||
if (finalResponseCode != Response::RespNothing) {
|
||||
player->playerMutex.lock();
|
||||
player->getUserInterface()->sendResponseContainer(responseContainer, finalResponseCode);
|
||||
player->playerMutex.unlock();
|
||||
participant->getUserInterface()->sendResponseContainer(responseContainer, finalResponseCode);
|
||||
}
|
||||
} catch (Response::ResponseCode code) {
|
||||
Response response;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue