1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-24 00:03:11 +01:00

Merge pull request #17933 from Broxzier/bugfix/17931-object-count-command

Fix #17931: The in-game command ‘count_objects’ crashes the game.
This commit is contained in:
Michael Steenbeek
2022-08-31 22:35:52 +02:00
committed by GitHub
2 changed files with 26 additions and 7 deletions

View File

@@ -44,6 +44,7 @@
- Fix: [#17788] Guests could leave queue if another guest rejoins it from the entrance building.
- Fix: [#17834] Finance window becomes blank after 4096 years.
- Fix: [#17905] The chain button in the map window is enabled for rectangular maps when (re)opened.
- Fix: [#17931] The in-game command count_objects crashes the game.
0.4.1 (2022-07-04)
------------------------------------------------------------------------

View File

@@ -59,6 +59,7 @@
#include "Viewport.h"
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdarg>
#include <cstdlib>
@@ -1265,25 +1266,42 @@ static int32_t cc_load_object(InteractiveConsole& console, const arguments_t& ar
return 0;
}
constexpr std::array _objectTypeNames = {
"Rides",
"Small Scenery",
"Large Scenery",
"Walls",
"Banners",
"Paths",
"Path Additions",
"Scenery groups",
"Park entrances",
"Water",
"ScenarioText",
"Terrain Surface",
"Terrain Edges",
"Stations",
"Music",
"Footpath Surface",
"Footpath Railings",
"Audio",
};
static_assert(_objectTypeNames.size() == EnumValue(ObjectType::Count));
static int32_t cc_object_count(InteractiveConsole& console, [[maybe_unused]] const arguments_t& argv)
{
const utf8* object_type_names[] = {
"Rides", "Small scenery", "Large scenery", "Walls", "Banners",
"Paths", "Path Additions", "Scenery groups", "Park entrances", "Water",
};
for (auto objectType : ObjectTypes)
{
int32_t entryGroupIndex = 0;
for (; entryGroupIndex < object_entry_group_counts[EnumValue(objectType)]; entryGroupIndex++)
{
if (object_entry_get_chunk(objectType, entryGroupIndex) == nullptr)
if (object_entry_get_object(objectType, entryGroupIndex) == nullptr)
{
break;
}
}
console.WriteFormatLine(
"%s: %d/%d", object_type_names[EnumValue(objectType)], entryGroupIndex,
"%s: %d/%d", _objectTypeNames[EnumValue(objectType)], entryGroupIndex,
object_entry_group_counts[EnumValue(objectType)]);
}