tr2/commands: add /wireframe and /cheats
Some checks are pending
Run code linters / Run code linters (push) Waiting to run
Publish a pre-release / Build TR1 (push) Has been skipped
Publish a pre-release / Build TR2 (push) Has been skipped
Publish a pre-release / Create a prerelease (push) Has been skipped

Resolves #2500.
This commit is contained in:
Marcin Kurczewski 2025-02-21 12:59:55 +01:00
parent 018c1925ed
commit ed2281d1d7
4 changed files with 51 additions and 6 deletions

View file

@ -1,4 +1,6 @@
## [Unreleased](https://github.com/LostArtefacts/TRX/compare/tr2-0.9.2...develop) - ××××-××-××
- added a `/cheats` console command
- added a `/wireframe` console command (#2500)
- fixed smashed windows blocking enemy pathing after loading a save (#2535)
## [0.9.2](https://github.com/LostArtefacts/TRX/compare/tr2-0.9.1...tr2-0.9.2) - 2025-02-19

View file

@ -16,8 +16,10 @@ Currently supported commands:
- `/heal`
Tough day, Lara? Heals our girl back to full health.
- `/fly`
Turns on the fly cheat. Why even walk?
- `/flip`
`/flip off`
`/flip on`
Switches the global flipmap on or off, turning the reality around you on its head.
- `/give {item_name}`
`/give {num} {item_name}`
@ -31,10 +33,16 @@ Currently supported commands:
`/kill {enemy_type}`
Tired of rats, spiders, tigers, Italian mafia and literally every living thing trying to spoil your adventure? This command instantly disposes of the nearest enemy, or kills them all at once.
- `/flip`
`/flip off`
`/flip on`
Switches the global flipmap on or off, turning the reality around you on its head.
- `/fly`
Turns on the fly cheat. Why even walk?
- `/cheats on`
`/cheats off`
Enables or disables cheat keys. It's not like disabling them will make this console any less of a cheat.
- `/wireframe on`
`/wireframe off`
Enables or disables the wireframe mode. Enter the debugging realm!
- `/endlevel`
Ends the current level. Ideal for speedruns.

View file

@ -0,0 +1,34 @@
#include <libtrx/config.h>
#include <libtrx/game/console/cmd/config.h>
#include <libtrx/game/console/registry.h>
#include <libtrx/strings.h>
typedef struct {
const char *prefix;
void *target;
} COMMAND_TO_OPTION_MAP;
static COMMAND_TO_OPTION_MAP m_CommandToOptionMap[] = {
{ "cheats", &g_Config.gameplay.enable_cheats },
{ "wireframe", &g_Config.rendering.enable_wireframe },
{ nullptr, nullptr },
};
static COMMAND_RESULT M_Entrypoint(const COMMAND_CONTEXT *ctx);
static COMMAND_RESULT M_Entrypoint(const COMMAND_CONTEXT *const ctx)
{
COMMAND_TO_OPTION_MAP *match = m_CommandToOptionMap;
while (match->target != nullptr) {
if (String_Equivalent(match->prefix, ctx->prefix)) {
return Console_Cmd_Config_Helper(
Console_Cmd_Config_GetOptionFromTarget(match->target),
ctx->args);
}
match++;
}
return CR_FAILURE;
}
REGISTER_CONSOLE_COMMAND("cheats|wireframe", M_Entrypoint)

View file

@ -94,6 +94,7 @@ sources = [
'game/camera.c',
'game/clock.c',
'game/collide.c',
'game/console/cmd/easy_config.c',
'game/console/common.c',
'game/creature.c',
'game/cutscene.c',