mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Store cheater state per player
This commit is contained in:
parent
baa865d857
commit
fcb13771f3
@ -105,6 +105,16 @@ bool PlayerMessageProcessor::handleHostCommand(PlayerColor player, const std::st
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if(words.size() == 2 && words[1] == "cheaters")
|
||||
{
|
||||
if (cheaters.empty())
|
||||
broadcastSystemMessage("No cheaters registered!");
|
||||
|
||||
for (auto const & entry : cheaters)
|
||||
broadcastSystemMessage("Player " + entry.getStr() + " is cheater!");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -384,6 +394,7 @@ bool PlayerMessageProcessor::handleCheatCode(const std::string & cheat, PlayerCo
|
||||
|
||||
std::vector<std::string> parameters = words;
|
||||
|
||||
cheaters.insert(i.first);
|
||||
playerTargetedCheat = true;
|
||||
parameters.erase(parameters.begin());
|
||||
|
||||
@ -402,6 +413,7 @@ bool PlayerMessageProcessor::handleCheatCode(const std::string & cheat, PlayerCo
|
||||
if (!playerTargetedCheat)
|
||||
executeCheatCode(cheatName, player, currObj, words);
|
||||
|
||||
cheaters.insert(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -9,9 +9,9 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "../lib/GameConstants.h"
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
class PlayerColor;
|
||||
class ObjectInstanceID;
|
||||
class CGHeroInstance;
|
||||
class CGTownInstance;
|
||||
class CConnection;
|
||||
@ -21,6 +21,8 @@ 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);
|
||||
@ -58,6 +60,6 @@ public:
|
||||
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
|
||||
h & cheaters;
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user