@@ -20,22 +20,71 @@ class Cheats
2020 Cheats (GameWorldBase& world);
2121 ~Cheats (); // = default - for unique_ptr
2222
23+ /* * In single player games, tracks keyboard events related to cheats.
24+ * Delegates this responsibility to CheatCommandTracker, which triggers the actual cheats.
25+ * In multiplayer games, does nothing. No cheats can be triggered in multiplayer.
26+ *
27+ * @param ke - The keyboard event encountered.
28+ */
2329 void trackKeyEvent (const KeyEvent& ke);
30+
31+ /* * In single player games, tracks chat commands related to cheats.
32+ * Delegates this responsibility to CheatCommandTracker, which triggers the actual cheats.
33+ * In multiplayer games, does nothing. No cheats can be triggered in multiplayer.
34+ *
35+ * @param cmd - The chat command to track.
36+ */
2437 void trackChatCommand (const std::string& cmd);
2538
39+ /* * Toggles cheat mode on and off.
40+ * Cheat mode needs to be on for any cheats to trigger.
41+ */
2642 void toggleCheatMode ();
43+ /* * Used by clients to check if cheat mode is on (e.g. to draw special sprites or enable or all buildings).
44+ * Cheat mode needs to be on for any cheats to trigger.
45+ *
46+ * @return true if cheat mode is on, false otherwise
47+ */
2748 bool isCheatModeOn () const { return isCheatModeOn_; }
2849
2950 // Classic S2 cheats
51+
52+ /* * The classic F7 cheat.
53+ * Does not modify game state, merely tricks clients into revealing the whole map.
54+ * In the background, visibility is tracked as expected, i.e. if you reveal the map, send a scout and unreveal the
55+ * map, you will see what was scouted.
56+ */
3057 void toggleAllVisible ();
3158 bool isAllVisible () const { return isAllVisible_; }
3259
60+ /* * The classic build headquarters cheat.
61+ * This function is used to check if the cheat building can be placed at the chosen point when opening the activity
62+ * window.
63+ *
64+ * @param mp - The map point where the user clicked to open the activity window.
65+ * @return true if the building can be placed, false otherwise
66+ */
3367 bool canPlaceCheatBuilding (const MapPoint& mp) const ;
68+ /* * The classic build headquarters cheat.
69+ * This function is used to place the cheat building at the chosen point.
70+ * The building is immediately fully built, there is no need for a building site.
71+ *
72+ * @param mp - The map point at which to place the building.
73+ * @param player - The player to whom the building should belong.
74+ */
3475 void placeCheatBuilding (const MapPoint& mp, const GamePlayer& player);
3576
77+ /* * The classic ALT+1 through ALT+6 cheat which changes the game speed.
78+ *
79+ * @param speedIndex - 0 is normal, 1 is faster, 2 is even faster, etc.
80+ */
3681 void setGameSpeed (uint8_t speedIndex);
3782
3883 // RTTR cheats
84+
85+ /* * Shares control of the (human) user's country with the AI. Both the user and the AI retain full control of the
86+ * country, so the user can observe what the AI does or "cooperate" with it.
87+ */
3988 void toggleHumanAIPlayer ();
4089
4190 void armageddon ();
@@ -47,14 +96,30 @@ class Cheats
4796 Fish,
4897 Water
4998 };
99+ /* * Tells clients which resources to reveal:
100+ * Nothing - reveal nothing
101+ * Ores - reveal ores
102+ * Fish - reveal ores and fish
103+ * Water - reveal ores, fish and water
104+ */
50105 ResourceRevealMode getResourceRevealMode () const ;
51106 void toggleResourceRevealMode ();
52107
53108 using PlayerIDSet = std::unordered_set<unsigned >;
109+ /* * Destroys all buildings of given players, effectively defeating them.
110+ *
111+ * @param playerIds - Set of IDs of players.
112+ */
54113 void destroyBuildings (const PlayerIDSet& playerIds);
114+ /* * Destroys all buildings of AI players.
115+ */
55116 void destroyAllAIBuildings ();
56117
57118private:
119+ /* * Checks if cheats can be turned on at all.
120+ *
121+ * @return true if if cheats can be turned on, false otherwise
122+ */
58123 bool canCheatModeBeOn () const ;
59124
60125 std::unique_ptr<CheatCommandTracker> cheatCmdTracker_;
0 commit comments