Skip to content

Commit

Permalink
console-cmd: fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Sep 2, 2024
1 parent eb44445 commit 0fe41c3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion data/ship/cfg/TR1X_gameflow.json5
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@
"OSD_LOAD_GAME": "Loaded game from save slot %d",
"OSD_LOAD_GAME_FAIL_UNAVAILABLE_SLOT": "Save slot %d is not available",
"OSD_LOAD_GAME_FAIL_INVALID_SLOT": "Invalid save slot %d",
"OSD_SAVE_GAME": "Save game to save slot %d",
"OSD_SAVE_GAME": "Saved game to save slot %d",
"OSD_SAVE_GAME_FAIL": "Cannot save the game in the current state",
"OSD_SAVE_GAME_FAIL_INVALID_SLOT": "Invalid save slot %d",
"OSD_CURRENT_HEALTH_GET": "Current Lara's health: %d",
Expand Down
2 changes: 1 addition & 1 deletion data/ship/cfg/TR1X_gameflow_demo_pc.json5
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@
"OSD_LOAD_GAME": "Loaded game from save slot %d",
"OSD_LOAD_GAME_FAIL_UNAVAILABLE_SLOT": "Save slot %d is not available",
"OSD_LOAD_GAME_FAIL_INVALID_SLOT": "Invalid save slot %d",
"OSD_SAVE_GAME": "Save game to save slot %d",
"OSD_SAVE_GAME": "Saved game to save slot %d",
"OSD_SAVE_GAME_FAIL": "Cannot save the game in the current state",
"OSD_SAVE_GAME_FAIL_INVALID_SLOT": "Invalid save slot %d",
"OSD_CURRENT_HEALTH_GET": "Current Lara's health: %d",
Expand Down
2 changes: 1 addition & 1 deletion data/ship/cfg/TR1X_gameflow_ub.json5
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@
"OSD_LOAD_GAME": "Loaded game from save slot %d",
"OSD_LOAD_GAME_FAIL_UNAVAILABLE_SLOT": "Save slot %d is not available",
"OSD_LOAD_GAME_FAIL_INVALID_SLOT": "Invalid save slot %d",
"OSD_SAVE_GAME": "Save game to save slot %d",
"OSD_SAVE_GAME": "Saved game to save slot %d",
"OSD_SAVE_GAME_FAIL": "Cannot save the game in the current state",
"OSD_SAVE_GAME_FAIL_INVALID_SLOT": "Invalid save slot %d",
"OSD_CURRENT_HEALTH_GET": "Current Lara's health: %d",
Expand Down
15 changes: 8 additions & 7 deletions src/game/console_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -670,14 +670,15 @@ static COMMAND_RESULT Console_Cmd_ExitGame(const char *args)

static COMMAND_RESULT Console_Cmd_LoadGame(const char *args)
{
int32_t slot_num = -1;
if (sscanf(args, "%d", &slot_num) != 1) {
int32_t slot_num;
if (!String_ParseInteger(args, &slot_num)) {
return CR_BAD_INVOCATION;
}

const int32_t slot_idx = slot_num - 1; // convert 1-indexing to 0-indexing

if (slot_idx < 0 || slot_idx >= g_Config.maximum_save_slots) {
Console_Log(GS(OSD_LOAD_GAME_FAIL_INVALID_SLOT));
Console_Log(GS(OSD_LOAD_GAME_FAIL_INVALID_SLOT), slot_num);
return CR_FAILURE;
}

Expand All @@ -696,14 +697,14 @@ static COMMAND_RESULT Console_Cmd_LoadGame(const char *args)

static COMMAND_RESULT Console_Cmd_SaveGame(const char *args)
{
int32_t slot_num = -1;
if (sscanf(args, "%d", &slot_num) != 1) {
int32_t slot_num;
if (!String_ParseInteger(args, &slot_num)) {
return CR_BAD_INVOCATION;
}
const int32_t slot_idx = slot_num - 1; // convert 1-indexing to 0-indexing

if (slot_idx < 0 || slot_idx >= g_Config.maximum_save_slots) {
Console_Log(GS(OSD_SAVE_GAME_FAIL_INVALID_SLOT));
Console_Log(GS(OSD_SAVE_GAME_FAIL_INVALID_SLOT), slot_num);
return CR_BAD_INVOCATION;
}

Expand Down Expand Up @@ -800,8 +801,8 @@ CONSOLE_COMMAND g_ConsoleCommands[] = {
{ .prefix = "wireframe", .proc = Console_Cmd_Wireframe },
{ .prefix = "cheats", .proc = Console_Cmd_Cheats },
{ .prefix = "give", .proc = Console_Cmd_GiveItem },
{ .prefix = "set", .proc = Console_Cmd_Set },
{ .prefix = "gimme", .proc = Console_Cmd_GiveItem },
{ .prefix = "set", .proc = Console_Cmd_Set },
{ .prefix = "flip", .proc = Console_Cmd_FlipMap },
{ .prefix = "flipmap", .proc = Console_Cmd_FlipMap },
{ .prefix = "kill", .proc = Console_Cmd_Kill },
Expand Down
2 changes: 1 addition & 1 deletion src/game/game_string.def
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ GS_DEFINE(OSD_DOOR_OPEN_FAIL, "No doors in Lara's proximity")
GS_DEFINE(OSD_LOAD_GAME, "Loaded game from save slot %d")
GS_DEFINE(OSD_LOAD_GAME_FAIL_UNAVAILABLE_SLOT, "Save slot %d is not available")
GS_DEFINE(OSD_LOAD_GAME_FAIL_INVALID_SLOT, "Invalid save slot %d")
GS_DEFINE(OSD_SAVE_GAME, "Save game to save slot %d")
GS_DEFINE(OSD_SAVE_GAME, "Saved game to save slot %d")
GS_DEFINE(OSD_SAVE_GAME_FAIL, "Cannot save the game in the current state")
GS_DEFINE(OSD_SAVE_GAME_FAIL_INVALID_SLOT, "Invalid save slot %d")
GS_DEFINE(OSD_CURRENT_HEALTH_GET, "Current Lara's health: %d")
Expand Down

0 comments on commit 0fe41c3

Please sign in to comment.