Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tr2/commands: add /wireframe and /cheats #2543

Merged
merged 1 commit into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/tr2/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
20 changes: 14 additions & 6 deletions docs/tr2/COMMANDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
Expand All @@ -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.
Expand Down
34 changes: 34 additions & 0 deletions src/tr2/game/console/cmd/easy_config.c
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions src/tr2/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down