create participant, move code

This commit is contained in:
ebbit1q 2025-09-18 12:02:09 +02:00
parent dc3d40d261
commit cf6826dc00
11 changed files with 1084 additions and 669 deletions

View file

@ -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;