Fix constant tile entity space updates

This commit is contained in:
Kae 2023-11-30 21:48:31 +11:00
parent 8d0dcd11d7
commit 2a56c3f9e3
2 changed files with 10 additions and 6 deletions

View File

@ -1538,15 +1538,20 @@ void WorldServer::updateTileEntityTiles(TileEntityPtr const& entity, bool removi
if (tile && (tile->foreground == EmptyMaterialId || tile->foreground == materialSpace.material)) { if (tile && (tile->foreground == EmptyMaterialId || tile->foreground == materialSpace.material)) {
tile->foreground = materialSpace.material; tile->foreground = materialSpace.material;
tile->foregroundMod = NoModId; tile->foregroundMod = NoModId;
bool hadRoot = tile->rootSource.isValid();
if (isRealMaterial(materialSpace.material)) if (isRealMaterial(materialSpace.material))
tile->rootSource = entity->tilePosition(); tile->rootSource = entity->tilePosition();
passedSpaces.emplaceAppend(materialSpace).prevCollision.emplace(tile->collision); auto& space = passedSpaces.emplaceAppend(materialSpace);
if (hadRoot)
space.prevCollision.emplace(tile->collision);
updatedCollision = tile->updateCollision(materialDatabase->materialCollisionKind(tile->foreground)); updatedCollision = tile->updateCollision(materialDatabase->materialCollisionKind(tile->foreground));
updated = true; updated = true;
passedSpaces.emplaceAppend(materialSpace);
} }
else if (tile && tile->collision < CollisionKind::Dynamic) { else if (tile && tile->collision < CollisionKind::Dynamic) {
passedSpaces.emplaceAppend(materialSpace).prevCollision.emplace(tile->collision); bool hadRoot = tile->rootSource.isValid();
auto& space = passedSpaces.emplaceAppend(materialSpace);
if (hadRoot)
space.prevCollision.emplace(tile->collision);
updatedCollision = tile->updateCollision(materialDatabase->materialCollisionKind(materialSpace.material)); updatedCollision = tile->updateCollision(materialDatabase->materialCollisionKind(materialSpace.material));
updated = true; updated = true;
} }

View File

@ -18,7 +18,7 @@ struct MaterialSpace {
Vec2I space; Vec2I space;
MaterialId material; MaterialId material;
Maybe<CollisionKind> prevCollision; Maybe<CollisionKind> prevCollision; //exclude from ==
}; };
DataStream& operator<<(DataStream& ds, MaterialSpace const& materialSpace); DataStream& operator<<(DataStream& ds, MaterialSpace const& materialSpace);
@ -92,8 +92,7 @@ inline MaterialSpace::MaterialSpace(Vec2I space, MaterialId material)
inline bool MaterialSpace::operator==(MaterialSpace const& rhs) const { inline bool MaterialSpace::operator==(MaterialSpace const& rhs) const {
return space == rhs.space return space == rhs.space
&& material == rhs.material && material == rhs.material;
&& prevCollision == rhs.prevCollision;
} }
} }