diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-08-19 22:49:05 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-08-19 22:49:05 +1000 |
commit | 572b492b938f52a0bbc7ef7306c9250bf902727c (patch) | |
tree | 860ac07b65fe326d842b378ff28fb0eaa9b6620b /source/game/StarWorldClient.cpp | |
parent | 3805db77226c1d46beb6e128dea796ab0bd94a63 (diff) |
Fix collision not refreshing on expired predictions and slight placement issue
Diffstat (limited to 'source/game/StarWorldClient.cpp')
-rw-r--r-- | source/game/StarWorldClient.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/source/game/StarWorldClient.cpp b/source/game/StarWorldClient.cpp index 6359a12..b07e488 100644 --- a/source/game/StarWorldClient.cpp +++ b/source/game/StarWorldClient.cpp @@ -1072,13 +1072,18 @@ void WorldClient::update(float dt) { float expireTime = min((float)m_latency + 100, 2000.f); auto now = Time::monotonicMilliseconds(); - eraseWhere(m_predictedTiles, [now, expireTime](auto& pair) { + eraseWhere(m_predictedTiles, [&](auto& pair) { float expiry = (float)(now - pair.second.time) / expireTime; auto center = Vec2F(pair.first) + Vec2F::filled(0.5f); auto size = Vec2F::filled(0.875f - expiry * 0.875f); auto poly = PolyF(RectF::withCenter(center, size)); SpatialLogger::logPoly("world", poly, Color::Cyan.mix(Color::Red, expiry).toRgba()); - return expiry >= 1.0f; + if (expiry >= 1.0f) { + dirtyCollision(RectI::withSize(pair.first, { 1, 1 })); + return true; + } else { + return false; + } }); // Secret broadcasts are transmitted through DamageNotifications for vanilla server compatibility. |