mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-18 12:33:17 +01:00
Update object manager API to access new object types (#24009)
* Update object manager API to access new object types * Use separate mapping for scripting due to different type names * Amend changelog
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include "../PlatformEnvironment.h"
|
||||
#include "../audio/Audio.h"
|
||||
#include "../core/Console.hpp"
|
||||
#include "../core/EnumMap.hpp"
|
||||
#include "../core/File.h"
|
||||
#include "../core/FileStream.h"
|
||||
#include "../core/Json.hpp"
|
||||
@@ -404,50 +405,29 @@ namespace OpenRCT2::ObjectFactory
|
||||
return result;
|
||||
}
|
||||
|
||||
static ObjectType ParseObjectType(const std::string& s)
|
||||
{
|
||||
if (s == "ride")
|
||||
return ObjectType::ride;
|
||||
if (s == "footpath_banner")
|
||||
return ObjectType::banners;
|
||||
if (s == "footpath_item")
|
||||
return ObjectType::pathAdditions;
|
||||
if (s == "scenery_small")
|
||||
return ObjectType::smallScenery;
|
||||
if (s == "scenery_large")
|
||||
return ObjectType::largeScenery;
|
||||
if (s == "scenery_wall")
|
||||
return ObjectType::walls;
|
||||
if (s == "scenery_group")
|
||||
return ObjectType::sceneryGroup;
|
||||
if (s == "park_entrance")
|
||||
return ObjectType::parkEntrance;
|
||||
if (s == "water")
|
||||
return ObjectType::water;
|
||||
if (s == "scenario_text")
|
||||
return ObjectType::scenarioText;
|
||||
if (s == "terrain_surface")
|
||||
return ObjectType::terrainSurface;
|
||||
if (s == "terrain_edge")
|
||||
return ObjectType::terrainEdge;
|
||||
if (s == "station")
|
||||
return ObjectType::station;
|
||||
if (s == "music")
|
||||
return ObjectType::music;
|
||||
if (s == "footpath_surface")
|
||||
return ObjectType::footpathSurface;
|
||||
if (s == "footpath_railings")
|
||||
return ObjectType::footpathRailings;
|
||||
if (s == "audio")
|
||||
return ObjectType::audio;
|
||||
if (s == "peep_names")
|
||||
return ObjectType::peepNames;
|
||||
if (s == "peep_animations")
|
||||
return ObjectType::peepAnimations;
|
||||
if (s == "climate")
|
||||
return ObjectType::climate;
|
||||
return ObjectType::none;
|
||||
}
|
||||
static const EnumMap<ObjectType> kObjectTypeMap = {
|
||||
{ "ride", ObjectType::ride },
|
||||
{ "scenery_small", ObjectType::smallScenery },
|
||||
{ "scenery_large", ObjectType::largeScenery },
|
||||
{ "scenery_wall", ObjectType::walls },
|
||||
{ "footpath_banner", ObjectType::banners },
|
||||
{ "footpath_legacy", ObjectType::paths },
|
||||
{ "footpath_item", ObjectType::pathAdditions },
|
||||
{ "scenery_group", ObjectType::sceneryGroup },
|
||||
{ "park_entrance", ObjectType::parkEntrance },
|
||||
{ "water", ObjectType::water },
|
||||
{ "scenario_text", ObjectType::scenarioText },
|
||||
{ "terrain_surface", ObjectType::terrainSurface },
|
||||
{ "terrain_edge", ObjectType::terrainEdge },
|
||||
{ "station", ObjectType::station },
|
||||
{ "music", ObjectType::music },
|
||||
{ "footpath_surface", ObjectType::footpathSurface },
|
||||
{ "footpath_railings", ObjectType::footpathRailings },
|
||||
{ "audio", ObjectType::audio },
|
||||
{ "peep_names", ObjectType::peepNames },
|
||||
{ "peep_animations", ObjectType::peepAnimations },
|
||||
{ "climate", ObjectType::climate },
|
||||
};
|
||||
|
||||
std::unique_ptr<Object> CreateObjectFromZipFile(IObjectRepository& objectRepository, std::string_view path, bool loadImages)
|
||||
{
|
||||
@@ -544,9 +524,10 @@ namespace OpenRCT2::ObjectFactory
|
||||
|
||||
std::unique_ptr<Object> result;
|
||||
|
||||
auto objectType = ParseObjectType(Json::GetString(jRoot["objectType"]));
|
||||
if (objectType != ObjectType::none)
|
||||
auto lookup = kObjectTypeMap.find(Json::GetString(jRoot["objectType"]));
|
||||
if (lookup != kObjectTypeMap.end())
|
||||
{
|
||||
auto objectType = lookup->second;
|
||||
auto id = Json::GetString(jRoot["id"]);
|
||||
|
||||
// Base audio files are renamed to a common, virtual name so asset packs can override it correctly.
|
||||
|
||||
Reference in New Issue
Block a user