From 91cf22aede37dddb08c008ec4719f045564a6df0 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Tue, 17 Dec 2024 20:40:49 +0100 Subject: [PATCH] Reset all peep sprite bounds at save file import time --- src/openrct2/Game.cpp | 3 +++ src/openrct2/entity/Peep.cpp | 15 ++++++++++++++- src/openrct2/entity/Peep.h | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index 7507550059..b641024f3a 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -337,6 +337,9 @@ void GameFixSaveVars() UpdateConsolidatedPatrolAreas(); MapCountRemainingLandRights(); + + // Update sprite bounds, rather than relying on stored data + PeepUpdateAllBoundingBoxes(); } void GameLoadInit() diff --git a/src/openrct2/entity/Peep.cpp b/src/openrct2/entity/Peep.cpp index f3c4b8050f..aee2996657 100644 --- a/src/openrct2/entity/Peep.cpp +++ b/src/openrct2/entity/Peep.cpp @@ -244,6 +244,19 @@ void PeepUpdateAll() } } +void PeepUpdateAllBoundingBoxes() +{ + for (auto* peep : EntityList()) + { + peep->UpdateSpriteBoundingBox(); + } + + for (auto* peep : EntityList()) + { + peep->UpdateSpriteBoundingBox(); + } +} + /* * rct2: 0x68F3AE * Set peep state to falling if path below has gone missing, return true if current path is valid, false if peep starts falling. @@ -360,7 +373,7 @@ void Peep::UpdateCurrentAnimationType() void Peep::UpdateSpriteBoundingBox() { - const& auto spriteBounds = GetSpriteBounds(AnimationGroup, AnimationType); + const auto& spriteBounds = GetSpriteBounds(AnimationGroup, AnimationType); SpriteData.Width = spriteBounds.sprite_width; SpriteData.HeightMin = spriteBounds.sprite_height_negative; SpriteData.HeightMax = spriteBounds.sprite_height_positive; diff --git a/src/openrct2/entity/Peep.h b/src/openrct2/entity/Peep.h index 69b6b59f3e..ec6fdeb6f6 100644 --- a/src/openrct2/entity/Peep.h +++ b/src/openrct2/entity/Peep.h @@ -436,6 +436,7 @@ extern const bool gAnimationGroupToSlowWalkMap[48]; int32_t PeepGetStaffCount(); void PeepUpdateAll(); +void PeepUpdateAllBoundingBoxes(); void PeepProblemWarningsUpdate(); void PeepStopCrowdNoise(); void PeepUpdateCrowdNoise();