Skip to content

Commit

Permalink
console: fix commands being too available
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Sep 4, 2024
1 parent 5edeccc commit 603f95c
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
52 changes: 49 additions & 3 deletions src/game/console_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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")) {
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down

0 comments on commit 603f95c

Please sign in to comment.