Skip to content
This repository was archived by the owner on Oct 4, 2024. It is now read-only.

Commit 86bf636

Browse files
committed
console/cmd: move /hp to libtrx
1 parent 37bd71c commit 86bf636

File tree

4 files changed

+20
-30
lines changed

4 files changed

+20
-30
lines changed

src/game/console_cmd.c

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "lara/lara_misc.h"
2020

2121
#include <libtrx/game/console/commands/pos.h>
22+
#include <libtrx/game/console/commands/set_health.h>
2223
#include <libtrx/game/console/common.h>
2324
#include <libtrx/memory.h>
2425
#include <libtrx/strings.h>
@@ -31,7 +32,6 @@ static bool Console_Cmd_CanTargetObjectCreature(GAME_OBJECT_ID object_id);
3132
static bool Console_Cmd_CanTargetObjectPickup(GAME_OBJECT_ID object_id);
3233
static bool Console_Cmd_IsFloatRound(float num);
3334
static COMMAND_RESULT Console_Cmd_Teleport(const char *args);
34-
static COMMAND_RESULT Console_Cmd_SetHealth(const char *args);
3535
static COMMAND_RESULT Console_Cmd_Heal(const char *args);
3636
static COMMAND_RESULT Console_Cmd_Fly(const char *const args);
3737
static COMMAND_RESULT Console_Cmd_FlipMap(const char *args);
@@ -199,33 +199,6 @@ static COMMAND_RESULT Console_Cmd_Teleport(const char *const args)
199199
return CR_BAD_INVOCATION;
200200
}
201201

202-
static COMMAND_RESULT Console_Cmd_SetHealth(const char *const args)
203-
{
204-
if (g_GameInfo.current_level.type == GFL_TITLE
205-
|| g_GameInfo.current_level.type == GFL_DEMO
206-
|| g_GameInfo.current_level.type == GFL_CUTSCENE) {
207-
return CR_UNAVAILABLE;
208-
}
209-
210-
if (!g_Objects[O_LARA].loaded) {
211-
return CR_UNAVAILABLE;
212-
}
213-
214-
if (strcmp(args, "") == 0) {
215-
Console_Log(GS(OSD_CURRENT_HEALTH_GET), g_LaraItem->hit_points);
216-
return CR_SUCCESS;
217-
}
218-
219-
int32_t hp;
220-
if (sscanf(args, "%d", &hp) != 1) {
221-
return CR_BAD_INVOCATION;
222-
}
223-
224-
g_LaraItem->hit_points = hp;
225-
Console_Log(GS(OSD_CURRENT_HEALTH_SET), hp);
226-
return CR_SUCCESS;
227-
}
228-
229202
static COMMAND_RESULT Console_Cmd_Heal(const char *const args)
230203
{
231204
if (g_GameInfo.current_level.type == GFL_TITLE
@@ -588,7 +561,6 @@ static COMMAND_RESULT Console_Cmd_Abortion(const char *const args)
588561

589562
CONSOLE_COMMAND *g_ConsoleCommands[] = {
590563
&(CONSOLE_COMMAND) { .prefix = "tp", .proc = Console_Cmd_Teleport },
591-
&(CONSOLE_COMMAND) { .prefix = "hp", .proc = Console_Cmd_SetHealth },
592564
&(CONSOLE_COMMAND) { .prefix = "heal", .proc = Console_Cmd_Heal },
593565
&(CONSOLE_COMMAND) { .prefix = "fly", .proc = Console_Cmd_Fly },
594566
&(CONSOLE_COMMAND) { .prefix = "give", .proc = Console_Cmd_GiveItem },
@@ -608,5 +580,6 @@ CONSOLE_COMMAND *g_ConsoleCommands[] = {
608580
&(CONSOLE_COMMAND) { .prefix = "natlastinks",
609581
.proc = Console_Cmd_Abortion },
610582
&g_Console_Cmd_Pos,
583+
&g_Console_Cmd_SetHealth,
611584
NULL,
612585
};

src/game/game.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "decomp/decomp.h"
44
#include "game/camera.h"
55
#include "game/demo.h"
6+
#include "game/gameflow/gameflow_new.h"
67
#include "game/input.h"
78
#include "game/inventory/common.h"
89
#include "game/lara/lara_control.h"
@@ -296,3 +297,18 @@ int32_t __cdecl Game_Loop(const bool demo_mode)
296297

297298
return dir;
298299
}
300+
301+
bool Game_IsPlayable(void)
302+
{
303+
if (g_GameInfo.current_level.type == GFL_TITLE
304+
|| g_GameInfo.current_level.type == GFL_DEMO
305+
|| g_GameInfo.current_level.type == GFL_CUTSCENE) {
306+
return false;
307+
}
308+
309+
if (!g_Objects[O_LARA].loaded) {
310+
return false;
311+
}
312+
313+
return true;
314+
}

src/game/game.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ int32_t __cdecl Game_Draw(void);
77
int32_t __cdecl Game_DrawCinematic(void);
88
int16_t __cdecl Game_Start(int32_t level_num, GF_LEVEL_TYPE level_type);
99
int32_t __cdecl Game_Loop(bool demo_mode);
10+
bool Game_IsPlayable(void);

subprojects/libtrx

0 commit comments

Comments
 (0)