From 68485e20d046267f5040a7cbec9e58686674d1d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Wed, 31 May 2023 18:21:33 +0300 Subject: [PATCH 1/4] Revert #20286 --- src/openrct2/entity/EntityBase.h | 10 ---------- src/openrct2/entity/EntityRegistry.cpp | 8 -------- src/openrct2/entity/EntityTweener.cpp | 8 -------- 3 files changed, 26 deletions(-) diff --git a/src/openrct2/entity/EntityBase.h b/src/openrct2/entity/EntityBase.h index e8a165d610..89ba30b514 100644 --- a/src/openrct2/entity/EntityBase.h +++ b/src/openrct2/entity/EntityBase.h @@ -35,14 +35,6 @@ struct EntitySpriteData ScreenRect SpriteRect; }; -namespace EntityRenderFlags -{ - // Disables tweening for this tick, this is helpful when entities are teleported - // and should not be tweened. - constexpr uint32_t kInvalidateTweening = (1U << 0); - -} // namespace EntityRenderFlags - struct EntityBase { EntityType Type; @@ -50,8 +42,6 @@ struct EntityBase int32_t x; int32_t y; int32_t z; - // Rendering specific flags, this should not be stored in the save file. - uint32_t RenderFlags; EntitySpriteData SpriteData; // Used as direction or rotation depending on the entity. uint8_t Orientation; diff --git a/src/openrct2/entity/EntityRegistry.cpp b/src/openrct2/entity/EntityRegistry.cpp index 8c27584cdd..b123f222f1 100644 --- a/src/openrct2/entity/EntityRegistry.cpp +++ b/src/openrct2/entity/EntityRegistry.cpp @@ -273,7 +273,6 @@ static void EntityReset(EntityBase* entity) entity->Id = entityIndex; entity->Type = EntityType::Null; - entity->RenderFlags = 0; } static constexpr uint16_t MAX_MISC_SPRITES = 300; @@ -473,13 +472,6 @@ void EntityBase::MoveTo(const CoordsXYZ& newLocation) EntitySetCoordinates(loc, this); Invalidate(); // Invalidate new position. } - - if (!gInUpdateCode) - { - // Make sure we don't tween when the position was modified outside of the - // update loop. - RenderFlags |= EntityRenderFlags::kInvalidateTweening; - } } void EntitySetCoordinates(const CoordsXYZ& entityPos, EntityBase* entity) diff --git a/src/openrct2/entity/EntityTweener.cpp b/src/openrct2/entity/EntityTweener.cpp index 6676edab46..8f724fe2ca 100644 --- a/src/openrct2/entity/EntityTweener.cpp +++ b/src/openrct2/entity/EntityTweener.cpp @@ -18,8 +18,6 @@ void EntityTweener::AddEntity(EntityBase* entity) { - entity->RenderFlags &= ~EntityRenderFlags::kInvalidateTweening; - Entities.push_back(entity); PrePos.emplace_back(entity->GetLocation()); } @@ -92,9 +90,6 @@ void EntityTweener::Tween(float alpha) if (ent == nullptr) continue; - if (ent->RenderFlags & EntityRenderFlags::kInvalidateTweening) - continue; - auto& posA = PrePos[i]; auto& posB = PostPos[i]; @@ -118,9 +113,6 @@ void EntityTweener::Restore() if (ent == nullptr) continue; - if (ent->RenderFlags & EntityRenderFlags::kInvalidateTweening) - continue; - EntitySetCoordinates(PostPos[i], ent); ent->Invalidate(); } From 0f00ad2dd2242020c5fe7212cd126b3f1892ff69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Thu, 1 Jun 2023 01:17:02 +0300 Subject: [PATCH 2/4] Signal that we are inside the update phase in the right function --- src/openrct2/GameState.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/openrct2/GameState.cpp b/src/openrct2/GameState.cpp index 7a419840c3..45d01d0836 100644 --- a/src/openrct2/GameState.cpp +++ b/src/openrct2/GameState.cpp @@ -109,8 +109,6 @@ void GameState::Tick() { PROFILED_FUNCTION(); - gInUpdateCode = true; - // Normal game play will update only once every GAME_UPDATE_TIME_MS uint32_t numUpdates = 1; @@ -250,7 +248,6 @@ void GameState::Tick() } gDoSingleUpdate = false; - gInUpdateCode = false; } void GameState::UpdateLogic(LogicTimings* timings) @@ -266,6 +263,8 @@ void GameState::UpdateLogic(LogicTimings* timings) } }; + gInUpdateCode = true; + gScreenAge++; if (gScreenAge == 0) gScreenAge--; @@ -290,6 +289,7 @@ void GameState::UpdateLogic(LogicTimings* timings) // Don't run past the server, this condition can happen during map changes. if (NetworkGetServerTick() == gCurrentTicks) { + gInUpdateCode = false; return; } @@ -397,6 +397,8 @@ void GameState::UpdateLogic(LogicTimings* timings) { timings->CurrentIdx = (timings->CurrentIdx + 1) % LOGIC_UPDATE_MEASUREMENTS_COUNT; } + + gInUpdateCode = false; } void GameState::CreateStateSnapshot() From cba6238ede09c837d2dd2d8a42f1d3133bfbc41b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Thu, 1 Jun 2023 01:20:31 +0300 Subject: [PATCH 3/4] Queue game actions when issued from UI --- src/openrct2/actions/GameAction.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/openrct2/actions/GameAction.cpp b/src/openrct2/actions/GameAction.cpp index c4cda77ac6..637a61520f 100644 --- a/src/openrct2/actions/GameAction.cpp +++ b/src/openrct2/actions/GameAction.cpp @@ -334,10 +334,11 @@ namespace GameActions return result; } } - else if (NetworkGetMode() == NETWORK_MODE_SERVER) + else if (NetworkGetMode() == NETWORK_MODE_SERVER || !gInUpdateCode) { // If player is the server it would execute right away as where clients execute the commands // at the beginning of the frame, so we have to put them into the queue. + // This is also the case when its executed from the UI update. if (!(actionFlags & GameActions::Flags::ClientOnly) && !(flags & GAME_COMMAND_FLAG_NETWORKED)) { LOG_VERBOSE("[%s] GameAction::Execute %s (Queue)", GetRealm(), action->GetName()); From c4c3743a6b799ef39079591f5197eea4a6ba199f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Thu, 1 Jun 2023 01:25:07 +0300 Subject: [PATCH 4/4] Fix formatting --- src/openrct2/GameState.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openrct2/GameState.cpp b/src/openrct2/GameState.cpp index 45d01d0836..3f3fb39184 100644 --- a/src/openrct2/GameState.cpp +++ b/src/openrct2/GameState.cpp @@ -264,7 +264,7 @@ void GameState::UpdateLogic(LogicTimings* timings) }; gInUpdateCode = true; - + gScreenAge++; if (gScreenAge == 0) gScreenAge--;