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

Commit

Permalink
console/cmd/heal: move to libtrx
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Sep 19, 2024
1 parent ad5a115 commit ee3c481
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 57 deletions.
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ dll_sources = [
'src/game/lara/lara_look.c',
'src/game/lara/lara_misc.c',
'src/game/lara/lara_state.c',
'src/game/lara/misc.c',
'src/game/level.c',
'src/game/los.c',
'src/game/lot.c',
Expand Down
27 changes: 2 additions & 25 deletions src/game/console_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "lara/lara_misc.h"

#include <libtrx/game/console/commands/config.h>
#include <libtrx/game/console/commands/heal.h>
#include <libtrx/game/console/commands/pos.h>
#include <libtrx/game/console/commands/set_health.h>
#include <libtrx/game/console/common.h>
Expand All @@ -33,7 +34,6 @@ static bool Console_Cmd_CanTargetObjectCreature(GAME_OBJECT_ID object_id);
static bool Console_Cmd_CanTargetObjectPickup(GAME_OBJECT_ID object_id);
static bool Console_Cmd_IsFloatRound(float num);
static COMMAND_RESULT Console_Cmd_Teleport(const char *args);
static COMMAND_RESULT Console_Cmd_Heal(const char *args);
static COMMAND_RESULT Console_Cmd_Fly(const char *const args);
static COMMAND_RESULT Console_Cmd_FlipMap(const char *args);
static COMMAND_RESULT Console_Cmd_GiveItem(const char *args);
Expand Down Expand Up @@ -200,29 +200,6 @@ static COMMAND_RESULT Console_Cmd_Teleport(const char *const args)
return CR_BAD_INVOCATION;
}

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;
}

if (g_LaraItem->hit_points == LARA_MAX_HITPOINTS) {
Console_Log(GS(OSD_HEAL_ALREADY_FULL_HP));
return CR_SUCCESS;
}

g_LaraItem->hit_points = LARA_MAX_HITPOINTS;
Lara_Extinguish();
Console_Log(GS(OSD_HEAL_SUCCESS));
return CR_SUCCESS;
}

static COMMAND_RESULT Console_Cmd_Fly(const char *const args)
{
if (g_GameInfo.current_level.type == GFL_TITLE
Expand Down Expand Up @@ -562,7 +539,6 @@ static COMMAND_RESULT Console_Cmd_Abortion(const char *const args)

CONSOLE_COMMAND *g_ConsoleCommands[] = {
&(CONSOLE_COMMAND) { .prefix = "tp", .proc = Console_Cmd_Teleport },
&(CONSOLE_COMMAND) { .prefix = "heal", .proc = Console_Cmd_Heal },
&(CONSOLE_COMMAND) { .prefix = "fly", .proc = Console_Cmd_Fly },
&(CONSOLE_COMMAND) { .prefix = "give", .proc = Console_Cmd_GiveItem },
&(CONSOLE_COMMAND) { .prefix = "gimme", .proc = Console_Cmd_GiveItem },
Expand All @@ -582,6 +558,7 @@ CONSOLE_COMMAND *g_ConsoleCommands[] = {
.proc = Console_Cmd_Abortion },
&g_Console_Cmd_Config,
&g_Console_Cmd_Pos,
&g_Console_Cmd_Heal,
&g_Console_Cmd_SetHealth,
NULL,
};
2 changes: 0 additions & 2 deletions src/game/game_string.def
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,3 @@ 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_CURRENT_HEALTH_GET, "Current Lara's health: %d")
GS_DEFINE(OSD_CURRENT_HEALTH_SET, "Lara's health set to %d")
GS_DEFINE(OSD_HEAL_ALREADY_FULL_HP, "Lara's already at full health")
GS_DEFINE(OSD_HEAL_SUCCESS, "Healed Lara back to full health")
4 changes: 2 additions & 2 deletions src/game/lara/common.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "game/lara/common.h"

#include "global/vars.h"

#include <libtrx/game/lara/common.h>

ITEM_INFO *Lara_GetItem(void)
{
return g_LaraItem;
Expand Down
5 changes: 0 additions & 5 deletions src/game/lara/common.h

This file was deleted.

21 changes: 0 additions & 21 deletions src/game/lara/lara_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1802,27 +1802,6 @@ void __cdecl Lara_WaterCurrent(COLL_INFO *const coll)
coll->old = item->pos;
}

void __cdecl Lara_Extinguish(void)
{
if (!g_Lara.burn) {
return;
}

g_Lara.burn = 0;

// put out flame objects
int16_t fx_num = g_NextEffectActive;
while (fx_num != NO_ITEM) {
FX_INFO *const fx = &g_Effects[fx_num];
const int16_t next_fx_num = fx->next_active;
if (fx->object_id == O_FLAME && fx->counter < 0) {
fx->counter = 0;
Effect_Kill(fx_num);
}
fx_num = next_fx_num;
}
}

void __cdecl Lara_CatchFire(void)
{
if (g_Lara.burn || g_Lara.water_status == LWS_CHEAT) {
Expand Down
1 change: 0 additions & 1 deletion src/game/lara/lara_misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ void __cdecl Lara_SwimCollision(ITEM_INFO *item, COLL_INFO *coll);

void __cdecl Lara_WaterCurrent(COLL_INFO *coll);

void __cdecl Lara_Extinguish(void);
void __cdecl Lara_CatchFire(void);

void __cdecl Lara_TouchLava(ITEM_INFO *item);
25 changes: 25 additions & 0 deletions src/game/lara/misc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "game/effects.h"
#include "global/vars.h"

#include <libtrx/game/lara/misc.h>

void __cdecl Lara_Extinguish(void)
{
if (!g_Lara.burn) {
return;
}

g_Lara.burn = 0;

// put out flame objects
int16_t fx_num = g_NextEffectActive;
while (fx_num != NO_ITEM) {
FX_INFO *const fx = &g_Effects[fx_num];
const int16_t next_fx_num = fx->next_active;
if (fx->object_id == O_FLAME && fx->counter < 0) {
fx->counter = 0;
Effect_Kill(fx_num);
}
fx_num = next_fx_num;
}
}

0 comments on commit ee3c481

Please sign in to comment.