1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-16 03:23:15 +01:00

Read JSON for park entrance objects

This commit is contained in:
Ted John
2017-12-07 23:50:44 +00:00
committed by Gymnasiast
parent 1e4a8c0da7
commit 2d037fb3ae
3 changed files with 35 additions and 5 deletions

View File

@@ -205,6 +205,19 @@ namespace ObjectFactory
return result;
}
static uint8 ParseObjectType(const std::string &s)
{
if (s == "ride")
{
return OBJECT_TYPE_RIDE;
}
else if (s == "park_entrance")
{
return OBJECT_TYPE_PARK_ENTRANCE;
}
return 0xFF;
}
Object * CreateObjectFromJsonFile(const std::string &path)
{
log_verbose("CreateObjectFromJsonFile(\"%s\")", path.c_str());
@@ -216,8 +229,8 @@ namespace ObjectFactory
auto jObjectType = json_object_get(jRoot, "objectType");
if (json_is_string(jObjectType))
{
auto objectType = std::string(json_string_value(jObjectType));
if (objectType == "ride")
auto objectType = ParseObjectType(json_string_value(jObjectType));
if (objectType != 0xFF)
{
auto id = json_string_value(json_object_get(jRoot, "id"));
@@ -233,7 +246,7 @@ namespace ObjectFactory
auto minLength = std::min<size_t>(8, originalName.length());
memcpy(entry.name, originalName.c_str(), minLength);
result = new RideObject(entry);
result = CreateObject(entry);
auto readContext = ReadObjectContext(id);
result->ReadJson(&readContext, jRoot);
if (readContext.WasError())