movable_block: fix stacking blocks on room portals (#1080)

Resolves #1079.
This commit is contained in:
walkawayy 2023-11-20 21:05:32 -05:00 committed by Marcin Kurczewski
parent bc1faffcec
commit e353b50be8
No known key found for this signature in database
GPG key ID: CC65E6FD28CAE42A
4 changed files with 33 additions and 14 deletions

View file

@ -1,4 +1,5 @@
## [Unreleased](https://github.com/LostArtefacts/TR1X/compare/stable...develop) - ××××-××-×× ## [Unreleased](https://github.com/LostArtefacts/TR1X/compare/stable...develop) - ××××-××-××
- fixed bugs when trying to stack multiple movable blocks (#1079)
## [3.0.5](https://github.com/LostArtefacts/TR1X/compare/3.0.4...3.0.5) - 2023-12-13 ## [3.0.5](https://github.com/LostArtefacts/TR1X/compare/3.0.4...3.0.5) - 2023-12-13
- fixed crash when pressing certain keys and the console is disabled (#1116, regression since 3.0) - fixed crash when pressing certain keys and the console is disabled (#1116, regression since 3.0)

View file

@ -300,6 +300,7 @@ Not all options are turned on by default. Refer to `TR1X_ConfigTool.exe` for det
- **Obelisk of Khamoon**: missing switch trigger type in room 66 - **Obelisk of Khamoon**: missing switch trigger type in room 66
- **Atlantean Stronghold**: fixed poorly configured portals between rooms 74 and 12 - **Atlantean Stronghold**: fixed poorly configured portals between rooms 74 and 12
- fixed various bugs with falling movable blocks - fixed various bugs with falling movable blocks
- fixed bugs when trying to stack multiple movable blocks
#### Cheats #### Cheats
- added a fly cheat - added a fly cheat

View file

@ -77,11 +77,13 @@ static bool MovableBlock_TestDestination(ITEM_INFO *item, int32_t block_height)
int16_t room_num = item->room_number; int16_t room_num = item->room_number;
FLOOR_INFO *floor = FLOOR_INFO *floor =
Room_GetFloor(item->pos.x, item->pos.y, item->pos.z, &room_num); Room_GetFloor(item->pos.x, item->pos.y, item->pos.z, &room_num);
if (floor->floor == NO_HEIGHT / 256) { if (Room_GetHeight(floor, item->pos.x, item->pos.y, item->pos.z)
== NO_HEIGHT) {
return true; return true;
} }
if ((floor->floor << 8) != item->pos.y - block_height) { if (Room_GetHeight(floor, item->pos.x, item->pos.y, item->pos.z)
!= item->pos.y - block_height) {
return false; return false;
} }
@ -123,12 +125,12 @@ static bool MovableBlock_TestPush(
return false; return false;
} }
if (((int32_t)floor->floor << 8) != y) { if (Room_GetHeight(floor, x, y, z) != y) {
return false; return false;
} }
floor = Room_GetFloor(x, y - block_height, z, &room_num); floor = Room_GetFloor(x, y - block_height, z, &room_num);
if (((int32_t)floor->ceiling << 8) > y - block_height) { if (Room_GetCeiling(floor, x, y - block_height, z) > y - block_height) {
return false; return false;
} }
@ -172,12 +174,12 @@ static bool MovableBlock_TestPull(
return false; return false;
} }
if (((int32_t)floor->floor << 8) != y) { if (Room_GetHeight(floor, x, y, z) != y) {
return false; return false;
} }
floor = Room_GetFloor(x, y - block_height, z, &room_num); floor = Room_GetFloor(x, y - block_height, z, &room_num);
if (((int32_t)floor->ceiling << 8) > y - block_height) { if (Room_GetCeiling(floor, x, y - block_height, z) > y - block_height) {
return false; return false;
} }
@ -186,12 +188,12 @@ static bool MovableBlock_TestPull(
room_num = item->room_number; room_num = item->room_number;
floor = Room_GetFloor(x, y, z, &room_num); floor = Room_GetFloor(x, y, z, &room_num);
if (((int32_t)floor->floor << 8) != y) { if (Room_GetHeight(floor, x, y, z) != y) {
return false; return false;
} }
floor = Room_GetFloor(x, y - LARA_HEIGHT, z, &room_num); floor = Room_GetFloor(x, y - LARA_HEIGHT, z, &room_num);
if (((int32_t)floor->ceiling << 8) > y - LARA_HEIGHT) { if (Room_GetCeiling(floor, x, y - LARA_HEIGHT, z) > y - LARA_HEIGHT) {
return false; return false;
} }
@ -242,10 +244,10 @@ void MovableBlock_Control(int16_t item_num)
Item_Animate(item); Item_Animate(item);
int16_t room_num = item->room_number; int16_t room_num = item->room_number;
FLOOR_INFO *floor = FLOOR_INFO *floor = Room_GetFloor(
Room_GetFloor(item->pos.x, item->pos.y, item->pos.z, &room_num); item->pos.x, item->pos.y - STEP_L / 2, item->pos.z, &room_num);
int32_t height = int32_t height = Room_GetHeight(
Room_GetHeight(floor, item->pos.x, item->pos.y, item->pos.z); floor, item->pos.x, item->pos.y - STEP_L / 2, item->pos.z);
if (item->pos.y < height) { if (item->pos.y < height) {
item->gravity_status = 1; item->gravity_status = 1;

View file

@ -640,13 +640,28 @@ void Room_AlterFloorHeight(ITEM_INFO *item, int32_t height)
} }
} while (data != NO_ROOM); } while (data != NO_ROOM);
FLOOR_INFO *f = floor;
while (f->sky_room != NO_ROOM) {
ROOM_INFO *r = &g_RoomInfo[f->sky_room];
int32_t x_floor = (item->pos.z - r->z) >> WALL_SHIFT;
int32_t y_floor = (item->pos.x - r->x) >> WALL_SHIFT;
f = &r->floor[x_floor + y_floor * r->x_size];
}
while (floor->pit_room != NO_ROOM) {
ROOM_INFO *r = &g_RoomInfo[floor->pit_room];
int32_t x_floor = (item->pos.z - r->z) >> WALL_SHIFT;
int32_t y_floor = (item->pos.x - r->x) >> WALL_SHIFT;
floor = &r->floor[x_floor + y_floor * r->x_size];
}
if (floor->floor != NO_HEIGHT / 256) { if (floor->floor != NO_HEIGHT / 256) {
floor->floor += height >> 8; floor->floor += height >> 8;
if (floor->floor == floor->ceiling && floor->sky_room == NO_ROOM) { if (floor->floor == f->ceiling) {
floor->floor = NO_HEIGHT / 256; floor->floor = NO_HEIGHT / 256;
} }
} else { } else {
floor->floor = floor->ceiling + (height >> 8); floor->floor = f->ceiling + (height >> 8);
} }
if (g_Boxes[floor->box].overlap_index & BLOCKABLE) { if (g_Boxes[floor->box].overlap_index & BLOCKABLE) {