From 603f95ce533619391cd7eb70278aa08ec2c4364d Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Wed, 4 Sep 2024 13:38:13 +0200 Subject: [PATCH] console: fix commands being too available Resolves #1489. --- CHANGELOG.md | 1 + src/game/console_cmd.c | 52 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 258e1e837..dc550cea9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## [Unreleased](https://github.com/LostArtefacts/TR1X/compare/stable...develop) - ××××-××-×× - added `/exit` command (#1462) - fixed `/play`, `/load`, `/demo` and similar commands not working in stats, credits, cinematics and fmvs (#1477) +- fixed console commands being able to interfere with demos, cutscenes and the title screen (#1489, regression from 3.0) - fixed reopening the compass not resetting its needle (#1472, regression from 4.0) - fixed holstering pistols hiding the gun meshes 1 frame too early (#1449, regression from 0.6) - fixed Lara's sliding animation sometimes being interrupted by a stumble (#1452, regression from 4.3) diff --git a/src/game/console_cmd.c b/src/game/console_cmd.c index 8f993cd13..3f2ad383e 100644 --- a/src/game/console_cmd.c +++ b/src/game/console_cmd.c @@ -106,6 +106,12 @@ static COMMAND_RESULT Console_Cmd_Pos(const char *const args) static COMMAND_RESULT Console_Cmd_Teleport(const char *const args) { + if (g_GameInfo.current_level_type == GFL_TITLE + || g_GameInfo.current_level_type == GFL_DEMO + || g_GameInfo.current_level_type == GFL_CUTSCENE) { + return CR_UNAVAILABLE; + } + if (!g_Objects[O_LARA].loaded || !g_LaraItem->hit_points) { return CR_UNAVAILABLE; } @@ -224,6 +230,12 @@ static COMMAND_RESULT Console_Cmd_Teleport(const char *const args) static COMMAND_RESULT Console_Cmd_SetHealth(const char *const args) { + if (g_GameInfo.current_level_type == GFL_TITLE + || g_GameInfo.current_level_type == GFL_DEMO + || g_GameInfo.current_level_type == GFL_CUTSCENE) { + return CR_UNAVAILABLE; + } + if (!g_Objects[O_LARA].loaded) { return CR_UNAVAILABLE; } @@ -245,6 +257,12 @@ static COMMAND_RESULT Console_Cmd_SetHealth(const char *const args) static COMMAND_RESULT Console_Cmd_Heal(const char *const args) { + if (g_GameInfo.current_level_type == GFL_TITLE + || g_GameInfo.current_level_type == GFL_DEMO + || g_GameInfo.current_level_type == GFL_CUTSCENE) { + return CR_UNAVAILABLE; + } + if (!g_Objects[O_LARA].loaded) { return CR_UNAVAILABLE; } @@ -261,6 +279,12 @@ static COMMAND_RESULT Console_Cmd_Heal(const char *const args) static COMMAND_RESULT Console_Cmd_Fly(const char *const args) { + if (g_GameInfo.current_level_type == GFL_TITLE + || g_GameInfo.current_level_type == GFL_DEMO + || g_GameInfo.current_level_type == GFL_CUTSCENE) { + return CR_UNAVAILABLE; + } + if (!g_Objects[O_LARA].loaded) { return CR_UNAVAILABLE; } @@ -493,9 +517,14 @@ static COMMAND_RESULT Console_Cmd_Cheats(const char *const args) static COMMAND_RESULT Console_Cmd_GiveItem(const char *args) { + if (g_GameInfo.current_level_type == GFL_TITLE + || g_GameInfo.current_level_type == GFL_DEMO + || g_GameInfo.current_level_type == GFL_CUTSCENE) { + return CR_UNAVAILABLE; + } + if (g_LaraItem == NULL) { - Console_Log(GS(OSD_INVALID_LEVEL), args); - return CR_SUCCESS; + return CR_UNAVAILABLE; } if (String_Equivalent(args, "keys")) { @@ -549,6 +578,12 @@ static COMMAND_RESULT Console_Cmd_GiveItem(const char *args) static COMMAND_RESULT Console_Cmd_FlipMap(const char *args) { + if (g_GameInfo.current_level_type == GFL_TITLE + || g_GameInfo.current_level_type == GFL_DEMO + || g_GameInfo.current_level_type == GFL_CUTSCENE) { + return CR_UNAVAILABLE; + } + bool new_state; if (String_Equivalent(args, "")) { new_state = !g_FlipStatus; @@ -570,6 +605,12 @@ static COMMAND_RESULT Console_Cmd_FlipMap(const char *args) static COMMAND_RESULT Console_Cmd_Kill(const char *args) { + if (g_GameInfo.current_level_type == GFL_TITLE + || g_GameInfo.current_level_type == GFL_DEMO + || g_GameInfo.current_level_type == GFL_CUTSCENE) { + return CR_UNAVAILABLE; + } + // kill all the enemies in the level if (String_Equivalent(args, "all")) { int32_t num = 0; @@ -700,6 +741,12 @@ static COMMAND_RESULT Console_Cmd_LoadGame(const char *args) static COMMAND_RESULT Console_Cmd_SaveGame(const char *args) { + if (g_GameInfo.current_level_type == GFL_TITLE + || g_GameInfo.current_level_type == GFL_DEMO + || g_GameInfo.current_level_type == GFL_CUTSCENE) { + return CR_UNAVAILABLE; + } + int32_t slot_num; if (!String_ParseInteger(args, &slot_num)) { return CR_BAD_INVOCATION; @@ -712,7 +759,6 @@ static COMMAND_RESULT Console_Cmd_SaveGame(const char *args) } if (g_LaraItem == NULL) { - Console_Log(GS(OSD_SAVE_GAME_FAIL), slot_num); return CR_UNAVAILABLE; }