diff --git a/AI/BattleAI/BattleAI.cpp b/AI/BattleAI/BattleAI.cpp index efd2c6d88..f96d33084 100644 --- a/AI/BattleAI/BattleAI.cpp +++ b/AI/BattleAI/BattleAI.cpp @@ -244,7 +244,7 @@ void CBattleAI::battleStart(const CCreatureSet *army1, const CCreatureSet *army2 void CBattleAI::print(const std::string &text) const { - logAi->trace("%s Battle AI[%p]: %s", playerID.getStr(), this, text); + logAi->trace("%s Battle AI[%p]: %s", playerID.toString(), this, text); } std::optional CBattleAI::considerFleeingOrSurrendering() diff --git a/AI/BattleAI/BattleEvaluator.cpp b/AI/BattleAI/BattleEvaluator.cpp index 64c505591..c67eab4db 100644 --- a/AI/BattleAI/BattleEvaluator.cpp +++ b/AI/BattleAI/BattleEvaluator.cpp @@ -703,7 +703,7 @@ void BattleEvaluator::evaluateCreatureSpellcast(const CStack * stack, PossibleSp void BattleEvaluator::print(const std::string & text) const { - logAi->trace("%s Battle AI[%p]: %s", playerID.getStr(), this, text); + logAi->trace("%s Battle AI[%p]: %s", playerID.toString(), this, text); } diff --git a/AI/BattleAI/StackWithBonuses.cpp b/AI/BattleAI/StackWithBonuses.cpp index 6c5f57e31..c80ec1dce 100644 --- a/AI/BattleAI/StackWithBonuses.cpp +++ b/AI/BattleAI/StackWithBonuses.cpp @@ -231,7 +231,7 @@ void StackWithBonuses::removeUnitBonus(const CSelector & selector) std::string StackWithBonuses::getDescription() const { std::ostringstream oss; - oss << unitOwner().getStr(); + oss << unitOwner().toString(); oss << " battle stack [" << unitId() << "]: " << getCount() << " of "; if(type) oss << type->getJsonKey(); diff --git a/AI/Nullkiller/AIGateway.cpp b/AI/Nullkiller/AIGateway.cpp index 9ae840d4b..ad30802c3 100644 --- a/AI/Nullkiller/AIGateway.cpp +++ b/AI/Nullkiller/AIGateway.cpp @@ -192,7 +192,7 @@ void AIGateway::gameOver(PlayerColor player, const EVictoryLossCheckResult & vic { LOG_TRACE_PARAMS(logAi, "victoryLossCheckResult '%s'", victoryLossCheckResult.messageToSelf.toString()); NET_EVENT_HANDLER; - logAi->debug("Player %d (%s): I heard that player %d (%s) %s.", playerID, playerID.getStr(), player, player.getStr(), (victoryLossCheckResult.victory() ? "won" : "lost")); + logAi->debug("Player %d (%s): I heard that player %d (%s) %s.", playerID, playerID.toString(), player, player.toString(), (victoryLossCheckResult.victory() ? "won" : "lost")); // some whitespace to flush stream logAi->debug(std::string(200, ' ')); @@ -201,12 +201,12 @@ void AIGateway::gameOver(PlayerColor player, const EVictoryLossCheckResult & vic { if(victoryLossCheckResult.victory()) { - logAi->debug("AIGateway: Player %d (%s) won. I won! Incredible!", player, player.getStr()); + logAi->debug("AIGateway: Player %d (%s) won. I won! Incredible!", player, player.toString()); logAi->debug("Turn nr %d", myCb->getDate()); } else { - logAi->debug("AIGateway: Player %d (%s) lost. It's me. What a disappointment! :(", player, player.getStr()); + logAi->debug("AIGateway: Player %d (%s) lost. It's me. What a disappointment! :(", player, player.toString()); } // some whitespace to flush stream @@ -776,7 +776,7 @@ void AIGateway::makeTurn() MAKING_TURN; auto day = cb->getDate(Date::DAY); - logAi->info("Player %d (%s) starting turn, day %d", playerID, playerID.getStr(), day); + logAi->info("Player %d (%s) starting turn, day %d", playerID, playerID.toString(), day); boost::shared_lock gsLock(CGameState::mutex); setThreadName("AIGateway::makeTurn"); @@ -1096,7 +1096,7 @@ void AIGateway::battleEnd(const BattleResult * br, QueryID queryID) assert(status.getBattle() == ONGOING_BATTLE); status.setBattle(ENDING_BATTLE); bool won = br->winner == myCb->battleGetMySide(); - logAi->debug("Player %d (%s): I %s the %s!", playerID, playerID.getStr(), (won ? "won" : "lost"), battlename); + logAi->debug("Player %d (%s): I %s the %s!", playerID, playerID.toString(), (won ? "won" : "lost"), battlename); battlename.clear(); if (queryID != QueryID::NONE) @@ -1421,7 +1421,7 @@ void AIGateway::tryRealize(Goals::Trade & g) //trade void AIGateway::endTurn() { - logAi->info("Player %d (%s) ends turn", playerID, playerID.getStr()); + logAi->info("Player %d (%s) ends turn", playerID, playerID.toString()); if(!status.haveTurn()) { logAi->error("Not having turn at the end of turn???"); @@ -1441,7 +1441,7 @@ void AIGateway::endTurn() } while(status.haveTurn()); //for some reasons, our request may fail -> stop requesting end of turn only after we've received a confirmation that it's over - logGlobal->info("Player %d (%s) ended turn", playerID, playerID.getStr()); + logGlobal->info("Player %d (%s) ended turn", playerID, playerID.toString()); } void AIGateway::buildArmyIn(const CGTownInstance * t) diff --git a/AI/VCAI/VCAI.cpp b/AI/VCAI/VCAI.cpp index 231c77cd8..a150e7c6a 100644 --- a/AI/VCAI/VCAI.cpp +++ b/AI/VCAI/VCAI.cpp @@ -204,7 +204,7 @@ void VCAI::gameOver(PlayerColor player, const EVictoryLossCheckResult & victoryL { LOG_TRACE_PARAMS(logAi, "victoryLossCheckResult '%s'", victoryLossCheckResult.messageToSelf.toString()); NET_EVENT_HANDLER; - logAi->debug("Player %d (%s): I heard that player %d (%s) %s.", playerID, playerID.getStr(), player, player.getStr(), (victoryLossCheckResult.victory() ? "won" : "lost")); + logAi->debug("Player %d (%s): I heard that player %d (%s) %s.", playerID, playerID.toString(), player, player.toString(), (victoryLossCheckResult.victory() ? "won" : "lost")); if(player == playerID) { if(victoryLossCheckResult.victory()) @@ -214,7 +214,7 @@ void VCAI::gameOver(PlayerColor player, const EVictoryLossCheckResult & victoryL } else { - logAi->debug("VCAI: Player %d (%s) lost. It's me. What a disappointment! :(", player, player.getStr()); + logAi->debug("VCAI: Player %d (%s) lost. It's me. What a disappointment! :(", player, player.toString()); } finish(); @@ -779,7 +779,7 @@ void VCAI::makeTurn() MAKING_TURN; auto day = cb->getDate(Date::DAY); - logAi->info("Player %d (%s) starting turn, day %d", playerID, playerID.getStr(), day); + logAi->info("Player %d (%s) starting turn, day %d", playerID, playerID.toString(), day); boost::shared_lock gsLock(CGameState::mutex); setThreadName("VCAI::makeTurn"); @@ -1593,7 +1593,7 @@ void VCAI::battleEnd(const BattleResult * br, QueryID queryID) assert(status.getBattle() == ONGOING_BATTLE); status.setBattle(ENDING_BATTLE); bool won = br->winner == myCb->battleGetMySide(); - logAi->debug("Player %d (%s): I %s the %s!", playerID, playerID.getStr(), (won ? "won" : "lost"), battlename); + logAi->debug("Player %d (%s): I %s the %s!", playerID, playerID.toString(), (won ? "won" : "lost"), battlename); battlename.clear(); if (queryID != QueryID::NONE) @@ -2288,7 +2288,7 @@ HeroPtr VCAI::primaryHero() const void VCAI::endTurn() { - logAi->info("Player %d (%s) ends turn", playerID, playerID.getStr()); + logAi->info("Player %d (%s) ends turn", playerID, playerID.toString()); if(!status.haveTurn()) { logAi->error("Not having turn at the end of turn???"); @@ -2300,7 +2300,7 @@ void VCAI::endTurn() } while(status.haveTurn()); //for some reasons, our request may fail -> stop requesting end of turn only after we've received a confirmation that it's over - logGlobal->info("Player %d (%s) ended turn", playerID, playerID.getStr()); + logGlobal->info("Player %d (%s) ended turn", playerID, playerID.toString()); } void VCAI::striveToGoal(Goals::TSubgoal basicGoal) diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 2240cd638..cddcfe2c9 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -125,7 +125,7 @@ struct HeroObjectRetriever CPlayerInterface::CPlayerInterface(PlayerColor Player): localState(std::make_unique(*this)) { - logGlobal->trace("\tHuman player interface for player %s being constructed", Player.getStr()); + logGlobal->trace("\tHuman player interface for player %s being constructed", Player.toString()); destinationTeleport = ObjectInstanceID(); destinationTeleportPos = int3(-1); GH.defActionsDef = 0; @@ -147,7 +147,7 @@ CPlayerInterface::CPlayerInterface(PlayerColor Player): CPlayerInterface::~CPlayerInterface() { - logGlobal->trace("\tHuman player interface for player %s being destructed", playerID.getStr()); + logGlobal->trace("\tHuman player interface for player %s being destructed", playerID.toString()); delete showingDialog; delete cingconsole; if (LOCPLINT == this) diff --git a/client/Client.cpp b/client/Client.cpp index b1d89cfa4..931dd4e36 100644 --- a/client/Client.cpp +++ b/client/Client.cpp @@ -408,7 +408,7 @@ void CClient::initPlayerEnvironments() bool hasHumanPlayer = false; for(auto & color : allPlayers) { - logNetwork->info("Preparing environment for player %s", color.getStr()); + logNetwork->info("Preparing environment for player %s", color.toString()); playerEnvironments[color] = std::make_shared(color, this, std::make_shared(gs, color, this)); if(!hasHumanPlayer && gs->players[color].isHuman()) @@ -439,7 +439,7 @@ void CClient::initPlayerInterfaces() if(!vstd::contains(playerint, color)) { - logNetwork->info("Preparing interface for player %s", color.getStr()); + logNetwork->info("Preparing interface for player %s", color.toString()); if(playerInfo.second.isControlledByAI()) { bool alliedToHuman = false; @@ -448,12 +448,12 @@ void CClient::initPlayerInterfaces() alliedToHuman = true; auto AiToGive = aiNameForPlayer(playerInfo.second, false, alliedToHuman); - logNetwork->info("Player %s will be lead by %s", color.getStr(), AiToGive); + logNetwork->info("Player %s will be lead by %s", color.toString(), AiToGive); installNewPlayerInterface(CDynLibHandler::getNewAI(AiToGive), color); } else { - logNetwork->info("Player %s will be lead by human", color.getStr()); + logNetwork->info("Player %s will be lead by human", color.toString()); installNewPlayerInterface(std::make_shared(color), color); } } @@ -503,7 +503,7 @@ void CClient::installNewPlayerInterface(std::shared_ptr gameInte playerint[color] = gameInterface; - logGlobal->trace("\tInitializing the interface for player %s", color.getStr()); + logGlobal->trace("\tInitializing the interface for player %s", color.toString()); auto cb = std::make_shared(gs, color, this); battleCallbacks[color] = cb; gameInterface->initGameInterface(playerEnvironments.at(color), cb); @@ -519,7 +519,7 @@ void CClient::installNewBattleInterface(std::shared_ptr ba if(needCallback) { - logGlobal->trace("\tInitializing the battle interface for player %s", color.getStr()); + logGlobal->trace("\tInitializing the battle interface for player %s", color.toString()); auto cbc = std::make_shared(color, this); battleCallbacks[color] = cbc; battleInterface->initBattleInterface(playerEnvironments.at(color), cbc); diff --git a/client/ClientCommandManager.cpp b/client/ClientCommandManager.cpp index 5a4c2f8cf..6f0e22010 100644 --- a/client/ClientCommandManager.cpp +++ b/client/ClientCommandManager.cpp @@ -97,7 +97,7 @@ void ClientCommandManager::handleGoSoloCommand() if(elem.second.human) { auto AiToGive = CSH->client->aiNameForPlayer(*CSH->client->getPlayerSettings(elem.first), false, false); - printCommandMessage("Player " + elem.first.getStr() + " will be lead by " + AiToGive, ELogLevel::INFO); + printCommandMessage("Player " + elem.first.toString() + " will be lead by " + AiToGive, ELogLevel::INFO); CSH->client->installNewPlayerInterface(CDynLibHandler::getNewAI(AiToGive), elem.first); } } diff --git a/client/NetPacksClient.cpp b/client/NetPacksClient.cpp index 2c692a31c..3a89d8e1b 100644 --- a/client/NetPacksClient.cpp +++ b/client/NetPacksClient.cpp @@ -874,7 +874,7 @@ void ApplyClientNetPackVisitor::visitPlayerBlocked(PlayerBlocked & pack) void ApplyClientNetPackVisitor::visitYourTurn(YourTurn & pack) { - logNetwork->debug("Server gives turn to %s", pack.player.getStr()); + logNetwork->debug("Server gives turn to %s", pack.player.toString()); callAllInterfaces(cl, &IGameEventsReceiver::playerStartsTurn, pack.player); callOnlyThatInterface(cl, pack.player, &CGameInterface::yourTurn, pack.queryID); @@ -882,12 +882,12 @@ void ApplyClientNetPackVisitor::visitYourTurn(YourTurn & pack) void ApplyClientNetPackVisitor::visitTurnTimeUpdate(TurnTimeUpdate & pack) { - logNetwork->debug("Server sets turn timer {turn: %d, base: %d, battle: %d, creature: %d} for %s", pack.turnTimer.turnTimer, pack.turnTimer.baseTimer, pack.turnTimer.battleTimer, pack.turnTimer.creatureTimer, pack.player.getStr()); + logNetwork->debug("Server sets turn timer {turn: %d, base: %d, battle: %d, creature: %d} for %s", pack.turnTimer.turnTimer, pack.turnTimer.baseTimer, pack.turnTimer.battleTimer, pack.turnTimer.creatureTimer, pack.player.toString()); } void ApplyClientNetPackVisitor::visitPlayerMessageClient(PlayerMessageClient & pack) { - logNetwork->debug("pack.player %s sends a message: %s", pack.player.getStr(), pack.text); + logNetwork->debug("pack.player %s sends a message: %s", pack.player.toString(), pack.text); std::ostringstream str; if(pack.player.isSpectator()) diff --git a/client/battle/BattleInterface.cpp b/client/battle/BattleInterface.cpp index deb640985..2cd96c9d9 100644 --- a/client/battle/BattleInterface.cpp +++ b/client/battle/BattleInterface.cpp @@ -244,7 +244,7 @@ void BattleInterface::giveCommand(EActionType action, BattleHex tile, SpellID sp auto side = curInt->cb->playerToSide(curInt->playerID); if(!side) { - logGlobal->error("Player %s is not in battle", curInt->playerID.getStr()); + logGlobal->error("Player %s is not in battle", curInt->playerID.toString()); return; } diff --git a/client/lobby/CSelectionBase.cpp b/client/lobby/CSelectionBase.cpp index 5701a17bc..9128a4e29 100644 --- a/client/lobby/CSelectionBase.cpp +++ b/client/lobby/CSelectionBase.cpp @@ -240,7 +240,7 @@ void InfoCard::changeSelection() int pid = p.first; if(pset) { - auto name = boost::str(boost::format("%s (%d-%d %s)") % p.second.name % p.second.connection % pid % pset->color.getStr()); + auto name = boost::str(boost::format("%s (%d-%d %s)") % p.second.name % p.second.connection % pid % pset->color.toString()); labelGroupPlayersAssigned->add(24, 285 + (int)labelGroupPlayersAssigned->currentSize()*(int)graphics->fonts[FONT_SMALL]->getLineHeight(), name); } else diff --git a/client/render/Graphics.cpp b/client/render/Graphics.cpp index ea9b55122..d6710effe 100644 --- a/client/render/Graphics.cpp +++ b/client/render/Graphics.cpp @@ -151,7 +151,7 @@ void Graphics::blueToPlayersAdv(SDL_Surface * sur, PlayerColor player) } else { - logGlobal->error("Wrong player id in blueToPlayersAdv (%s)!", player.getStr()); + logGlobal->error("Wrong player id in blueToPlayersAdv (%s)!", player.toString()); return; } //FIXME: not all player colored images have player palette at last 32 indexes diff --git a/lib/CPlayerState.cpp b/lib/CPlayerState.cpp index 41d2676d9..faa021bbe 100644 --- a/lib/CPlayerState.cpp +++ b/lib/CPlayerState.cpp @@ -11,6 +11,8 @@ #include "CPlayerState.h" #include "gameState/QuestInfo.h" +#include "CGeneralTextHandler.h" +#include "VCMI_Lib.h" VCMI_LIB_NAMESPACE_BEGIN @@ -43,7 +45,7 @@ PlayerState::~PlayerState() = default; std::string PlayerState::nodeName() const { - return "Player " + color.getStrCap(false); + return "Player " + color.toString(); } PlayerColor PlayerState::getId() const @@ -60,18 +62,22 @@ int32_t PlayerState::getIconIndex() const { return color.getNum(); } + std::string PlayerState::getJsonKey() const { - return color.getStr(false); + return color.toString(); } + std::string PlayerState::getNameTranslated() const { - return color.getStr(true); + return VLC->generaltexth->translate(getNameTextID()); } + std::string PlayerState::getNameTextID() const { - return color.getStr(false); + return TextIdentifier("core.plcolors", color.getNum()).get(); } + void PlayerState::registerIcons(const IconRegistar & cb) const { //We cannot register new icons for players diff --git a/lib/CStack.cpp b/lib/CStack.cpp index c8e63313c..9343340cf 100644 --- a/lib/CStack.cpp +++ b/lib/CStack.cpp @@ -162,7 +162,7 @@ const CGHeroInstance * CStack::getMyHero() const std::string CStack::nodeName() const { std::ostringstream oss; - oss << owner.getStr(); + oss << owner.toString(); oss << " battle stack [" << ID << "]: " << getCount() << " of "; if(type) oss << type->getNamePluralTextID(); diff --git a/lib/StartInfo.cpp b/lib/StartInfo.cpp index 5625807ff..fd1bd8dcd 100644 --- a/lib/StartInfo.cpp +++ b/lib/StartInfo.cpp @@ -41,7 +41,7 @@ PlayerSettings & StartInfo::getIthPlayersSettings(const PlayerColor & no) { if(playerInfos.find(no) != playerInfos.end()) return playerInfos[no]; - logGlobal->error("Cannot find info about player %s. Throwing...", no.getStr()); + logGlobal->error("Cannot find info about player %s. Throwing...", no.toString()); throw std::runtime_error("Cannot find info about player"); } const PlayerSettings & StartInfo::getIthPlayersSettings(const PlayerColor & no) const diff --git a/lib/battle/BattleInfo.cpp b/lib/battle/BattleInfo.cpp index d5a714dcb..52c1b274e 100644 --- a/lib/battle/BattleInfo.cpp +++ b/lib/battle/BattleInfo.cpp @@ -532,7 +532,7 @@ const CGHeroInstance * BattleInfo::getHero(const PlayerColor & player) const if(side.color == player) return side.hero; - logGlobal->error("Player %s is not in battle!", player.getStr()); + logGlobal->error("Player %s is not in battle!", player.toString()); return nullptr; } @@ -542,7 +542,7 @@ ui8 BattleInfo::whatSide(const PlayerColor & player) const if(sides[i].color == player) return i; - logGlobal->warn("BattleInfo::whatSide: Player %s is not in battle!", player.getStr()); + logGlobal->warn("BattleInfo::whatSide: Player %s is not in battle!", player.toString()); return -1; } diff --git a/lib/battle/CBattleInfoEssentials.cpp b/lib/battle/CBattleInfoEssentials.cpp index df60ba5f5..130d6ad20 100644 --- a/lib/battle/CBattleInfoEssentials.cpp +++ b/lib/battle/CBattleInfoEssentials.cpp @@ -164,7 +164,7 @@ BattlePerspective::BattlePerspective CBattleInfoEssentials::battleGetMySide() co if(*player == getBattle()->getSidePlayer(BattleSide::DEFENDER)) return BattlePerspective::RIGHT_SIDE; - logGlobal->error("Cannot find player %s in battle!", player->getStr()); + logGlobal->error("Cannot find player %s in battle!", player->toString()); return BattlePerspective::INVALID; } @@ -296,7 +296,7 @@ BattleSideOpt CBattleInfoEssentials::playerToSide(const PlayerColor & player) co if(getBattle()->getSidePlayer(BattleSide::DEFENDER) == player) return BattleSideOpt(BattleSide::DEFENDER); - logGlobal->warn("Cannot find side for player %s", player.getStr()); + logGlobal->warn("Cannot find side for player %s", player.toString()); return std::nullopt; } diff --git a/lib/constants/EntityIdentifiers.cpp b/lib/constants/EntityIdentifiers.cpp index bc0e92843..bb1eaa497 100644 --- a/lib/constants/EntityIdentifiers.cpp +++ b/lib/constants/EntityIdentifiers.cpp @@ -199,36 +199,15 @@ bool PlayerColor::isValidPlayer() const bool PlayerColor::isSpectator() const { - return num == SPECTATOR.num; -} - -std::string PlayerColor::getStr(bool L10n) const -{ - std::string ret = "unnamed"; - if(isValidPlayer()) - { - if(L10n) - ret = VLC->generaltexth->colors[num]; - else - ret = GameConstants::PLAYER_COLOR_NAMES[num]; - } - else if(L10n) - { - ret = VLC->generaltexth->allTexts[508]; - ret[0] = std::tolower(ret[0]); - } - - return ret; -} - -std::string PlayerColor::getStrCap(bool L10n) const -{ - std::string ret = getStr(L10n); - ret[0] = std::toupper(ret[0]); - return ret; -} - -si32 PlayerColor::decode(const std::string & identifier) + return num == SPECTATOR.num; +} + +std::string PlayerColor::toString() const +{ + return encode(num); +} + +si32 PlayerColor::decode(const std::string & identifier) { return vstd::find_pos(GameConstants::PLAYER_COLOR_NAMES, identifier); } diff --git a/lib/constants/EntityIdentifiers.h b/lib/constants/EntityIdentifiers.h index 1cdb4300f..6f242c564 100644 --- a/lib/constants/EntityIdentifiers.h +++ b/lib/constants/EntityIdentifiers.h @@ -236,17 +236,16 @@ public: static const PlayerColor NEUTRAL; //255 static const PlayerColor PLAYER_LIMIT; //player limit per map - bool isValidPlayer() const; //valid means < PLAYER_LIMIT (especially non-neutral) - bool isSpectator() const; - - std::string getStr(bool L10n = false) const; - std::string getStrCap(bool L10n = false) const; - - static si32 decode(const std::string& identifier); - static std::string encode(const si32 index); -}; - -class TeamID : public Identifier + bool isValidPlayer() const; //valid means < PLAYER_LIMIT (especially non-neutral) + bool isSpectator() const; + + std::string toString() const; + + static si32 decode(const std::string& identifier); + static std::string encode(const si32 index); +}; + +class TeamID : public Identifier { public: using Identifier::Identifier; diff --git a/lib/gameState/CGameState.cpp b/lib/gameState/CGameState.cpp index c81342752..f182570ca 100644 --- a/lib/gameState/CGameState.cpp +++ b/lib/gameState/CGameState.cpp @@ -136,7 +136,7 @@ HeroTypeID CGameState::pickUnusedHeroTypeRandomly(const PlayerColor & owner) return *RandomGeneratorUtil::nextItem(factionHeroes, getRandomGenerator()); } - logGlobal->warn("Cannot find free hero of appropriate faction for player %s - trying to get first available...", owner.getStr()); + logGlobal->warn("Cannot find free hero of appropriate faction for player %s - trying to get first available...", owner.toString()); if(!otherHeroes.empty()) { return *RandomGeneratorUtil::nextItem(otherHeroes, getRandomGenerator()); diff --git a/lib/mapping/MapFormatH3M.cpp b/lib/mapping/MapFormatH3M.cpp index 2c3862745..cbed7f3e7 100644 --- a/lib/mapping/MapFormatH3M.cpp +++ b/lib/mapping/MapFormatH3M.cpp @@ -1297,12 +1297,12 @@ CGObjectInstance * CMapLoaderH3M::readHeroPlaceholder(const int3 & mapPosition) if(htid.getNum() == -1) { object->powerRank = reader->readUInt8(); - logGlobal->debug("Map '%s': Hero placeholder: by power at %s, owned by %s", mapName, mapPosition.toString(), object->getOwner().getStr()); + logGlobal->debug("Map '%s': Hero placeholder: by power at %s, owned by %s", mapName, mapPosition.toString(), object->getOwner().toString()); } else { object->heroType = htid; - logGlobal->debug("Map '%s': Hero placeholder: %s at %s, owned by %s", mapName, VLC->heroh->getById(htid)->getJsonKey(), mapPosition.toString(), object->getOwner().getStr()); + logGlobal->debug("Map '%s': Hero placeholder: %s at %s, owned by %s", mapName, VLC->heroh->getById(htid)->getJsonKey(), mapPosition.toString(), object->getOwner().toString()); } return object; @@ -1774,9 +1774,9 @@ CGObjectInstance * CMapLoaderH3M::readHero(const int3 & mapPosition, const Objec } if (object->subID != -1) - logGlobal->debug("Map '%s': Hero on map: %s at %s, owned by %s", mapName, VLC->heroh->getByIndex(object->subID)->getJsonKey(), mapPosition.toString(), object->getOwner().getStr()); + logGlobal->debug("Map '%s': Hero on map: %s at %s, owned by %s", mapName, VLC->heroh->getByIndex(object->subID)->getJsonKey(), mapPosition.toString(), object->getOwner().toString()); else - logGlobal->debug("Map '%s': Hero on map: (random) at %s, owned by %s", mapName, mapPosition.toString(), object->getOwner().getStr()); + logGlobal->debug("Map '%s': Hero on map: (random) at %s, owned by %s", mapName, mapPosition.toString(), object->getOwner().toString()); reader->skipZero(16); return object; diff --git a/mapeditor/graphics.cpp b/mapeditor/graphics.cpp index ce797921c..ee4fa8ade 100644 --- a/mapeditor/graphics.cpp +++ b/mapeditor/graphics.cpp @@ -238,7 +238,7 @@ void Graphics::blueToPlayersAdv(QImage * sur, PlayerColor player) } else { - logGlobal->error("Wrong player id in blueToPlayersAdv (%s)!", player.getStr()); + logGlobal->error("Wrong player id in blueToPlayersAdv (%s)!", player.toString()); return; } //FIXME: not all player colored images have player palette at last 32 indexes diff --git a/mapeditor/validator.cpp b/mapeditor/validator.cpp index 4b70ddc84..ab84a05d6 100644 --- a/mapeditor/validator.cpp +++ b/mapeditor/validator.cpp @@ -97,14 +97,14 @@ std::list Validator::validate(const CMap * map) if(o->getOwner() != PlayerColor::NEUTRAL && o->getOwner().getNum() < map->players.size()) { if(!map->players[o->getOwner().getNum()].canAnyonePlay()) - issues.emplace_back(QString(tr("Object %1 is assigned to non-playable player %2")).arg(o->instanceName.c_str(), o->getOwner().getStr().c_str()), true); + issues.emplace_back(QString(tr("Object %1 is assigned to non-playable player %2")).arg(o->instanceName.c_str(), o->getOwner().toString().c_str()), true); } //checking towns if(auto * ins = dynamic_cast(o.get())) { bool has = amountOfCastles.count(ins->getOwner().getNum()); if(!has && ins->getOwner() != PlayerColor::NEUTRAL) - issues.emplace_back(tr("Town %1 has undefined owner %2").arg(ins->instanceName.c_str(), ins->getOwner().getStr().c_str()), true); + issues.emplace_back(tr("Town %1 has undefined owner %2").arg(ins->instanceName.c_str(), ins->getOwner().toString().c_str()), true); if(has) ++amountOfCastles[ins->getOwner().getNum()]; } diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index d6f700b6e..2d162a52c 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -1072,7 +1072,7 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, boo return false; } - logGlobal->trace("Player %d (%s) wants to move hero %d from %s to %s", asker, asker.getStr(), hid.getNum(), h->pos.toString(), dst.toString()); + logGlobal->trace("Player %d (%s) wants to move hero %d from %s to %s", asker, asker.toString(), hid.getNum(), h->pos.toString(), dst.toString()); const int3 hmpos = h->convertToVisitablePos(dst); if (!gs->map->isInTheMap(hmpos)) @@ -3991,7 +3991,7 @@ bool CGameHandler::isBlockedByQueries(const CPack *pack, PlayerColor player) { complain(boost::str(boost::format( "\r\n| Player \"%s\" has to answer queries before attempting any further actions.\r\n| Top Query: \"%s\"\r\n") - % boost::to_upper_copy(player.getStr()) + % boost::to_upper_copy(player.toString()) % query->toString() )); return true; diff --git a/server/processors/HeroPoolProcessor.cpp b/server/processors/HeroPoolProcessor.cpp index b9c9ae227..2e129098f 100644 --- a/server/processors/HeroPoolProcessor.cpp +++ b/server/processors/HeroPoolProcessor.cpp @@ -272,7 +272,7 @@ const CHeroClass * HeroPoolProcessor::pickClassFor(bool isNative, const PlayerCo { if(!player.isValidPlayer()) { - logGlobal->error("Cannot pick hero for player %d. Wrong owner!", player.getStr()); + logGlobal->error("Cannot pick hero for player %d. Wrong owner!", player.toString()); return nullptr; } @@ -285,7 +285,7 @@ const CHeroClass * HeroPoolProcessor::pickClassFor(bool isNative, const PlayerCo if(potentialClasses.empty()) { - logGlobal->error("There are no heroes available for player %s!", player.getStr()); + logGlobal->error("There are no heroes available for player %s!", player.toString()); return nullptr; } @@ -306,7 +306,7 @@ const CHeroClass * HeroPoolProcessor::pickClassFor(bool isNative, const PlayerCo if (possibleClasses.empty()) { - logGlobal->error("Cannot pick native hero for %s. Picking any...", player.getStr()); + logGlobal->error("Cannot pick native hero for %s. Picking any...", player.toString()); possibleClasses = potentialClasses; } diff --git a/server/processors/PlayerMessageProcessor.cpp b/server/processors/PlayerMessageProcessor.cpp index 26c94c835..6f5358c9c 100644 --- a/server/processors/PlayerMessageProcessor.cpp +++ b/server/processors/PlayerMessageProcessor.cpp @@ -92,7 +92,7 @@ bool PlayerMessageProcessor::handleHostCommand(PlayerColor player, const std::st { for(auto & c : gameHandler->connections) { - if(c.first.getStr(false) == playername) + if(c.first.toString() == playername) playerToKick = c.first; } } @@ -113,7 +113,7 @@ bool PlayerMessageProcessor::handleHostCommand(PlayerColor player, const std::st broadcastSystemMessage("No cheaters registered!"); for (auto const & entry : cheaters) - broadcastSystemMessage("Player " + entry.getStr() + " is cheater!"); + broadcastSystemMessage("Player " + entry.toString() + " is cheater!"); return true; } @@ -406,7 +406,7 @@ bool PlayerMessageProcessor::handleCheatCode(const std::string & cheat, PlayerCo if (words.front() == "ai" && i.second.human) continue; - if (words.front() != "all" && words.front() != i.first.getStr()) + if (words.front() != "all" && words.front() != i.first.toString()) continue; std::vector parameters = words; diff --git a/server/queries/CQuery.cpp b/server/queries/CQuery.cpp index b8c1e072c..cc0025055 100644 --- a/server/queries/CQuery.cpp +++ b/server/queries/CQuery.cpp @@ -75,7 +75,7 @@ std::string CQuery::toString() const for(size_t i = 0; i < size; i++) { - names += boost::to_upper_copy(players[i].getStr()); + names += boost::to_upper_copy(players[i].toString()); if(i < size - 2) names += ", ";