1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
#include "globalincs/globals.h"
#include "globalincs/pstypes.h"
#include "globalincs/systemvars.h"
#include "io/key.h"
#include "hud/hudmessage.h"
#include "hud/hudsquadmsg.h"
#include "scripting/global_hooks.h"
#include "scripting/hook_api.h"
#include "ship/ship.h"
#include "ship/shipfx.h"
#define CHEAT_BUFFER_LEN 17
class CustomCheat {
public:
SCP_string cheatCode;
SCP_string cheatMsg;
bool requireCheatsEnabled;
CustomCheat(SCP_string cheat_code, SCP_string cheat_msg, bool require_cheats_enabled) :
cheatCode(std::move(cheat_code)),
cheatMsg(std::move(cheat_msg)),
requireCheatsEnabled(require_cheats_enabled) { }
virtual ~CustomCheat() = default;
virtual void runCheat();
bool canUseCheat();
};
class SpawnShipCheat : public CustomCheat {
protected:
SCP_string shipClassName;
SCP_string shipName;
public:
SpawnShipCheat(SCP_string cheat_code, SCP_string cheat_msg, bool require_cheats_enabled, SCP_string class_name, SCP_string ship_name) : CustomCheat(cheat_code, cheat_msg, require_cheats_enabled),
shipClassName(std::move(class_name)),
shipName(std::move(ship_name)) { }
void runCheat() override;
};
static SCP_map<SCP_string, std::unique_ptr<CustomCheat>> customCheats;
void cheat_table_init();
void parse_cheat_table(const char* filename);
bool checkForCustomCheats(const char* converted_buffer, int buffer_length);
|