items: replace items by index rather than room

Carried items use NO_ROOM so were not included when replacing guns
with ammo. This ensures everything is checked when replacing IDs.

Resolves #2850.
Resolves #2856.
This commit is contained in:
lahm86 2025-04-26 09:57:06 +01:00
parent 10b9bcc780
commit 0c27247294
3 changed files with 8 additions and 9 deletions

View file

@ -1,4 +1,6 @@
## [Unreleased](https://github.com/LostArtefacts/TRX/compare/tr2-1.0.1...develop) - ××××-××-×× ## [Unreleased](https://github.com/LostArtefacts/TRX/compare/tr2-1.0.1...develop) - ××××-××-××
- fixed guns carried by enemies not being converted to ammo if Lara has picked up the same gun elsewhere in the same level (#2856)
- fixed guns carried by enemies not being converted to ammo if Lara starts the level with the gun and the game has later been reloaded (#2850, regression from 1.0)
## [1.0.1](https://github.com/LostArtefacts/TRX/compare/tr2-1.0...tr2-1.0.1) - 2025-04-24 ## [1.0.1](https://github.com/LostArtefacts/TRX/compare/tr2-1.0...tr2-1.0.1) - 2025-04-24
- added an option to wraparound when scrolling UI dialogs, such as save/load (#2834) - added an option to wraparound when scrolling UI dialogs, such as save/load (#2834)

View file

@ -254,6 +254,7 @@ However, you can easily download them manually from these urls:
- fixed Floating Islands mystic plaque inventory rotation - fixed Floating Islands mystic plaque inventory rotation
- fixed pushblocks being rotated when Lara grabs them, most noticeable if asymmetric textures have been used - fixed pushblocks being rotated when Lara grabs them, most noticeable if asymmetric textures have been used
- fixed being able to use hotkeys in the end-level statistics screen - fixed being able to use hotkeys in the end-level statistics screen
- fixed guns carried by enemies not being converted to ammo if Lara has picked up the same gun elsewhere in the same level
- fixed destroyed gondolas appearing embedded in the ground after loading a save - fixed destroyed gondolas appearing embedded in the ground after loading a save
- improved the animation of Lara's braid - improved the animation of Lara's braid

View file

@ -219,15 +219,11 @@ int32_t Item_GlobalReplace(
{ {
int32_t changed = 0; int32_t changed = 0;
for (int32_t i = 0; i < Room_GetCount(); i++) { for (int32_t item_num = 0; item_num < m_MaxUsedItemCount; item_num++) {
int16_t item_num = Room_Get(i)->item_num; ITEM *const item = &m_Items[item_num];
while (item_num != NO_ITEM) { if (item->object_id == src_obj_id) {
ITEM *const item = &m_Items[item_num]; item->object_id = dst_obj_id;
if (item->object_id == src_obj_id) { changed++;
item->object_id = dst_obj_id;
changed++;
}
item_num = item->next_item;
} }
} }