From 0a865c2f64ec52fc84d8333cb3e597f19fb832a3 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sat, 27 Apr 2024 20:51:30 +0200 Subject: [PATCH] inv: fix regression in Inv_Construct Partially resolves #69 --- CHANGELOG.md | 1 + docs/progress.txt | 6 +++--- src/game/inventory.c | 26 +++++++++++++------------- src/global/vars.h | 6 +++--- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 43623a0..49cbe30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - fixed Lara's shadow with z-buffer option on (#64, regression from 0.1) - fixed rare camera issues (#65, regression from 0.1) - fixed flat rectangle colors (#70, regression from 0.1) +- fixed medpacks staying open after use in Lara's inventory (#69, regression from 0.1) ## [0.1](https://github.com/rr-/TR2X/compare/...0.1) - 2024-04-26 - added version string to the inventory diff --git a/docs/progress.txt b/docs/progress.txt index 5e93553..5324b64 100644 --- a/docs/progress.txt +++ b/docs/progress.txt @@ -3622,8 +3622,8 @@ typedef struct __unaligned { 00525BEC - int32_t g_DynamicLightCount; 004D7784 - int32_t g_CineTickCount; 004D7788 - int32_t g_OriginalRoom; -00465518 - INVENTORY_ITEM *g_Inv_MainList; -00465608 - INVENTORY_ITEM *g_Inv_OptionList; -004655A8 - INVENTORY_ITEM *g_Inv_KeysList; +00465518 - INVENTORY_ITEM *g_Inv_MainList[]; +00465608 - INVENTORY_ITEM *g_Inv_OptionList[]; +004655A8 - INVENTORY_ITEM *g_Inv_KeysList[]; 004644F8 - int32_t g_Inv_NFrames; 00525C00 - STATIC_INFO g_StaticObjects[256]; diff --git a/src/game/inventory.c b/src/game/inventory.c index 41d4519..5528a6f 100644 --- a/src/game/inventory.c +++ b/src/game/inventory.c @@ -54,7 +54,7 @@ void __cdecl Inv_Construct(void) } for (int32_t i = 0; i < g_Inv_MainObjectsCount; i++) { - INVENTORY_ITEM *const inv_item = &g_Inv_MainList[i]; + INVENTORY_ITEM *const inv_item = g_Inv_MainList[i]; inv_item->meshes_drawn = inv_item->meshes_sel; inv_item->current_frame = 0; inv_item->goal_frame = 0; @@ -63,7 +63,7 @@ void __cdecl Inv_Construct(void) } for (int32_t i = 0; i < g_Inv_OptionObjectsCount; i++) { - INVENTORY_ITEM *const inv_item = &g_Inv_OptionList[i]; + INVENTORY_ITEM *const inv_item = g_Inv_OptionList[i]; inv_item->current_frame = 0; inv_item->goal_frame = 0; inv_item->anim_count = 0; @@ -120,24 +120,24 @@ int32_t __cdecl Inv_Display(int32_t inventory_mode) case INV_LOAD_MODE: case INV_DEATH_MODE: Inv_Ring_Init( - &ring, 1, &g_Inv_OptionList, g_Inv_OptionObjectsCount, + &ring, 1, g_Inv_OptionList, g_Inv_OptionObjectsCount, g_Inv_OptionCurrent, &imo); break; case INV_KEYS_MODE: Inv_Ring_Init( - &ring, 2, &g_Inv_KeysList, g_Inv_KeyObjectsCount, g_Inv_MainCurrent, + &ring, 2, g_Inv_KeysList, g_Inv_KeyObjectsCount, g_Inv_MainCurrent, &imo); break; default: if (g_Inv_MainObjectsCount) { Inv_Ring_Init( - &ring, 0, &g_Inv_MainList, g_Inv_MainObjectsCount, + &ring, 0, g_Inv_MainList, g_Inv_MainObjectsCount, g_Inv_MainCurrent, &imo); } else { Inv_Ring_Init( - &ring, 1, &g_Inv_OptionList, g_Inv_OptionObjectsCount, + &ring, 1, g_Inv_OptionList, g_Inv_OptionObjectsCount, g_Inv_OptionCurrent, &imo); } break; @@ -366,13 +366,13 @@ int32_t __cdecl Inv_Display(int32_t inventory_mode) INVENTORY_ITEM *inv_item; if (ring.type == RT_MAIN) { g_Inv_MainCurrent = ring.current_object; - inv_item = *(&g_Inv_MainList + ring.current_object); + inv_item = g_Inv_MainList[ring.current_object]; } else if (ring.type == RT_OPTION) { g_Inv_OptionCurrent = ring.current_object; - inv_item = *(&g_Inv_OptionList + ring.current_object); + inv_item = g_Inv_OptionList[ring.current_object]; } else { g_Inv_KeysCurrent = ring.current_object; - inv_item = *(&g_Inv_KeysList + ring.current_object); + inv_item = g_Inv_KeysList[ring.current_object]; } inv_item->goal_frame = inv_item->open_frame; @@ -476,7 +476,7 @@ int32_t __cdecl Inv_Display(int32_t inventory_mode) ring.camera_pitch = -(int16_t)(imo.misc); imo.camera_pitch_rate = imo.misc / 24; imo.camera_pitch_target = 0; - ring.list = &g_Inv_OptionList; + ring.list = g_Inv_OptionList; ring.type = RT_OPTION; g_Inv_MainCurrent = ring.current_object; g_Inv_MainObjectsCount = ring.number_of_objects; @@ -497,7 +497,7 @@ int32_t __cdecl Inv_Display(int32_t inventory_mode) imo.camera_pitch_rate = imo.misc / 24; g_Inv_MainCurrent = ring.current_object; g_Inv_MainObjectsCount = ring.number_of_objects; - ring.list = &g_Inv_KeysList; + ring.list = g_Inv_KeysList; ring.type = RT_KEYS; ring.number_of_objects = g_Inv_KeyObjectsCount; ring.current_object = g_Inv_KeysCurrent; @@ -514,7 +514,7 @@ int32_t __cdecl Inv_Display(int32_t inventory_mode) ring.camera_pitch = -(int16_t)(imo.misc); imo.camera_pitch_rate = imo.misc / 24; imo.camera_pitch_target = 0; - ring.list = &g_Inv_MainList; + ring.list = g_Inv_MainList; ring.type = RT_MAIN; g_Inv_KeysCurrent = ring.current_object; ring.number_of_objects = g_Inv_MainObjectsCount; @@ -534,7 +534,7 @@ int32_t __cdecl Inv_Display(int32_t inventory_mode) g_Inv_OptionCurrent = ring.current_object; g_Inv_OptionObjectsCount = ring.number_of_objects; imo.camera_pitch_target = 0; - ring.list = &g_Inv_MainList; + ring.list = g_Inv_MainList; ring.type = RT_MAIN; ring.number_of_objects = g_Inv_MainObjectsCount; ring.current_object = g_Inv_MainCurrent; diff --git a/src/global/vars.h b/src/global/vars.h index db8f3d8..19de41c 100644 --- a/src/global/vars.h +++ b/src/global/vars.h @@ -22,10 +22,10 @@ extern const char *g_TR2XVersion; #define g_OverlayStatus (*(int32_t*)0x004644E0) // = 1 #define g_Inv_NFrames (*(int32_t*)0x004644F8) #define g_Inv_MainObjectsCount (*(int16_t*)0x004654E0) // = 8 -#define g_Inv_MainList (*(INVENTORY_ITEM **)0x00465518) -#define g_Inv_KeysList (*(INVENTORY_ITEM **)0x004655A8) +#define g_Inv_MainList (*(INVENTORY_ITEM *(*)[])0x00465518) +#define g_Inv_KeysList (*(INVENTORY_ITEM *(*)[])0x004655A8) #define g_Inv_OptionObjectsCount (*(int16_t*)0x00465604) // = 4 -#define g_Inv_OptionList (*(INVENTORY_ITEM **)0x00465608) +#define g_Inv_OptionList (*(INVENTORY_ITEM *(*)[])0x00465608) #define g_GymInvOpenEnabled (*(BOOL*)0x00465618) // = TRUE #define g_Inv_Chosen (*(int16_t*)0x00465A50) // = -1 #define g_Inv_Mode (*(INVENTORY_MODE*)0x00465A54) // = INV_TITLE_MODE