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

Commit ee3c481

Browse files
committed
console/cmd/heal: move to libtrx
1 parent ad5a115 commit ee3c481

File tree

9 files changed

+31
-57
lines changed

9 files changed

+31
-57
lines changed

meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ dll_sources = [
118118
'src/game/lara/lara_look.c',
119119
'src/game/lara/lara_misc.c',
120120
'src/game/lara/lara_state.c',
121+
'src/game/lara/misc.c',
121122
'src/game/level.c',
122123
'src/game/los.c',
123124
'src/game/lot.c',

src/game/console_cmd.c

Lines changed: 2 additions & 25 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/config.h>
22+
#include <libtrx/game/console/commands/heal.h>
2223
#include <libtrx/game/console/commands/pos.h>
2324
#include <libtrx/game/console/commands/set_health.h>
2425
#include <libtrx/game/console/common.h>
@@ -33,7 +34,6 @@ static bool Console_Cmd_CanTargetObjectCreature(GAME_OBJECT_ID object_id);
3334
static bool Console_Cmd_CanTargetObjectPickup(GAME_OBJECT_ID object_id);
3435
static bool Console_Cmd_IsFloatRound(float num);
3536
static COMMAND_RESULT Console_Cmd_Teleport(const char *args);
36-
static COMMAND_RESULT Console_Cmd_Heal(const char *args);
3737
static COMMAND_RESULT Console_Cmd_Fly(const char *const args);
3838
static COMMAND_RESULT Console_Cmd_FlipMap(const char *args);
3939
static COMMAND_RESULT Console_Cmd_GiveItem(const char *args);
@@ -200,29 +200,6 @@ static COMMAND_RESULT Console_Cmd_Teleport(const char *const args)
200200
return CR_BAD_INVOCATION;
201201
}
202202

203-
static COMMAND_RESULT Console_Cmd_Heal(const char *const args)
204-
{
205-
if (g_GameInfo.current_level.type == GFL_TITLE
206-
|| g_GameInfo.current_level.type == GFL_DEMO
207-
|| g_GameInfo.current_level.type == GFL_CUTSCENE) {
208-
return CR_UNAVAILABLE;
209-
}
210-
211-
if (!g_Objects[O_LARA].loaded) {
212-
return CR_UNAVAILABLE;
213-
}
214-
215-
if (g_LaraItem->hit_points == LARA_MAX_HITPOINTS) {
216-
Console_Log(GS(OSD_HEAL_ALREADY_FULL_HP));
217-
return CR_SUCCESS;
218-
}
219-
220-
g_LaraItem->hit_points = LARA_MAX_HITPOINTS;
221-
Lara_Extinguish();
222-
Console_Log(GS(OSD_HEAL_SUCCESS));
223-
return CR_SUCCESS;
224-
}
225-
226203
static COMMAND_RESULT Console_Cmd_Fly(const char *const args)
227204
{
228205
if (g_GameInfo.current_level.type == GFL_TITLE
@@ -562,7 +539,6 @@ static COMMAND_RESULT Console_Cmd_Abortion(const char *const args)
562539

563540
CONSOLE_COMMAND *g_ConsoleCommands[] = {
564541
&(CONSOLE_COMMAND) { .prefix = "tp", .proc = Console_Cmd_Teleport },
565-
&(CONSOLE_COMMAND) { .prefix = "heal", .proc = Console_Cmd_Heal },
566542
&(CONSOLE_COMMAND) { .prefix = "fly", .proc = Console_Cmd_Fly },
567543
&(CONSOLE_COMMAND) { .prefix = "give", .proc = Console_Cmd_GiveItem },
568544
&(CONSOLE_COMMAND) { .prefix = "gimme", .proc = Console_Cmd_GiveItem },
@@ -582,6 +558,7 @@ CONSOLE_COMMAND *g_ConsoleCommands[] = {
582558
.proc = Console_Cmd_Abortion },
583559
&g_Console_Cmd_Config,
584560
&g_Console_Cmd_Pos,
561+
&g_Console_Cmd_Heal,
585562
&g_Console_Cmd_SetHealth,
586563
NULL,
587564
};

src/game/game_string.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,3 @@ GS_DEFINE(OSD_SAVE_GAME, "Saved game to save slot %d")
3838
GS_DEFINE(OSD_SAVE_GAME_FAIL, "Cannot save the game in the current state")
3939
GS_DEFINE(OSD_CURRENT_HEALTH_GET, "Current Lara's health: %d")
4040
GS_DEFINE(OSD_CURRENT_HEALTH_SET, "Lara's health set to %d")
41-
GS_DEFINE(OSD_HEAL_ALREADY_FULL_HP, "Lara's already at full health")
42-
GS_DEFINE(OSD_HEAL_SUCCESS, "Healed Lara back to full health")

src/game/lara/common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#include "game/lara/common.h"
2-
31
#include "global/vars.h"
42

3+
#include <libtrx/game/lara/common.h>
4+
55
ITEM_INFO *Lara_GetItem(void)
66
{
77
return g_LaraItem;

src/game/lara/common.h

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/game/lara/lara_misc.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,27 +1802,6 @@ void __cdecl Lara_WaterCurrent(COLL_INFO *const coll)
18021802
coll->old = item->pos;
18031803
}
18041804

1805-
void __cdecl Lara_Extinguish(void)
1806-
{
1807-
if (!g_Lara.burn) {
1808-
return;
1809-
}
1810-
1811-
g_Lara.burn = 0;
1812-
1813-
// put out flame objects
1814-
int16_t fx_num = g_NextEffectActive;
1815-
while (fx_num != NO_ITEM) {
1816-
FX_INFO *const fx = &g_Effects[fx_num];
1817-
const int16_t next_fx_num = fx->next_active;
1818-
if (fx->object_id == O_FLAME && fx->counter < 0) {
1819-
fx->counter = 0;
1820-
Effect_Kill(fx_num);
1821-
}
1822-
fx_num = next_fx_num;
1823-
}
1824-
}
1825-
18261805
void __cdecl Lara_CatchFire(void)
18271806
{
18281807
if (g_Lara.burn || g_Lara.water_status == LWS_CHEAT) {

src/game/lara/lara_misc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ void __cdecl Lara_SwimCollision(ITEM_INFO *item, COLL_INFO *coll);
8181

8282
void __cdecl Lara_WaterCurrent(COLL_INFO *coll);
8383

84-
void __cdecl Lara_Extinguish(void);
8584
void __cdecl Lara_CatchFire(void);
8685

8786
void __cdecl Lara_TouchLava(ITEM_INFO *item);

src/game/lara/misc.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include "game/effects.h"
2+
#include "global/vars.h"
3+
4+
#include <libtrx/game/lara/misc.h>
5+
6+
void __cdecl Lara_Extinguish(void)
7+
{
8+
if (!g_Lara.burn) {
9+
return;
10+
}
11+
12+
g_Lara.burn = 0;
13+
14+
// put out flame objects
15+
int16_t fx_num = g_NextEffectActive;
16+
while (fx_num != NO_ITEM) {
17+
FX_INFO *const fx = &g_Effects[fx_num];
18+
const int16_t next_fx_num = fx->next_active;
19+
if (fx->object_id == O_FLAME && fx->counter < 0) {
20+
fx->counter = 0;
21+
Effect_Kill(fx_num);
22+
}
23+
fx_num = next_fx_num;
24+
}
25+
}

0 commit comments

Comments
 (0)