diff --git a/contributors.md b/contributors.md index f3a46fc8a5..7096e4e934 100644 --- a/contributors.md +++ b/contributors.md @@ -103,6 +103,7 @@ The following people are not part of the project team, but have been contributin * Tyler Ruckinger (TyPR124) * Justin Gottula (jgottula) * Seongsik Park (pss9205) +* (Deurklink) ## Toolchain * (Balletie) - macOS diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 44759befaa..f95951eece 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -110,6 +110,7 @@ - Fix: [#7003] Building sloped paths through flat paths with clearance checks off causes glitches. - Fix: [#7011] Swinging and bobsleigh cars going backwards swing in the wrong direction (original bug). - Fix: [#7125] No entry signs not correctly handled in pathfinding. +- Fix: [#7223] Vehicle mass not correctly recalculated when using remove all guests cheat. - Fix: Infinite loop when removing scenery elements with >127 base height. - Fix: Ghosting of transparent map elements when the viewport is moved in OpenGL mode. - Fix: Clear IME buffer after committing composed text. diff --git a/src/openrct2/Cheats.cpp b/src/openrct2/Cheats.cpp index d3ed2e3098..db61bdef79 100644 --- a/src/openrct2/Cheats.cpp +++ b/src/openrct2/Cheats.cpp @@ -355,15 +355,6 @@ static void cheat_remove_all_guests() rct_peep *peep; rct_vehicle *vehicle; uint16 spriteIndex, nextSpriteIndex; - - for (spriteIndex = gSpriteListHead[SPRITE_LIST_PEEP]; spriteIndex != SPRITE_INDEX_NULL; spriteIndex = nextSpriteIndex) { - peep = &(get_sprite(spriteIndex)->peep); - nextSpriteIndex = peep->next; - if (peep->type == PEEP_TYPE_GUEST) { - peep_remove(peep); - } - } - sint32 rideIndex; Ride *ride; @@ -384,19 +375,33 @@ static void cheat_remove_all_guests() { vehicle = GET_VEHICLE(spriteIndex); - vehicle->num_peeps = 0; - vehicle->next_free_seat = 0; + for (size_t i = 0; i < vehicle->num_peeps; i++) + { + peep = GET_PEEP(vehicle->peep[i]); + vehicle->mass -= peep->mass; + } for (auto &peepInTrainIndex : vehicle->peep) { peepInTrainIndex = SPRITE_INDEX_NULL; } + vehicle->num_peeps = 0; + vehicle->next_free_seat = 0; + spriteIndex = vehicle->next_vehicle_on_train; } } } + for (spriteIndex = gSpriteListHead[SPRITE_LIST_PEEP]; spriteIndex != SPRITE_INDEX_NULL; spriteIndex = nextSpriteIndex) { + peep = &(get_sprite(spriteIndex)->peep); + nextSpriteIndex = peep->next; + if (peep->type == PEEP_TYPE_GUEST) { + peep_remove(peep); + } + } + window_invalidate_by_class(WC_RIDE); gfx_invalidate_screen(); }