mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-02 19:43:55 -07:00
Don't get local ID from playerInfo on concession (#6143)
* Don't get local ID from playerInfo. Took 39 minutes Took 39 seconds * Introduce isLocalPlayer convenience method. Took 21 minutes --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
4de5274996
commit
aff775f488
2 changed files with 7 additions and 1 deletions
|
|
@ -35,6 +35,11 @@ Player *PlayerManager::getActiveLocalPlayer(int activePlayer) const
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PlayerManager::isLocalPlayer(int playerId)
|
||||||
|
{
|
||||||
|
return game->getGameState()->getIsLocalGame() || playerId == localPlayerId;
|
||||||
|
}
|
||||||
|
|
||||||
Player *PlayerManager::addPlayer(int playerId, const ServerInfo_User &info)
|
Player *PlayerManager::addPlayer(int playerId, const ServerInfo_User &info)
|
||||||
{
|
{
|
||||||
auto *newPlayer = new Player(info, playerId, isLocalPlayer(playerId) || game->getGameState()->getIsLocalGame(),
|
auto *newPlayer = new Player(info, playerId, isLocalPlayer(playerId) || game->getGameState()->getIsLocalGame(),
|
||||||
|
|
@ -68,7 +73,7 @@ Player *PlayerManager::getPlayer(int playerId) const
|
||||||
void PlayerManager::onPlayerConceded(int playerId, bool conceded)
|
void PlayerManager::onPlayerConceded(int playerId, bool conceded)
|
||||||
{
|
{
|
||||||
// GameEventHandler cares about this for sending the concede/unconcede commands
|
// GameEventHandler cares about this for sending the concede/unconcede commands
|
||||||
if (playerId == getActiveLocalPlayer(playerId)->getPlayerInfo()->getId()) {
|
if (isLocalPlayer(playerId)) {
|
||||||
if (conceded) {
|
if (conceded) {
|
||||||
emit activeLocalPlayerConceded();
|
emit activeLocalPlayerConceded();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
Player *getActiveLocalPlayer(int activePlayer) const;
|
Player *getActiveLocalPlayer(int activePlayer) const;
|
||||||
|
bool isLocalPlayer(int playerId);
|
||||||
|
|
||||||
Player *addPlayer(int playerId, const ServerInfo_User &info);
|
Player *addPlayer(int playerId, const ServerInfo_User &info);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue