mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-15 11:46:56 +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;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
@ -384,6 +394,7 @@ bool PlayerMessageProcessor::handleCheatCode(const std::string & cheat, PlayerCo
|
|||||||
|
|
||||||
std::vector<std::string> parameters = words;
|
std::vector<std::string> parameters = words;
|
||||||
|
|
||||||
|
cheaters.insert(i.first);
|
||||||
playerTargetedCheat = true;
|
playerTargetedCheat = true;
|
||||||
parameters.erase(parameters.begin());
|
parameters.erase(parameters.begin());
|
||||||
|
|
||||||
@ -402,6 +413,7 @@ bool PlayerMessageProcessor::handleCheatCode(const std::string & cheat, PlayerCo
|
|||||||
if (!playerTargetedCheat)
|
if (!playerTargetedCheat)
|
||||||
executeCheatCode(cheatName, player, currObj, words);
|
executeCheatCode(cheatName, player, currObj, words);
|
||||||
|
|
||||||
|
cheaters.insert(player);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,9 +9,9 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "../lib/GameConstants.h"
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
class PlayerColor;
|
|
||||||
class ObjectInstanceID;
|
|
||||||
class CGHeroInstance;
|
class CGHeroInstance;
|
||||||
class CGTownInstance;
|
class CGTownInstance;
|
||||||
class CConnection;
|
class CConnection;
|
||||||
@ -21,6 +21,8 @@ class CGameHandler;
|
|||||||
|
|
||||||
class PlayerMessageProcessor
|
class PlayerMessageProcessor
|
||||||
{
|
{
|
||||||
|
std::set<PlayerColor> cheaters;
|
||||||
|
|
||||||
void executeCheatCode(const std::string & cheatName, PlayerColor player, ObjectInstanceID currObj, const std::vector<std::string> & arguments );
|
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 handleCheatCode(const std::string & cheatFullCommand, PlayerColor player, ObjectInstanceID currObj);
|
||||||
bool handleHostCommand(PlayerColor player, const std::string & message);
|
bool handleHostCommand(PlayerColor player, const std::string & message);
|
||||||
@ -58,6 +60,6 @@ public:
|
|||||||
|
|
||||||
template <typename Handler> void serialize(Handler &h, const int version)
|
template <typename Handler> void serialize(Handler &h, const int version)
|
||||||
{
|
{
|
||||||
|
h & cheaters;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user