From 5a63afeb32db04c4e168a2065a90cd3861f701f7 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Mon, 30 Sep 2024 15:05:43 +0200 Subject: [PATCH 1/7] console/cmd: add new aliases --- CHANGELOG.md | 2 ++ subprojects/libtrx | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c957bc2d..5566ff37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## [Unreleased](https://github.com/LostArtefacts/TR2X/compare/stable...develop) - ××××-××-×× - added `/sfx` command +- added `/nextlevel` alias to `/endlevel` console command +- added `/quit` alias to `/exit` console command - fixed crash in the `/set` console command (regression from 0.3) - fixed using console in cutscenes immediately exiting the game (regression from 0.3) - fixed Lara remaining tilted when teleporting off a vehicle while on a slope (#275, regression from 0.3) diff --git a/subprojects/libtrx b/subprojects/libtrx index 3e514225..9608bc04 160000 --- a/subprojects/libtrx +++ b/subprojects/libtrx @@ -1 +1 @@ -Subproject commit 3e51422534f81fcc3178bb9516567ed0b15b8618 +Subproject commit 9608bc0461e74461b438695b78a3f33d4f0229f4 From 464762c49a8df08518a43378f7e4a28f46cbe625 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Mon, 30 Sep 2024 14:34:40 +0200 Subject: [PATCH 2/7] console/cmd: move /play to libtrx --- docs/progress.svg | 20 ++++++------ docs/progress.txt | 32 +++++++++---------- meson.build | 1 - src/decomp/decomp.c | 4 +-- src/decomp/decomp.h | 3 +- src/game/console/cmd/play_level.c | 53 ------------------------------- src/game/console/cmd/play_level.h | 5 --- src/game/console/setup.c | 2 +- src/game/game.c | 2 +- src/game/game.h | 2 +- src/game/gameflow.c | 32 +++++++++---------- src/game/gameflow.h | 4 +-- src/game/gameflow/gameflow_new.c | 20 ++++++++++++ src/game/gameflow/gameflow_new.h | 2 +- src/game/lara/control.c | 2 +- src/game/lara/control.h | 2 +- src/global/funcs.h | 4 +-- src/global/types.h | 13 +------- subprojects/libtrx | 2 +- tools/generate_funcs | 1 + 20 files changed, 79 insertions(+), 127 deletions(-) delete mode 100644 src/game/console/cmd/play_level.c delete mode 100644 src/game/console/cmd/play_level.h diff --git a/docs/progress.svg b/docs/progress.svg index 187c6a8b..52887bba 100644 --- a/docs/progress.svg +++ b/docs/progress.svg @@ -384,8 +384,8 @@ void __cdecl WarriorControl(int16_t item_num); int32_t __cdecl GF_LoadScriptFile(const char *fname); int32_t __cdecl GF_DoFrontendSequence(void); -int32_t __cdecl GF_DoLevelSequence(int32_t level, GF_LEVEL_TYPE type); -int32_t __cdecl GF_InterpretSequence(int16_t *ptr, GF_LEVEL_TYPE type, int32_t seq_type); +int32_t __cdecl GF_DoLevelSequence(int32_t level, GAMEFLOW_LEVEL_TYPE type); +int32_t __cdecl GF_InterpretSequence(int16_t *ptr, GAMEFLOW_LEVEL_TYPE type, int32_t seq_type); void __cdecl GF_ModifyInventory(int32_t level, int32_t type); void __cdecl InitialiseHair(void); void __cdecl HairControl(int32_t in_cutscene); @@ -1049,7 +1049,7 @@ LPCTSTR __cdecl GetFullPath(LPCTSTR file_name); BOOL __cdecl SelectDrive(void); bool __cdecl Level_Load(const char *file_name, int32_t level_num); -BOOL __cdecl S_LoadLevelFile(LPCTSTR file_name, int32_t level_num, GF_LEVEL_TYPE level_type); +BOOL __cdecl S_LoadLevelFile(LPCTSTR file_name, int32_t level_num, GAMEFLOW_LEVEL_TYPE level_type); void __cdecl S_UnloadLevelFile(void); void __cdecl S_AdjustTexelCoordinates(void); BOOL __cdecl S_ReloadLevelGraphics(BOOL reload_palettes, BOOL reload_tex_pages); @@ -1068,7 +1068,7 @@ void __cdecl S_Wait(int32_t timeout, BOOL input_check); bool __cdecl S_PlayFMV(const char *file_name); bool __cdecl S_IntroFMV(const char *file_name1, const char *file_name2); -int16_t __cdecl Game_Start(int32_t level_num, GF_LEVEL_TYPE level_type); +int16_t __cdecl Game_Start(int32_t level_num, GAMEFLOW_LEVEL_TYPE level_type); int32_t __cdecl Game_Loop(bool demo_mode); int32_t __cdecl LevelCompleteSequence(void); int32_t __cdecl LevelStats(int32_t level_num); @@ -1137,7 +1137,7 @@ void __cdecl S_InitialisePolyList(BOOL clear_back_buffer); DWORD __cdecl S_DumpScreen(void); void __cdecl S_ClearScreen(void); -void __cdecl S_InitialiseScreen(GF_LEVEL_TYPE level_type); +void __cdecl S_InitialiseScreen(GAMEFLOW_LEVEL_TYPE level_type); void __cdecl S_OutputPolyList(void); int32_t __cdecl S_GetObjectBounds(const BOUNDS_16 *bounds); void __cdecl S_InsertBackPolygon(int32_t x0, int32_t y0, int32_t x1, int32_t y1); @@ -1353,7 +1353,7 @@ void __cdecl Option_Sound(INVENTORY_ITEM *item); void __cdecl Sound_Effect(int32_t sample_id, const XYZ_32 *pos, uint32_t flags); void __cdecl PickUpCollision(int16_t item_num, ITEM *lara_item, COLL_INFO *coll); -int32_t __cdecl GF_InterpretSequence(int16_t *ptr, GF_LEVEL_TYPE type, int32_t seq_type); +int32_t __cdecl GF_InterpretSequence(int16_t *ptr, GAMEFLOW_LEVEL_TYPE type, int32_t seq_type); TARGET_TYPE __cdecl Box_CalculateTarget(XYZ_32 *target, ITEM *item, LOT_INFO *lot); void __cdecl Output_InsertGT4_ZBuffered(const PHD_VBUF *vtx0, const PHD_VBUF *vtx1, const PHD_VBUF *vtx2, const PHD_VBUF *vtx3, const PHD_TEXTURE *texture); int32_t __cdecl SkidooControl(void); @@ -1591,7 +1591,7 @@ void __cdecl Effect_Draw(int16_t fx_num); int32_t __cdecl Output_XGenXG(const int16_t *obj_ptr); void __cdecl Overlay_DrawAssaultTimer(void); -int16_t __cdecl Game_Start(int32_t level_num, GF_LEVEL_TYPE level_type); +int16_t __cdecl Game_Start(int32_t level_num, GAMEFLOW_LEVEL_TYPE level_type); void __cdecl Lara_State_Run(ITEM *item, COLL_INFO *coll); int32_t __cdecl Output_ZedClipper(int32_t vtx_count, POINT_INFO *pts, VERTEX_INFO *vtx); void __cdecl Output_DrawClippedPoly_Textured(int32_t vtx_count); @@ -2012,7 +2012,7 @@ void __cdecl ControlAlarmSound(int16_t item_num); int32_t __cdecl Lara_HitCeiling(ITEM *item, COLL_INFO *coll); void __cdecl UpdateGameResolution(void); -int32_t __cdecl GF_DoLevelSequence(int32_t level, GF_LEVEL_TYPE type); +int32_t __cdecl GF_DoLevelSequence(int32_t level, GAMEFLOW_LEVEL_TYPE type); void __cdecl Lara_LookUpDown(void); int16_t __cdecl GunShot(int32_t x, int32_t y, int32_t z, int16_t speed, PHD_ANGLE yrot, int16_t room_num); void __cdecl CreateBubble(PHD_3DPOS *pos, int16_t room_num); @@ -2224,7 +2224,7 @@ void __cdecl Text_ChangeText(TEXTSTRING *string, const char *text); uint32_t __cdecl Text_GetScaleH(uint32_t value); bool __cdecl D3DIsSupported(LPD3DDEVICEDESC desc); -void __cdecl S_InitialiseScreen(GF_LEVEL_TYPE level_type); +void __cdecl S_InitialiseScreen(GAMEFLOW_LEVEL_TYPE level_type); LONG __cdecl SetRegistryBinaryValue(LPCTSTR lpValueName, LPBYTE value, DWORD valueSize); void __thiscall SE_ReleaseBitmapResource(BITMAP_RESOURCE *bmpRsrc); void __cdecl Output_PrintPolyList(uint8_t *surface_ptr); @@ -2429,7 +2429,7 @@ sub_447160 sub_447A80 sub_447B30 -BOOL __cdecl S_LoadLevelFile(LPCTSTR file_name, int32_t level_num, GF_LEVEL_TYPE level_type); +BOOL __cdecl S_LoadLevelFile(LPCTSTR file_name, int32_t level_num, GAMEFLOW_LEVEL_TYPE level_type); int32_t __cdecl UT_MessageBox(LPCTSTR lpText, HWND hWnd); void __cdecl AssaultReset(ITEM *item); void __cdecl Text_SetScale(TEXTSTRING *string, int32_t scale_h, int32_t scale_v); diff --git a/docs/progress.txt b/docs/progress.txt index eeca13b4..2b2a032e 100644 --- a/docs/progress.txt +++ b/docs/progress.txt @@ -685,17 +685,17 @@ typedef struct __unaligned { // decompiled XYZ_32 target; } LOT_INFO; -typedef enum { - GFL_NOLEVEL = -1, - GFL_TITLE = 0, - GFL_NORMAL = 1, - GFL_SAVED = 2, - GFL_DEMO = 3, - GFL_CUTSCENE = 4, - GFL_STORY = 5, - GFL_QUIET = 6, - GFL_MIDSTORY = 7, -} GF_LEVEL_TYPE; +typedef enum { // decompiled + GFL_NO_LEVEL = -1, + GFL_TITLE = 0, + GFL_NORMAL = 1, + GFL_SAVED = 2, + GFL_DEMO = 3, + GFL_CUTSCENE = 4, + GFL_STORY = 5, + GFL_QUIET = 6, + GFL_MID_STORY = 7, +} GAMEFLOW_LEVEL_TYPE; typedef struct __unaligned { int16_t timer; @@ -3189,8 +3189,8 @@ typedef enum { # game/gameflow.c 0x0041FA60 0x01E9 + int32_t __cdecl GF_LoadScriptFile(const char *fname); 0x0041FC50 0x001F + int32_t __cdecl GF_DoFrontendSequence(void); -0x0041FC70 0x0066 + int32_t __cdecl GF_DoLevelSequence(int32_t level, GF_LEVEL_TYPE type); -0x0041FCE0 0x047C + int32_t __cdecl GF_InterpretSequence(int16_t *ptr, GF_LEVEL_TYPE type, int32_t seq_type); +0x0041FC70 0x0066 + int32_t __cdecl GF_DoLevelSequence(int32_t level, GAMEFLOW_LEVEL_TYPE type); +0x0041FCE0 0x047C + int32_t __cdecl GF_InterpretSequence(int16_t *ptr, GAMEFLOW_LEVEL_TYPE type, int32_t seq_type); 0x004201C0 0x0CD3 + void __cdecl GF_ModifyInventory(int32_t level, int32_t type); # game/hair.c @@ -3919,7 +3919,7 @@ typedef enum { 0x0044B150 0x0026 -R LPCTSTR __cdecl GetFullPath(LPCTSTR file_name); 0x0044B180 0x00E0 -R BOOL __cdecl SelectDrive(void); 0x0044B260 0x024A + bool __cdecl Level_Load(const char *file_name, int32_t level_num); -0x0044B4B0 0x0018 -R BOOL __cdecl S_LoadLevelFile(LPCTSTR file_name, int32_t level_num, GF_LEVEL_TYPE level_type); +0x0044B4B0 0x0018 -R BOOL __cdecl S_LoadLevelFile(LPCTSTR file_name, int32_t level_num, GAMEFLOW_LEVEL_TYPE level_type); 0x0044B4D0 0x002A -R void __cdecl S_UnloadLevelFile(void); 0x0044B500 0x0014 -R void __cdecl S_AdjustTexelCoordinates(void); 0x0044B520 0x00C4 -R BOOL __cdecl S_ReloadLevelGraphics(BOOL reload_palettes, BOOL reload_tex_pages); @@ -3938,7 +3938,7 @@ typedef enum { 0x0044C3F0 0x0057 *R void __cdecl S_Wait(int32_t timeout, BOOL input_check); 0x0044C450 0x000E -R bool __cdecl S_PlayFMV(const char *file_name); 0x0044C460 0x0013 -R bool __cdecl S_IntroFMV(const char *file_name1, const char *file_name2); -0x0044C480 0x0144 + int16_t __cdecl Game_Start(int32_t level_num, GF_LEVEL_TYPE level_type); +0x0044C480 0x0144 + int16_t __cdecl Game_Start(int32_t level_num, GAMEFLOW_LEVEL_TYPE level_type); 0x0044C5D0 0x009A + int32_t __cdecl Game_Loop(bool demo_mode); 0x0044C670 0x0006 +R int32_t __cdecl LevelCompleteSequence(void); 0x0044C680 0x01C2 +R int32_t __cdecl LevelStats(int32_t level_num); @@ -4007,7 +4007,7 @@ typedef enum { 0x00450B00 0x00E4 *R void __cdecl S_InitialisePolyList(BOOL clear_back_buffer); 0x00450BF0 0x0036 *R DWORD __cdecl S_DumpScreen(void); 0x00450C30 0x000B -R void __cdecl S_ClearScreen(void); -0x00450C40 0x0037 -R void __cdecl S_InitialiseScreen(GF_LEVEL_TYPE level_type); +0x00450C40 0x0037 -R void __cdecl S_InitialiseScreen(GAMEFLOW_LEVEL_TYPE level_type); 0x00450C80 0x0089 *R void __cdecl S_OutputPolyList(void); 0x00450CC0 0x0270 -R int32_t __cdecl S_GetObjectBounds(const BOUNDS_16 *bounds); 0x00450F30 0x0046 -R void __cdecl S_InsertBackPolygon(int32_t x0, int32_t y0, int32_t x1, int32_t y1); diff --git a/meson.build b/meson.build index 28b6d8b5..58f36b6f 100644 --- a/meson.build +++ b/meson.build @@ -93,7 +93,6 @@ dll_sources = [ 'src/game/collide.c', 'src/game/console/cmd/flipmap.c', 'src/game/console/cmd/load_game.c', - 'src/game/console/cmd/play_level.c', 'src/game/console/cmd/save_game.c', 'src/game/console/common.c', 'src/game/console/setup.c', diff --git a/src/decomp/decomp.c b/src/decomp/decomp.c index 2107b559..353bc248 100644 --- a/src/decomp/decomp.c +++ b/src/decomp/decomp.c @@ -1349,7 +1349,7 @@ void __cdecl CutscenePlayerGen_Initialise(const int16_t item_num) } int32_t __cdecl Level_Initialise( - const int32_t level_num, const GF_LEVEL_TYPE level_type) + const int32_t level_num, const GAMEFLOW_LEVEL_TYPE level_type) { g_GameInfo.current_level.num = level_num; g_GameInfo.current_level.type = level_type; @@ -1978,7 +1978,7 @@ bool __cdecl ApplySettings(const APP_SETTINGS *const new_settings) g_SavedAppSettings = *new_settings; RenderStart(false); - S_InitialiseScreen(GFL_NOLEVEL); + S_InitialiseScreen(GFL_NO_LEVEL); if (g_SavedAppSettings.render_mode != old_settings.render_mode) { S_ReloadLevelGraphics(1, 1); diff --git a/src/decomp/decomp.h b/src/decomp/decomp.h index 8c63d2c8..eb51c624 100644 --- a/src/decomp/decomp.h +++ b/src/decomp/decomp.h @@ -66,7 +66,8 @@ void __cdecl CutscenePlayer_Control(int16_t item_num); void __cdecl Lara_Control_Cutscene(int16_t item_num); void __cdecl CutscenePlayer1_Initialise(int16_t item_num); void __cdecl CutscenePlayerGen_Initialise(int16_t item_num); -int32_t __cdecl Level_Initialise(int32_t level_num, GF_LEVEL_TYPE level_type); +int32_t __cdecl Level_Initialise( + int32_t level_num, GAMEFLOW_LEVEL_TYPE level_type); void __cdecl CreateScreenBuffers(void); void __cdecl CreatePrimarySurface(void); void __cdecl CreateBackBuffer(void); diff --git a/src/game/console/cmd/play_level.c b/src/game/console/cmd/play_level.c deleted file mode 100644 index 52e8bd9f..00000000 --- a/src/game/console/cmd/play_level.c +++ /dev/null @@ -1,53 +0,0 @@ -#include "game/console/cmd/play_level.h" - -#include "game/game_string.h" -#include "global/vars.h" - -#include - -#include - -static COMMAND_RESULT M_Entrypoint(const COMMAND_CONTEXT *ctx); - -static COMMAND_RESULT M_Entrypoint(const COMMAND_CONTEXT *const ctx) -{ - int32_t level_to_load = -1; - - if (level_to_load == -1) { - int32_t num = 0; - if (sscanf(ctx->args, "%d", &num) == 1) { - level_to_load = num; - } - } - - if (level_to_load == -1 && strlen(ctx->args) >= 2) { - for (int i = 0; i < g_GameFlow.num_levels; i++) { - if (String_CaseSubstring(g_GF_LevelNames[i], ctx->args) != NULL) { - level_to_load = i; - break; - } - } - } - - if (level_to_load == -1 && String_Equivalent(ctx->args, "gym")) { - level_to_load = LV_GYM; - } - - if (level_to_load >= g_GameFlow.num_levels) { - Console_Log(GS(OSD_INVALID_LEVEL)); - return CR_FAILURE; - } - - if (level_to_load != -1) { - g_GF_OverrideDir = GFD_START_GAME | level_to_load; - Console_Log(GS(OSD_PLAY_LEVEL), g_GF_LevelNames[level_to_load]); - return CR_SUCCESS; - } - - return CR_BAD_INVOCATION; -} - -CONSOLE_COMMAND g_Console_Cmd_PlayLevel = { - .prefix = "play|level", - .proc = M_Entrypoint, -}; diff --git a/src/game/console/cmd/play_level.h b/src/game/console/cmd/play_level.h deleted file mode 100644 index 200cc8c7..00000000 --- a/src/game/console/cmd/play_level.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#include - -extern CONSOLE_COMMAND g_Console_Cmd_PlayLevel; diff --git a/src/game/console/setup.c b/src/game/console/setup.c index ef71fe7c..e9ddb273 100644 --- a/src/game/console/setup.c +++ b/src/game/console/setup.c @@ -2,7 +2,6 @@ #include "game/console/cmd/flipmap.h" #include "game/console/cmd/load_game.h" -#include "game/console/cmd/play_level.h" #include "game/console/cmd/save_game.h" #include @@ -15,6 +14,7 @@ #include #include #include +#include #include #include #include diff --git a/src/game/game.c b/src/game/game.c index 28931aa3..4fcc0075 100644 --- a/src/game/game.c +++ b/src/game/game.c @@ -200,7 +200,7 @@ int32_t __cdecl Game_DrawCinematic(void) } int16_t __cdecl Game_Start( - const int32_t level_num, const GF_LEVEL_TYPE level_type) + const int32_t level_num, const GAMEFLOW_LEVEL_TYPE level_type) { if (level_type == GFL_NORMAL || level_type == GFL_SAVED || level_type == GFL_DEMO) { diff --git a/src/game/game.h b/src/game/game.h index 6a32c5f9..660899ba 100644 --- a/src/game/game.h +++ b/src/game/game.h @@ -5,6 +5,6 @@ int32_t __cdecl Game_Control(int32_t nframes, bool demo_mode); int32_t __cdecl Game_Draw(void); int32_t __cdecl Game_DrawCinematic(void); -int16_t __cdecl Game_Start(int32_t level_num, GF_LEVEL_TYPE level_type); +int16_t __cdecl Game_Start(int32_t level_num, GAMEFLOW_LEVEL_TYPE level_type); int32_t __cdecl Game_Loop(bool demo_mode); bool Game_IsPlayable(void); diff --git a/src/game/gameflow.c b/src/game/gameflow.c index ba700062..e579113a 100644 --- a/src/game/gameflow.c +++ b/src/game/gameflow.c @@ -353,7 +353,7 @@ int32_t __cdecl GF_DoFrontendSequence(void) } int32_t __cdecl GF_DoLevelSequence( - const int32_t start_level, const GF_LEVEL_TYPE type) + const int32_t start_level, const GAMEFLOW_LEVEL_TYPE type) { GF_N_LoadStrings(start_level); @@ -378,7 +378,7 @@ int32_t __cdecl GF_DoLevelSequence( } int32_t __cdecl GF_InterpretSequence( - const int16_t *ptr, GF_LEVEL_TYPE type, const int32_t seq_type) + const int16_t *ptr, GAMEFLOW_LEVEL_TYPE type, const int32_t seq_type) { g_GF_NoFloor = false; g_GF_DeadlyWater = false; @@ -431,7 +431,7 @@ int32_t __cdecl GF_InterpretSequence( if (ptr[1] > g_GameFlow.num_levels) { dir = GFD_EXIT_TO_TITLE; } else if (type != GFL_STORY) { - if (type == GFL_MIDSTORY) { + if (type == GFL_MID_STORY) { return GFD_EXIT_TO_TITLE; } dir = Game_Start(ptr[1], type); @@ -453,7 +453,7 @@ int32_t __cdecl GF_InterpretSequence( g_CurrentLevel = level; // TODO: make Game_Cutscene_Start return GAME_FLOW_DIR if (result == 2 - && (type == GFL_STORY || type == GFL_MIDSTORY)) { + && (type == GFL_STORY || type == GFL_MID_STORY)) { return GFD_EXIT_TO_TITLE; } if (result == 3) { @@ -469,7 +469,7 @@ int32_t __cdecl GF_InterpretSequence( break; case GFE_LEVEL_COMPLETE: - if (type != GFL_STORY && type != GFL_MIDSTORY) { + if (type != GFL_STORY && type != GFL_MID_STORY) { if (LevelStats(g_CurrentLevel)) { return GFD_EXIT_TO_TITLE; } @@ -480,7 +480,7 @@ int32_t __cdecl GF_InterpretSequence( case GFE_DEMO_PLAY: if (type != GFL_SAVED && type != GFL_STORY - && type != GFL_MIDSTORY) { + && type != GFL_MID_STORY) { return Demo_Start(ptr[1]); } ptr += 2; @@ -498,7 +498,7 @@ int32_t __cdecl GF_InterpretSequence( break; case GFE_SUNSET: - if (type != GFL_STORY && type != GFL_MIDSTORY) { + if (type != GFL_STORY && type != GFL_MID_STORY) { g_GF_SunsetEnabled = true; } ptr++; @@ -509,14 +509,14 @@ int32_t __cdecl GF_InterpretSequence( break; case GFE_DEADLY_WATER: - if (type != GFL_STORY && type != GFL_MIDSTORY) { + if (type != GFL_STORY && type != GFL_MID_STORY) { g_GF_DeadlyWater = true; } ptr++; break; case GFE_REMOVE_WEAPONS: - if (type != GFL_STORY && type != GFL_MIDSTORY + if (type != GFL_STORY && type != GFL_MID_STORY && type != GFL_SAVED) { g_GF_RemoveWeapons = true; } @@ -540,14 +540,14 @@ int32_t __cdecl GF_InterpretSequence( break; case GFE_NO_FLOOR: - if (type != GFL_STORY && type != GFL_MIDSTORY) { + if (type != GFL_STORY && type != GFL_MID_STORY) { g_GF_NoFloor = ptr[1]; } ptr += 2; break; case GFE_ADD_TO_INV: - if (type != GFL_STORY && type != GFL_MIDSTORY) { + if (type != GFL_STORY && type != GFL_MID_STORY) { if (ptr[1] < 1000) { g_GF_SecretInvItems[ptr[1]]++; } else if (type != GFL_SAVED) { @@ -558,28 +558,28 @@ int32_t __cdecl GF_InterpretSequence( break; case GFE_START_ANIM: - if (type != GFL_STORY && type != GFL_MIDSTORY) { + if (type != GFL_STORY && type != GFL_MID_STORY) { g_GF_LaraStartAnim = ptr[1]; } ptr += 2; break; case GFE_NUM_SECRETS: - if (type != GFL_STORY && type != GFL_MIDSTORY) { + if (type != GFL_STORY && type != GFL_MID_STORY) { g_GF_NumSecrets = ptr[1]; } ptr += 2; break; case GFE_KILL_TO_COMPLETE: - if (type != GFL_STORY && type != GFL_MIDSTORY) { + if (type != GFL_STORY && type != GFL_MID_STORY) { g_GF_Kill2Complete = true; } ptr++; break; case GFE_REMOVE_AMMO: - if (type != GFL_STORY && type != GFL_MIDSTORY + if (type != GFL_STORY && type != GFL_MID_STORY && type != GFL_SAVED) { g_GF_RemoveAmmo = true; } @@ -591,7 +591,7 @@ int32_t __cdecl GF_InterpretSequence( } } - if (type == GFL_STORY || type == GFL_MIDSTORY) { + if (type == GFL_STORY || type == GFL_MID_STORY) { return 0; } return dir; diff --git a/src/game/gameflow.h b/src/game/gameflow.h index 9644b63a..73e933b5 100644 --- a/src/game/gameflow.h +++ b/src/game/gameflow.h @@ -7,7 +7,7 @@ BOOL __cdecl GF_LoadFromFile(const char *file_name); int32_t __cdecl GF_LoadScriptFile(const char *fname); int32_t __cdecl GF_DoFrontendSequence(void); -int32_t __cdecl GF_DoLevelSequence(int32_t level, GF_LEVEL_TYPE type); +int32_t __cdecl GF_DoLevelSequence(int32_t level, GAMEFLOW_LEVEL_TYPE type); int32_t __cdecl GF_InterpretSequence( - const int16_t *ptr, GF_LEVEL_TYPE type, int32_t seq_type); + const int16_t *ptr, GAMEFLOW_LEVEL_TYPE type, int32_t seq_type); void __cdecl GF_ModifyInventory(int32_t level, int32_t type); diff --git a/src/game/gameflow/gameflow_new.c b/src/game/gameflow/gameflow_new.c index d8c39cf4..65e309c4 100644 --- a/src/game/gameflow/gameflow_new.c +++ b/src/game/gameflow/gameflow_new.c @@ -217,6 +217,26 @@ void GF_N_LoadStrings(const int32_t level_num) } } +int32_t Gameflow_GetLevelCount(void) +{ + return g_GameflowNew.level_count; +} + +const char *Gameflow_GetLevelFileName(int32_t level_num) +{ + return g_GF_LevelFileNames[level_num]; +} + +const char *Gameflow_GetLevelTitle(int32_t level_num) +{ + return g_GF_LevelNames[level_num]; +} + +int32_t Gameflow_GetGymLevelNumber(void) +{ + return g_GameFlow.gym_enabled ? LV_GYM : -1; +} + void Gameflow_OverrideCommand(const GAMEFLOW_COMMAND command) { switch (command.action) { diff --git a/src/game/gameflow/gameflow_new.h b/src/game/gameflow/gameflow_new.h index 8aed219b..ed36de74 100644 --- a/src/game/gameflow/gameflow_new.h +++ b/src/game/gameflow/gameflow_new.h @@ -4,7 +4,7 @@ typedef struct { struct { - GF_LEVEL_TYPE type; + GAMEFLOW_LEVEL_TYPE type; int32_t num; } current_level; } GAME_INFO; diff --git a/src/game/lara/control.c b/src/game/lara/control.c index 68b23ba6..5ac6aa92 100644 --- a/src/game/lara/control.c +++ b/src/game/lara/control.c @@ -710,7 +710,7 @@ void __cdecl Lara_InitialiseLoad(const int16_t item_num) g_LaraItem = &g_Items[item_num]; } -void __cdecl Lara_Initialise(const GF_LEVEL_TYPE type) +void __cdecl Lara_Initialise(const GAMEFLOW_LEVEL_TYPE type) { ITEM *const item = g_LaraItem; diff --git a/src/game/lara/control.h b/src/game/lara/control.h index d80f5660..47c9a8fd 100644 --- a/src/game/lara/control.h +++ b/src/game/lara/control.h @@ -17,7 +17,7 @@ void __cdecl Lara_UseItem(GAME_OBJECT_ID object_id); void __cdecl Lara_InitialiseLoad(int16_t item_num); -void __cdecl Lara_Initialise(GF_LEVEL_TYPE type); +void __cdecl Lara_Initialise(GAMEFLOW_LEVEL_TYPE type); void __cdecl Lara_InitialiseInventory(int32_t level_num); diff --git a/src/global/funcs.h b/src/global/funcs.h index 11a0cd15..10065f2a 100644 --- a/src/global/funcs.h +++ b/src/global/funcs.h @@ -283,7 +283,7 @@ #define ChangeFileNameExtension ((void __cdecl (*)(char *file_name, const char *file_ext))0x0044B110) #define GetFullPath ((LPCTSTR __cdecl (*)(LPCTSTR file_name))0x0044B150) #define SelectDrive ((BOOL __cdecl (*)(void))0x0044B180) -#define S_LoadLevelFile ((BOOL __cdecl (*)(LPCTSTR file_name, int32_t level_num, GF_LEVEL_TYPE level_type))0x0044B4B0) +#define S_LoadLevelFile ((BOOL __cdecl (*)(LPCTSTR file_name, int32_t level_num, GAMEFLOW_LEVEL_TYPE level_type))0x0044B4B0) #define S_UnloadLevelFile ((void __cdecl (*)(void))0x0044B4D0) #define S_AdjustTexelCoordinates ((void __cdecl (*)(void))0x0044B500) #define S_ReloadLevelGraphics ((BOOL __cdecl (*)(BOOL reload_palettes, BOOL reload_tex_pages))0x0044B520) @@ -317,7 +317,7 @@ #define S_InitialisePolyList ((void __cdecl (*)(BOOL clear_back_buffer))0x00450B00) #define S_DumpScreen ((DWORD __cdecl (*)(void))0x00450BF0) #define S_ClearScreen ((void __cdecl (*)(void))0x00450C30) -#define S_InitialiseScreen ((void __cdecl (*)(GF_LEVEL_TYPE level_type))0x00450C40) +#define S_InitialiseScreen ((void __cdecl (*)(GAMEFLOW_LEVEL_TYPE level_type))0x00450C40) #define S_OutputPolyList ((void __cdecl (*)(void))0x00450C80) #define S_GetObjectBounds ((int32_t __cdecl (*)(const BOUNDS_16 *bounds))0x00450CC0) #define S_InsertBackPolygon ((void __cdecl (*)(int32_t x0, int32_t y0, int32_t x1, int32_t y1))0x00450F30) diff --git a/src/global/types.h b/src/global/types.h index 5348068c..aa3b0457 100644 --- a/src/global/types.h +++ b/src/global/types.h @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -549,18 +550,6 @@ typedef struct __unaligned { int16_t enemy_facing; } AI_INFO; -typedef enum { - GFL_NOLEVEL = -1, - GFL_TITLE = 0, - GFL_NORMAL = 1, - GFL_SAVED = 2, - GFL_DEMO = 3, - GFL_CUTSCENE = 4, - GFL_STORY = 5, - GFL_QUIET = 6, - GFL_MIDSTORY = 7, -} GF_LEVEL_TYPE; - typedef struct __unaligned { int16_t timer; int16_t sprite; diff --git a/subprojects/libtrx b/subprojects/libtrx index 9608bc04..f40b3111 160000 --- a/subprojects/libtrx +++ b/subprojects/libtrx @@ -1 +1 @@ -Subproject commit 9608bc0461e74461b438695b78a3f33d4f0229f4 +Subproject commit f40b311164375db0b85d048d2c0381f2c63563cf diff --git a/tools/generate_funcs b/tools/generate_funcs index b78316d7..8d3c63ee 100755 --- a/tools/generate_funcs +++ b/tools/generate_funcs @@ -115,6 +115,7 @@ def make_types_h(types: list[str]) -> None: "", "#include ", "#include ", + "#include ", "#include ", "#include ", "#include ", From 0eced943bbb5d1873eadc867526ec9e253b33c17 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Mon, 30 Sep 2024 15:06:47 +0200 Subject: [PATCH 3/7] console/cmd: fix /endlevel working in title screen --- CHANGELOG.md | 1 + src/game/game.c | 5 +++++ subprojects/libtrx | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5566ff37..2eef7374 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - fixed crash in the `/set` console command (regression from 0.3) - fixed using console in cutscenes immediately exiting the game (regression from 0.3) - fixed Lara remaining tilted when teleporting off a vehicle while on a slope (#275, regression from 0.3) +- fixed `/endlevel` displaying a success message in the title screen ## [0.3](https://github.com/LostArtefacts/TR2X/compare/0.2-460-g4721b93...0.3) - 2024-09-20 - added new console commands: diff --git a/src/game/game.c b/src/game/game.c index 4fcc0075..21d75a8e 100644 --- a/src/game/game.c +++ b/src/game/game.c @@ -298,6 +298,11 @@ int32_t __cdecl Game_Loop(const bool demo_mode) return dir; } +GAMEFLOW_LEVEL_TYPE Game_GetCurrentLevelType(void) +{ + return g_GameInfo.current_level.type; +} + bool Game_IsPlayable(void) { if (g_GameInfo.current_level.type == GFL_TITLE diff --git a/subprojects/libtrx b/subprojects/libtrx index f40b3111..02ec3a8e 160000 --- a/subprojects/libtrx +++ b/subprojects/libtrx @@ -1 +1 @@ -Subproject commit f40b311164375db0b85d048d2c0381f2c63563cf +Subproject commit 02ec3a8e2d55307d4996a762a350140ccbc0b68a From b0afdcd851b0ce58ec15480bbfbf0a29dbfd5e0d Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Mon, 30 Sep 2024 16:56:06 +0200 Subject: [PATCH 4/7] console/cmd: move /save and /load to libtrx --- data/ship/cfg/TR2X_gameflow.json5 | 2 ++ meson.build | 3 +- src/game/console/cmd/load_game.c | 39 ------------------------- src/game/console/cmd/load_game.h | 5 ---- src/game/console/cmd/save_game.c | 48 ------------------------------- src/game/console/cmd/save_game.h | 5 ---- src/game/console/setup.c | 4 +-- src/game/savegame/common.c | 23 +++++++++++++++ subprojects/libtrx | 2 +- 9 files changed, 29 insertions(+), 102 deletions(-) delete mode 100644 src/game/console/cmd/load_game.c delete mode 100644 src/game/console/cmd/load_game.h delete mode 100644 src/game/console/cmd/save_game.c delete mode 100644 src/game/console/cmd/save_game.h create mode 100644 src/game/savegame/common.c diff --git a/data/ship/cfg/TR2X_gameflow.json5 b/data/ship/cfg/TR2X_gameflow.json5 index e6699b1b..4454bcd5 100644 --- a/data/ship/cfg/TR2X_gameflow.json5 +++ b/data/ship/cfg/TR2X_gameflow.json5 @@ -387,6 +387,7 @@ "OSD_KILL_ALL_FAIL": "Uh-oh, there are no enemies left to kill...", "OSD_KILL_FAIL": "No enemy nearby...", "OSD_LOAD_GAME": "Loaded game from save slot %d", + "OSD_LOAD_GAME_FAIL_INVALID_SLOT": "Invalid save slot %d", "OSD_LOAD_GAME_FAIL_UNAVAILABLE_SLOT": "Save slot %d is not available", "OSD_OBJECT_NOT_FOUND": "Object not found", "OSD_PLAY_LEVEL": "Loading %s", @@ -399,6 +400,7 @@ "OSD_POS_SET_ROOM_FAIL": "Failed to teleport to room: %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_SOUND_AVAILABLE_SAMPLES": "Available sounds: %s", "OSD_SOUND_PLAYING_SAMPLE": "Playing sound %d", "OSD_UNKNOWN_COMMAND": "Unknown command: %s", diff --git a/meson.build b/meson.build index 58f36b6f..ec1a6c5c 100644 --- a/meson.build +++ b/meson.build @@ -92,8 +92,6 @@ dll_sources = [ 'src/game/clock.c', 'src/game/collide.c', 'src/game/console/cmd/flipmap.c', - 'src/game/console/cmd/load_game.c', - 'src/game/console/cmd/save_game.c', 'src/game/console/common.c', 'src/game/console/setup.c', 'src/game/creature.c', @@ -156,6 +154,7 @@ dll_sources = [ 'src/game/requester.c', 'src/game/room.c', 'src/game/room_draw.c', + 'src/game/savegame/common.c', 'src/game/shell.c', 'src/game/sound.c', 'src/game/text.c', diff --git a/src/game/console/cmd/load_game.c b/src/game/console/cmd/load_game.c deleted file mode 100644 index 9f36c2e0..00000000 --- a/src/game/console/cmd/load_game.c +++ /dev/null @@ -1,39 +0,0 @@ -#include "game/console/cmd/load_game.h" - -#include "game/game_string.h" -#include "global/vars.h" - -#include - -static COMMAND_RESULT M_Entrypoint(const COMMAND_CONTEXT *ctx); - -static COMMAND_RESULT M_Entrypoint(const COMMAND_CONTEXT *const ctx) -{ - int32_t slot_num; - if (!String_ParseInteger(ctx->args, &slot_num)) { - return CR_BAD_INVOCATION; - } - - // convert 1-indexing to 0-indexing - const int32_t slot_idx = slot_num - 1; - - if (slot_idx < 0 || slot_idx >= MAX_SAVE_SLOTS) { - Console_Log(GS(OSD_INVALID_SAVE_SLOT), slot_num); - return CR_FAILURE; - } - - // TODO: replace this with a proper status check - if (g_SavedLevels[slot_idx] <= 0) { - Console_Log(GS(OSD_LOAD_GAME_FAIL_UNAVAILABLE_SLOT), slot_num); - return CR_FAILURE; - } - - g_GF_OverrideDir = GFD_START_SAVED_GAME | slot_idx; - Console_Log(GS(OSD_LOAD_GAME), slot_num); - return CR_SUCCESS; -} - -CONSOLE_COMMAND g_Console_Cmd_LoadGame = { - .prefix = "load", - .proc = M_Entrypoint, -}; diff --git a/src/game/console/cmd/load_game.h b/src/game/console/cmd/load_game.h deleted file mode 100644 index 6bf43395..00000000 --- a/src/game/console/cmd/load_game.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#include - -extern CONSOLE_COMMAND g_Console_Cmd_LoadGame; diff --git a/src/game/console/cmd/save_game.c b/src/game/console/cmd/save_game.c deleted file mode 100644 index f600afb5..00000000 --- a/src/game/console/cmd/save_game.c +++ /dev/null @@ -1,48 +0,0 @@ -#include "game/console/cmd/save_game.h" - -#include "decomp/decomp.h" -#include "game/game_string.h" -#include "game/gameflow/gameflow_new.h" -#include "global/funcs.h" -#include "global/vars.h" - -#include - -static COMMAND_RESULT M_Entrypoint(const COMMAND_CONTEXT *ctx); - -static COMMAND_RESULT M_Entrypoint(const COMMAND_CONTEXT *const ctx) -{ - int32_t slot_num; - if (!String_ParseInteger(ctx->args, &slot_num)) { - return CR_BAD_INVOCATION; - } - - // convert 1-indexing to 0-indexing - const int32_t slot_idx = slot_num - 1; - - if (slot_idx < 0 || slot_idx >= MAX_SAVE_SLOTS) { - Console_Log(GS(OSD_INVALID_SAVE_SLOT), slot_num); - return CR_BAD_INVOCATION; - } - - 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_LaraItem == NULL || g_LaraItem->hit_points <= 0) { - return CR_UNAVAILABLE; - } - - CreateSaveGameInfo(); - S_SaveGame(&g_SaveGame, sizeof(SAVEGAME_INFO), slot_idx); - GetSavedGamesList(&g_LoadGameRequester); - Console_Log(GS(OSD_SAVE_GAME), slot_num); - return CR_SUCCESS; -} - -CONSOLE_COMMAND g_Console_Cmd_SaveGame = { - .prefix = "save", - .proc = M_Entrypoint, -}; diff --git a/src/game/console/cmd/save_game.h b/src/game/console/cmd/save_game.h deleted file mode 100644 index 26cab28f..00000000 --- a/src/game/console/cmd/save_game.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#include - -extern CONSOLE_COMMAND g_Console_Cmd_SaveGame; diff --git a/src/game/console/setup.c b/src/game/console/setup.c index e9ddb273..0157abb7 100644 --- a/src/game/console/setup.c +++ b/src/game/console/setup.c @@ -1,8 +1,6 @@ #include "game/console/setup.h" #include "game/console/cmd/flipmap.h" -#include "game/console/cmd/load_game.h" -#include "game/console/cmd/save_game.h" #include #include @@ -13,9 +11,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include diff --git a/src/game/savegame/common.c b/src/game/savegame/common.c new file mode 100644 index 00000000..de29fdcf --- /dev/null +++ b/src/game/savegame/common.c @@ -0,0 +1,23 @@ +#include "global/funcs.h" +#include "global/vars.h" + +#include +#include + +int32_t Savegame_GetSlotCount(void) +{ + return MAX_SAVE_SLOTS; +} + +bool Savegame_IsSlotFree(const int32_t slot_idx) +{ + return g_SavedLevels[slot_idx] == 0; +} + +bool Savegame_Save(const int32_t slot_idx) +{ + CreateSaveGameInfo(); + S_SaveGame(&g_SaveGame, sizeof(SAVEGAME_INFO), slot_idx); + GetSavedGamesList(&g_LoadGameRequester); + return true; +} diff --git a/subprojects/libtrx b/subprojects/libtrx index 02ec3a8e..e770eacf 160000 --- a/subprojects/libtrx +++ b/subprojects/libtrx @@ -1 +1 @@ -Subproject commit 02ec3a8e2d55307d4996a762a350140ccbc0b68a +Subproject commit e770eacfb36bb671b637f8855e7a019fc048d8ea From 75661e4b0954b30b3639a484460b2e73ff09e2c0 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Mon, 30 Sep 2024 17:22:50 +0200 Subject: [PATCH 5/7] console/cmd: move /flip to libtrx --- meson.build | 1 - src/game/console/cmd/flipmap.c | 42 ---------------------------------- src/game/console/cmd/flipmap.h | 5 ---- src/game/console/setup.c | 3 +-- src/game/room.c | 5 ++++ src/game/room.h | 2 +- subprojects/libtrx | 2 +- 7 files changed, 8 insertions(+), 52 deletions(-) delete mode 100644 src/game/console/cmd/flipmap.c delete mode 100644 src/game/console/cmd/flipmap.h diff --git a/meson.build b/meson.build index ec1a6c5c..54e3cc9c 100644 --- a/meson.build +++ b/meson.build @@ -91,7 +91,6 @@ dll_sources = [ 'src/game/camera.c', 'src/game/clock.c', 'src/game/collide.c', - 'src/game/console/cmd/flipmap.c', 'src/game/console/common.c', 'src/game/console/setup.c', 'src/game/creature.c', diff --git a/src/game/console/cmd/flipmap.c b/src/game/console/cmd/flipmap.c deleted file mode 100644 index 040e137c..00000000 --- a/src/game/console/cmd/flipmap.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "game/console/cmd/flipmap.h" - -#include "game/game_string.h" -#include "game/gameflow/gameflow_new.h" -#include "game/room.h" -#include "global/vars.h" - -#include - -static COMMAND_RESULT M_Entrypoint(const COMMAND_CONTEXT *ctx); - -static COMMAND_RESULT M_Entrypoint(const COMMAND_CONTEXT *const ctx) -{ - 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; - } - - bool new_state; - if (String_Equivalent(ctx->args, "")) { - new_state = !g_FlipStatus; - } else if (!String_ParseBool(ctx->args, &new_state)) { - return CR_BAD_INVOCATION; - } - - if (g_FlipStatus == new_state) { - Console_Log( - new_state ? GS(OSD_FLIPMAP_FAIL_ALREADY_ON) - : GS(OSD_FLIPMAP_FAIL_ALREADY_OFF)); - return CR_SUCCESS; - } - - Room_FlipMap(); - Console_Log(new_state ? GS(OSD_FLIPMAP_ON) : GS(OSD_FLIPMAP_OFF)); - return CR_SUCCESS; -} - -CONSOLE_COMMAND g_Console_Cmd_FlipMap = { - .prefix = "flip|flipmap", - .proc = M_Entrypoint, -}; diff --git a/src/game/console/cmd/flipmap.h b/src/game/console/cmd/flipmap.h deleted file mode 100644 index 1f9786dd..00000000 --- a/src/game/console/cmd/flipmap.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#include - -extern CONSOLE_COMMAND g_Console_Cmd_FlipMap; diff --git a/src/game/console/setup.c b/src/game/console/setup.c index 0157abb7..fcb77c1f 100644 --- a/src/game/console/setup.c +++ b/src/game/console/setup.c @@ -1,12 +1,11 @@ #include "game/console/setup.h" -#include "game/console/cmd/flipmap.h" - #include #include #include #include #include +#include #include #include #include diff --git a/src/game/room.c b/src/game/room.c index 33e3cbe7..f2367bcf 100644 --- a/src/game/room.c +++ b/src/game/room.c @@ -833,6 +833,11 @@ void __cdecl Room_AlterFloorHeight(const ITEM *const item, const int32_t height) } } +bool Room_GetFlipStatus(void) +{ + return g_FlipStatus; +} + void __cdecl Room_FlipMap(void) { for (int32_t i = 0; i < g_RoomCount; i++) { diff --git a/src/game/room.h b/src/game/room.h index c5ee28f3..20436dff 100644 --- a/src/game/room.h +++ b/src/game/room.h @@ -2,7 +2,7 @@ #include "global/types.h" -#include +#include #include diff --git a/subprojects/libtrx b/subprojects/libtrx index e770eacf..1a70b8c9 160000 --- a/subprojects/libtrx +++ b/subprojects/libtrx @@ -1 +1 @@ -Subproject commit e770eacfb36bb671b637f8855e7a019fc048d8ea +Subproject commit 1a70b8c9b67da61af432d06edd6ea8f00f996662 From b2682f31d1472a1b0ae8e988006937cae08b60d2 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Mon, 30 Sep 2024 17:37:20 +0200 Subject: [PATCH 6/7] console/cmd: make /set do fuzzy matching --- CHANGELOG.md | 1 + data/ship/cfg/TR2X_gameflow.json5 | 2 ++ subprojects/libtrx | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2eef7374..31627119 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - added `/sfx` command - added `/nextlevel` alias to `/endlevel` console command - added `/quit` alias to `/exit` console command +- changed `/set` console command to do fuzzy matching (LostArtefacts/libtrx#38) - fixed crash in the `/set` console command (regression from 0.3) - fixed using console in cutscenes immediately exiting the game (regression from 0.3) - fixed Lara remaining tilted when teleporting off a vehicle while on a slope (#275, regression from 0.3) diff --git a/data/ship/cfg/TR2X_gameflow.json5 b/data/ship/cfg/TR2X_gameflow.json5 index 4454bcd5..2db7371a 100644 --- a/data/ship/cfg/TR2X_gameflow.json5 +++ b/data/ship/cfg/TR2X_gameflow.json5 @@ -353,6 +353,8 @@ "game_strings": { "MISC_OFF": "Off", "MISC_ON": "On", + "OSD_AMBIGUOUS_INPUT_2": "Ambiguous input: %s and %s", + "OSD_AMBIGUOUS_INPUT_3": "Ambiguous input: %s, %s, ...", "OSD_COMMAND_BAD_INVOCATION": "Invalid invocation: %s", "OSD_COMMAND_UNAVAILABLE": "This command is not currently available", "OSD_COMPLETE_LEVEL": "Level complete!", diff --git a/subprojects/libtrx b/subprojects/libtrx index 1a70b8c9..ee2f6107 160000 --- a/subprojects/libtrx +++ b/subprojects/libtrx @@ -1 +1 @@ -Subproject commit 1a70b8c9b67da61af432d06edd6ea8f00f996662 +Subproject commit ee2f6107f96c31607d2347e24f6813792c39707f From 5f7b2c10f09d44b63e33daad694b739ab4dfe646 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Mon, 30 Sep 2024 17:47:49 +0200 Subject: [PATCH 7/7] shell: fix crash when opening console too early --- src/decomp/decomp.c | 2 +- src/game/shell.c | 3 +++ src/game/text.c | 9 +++------ src/game/text.h | 2 ++ 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/decomp/decomp.c b/src/decomp/decomp.c index 353bc248..611459da 100644 --- a/src/decomp/decomp.c +++ b/src/decomp/decomp.c @@ -564,6 +564,7 @@ void __cdecl Shell_Shutdown(void) if (g_ErrorMessage[0]) { MessageBoxA(NULL, g_ErrorMessage, NULL, MB_ICONWARNING); } + Text_Shutdown(); UI_Shutdown(); Config_Shutdown(); } @@ -572,7 +573,6 @@ int16_t __cdecl TitleSequence(void) { GF_N_LoadStrings(-1); - Text_Init(); TempVideoAdjust(1, 1.0); g_NoInputCounter = 0; diff --git a/src/game/shell.c b/src/game/shell.c index 1f6eeee4..7532d5dc 100644 --- a/src/game/shell.c +++ b/src/game/shell.c @@ -10,6 +10,7 @@ #include "game/input.h" #include "game/music.h" #include "game/sound.h" +#include "game/text.h" #include "global/funcs.h" #include "global/vars.h" @@ -31,7 +32,9 @@ BOOL __cdecl Shell_Main(void) GameString_Init(); EnumMap_Init(); Config_Init(); + Text_Init(); UI_Init(); + Console_Init(); Config_Read(); if (!S_InitialiseSystem()) { diff --git a/src/game/text.c b/src/game/text.c index 3dc37b4d..350dfd82 100644 --- a/src/game/text.c +++ b/src/game/text.c @@ -34,13 +34,10 @@ void __cdecl Text_Init(void) for (int32_t i = 0; i < MAX_TEXTSTRINGS; i++) { m_TextStrings[i].flags.all = 0; } +} - // TODO: move me outta here! - // instead Text_Init should be only called once per game launch, and - // everyone should clean up after themselves rather than creating dangling - // pointers. - Console_Shutdown(); - Console_Init(); +void Text_Shutdown(void) +{ } TEXTSTRING *__cdecl Text_Create( diff --git a/src/game/text.h b/src/game/text.h index 30954400..d9204340 100644 --- a/src/game/text.h +++ b/src/game/text.h @@ -6,6 +6,8 @@ #define TEXT_MAX_STRING_SIZE 64 void __cdecl Text_Init(void); +void Text_Shutdown(void); + TEXTSTRING *__cdecl Text_Create( int32_t x, int32_t y, int32_t z, const char *string); void __cdecl Text_ChangeText(TEXTSTRING *string, const char *text);