tr2/objects/window: unblock box on savegame load

This ensures that the box where a window sits is unblocked if the
window has already been smashed and the game is loaded from a save.

Resolves #2535.
This commit is contained in:
lahm86 2025-02-20 14:54:40 +00:00
parent 6cb1a5ebfa
commit a187d535a7
3 changed files with 16 additions and 20 deletions

View file

@ -1,4 +1,5 @@
## [Unreleased](https://github.com/LostArtefacts/TRX/compare/tr2-0.9.2...develop) - ××××-××-××
- fixed smashed windows blocking enemy pathing after loading a save (#2535)
## [0.9.2](https://github.com/LostArtefacts/TRX/compare/tr2-0.9.1...tr2-0.9.2) - 2025-02-19
- fixed secret rewards not handed out after loading a save (#2528, regression from 0.8)

View file

@ -77,6 +77,7 @@ game with new enhancements and features.
- **Temple of Xian**: fixed missing death tiles in room 91
- **Floating Islands**: fixed door 72's position to resolve the invisible wall in front of it
- fixed the game crashing if a cinematic is triggered but the level contains no cinematic frames
- fixed smashed windows blocking enemy pathing after loading a save
- improved the animation of Lara's braid
#### Cheats

View file

@ -18,6 +18,7 @@ static void M_Initialise(int16_t item_num);
static void M_HandleSave(ITEM *item, SAVEGAME_STAGE stage);
static void M_Control1(int16_t item_num);
static void M_Control2(int16_t item_num);
static void M_SetBoxBlocked(const ITEM *item, bool blocked);
static void M_SetupBase(OBJECT *const obj)
{
@ -45,15 +46,7 @@ static void M_Initialise(const int16_t item_num)
ITEM *const item = Item_Get(item_num);
item->flags = 0;
item->mesh_bits = 1;
const ROOM *const room = Room_Get(item->room_num);
const SECTOR *const sector =
Room_GetWorldSector(room, item->pos.x, item->pos.z);
BOX_INFO *const box = Box_GetBox(sector->box);
if (box->overlap_index & BOX_BLOCKABLE) {
box->overlap_index |= BOX_BLOCKED;
}
M_SetBoxBlocked(item, true);
}
static void M_HandleSave(ITEM *const item, const SAVEGAME_STAGE stage)
@ -62,6 +55,7 @@ static void M_HandleSave(ITEM *const item, const SAVEGAME_STAGE stage)
if ((item->object_id == O_WINDOW_1 || item->object_id == O_WINDOW_2)
&& (item->flags & IF_ONE_SHOT)) {
item->mesh_bits = 0x100;
M_SetBoxBlocked(item, false);
}
}
}
@ -95,14 +89,7 @@ static void M_Control2(const int16_t item_num)
return;
}
const ROOM *const room = Room_Get(item->room_num);
const SECTOR *const sector =
Room_GetWorldSector(room, item->pos.x, item->pos.z);
BOX_INFO *const box = Box_GetBox(sector->box);
if (box->overlap_index & BOX_BLOCKED) {
box->overlap_index &= ~BOX_BLOCKED;
}
M_SetBoxBlocked(item, false);
item->mesh_bits = ~1;
item->collidable = 0;
@ -114,17 +101,24 @@ static void M_Control2(const int16_t item_num)
Item_RemoveActive(item_num);
}
void Window_Smash(const int16_t item_num)
static void M_SetBoxBlocked(const ITEM *const item, const bool blocked)
{
ITEM *const item = Item_Get(item_num);
const ROOM *const room = Room_Get(item->room_num);
const SECTOR *const sector =
Room_GetWorldSector(room, item->pos.x, item->pos.z);
BOX_INFO *const box = Box_GetBox(sector->box);
if (box->overlap_index & BOX_BLOCKABLE) {
if (blocked && (box->overlap_index & BOX_BLOCKABLE) != 0) {
box->overlap_index |= BOX_BLOCKED;
} else if (!blocked && (box->overlap_index & BOX_BLOCKED) != 0) {
box->overlap_index &= ~BOX_BLOCKED;
}
}
void Window_Smash(const int16_t item_num)
{
ITEM *const item = Item_Get(item_num);
M_SetBoxBlocked(item, false);
item->collidable = 0;
item->mesh_bits = ~1;