1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-17 01:32:21 +02:00

Merge pull request #2892 from Laserlicht/highscore_menu

Highscore Menu & end video
This commit is contained in:
Ivan Savenko
2023-09-27 15:48:47 +03:00
committed by GitHub
26 changed files with 728 additions and 39 deletions

View File

@ -109,11 +109,18 @@ bool PlayerMessageProcessor::handleHostCommand(PlayerColor player, const std::st
}
if(words.size() == 2 && words[1] == "cheaters")
{
if (cheaters.empty())
broadcastSystemMessage("No cheaters registered!");
int playersCheated = 0;
for (const auto & player : gameHandler->gameState()->players)
{
if(player.second.cheated)
{
broadcastSystemMessage("Player " + player.first.toString() + " is cheater!");
playersCheated++;
}
}
for (auto const & entry : cheaters)
broadcastSystemMessage("Player " + entry.toString() + " is cheater!");
if (!playersCheated)
broadcastSystemMessage("No cheaters registered!");
return true;
}
@ -411,7 +418,10 @@ bool PlayerMessageProcessor::handleCheatCode(const std::string & cheat, PlayerCo
std::vector<std::string> parameters = words;
cheaters.insert(i.first);
PlayerCheated pc;
pc.player = i.first;
gameHandler->sendAndApply(&pc);
playerTargetedCheat = true;
parameters.erase(parameters.begin());
@ -427,10 +437,13 @@ bool PlayerMessageProcessor::handleCheatCode(const std::string & cheat, PlayerCo
executeCheatCode(cheatName, i.first, h->id, parameters);
}
PlayerCheated pc;
pc.player = player;
gameHandler->sendAndApply(&pc);
if (!playerTargetedCheat)
executeCheatCode(cheatName, player, currObj, words);
cheaters.insert(player);
return true;
}

View File

@ -21,8 +21,6 @@ class CGameHandler;
class PlayerMessageProcessor
{
std::set<PlayerColor> cheaters;
void executeCheatCode(const std::string & cheatName, PlayerColor player, ObjectInstanceID currObj, const std::vector<std::string> & arguments );
bool handleCheatCode(const std::string & cheatFullCommand, PlayerColor player, ObjectInstanceID currObj);
bool handleHostCommand(PlayerColor player, const std::string & message);
@ -60,6 +58,5 @@ public:
template <typename Handler> void serialize(Handler &h, const int version)
{
h & cheaters;
}
};