diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-03-09 12:18:22 +1100 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-03-09 12:18:22 +1100 |
commit | dc7706184094e653dbb46310195e88604c007854 (patch) | |
tree | 38081a61390521c2778dff44b757ea7a66a84d14 /source/game/StarWorldTiles.cpp | |
parent | 165bcbefee1c6c0f73553190ecffadcfdf40f16d (diff) |
hopefully fix #33
in OpenStarbound, players can place blocks with their own collision type. this can cause objects to override the collision type if the object has material spaces and a previous attempt at accounting for this led to that bug: giving object collision its own field in the server tile should fix this
Diffstat (limited to 'source/game/StarWorldTiles.cpp')
-rw-r--r-- | source/game/StarWorldTiles.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/source/game/StarWorldTiles.cpp b/source/game/StarWorldTiles.cpp index 20ced8d..826bfbb 100644 --- a/source/game/StarWorldTiles.cpp +++ b/source/game/StarWorldTiles.cpp @@ -26,7 +26,7 @@ bool WorldTile::isColliding(CollisionSet const& collisionSet) const { VersionNumber const ServerTile::CurrentSerializationVersion = 418; -ServerTile::ServerTile() {} +ServerTile::ServerTile() : objectCollision(CollisionKind::None) {} ServerTile::ServerTile(ServerTile const& serverTile) : WorldTile() { *this = serverTile; @@ -37,7 +37,7 @@ ServerTile& ServerTile::operator=(ServerTile const& serverTile) { liquid = serverTile.liquid; rootSource = serverTile.rootSource; - + objectCollision = serverTile.objectCollision; return *this; } @@ -109,6 +109,25 @@ bool ServerTile::updateCollision(CollisionKind kind) { return false; } +bool ServerTile::updateObjectCollision(CollisionKind kind) { + if (objectCollision != kind) { + objectCollision = kind; + collisionCacheDirty = true; + collisionCache.clear(); + return true; + } + return false; +} + +CollisionKind ServerTile::getCollision() const { + CollisionKind kind = collision; + if (objectCollision != CollisionKind::None + && (objectCollision != CollisionKind::Platform || kind == CollisionKind::None)) { + kind = objectCollision; + } + return kind; +} + PredictedTile::operator bool() const { return background |