diff --git a/CHANGELOG.md b/CHANGELOG.md index ee7389cd..cd3f5af7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - `/give` - `/kill` - `/flip` + - `/set` - added an ability to remap the console key (#163) - added `/tp` console command's ability to teleport to specific items - added `/fly` console command's ability to open nearest doors diff --git a/data/ship/cfg/TR2X_gameflow.json5 b/data/ship/cfg/TR2X_gameflow.json5 index 634cf7f3..c3a14de4 100644 --- a/data/ship/cfg/TR2X_gameflow.json5 +++ b/data/ship/cfg/TR2X_gameflow.json5 @@ -351,9 +351,14 @@ }, "game_strings": { + "MISC_OFF": "Off", + "MISC_ON": "On", "OSD_COMMAND_BAD_INVOCATION": "Invalid invocation: %s", "OSD_COMMAND_UNAVAILABLE": "This command is not currently available", "OSD_COMPLETE_LEVEL": "Level complete!", + "OSD_CONFIG_OPTION_GET": "%s is currently set to %s", + "OSD_CONFIG_OPTION_SET": "%s changed to %s", + "OSD_CONFIG_OPTION_UNKNOWN_OPTION": "Unknown option: %s", "OSD_CURRENT_HEALTH_GET": "Current Lara's health: %d", "OSD_CURRENT_HEALTH_SET": "Lara's health set to %d", "OSD_DOOR_CLOSE": "Close Sesame!", diff --git a/meson.build b/meson.build index 9e95cc4f..38fa8fa7 100644 --- a/meson.build +++ b/meson.build @@ -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', diff --git a/src/config.c b/src/config.c index e6c99649..945cfbf0 100644 --- a/src/config.c +++ b/src/config.c @@ -36,3 +36,16 @@ bool Config_Write(void) File_CreateDirectory(DIR_CONFIG); return ConfigFile_Write(m_ConfigPath, &Config_Dump); } + +void Config_Sanitize(void) +{ +} + +void Config_ApplyChanges(void) +{ +} + +const CONFIG_OPTION *Config_GetOptionMap(void) +{ + return g_ConfigOptionMap; +} diff --git a/src/config.h b/src/config.h index ad5da1f3..2e3a0731 100644 --- a/src/config.h +++ b/src/config.h @@ -1,5 +1,7 @@ #pragma once +#include + #include typedef struct { @@ -14,3 +16,6 @@ extern CONFIG g_Config; bool Config_Read(void); bool Config_Write(void); +void Config_Sanitize(void); +void Config_ApplyChanges(void); +const CONFIG_OPTION *Config_GetOptionMap(void); diff --git a/src/game/console_cmd.c b/src/game/console_cmd.c index a1ba93f6..e054d2df 100644 --- a/src/game/console_cmd.c +++ b/src/game/console_cmd.c @@ -18,6 +18,8 @@ #include "global/vars.h" #include "lara/lara_misc.h" +#include +#include #include #include #include @@ -32,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); @@ -199,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 @@ -561,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 }, @@ -579,7 +556,9 @@ CONSOLE_COMMAND *g_ConsoleCommands[] = { &(CONSOLE_COMMAND) { .prefix = "abortion", .proc = Console_Cmd_Abortion }, &(CONSOLE_COMMAND) { .prefix = "natlastinks", .proc = Console_Cmd_Abortion }, + &g_Console_Cmd_Config, &g_Console_Cmd_Pos, + &g_Console_Cmd_Heal, &g_Console_Cmd_SetHealth, NULL, }; diff --git a/src/game/game_string.def b/src/game/game_string.def index 49cc2d42..6200cebd 100644 --- a/src/game/game_string.def +++ b/src/game/game_string.def @@ -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") diff --git a/src/game/lara/common.c b/src/game/lara/common.c index d0ec42c7..b28f4d6c 100644 --- a/src/game/lara/common.c +++ b/src/game/lara/common.c @@ -1,7 +1,7 @@ -#include "game/lara/common.h" - #include "global/vars.h" +#include + ITEM_INFO *Lara_GetItem(void) { return g_LaraItem; diff --git a/src/game/lara/common.h b/src/game/lara/common.h deleted file mode 100644 index ee4675e4..00000000 --- a/src/game/lara/common.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#include "game/items.h" - -ITEM_INFO *Lara_GetItem(void); diff --git a/src/game/lara/lara_misc.c b/src/game/lara/lara_misc.c index 5d81dddc..597246e3 100644 --- a/src/game/lara/lara_misc.c +++ b/src/game/lara/lara_misc.c @@ -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) { diff --git a/src/game/lara/lara_misc.h b/src/game/lara/lara_misc.h index ead1689f..6475d284 100644 --- a/src/game/lara/lara_misc.h +++ b/src/game/lara/lara_misc.h @@ -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); diff --git a/src/game/lara/misc.c b/src/game/lara/misc.c new file mode 100644 index 00000000..4ff1e0c7 --- /dev/null +++ b/src/game/lara/misc.c @@ -0,0 +1,25 @@ +#include "game/effects.h" +#include "global/vars.h" + +#include + +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; + } +} diff --git a/subprojects/libtrx b/subprojects/libtrx index b95beda5..39c2d551 160000 --- a/subprojects/libtrx +++ b/subprojects/libtrx @@ -1 +1 @@ -Subproject commit b95beda546dc57bb42dcd781471e13e10a82b9fd +Subproject commit 39c2d55127f456909c21934ba48f431a0040eac6 diff --git a/tools/additional_lint b/tools/additional_lint index 27e552ec..e3985e99 100755 --- a/tools/additional_lint +++ b/tools/additional_lint @@ -1,4 +1,5 @@ #!/usr/bin/env python3 from libtrx.cli.additional_lint import run_script +from tr2x.paths import TR2X_REPO_DIR -run_script() +run_script(root_dir=TR2X_REPO_DIR)