Browse Source

Fix state of doors after ObjChangeMapResync (#6085)

pull/6088/head
Stephen C. Wills 3 years ago committed by GitHub
parent
commit
acae4d0ee9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 43
      Source/objects.cpp

43
Source/objects.cpp

@ -3644,6 +3644,21 @@ void SyncDoor(Object &door)
}
}
void ResyncDoors(WorldTilePosition p1, WorldTilePosition p2)
{
const WorldTileSize size { static_cast<WorldTileCoord>(p2.x - p1.x), static_cast<WorldTileCoord>(p2.y - p1.y) };
const WorldTileRectangle area { p1, size };
for (WorldTilePosition p : PointsInRectangleRange<WorldTileCoord> { area }) {
Object *obj = FindObjectAtPosition(p);
if (obj == nullptr)
continue;
if (IsNoneOf(obj->_otype, OBJ_L1LDOOR, OBJ_L1RDOOR, OBJ_L2LDOOR, OBJ_L2RDOOR, OBJ_L3LDOOR, OBJ_L3RDOOR, OBJ_L5LDOOR, OBJ_L5RDOOR))
continue;
SyncDoor(*obj);
}
}
void UpdateState(Object &object, int frame)
{
if (object._oSelFlag == 0) {
@ -4349,20 +4364,26 @@ void ObjChangeMap(int x1, int y1, int x2, int y2)
dungeon[i][j] = pdungeon[i][j];
}
}
WorldTilePosition mega1 { static_cast<WorldTileCoord>(x1), static_cast<WorldTileCoord>(y1) };
WorldTilePosition mega2 { static_cast<WorldTileCoord>(x2), static_cast<WorldTileCoord>(y2) };
WorldTilePosition world1 = mega1.megaToWorld();
WorldTilePosition world2 = mega2.megaToWorld() + Displacement { 1, 1 };
if (leveltype == DTYPE_CATHEDRAL) {
ObjL1Special(2 * x1 + 16, 2 * y1 + 16, 2 * x2 + 17, 2 * y2 + 17);
AddL1Objs(2 * x1 + 16, 2 * y1 + 16, 2 * x2 + 17, 2 * y2 + 17);
ObjL1Special(world1.x, world1.y, world2.x, world2.y);
AddL1Objs(world1.x, world1.y, world2.x, world2.y);
}
if (leveltype == DTYPE_CATACOMBS) {
ObjL2Special(2 * x1 + 16, 2 * y1 + 16, 2 * x2 + 17, 2 * y2 + 17);
AddL2Objs(2 * x1 + 16, 2 * y1 + 16, 2 * x2 + 17, 2 * y2 + 17);
ObjL2Special(world1.x, world1.y, world2.x, world2.y);
AddL2Objs(world1.x, world1.y, world2.x, world2.y);
}
if (leveltype == DTYPE_CAVES) {
AddL3Objs(2 * x1 + 16, 2 * y1 + 16, 2 * x2 + 17, 2 * y2 + 17);
AddL3Objs(world1.x, world1.y, world2.x, world2.y);
}
if (leveltype == DTYPE_CRYPT) {
AddCryptObjects(2 * x1 + 16, 2 * y1 + 16, 2 * x2 + 17, 2 * y2 + 17);
AddCryptObjects(world1.x, world1.y, world2.x, world2.y);
}
ResyncDoors(world1, world2);
}
void ObjChangeMapResync(int x1, int y1, int x2, int y2)
@ -4373,12 +4394,18 @@ void ObjChangeMapResync(int x1, int y1, int x2, int y2)
dungeon[i][j] = pdungeon[i][j];
}
}
WorldTilePosition mega1 { static_cast<WorldTileCoord>(x1), static_cast<WorldTileCoord>(y1) };
WorldTilePosition mega2 { static_cast<WorldTileCoord>(x2), static_cast<WorldTileCoord>(y2) };
WorldTilePosition world1 = mega1.megaToWorld();
WorldTilePosition world2 = mega2.megaToWorld() + Displacement { 1, 1 };
if (leveltype == DTYPE_CATHEDRAL) {
ObjL1Special(2 * x1 + 16, 2 * y1 + 16, 2 * x2 + 17, 2 * y2 + 17);
ObjL1Special(world1.x, world1.y, world2.x, world2.y);
}
if (leveltype == DTYPE_CATACOMBS) {
ObjL2Special(2 * x1 + 16, 2 * y1 + 16, 2 * x2 + 17, 2 * y2 + 17);
ObjL2Special(world1.x, world1.y, world2.x, world2.y);
}
ResyncDoors(world1, world2);
}
_item_indexes ItemMiscIdIdx(item_misc_id imiscid)

Loading…
Cancel
Save