mirror of https://github.com/OpenRCT2/OpenRCT2.git
clang-format object
This commit is contained in:
parent
e32189fd98
commit
a6a12af1ec
|
@ -7,12 +7,13 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include "BannerObject.h"
|
||||||
|
|
||||||
#include "../core/IStream.hpp"
|
#include "../core/IStream.hpp"
|
||||||
#include "../drawing/Drawing.h"
|
#include "../drawing/Drawing.h"
|
||||||
#include "../localisation/Language.h"
|
#include "../localisation/Language.h"
|
||||||
#include "../object/Object.h"
|
#include "../object/Object.h"
|
||||||
#include "../object/ObjectRepository.h"
|
#include "../object/ObjectRepository.h"
|
||||||
#include "BannerObject.h"
|
|
||||||
#include "ObjectJsonHelpers.h"
|
#include "ObjectJsonHelpers.h"
|
||||||
#include "ObjectList.h"
|
#include "ObjectList.h"
|
||||||
|
|
||||||
|
@ -47,9 +48,9 @@ void BannerObject::ReadLegacy(IReadObjectContext * context, IStream * stream)
|
||||||
if (item != nullptr)
|
if (item != nullptr)
|
||||||
{
|
{
|
||||||
auto objectEntry = &item->ObjectEntry;
|
auto objectEntry = &item->ObjectEntry;
|
||||||
if (object_entry_get_source_game(objectEntry) == OBJECT_SOURCE_WACKY_WORLDS ||
|
if (object_entry_get_source_game(objectEntry) == OBJECT_SOURCE_WACKY_WORLDS
|
||||||
object_entry_get_source_game(objectEntry) == OBJECT_SOURCE_TIME_TWISTER ||
|
|| object_entry_get_source_game(objectEntry) == OBJECT_SOURCE_TIME_TWISTER
|
||||||
object_entry_get_source_game(objectEntry) == OBJECT_SOURCE_CUSTOM)
|
|| object_entry_get_source_game(objectEntry) == OBJECT_SOURCE_CUSTOM)
|
||||||
{
|
{
|
||||||
auto scgPathX = Object::GetScgPathXHeader();
|
auto scgPathX = Object::GetScgPathXHeader();
|
||||||
SetPrimarySceneryGroup(&scgPathX);
|
SetPrimarySceneryGroup(&scgPathX);
|
||||||
|
@ -89,8 +90,8 @@ void BannerObject::ReadJson(IReadObjectContext * context, const json_t * root)
|
||||||
|
|
||||||
_legacyType.banner.scrolling_mode = json_integer_value(json_object_get(properties, "scrollingMode"));
|
_legacyType.banner.scrolling_mode = json_integer_value(json_object_get(properties, "scrollingMode"));
|
||||||
_legacyType.banner.price = json_integer_value(json_object_get(properties, "price"));
|
_legacyType.banner.price = json_integer_value(json_object_get(properties, "price"));
|
||||||
_legacyType.banner.flags = ObjectJsonHelpers::GetFlags<uint8_t>(properties, {
|
_legacyType.banner.flags
|
||||||
{ "hasPrimaryColour", BANNER_ENTRY_FLAG_HAS_PRIMARY_COLOUR }});
|
= ObjectJsonHelpers::GetFlags<uint8_t>(properties, { { "hasPrimaryColour", BANNER_ENTRY_FLAG_HAS_PRIMARY_COLOUR } });
|
||||||
|
|
||||||
SetPrimarySceneryGroup(ObjectJsonHelpers::GetString(json_object_get(properties, "sceneryGroup")));
|
SetPrimarySceneryGroup(ObjectJsonHelpers::GetString(json_object_get(properties, "sceneryGroup")));
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "SceneryObject.h"
|
|
||||||
|
|
||||||
#include "../world/Scenery.h"
|
#include "../world/Scenery.h"
|
||||||
|
#include "SceneryObject.h"
|
||||||
|
|
||||||
class BannerObject final : public SceneryObject
|
class BannerObject final : public SceneryObject
|
||||||
{
|
{
|
||||||
|
@ -19,9 +18,15 @@ private:
|
||||||
rct_scenery_entry _legacyType = {};
|
rct_scenery_entry _legacyType = {};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit BannerObject(const rct_object_entry &entry) : SceneryObject(entry) { }
|
explicit BannerObject(const rct_object_entry& entry)
|
||||||
|
: SceneryObject(entry)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void * GetLegacyData() override { return &_legacyType; }
|
void* GetLegacyData() override
|
||||||
|
{
|
||||||
|
return &_legacyType;
|
||||||
|
}
|
||||||
|
|
||||||
void ReadLegacy(IReadObjectContext* context, IStream* stream) override;
|
void ReadLegacy(IReadObjectContext* context, IStream* stream) override;
|
||||||
void ReadJson(IReadObjectContext* context, const json_t* root) override;
|
void ReadJson(IReadObjectContext* context, const json_t* root) override;
|
||||||
|
|
|
@ -8,11 +8,11 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "DefaultObjects.h"
|
#include "DefaultObjects.h"
|
||||||
|
|
||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
|
|
||||||
/** rct2: 0x0098DA74 */
|
/** rct2: 0x0098DA74 */
|
||||||
const rct_object_entry RequiredSelectedObjects[7] =
|
const rct_object_entry RequiredSelectedObjects[7] = {
|
||||||
{
|
|
||||||
// Objects that are always required
|
// Objects that are always required
|
||||||
{ 0x00000087, { "SCGTREES" } }, // Scenery: Trees
|
{ 0x00000087, { "SCGTREES" } }, // Scenery: Trees
|
||||||
{ 0x00000087, { "SCGSHRUB" } }, // Scenery: Shrubs and Ornaments
|
{ 0x00000087, { "SCGSHRUB" } }, // Scenery: Shrubs and Ornaments
|
||||||
|
@ -23,8 +23,7 @@ const rct_object_entry RequiredSelectedObjects[7] =
|
||||||
{ 0x00000085, { "TARMAC " } }, // Footpath: Tarmac
|
{ 0x00000085, { "TARMAC " } }, // Footpath: Tarmac
|
||||||
};
|
};
|
||||||
|
|
||||||
const rct_object_entry DefaultSelectedObjects[26] =
|
const rct_object_entry DefaultSelectedObjects[26] = {
|
||||||
{
|
|
||||||
// An initial default selection
|
// An initial default selection
|
||||||
{ 0x00000080, { "TWIST1 " } }, // Ride: Twist
|
{ 0x00000080, { "TWIST1 " } }, // Ride: Twist
|
||||||
{ 0x00000080, { "PTCT1 " } }, // Ride: Wooden Roller Coaster (Wooden Roller Coaster Trains)
|
{ 0x00000080, { "PTCT1 " } }, // Ride: Wooden Roller Coaster (Wooden Roller Coaster Trains)
|
||||||
|
|
|
@ -7,11 +7,12 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include "EntranceObject.h"
|
||||||
|
|
||||||
#include "../core/IStream.hpp"
|
#include "../core/IStream.hpp"
|
||||||
#include "../core/String.hpp"
|
#include "../core/String.hpp"
|
||||||
#include "../drawing/Drawing.h"
|
#include "../drawing/Drawing.h"
|
||||||
#include "../localisation/Localisation.h"
|
#include "../localisation/Localisation.h"
|
||||||
#include "EntranceObject.h"
|
|
||||||
#include "ObjectJsonHelpers.h"
|
#include "ObjectJsonHelpers.h"
|
||||||
|
|
||||||
void EntranceObject::ReadLegacy(IReadObjectContext* context, IStream* stream)
|
void EntranceObject::ReadLegacy(IReadObjectContext* context, IStream* stream)
|
||||||
|
|
|
@ -9,9 +9,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Object.h"
|
|
||||||
|
|
||||||
#include "../world/Entrance.h"
|
#include "../world/Entrance.h"
|
||||||
|
#include "Object.h"
|
||||||
|
|
||||||
class EntranceObject final : public Object
|
class EntranceObject final : public Object
|
||||||
{
|
{
|
||||||
|
@ -19,9 +18,15 @@ private:
|
||||||
rct_entrance_type _legacyType = {};
|
rct_entrance_type _legacyType = {};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit EntranceObject(const rct_object_entry &entry) : Object(entry) { }
|
explicit EntranceObject(const rct_object_entry& entry)
|
||||||
|
: Object(entry)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void * GetLegacyData() override { return &_legacyType; }
|
void* GetLegacyData() override
|
||||||
|
{
|
||||||
|
return &_legacyType;
|
||||||
|
}
|
||||||
|
|
||||||
void ReadLegacy(IReadObjectContext* context, IStream* stream) override;
|
void ReadLegacy(IReadObjectContext* context, IStream* stream) override;
|
||||||
void ReadJson(IReadObjectContext* context, const json_t* root) override;
|
void ReadJson(IReadObjectContext* context, const json_t* root) override;
|
||||||
|
|
|
@ -7,16 +7,18 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include <unordered_map>
|
#include "FootpathItemObject.h"
|
||||||
|
|
||||||
#include "../core/IStream.hpp"
|
#include "../core/IStream.hpp"
|
||||||
#include "../drawing/Drawing.h"
|
#include "../drawing/Drawing.h"
|
||||||
#include "../interface/Cursors.h"
|
#include "../interface/Cursors.h"
|
||||||
#include "../localisation/Localisation.h"
|
#include "../localisation/Localisation.h"
|
||||||
#include "../object/Object.h"
|
#include "../object/Object.h"
|
||||||
#include "../object/ObjectRepository.h"
|
#include "../object/ObjectRepository.h"
|
||||||
#include "ObjectList.h"
|
|
||||||
#include "FootpathItemObject.h"
|
|
||||||
#include "ObjectJsonHelpers.h"
|
#include "ObjectJsonHelpers.h"
|
||||||
|
#include "ObjectList.h"
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
void FootpathItemObject::ReadLegacy(IReadObjectContext* context, IStream* stream)
|
void FootpathItemObject::ReadLegacy(IReadObjectContext* context, IStream* stream)
|
||||||
{
|
{
|
||||||
|
@ -50,9 +52,8 @@ void FootpathItemObject::ReadLegacy(IReadObjectContext * context, IStream * stre
|
||||||
if (item != nullptr)
|
if (item != nullptr)
|
||||||
{
|
{
|
||||||
auto sourceGame = object_entry_get_source_game(&item->ObjectEntry);
|
auto sourceGame = object_entry_get_source_game(&item->ObjectEntry);
|
||||||
if (sourceGame == OBJECT_SOURCE_WACKY_WORLDS ||
|
if (sourceGame == OBJECT_SOURCE_WACKY_WORLDS || sourceGame == OBJECT_SOURCE_TIME_TWISTER
|
||||||
sourceGame == OBJECT_SOURCE_TIME_TWISTER ||
|
|| sourceGame == OBJECT_SOURCE_CUSTOM)
|
||||||
sourceGame == OBJECT_SOURCE_CUSTOM)
|
|
||||||
{
|
{
|
||||||
auto scgPathX = Object::GetScgPathXHeader();
|
auto scgPathX = Object::GetScgPathXHeader();
|
||||||
SetPrimarySceneryGroup(&scgPathX);
|
SetPrimarySceneryGroup(&scgPathX);
|
||||||
|
@ -87,10 +88,14 @@ void FootpathItemObject::DrawPreview(rct_drawpixelinfo * dpi, int32_t width, int
|
||||||
|
|
||||||
static uint8_t ParseDrawType(const std::string& s)
|
static uint8_t ParseDrawType(const std::string& s)
|
||||||
{
|
{
|
||||||
if (s == "lamp") return PATH_BIT_DRAW_TYPE_LIGHTS;
|
if (s == "lamp")
|
||||||
if (s == "bin") return PATH_BIT_DRAW_TYPE_BINS;
|
return PATH_BIT_DRAW_TYPE_LIGHTS;
|
||||||
if (s == "bench") return PATH_BIT_DRAW_TYPE_BENCHES;
|
if (s == "bin")
|
||||||
if (s == "fountain") return PATH_BIT_DRAW_TYPE_JUMPING_FOUNTAINS;
|
return PATH_BIT_DRAW_TYPE_BINS;
|
||||||
|
if (s == "bench")
|
||||||
|
return PATH_BIT_DRAW_TYPE_BENCHES;
|
||||||
|
if (s == "fountain")
|
||||||
|
return PATH_BIT_DRAW_TYPE_JUMPING_FOUNTAINS;
|
||||||
return PATH_BIT_DRAW_TYPE_LIGHTS;
|
return PATH_BIT_DRAW_TYPE_LIGHTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,14 +103,16 @@ void FootpathItemObject::ReadJson(IReadObjectContext * context, const json_t * r
|
||||||
{
|
{
|
||||||
auto properties = json_object_get(root, "properties");
|
auto properties = json_object_get(root, "properties");
|
||||||
_legacyType.path_bit.draw_type = ParseDrawType(ObjectJsonHelpers::GetString(properties, "renderAs"));
|
_legacyType.path_bit.draw_type = ParseDrawType(ObjectJsonHelpers::GetString(properties, "renderAs"));
|
||||||
_legacyType.path_bit.tool_id = ObjectJsonHelpers::ParseCursor(ObjectJsonHelpers::GetString(properties, "cursor"), CURSOR_LAMPPOST_DOWN);
|
_legacyType.path_bit.tool_id
|
||||||
|
= ObjectJsonHelpers::ParseCursor(ObjectJsonHelpers::GetString(properties, "cursor"), CURSOR_LAMPPOST_DOWN);
|
||||||
_legacyType.path_bit.price = json_integer_value(json_object_get(properties, "price"));
|
_legacyType.path_bit.price = json_integer_value(json_object_get(properties, "price"));
|
||||||
|
|
||||||
SetPrimarySceneryGroup(ObjectJsonHelpers::GetString(json_object_get(properties, "sceneryGroup")));
|
SetPrimarySceneryGroup(ObjectJsonHelpers::GetString(json_object_get(properties, "sceneryGroup")));
|
||||||
|
|
||||||
// Flags
|
// Flags
|
||||||
_legacyType.path_bit.flags = ObjectJsonHelpers::GetFlags<uint16_t>(properties, {
|
_legacyType.path_bit.flags = ObjectJsonHelpers::GetFlags<uint16_t>(
|
||||||
{ "isBin", PATH_BIT_FLAG_IS_BIN },
|
properties,
|
||||||
|
{ { "isBin", PATH_BIT_FLAG_IS_BIN },
|
||||||
{ "isBench", PATH_BIT_FLAG_IS_BENCH },
|
{ "isBench", PATH_BIT_FLAG_IS_BENCH },
|
||||||
{ "isBreakable", PATH_BIT_FLAG_BREAKABLE },
|
{ "isBreakable", PATH_BIT_FLAG_BREAKABLE },
|
||||||
{ "isLamp", PATH_BIT_FLAG_LAMP },
|
{ "isLamp", PATH_BIT_FLAG_LAMP },
|
||||||
|
|
|
@ -9,9 +9,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "SceneryObject.h"
|
|
||||||
|
|
||||||
#include "../world/Scenery.h"
|
#include "../world/Scenery.h"
|
||||||
|
#include "SceneryObject.h"
|
||||||
|
|
||||||
class FootpathItemObject final : public SceneryObject
|
class FootpathItemObject final : public SceneryObject
|
||||||
{
|
{
|
||||||
|
@ -19,9 +18,15 @@ private:
|
||||||
rct_scenery_entry _legacyType = {};
|
rct_scenery_entry _legacyType = {};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit FootpathItemObject(const rct_object_entry &entry) : SceneryObject(entry) { }
|
explicit FootpathItemObject(const rct_object_entry& entry)
|
||||||
|
: SceneryObject(entry)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void * GetLegacyData() override { return &_legacyType; }
|
void* GetLegacyData() override
|
||||||
|
{
|
||||||
|
return &_legacyType;
|
||||||
|
}
|
||||||
|
|
||||||
void ReadLegacy(IReadObjectContext* context, IStream* stream) override;
|
void ReadLegacy(IReadObjectContext* context, IStream* stream) override;
|
||||||
void ReadJson(IReadObjectContext* context, const json_t* root) override;
|
void ReadJson(IReadObjectContext* context, const json_t* root) override;
|
||||||
|
|
|
@ -7,11 +7,12 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include "FootpathObject.h"
|
||||||
|
|
||||||
#include "../core/IStream.hpp"
|
#include "../core/IStream.hpp"
|
||||||
#include "../drawing/Drawing.h"
|
#include "../drawing/Drawing.h"
|
||||||
#include "../localisation/Language.h"
|
#include "../localisation/Language.h"
|
||||||
#include "../world/Footpath.h"
|
#include "../world/Footpath.h"
|
||||||
#include "FootpathObject.h"
|
|
||||||
#include "ObjectJsonHelpers.h"
|
#include "ObjectJsonHelpers.h"
|
||||||
|
|
||||||
void FootpathObject::ReadLegacy(IReadObjectContext* context, IStream* stream)
|
void FootpathObject::ReadLegacy(IReadObjectContext* context, IStream* stream)
|
||||||
|
@ -59,8 +60,10 @@ void FootpathObject::DrawPreview(rct_drawpixelinfo * dpi, int32_t width, int32_t
|
||||||
|
|
||||||
static uint8_t ParseSupportType(const std::string& s)
|
static uint8_t ParseSupportType(const std::string& s)
|
||||||
{
|
{
|
||||||
if (s == "pole") return FOOTPATH_ENTRY_SUPPORT_TYPE_POLE;
|
if (s == "pole")
|
||||||
else /* if (s == "box") */ return FOOTPATH_ENTRY_SUPPORT_TYPE_BOX;
|
return FOOTPATH_ENTRY_SUPPORT_TYPE_POLE;
|
||||||
|
else /* if (s == "box") */
|
||||||
|
return FOOTPATH_ENTRY_SUPPORT_TYPE_BOX;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FootpathObject::ReadJson(IReadObjectContext* context, const json_t* root)
|
void FootpathObject::ReadJson(IReadObjectContext* context, const json_t* root)
|
||||||
|
@ -70,8 +73,9 @@ void FootpathObject::ReadJson(IReadObjectContext * context, const json_t * root)
|
||||||
_legacyType.scrolling_mode = json_integer_value(json_object_get(properties, "scrollingMode"));
|
_legacyType.scrolling_mode = json_integer_value(json_object_get(properties, "scrollingMode"));
|
||||||
|
|
||||||
// Flags
|
// Flags
|
||||||
_legacyType.flags = ObjectJsonHelpers::GetFlags<uint8_t>(properties, {
|
_legacyType.flags = ObjectJsonHelpers::GetFlags<uint8_t>(
|
||||||
{ "hasSupportImages", FOOTPATH_ENTRY_FLAG_HAS_SUPPORT_BASE_SPRITE },
|
properties,
|
||||||
|
{ { "hasSupportImages", FOOTPATH_ENTRY_FLAG_HAS_SUPPORT_BASE_SPRITE },
|
||||||
{ "hasElevatedPathImages", FOOTPATH_ENTRY_FLAG_HAS_PATH_BASE_SPRITE },
|
{ "hasElevatedPathImages", FOOTPATH_ENTRY_FLAG_HAS_PATH_BASE_SPRITE },
|
||||||
{ "editorOnly", FOOTPATH_ENTRY_FLAG_SHOW_ONLY_IN_SCENARIO_EDITOR } });
|
{ "editorOnly", FOOTPATH_ENTRY_FLAG_SHOW_ONLY_IN_SCENARIO_EDITOR } });
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Object.h"
|
|
||||||
|
|
||||||
#include "../world/Footpath.h"
|
#include "../world/Footpath.h"
|
||||||
|
#include "Object.h"
|
||||||
|
|
||||||
class FootpathObject final : public Object
|
class FootpathObject final : public Object
|
||||||
{
|
{
|
||||||
|
@ -19,9 +18,15 @@ private:
|
||||||
rct_footpath_entry _legacyType = {};
|
rct_footpath_entry _legacyType = {};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit FootpathObject(const rct_object_entry &entry) : Object(entry) { }
|
explicit FootpathObject(const rct_object_entry& entry)
|
||||||
|
: Object(entry)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void * GetLegacyData() override { return &_legacyType; }
|
void* GetLegacyData() override
|
||||||
|
{
|
||||||
|
return &_legacyType;
|
||||||
|
}
|
||||||
|
|
||||||
void ReadLegacy(IReadObjectContext* context, IStream* stream) override;
|
void ReadLegacy(IReadObjectContext* context, IStream* stream) override;
|
||||||
void ReadJson(IReadObjectContext* context, const json_t* root) override;
|
void ReadJson(IReadObjectContext* context, const json_t* root) override;
|
||||||
|
|
|
@ -7,13 +7,15 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include "ImageTable.h"
|
||||||
|
|
||||||
|
#include "../OpenRCT2.h"
|
||||||
|
#include "../core/IStream.hpp"
|
||||||
|
#include "Object.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include "../core/IStream.hpp"
|
|
||||||
#include "../OpenRCT2.h"
|
|
||||||
#include "ImageTable.h"
|
|
||||||
#include "Object.h"
|
|
||||||
|
|
||||||
ImageTable::~ImageTable()
|
ImageTable::~ImageTable()
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,11 +9,12 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <vector>
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
#include "../drawing/Drawing.h"
|
#include "../drawing/Drawing.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
interface IReadObjectContext;
|
interface IReadObjectContext;
|
||||||
interface IStream;
|
interface IStream;
|
||||||
|
|
||||||
|
@ -30,7 +31,13 @@ public:
|
||||||
~ImageTable();
|
~ImageTable();
|
||||||
|
|
||||||
void Read(IReadObjectContext* context, IStream* stream);
|
void Read(IReadObjectContext* context, IStream* stream);
|
||||||
const rct_g1_element * GetImages() const { return _entries.data(); }
|
const rct_g1_element* GetImages() const
|
||||||
uint32_t GetCount() const { return (uint32_t)_entries.size(); }
|
{
|
||||||
|
return _entries.data();
|
||||||
|
}
|
||||||
|
uint32_t GetCount() const
|
||||||
|
{
|
||||||
|
return (uint32_t)_entries.size();
|
||||||
|
}
|
||||||
void AddImage(const rct_g1_element* g1);
|
void AddImage(const rct_g1_element* g1);
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
|
|
||||||
#pragma warning(disable : 4706) // assignment within conditional expression
|
#pragma warning(disable : 4706) // assignment within conditional expression
|
||||||
|
|
||||||
#include <algorithm>
|
#include "LargeSceneryObject.h"
|
||||||
|
|
||||||
#include "../core/IStream.hpp"
|
#include "../core/IStream.hpp"
|
||||||
#include "../core/Memory.hpp"
|
#include "../core/Memory.hpp"
|
||||||
#include "../core/Util.hpp"
|
#include "../core/Util.hpp"
|
||||||
|
@ -17,9 +18,10 @@
|
||||||
#include "../interface/Cursors.h"
|
#include "../interface/Cursors.h"
|
||||||
#include "../localisation/Language.h"
|
#include "../localisation/Language.h"
|
||||||
#include "../world/Location.hpp"
|
#include "../world/Location.hpp"
|
||||||
#include "LargeSceneryObject.h"
|
|
||||||
#include "ObjectJsonHelpers.h"
|
#include "ObjectJsonHelpers.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
void LargeSceneryObject::ReadLegacy(IReadObjectContext* context, IStream* stream)
|
void LargeSceneryObject::ReadLegacy(IReadObjectContext* context, IStream* stream)
|
||||||
{
|
{
|
||||||
stream->Seek(6, STREAM_SEEK_CURRENT);
|
stream->Seek(6, STREAM_SEEK_CURRENT);
|
||||||
|
@ -123,18 +125,18 @@ void LargeSceneryObject::ReadJson(IReadObjectContext * context, const json_t * r
|
||||||
{
|
{
|
||||||
auto properties = json_object_get(root, "properties");
|
auto properties = json_object_get(root, "properties");
|
||||||
|
|
||||||
_legacyType.large_scenery.tool_id = ObjectJsonHelpers::ParseCursor(ObjectJsonHelpers::GetString(properties, "cursor"), CURSOR_STATUE_DOWN);
|
_legacyType.large_scenery.tool_id
|
||||||
|
= ObjectJsonHelpers::ParseCursor(ObjectJsonHelpers::GetString(properties, "cursor"), CURSOR_STATUE_DOWN);
|
||||||
_legacyType.large_scenery.price = json_integer_value(json_object_get(properties, "price"));
|
_legacyType.large_scenery.price = json_integer_value(json_object_get(properties, "price"));
|
||||||
_legacyType.large_scenery.removal_price = json_integer_value(json_object_get(properties, "removalPrice"));
|
_legacyType.large_scenery.removal_price = json_integer_value(json_object_get(properties, "removalPrice"));
|
||||||
|
|
||||||
auto jScrollingMode = json_object_get(properties, "scrollingMode");
|
auto jScrollingMode = json_object_get(properties, "scrollingMode");
|
||||||
_legacyType.large_scenery.scrolling_mode = jScrollingMode != nullptr ?
|
_legacyType.large_scenery.scrolling_mode = jScrollingMode != nullptr ? json_integer_value(jScrollingMode) : -1;
|
||||||
json_integer_value(jScrollingMode) :
|
|
||||||
-1;
|
|
||||||
|
|
||||||
// Flags
|
// Flags
|
||||||
_legacyType.large_scenery.flags = ObjectJsonHelpers::GetFlags<uint8_t>(properties, {
|
_legacyType.large_scenery.flags = ObjectJsonHelpers::GetFlags<uint8_t>(
|
||||||
{ "hasPrimaryColour", LARGE_SCENERY_FLAG_HAS_PRIMARY_COLOUR },
|
properties,
|
||||||
|
{ { "hasPrimaryColour", LARGE_SCENERY_FLAG_HAS_PRIMARY_COLOUR },
|
||||||
{ "hasSecondaryColour", LARGE_SCENERY_FLAG_HAS_SECONDARY_COLOUR },
|
{ "hasSecondaryColour", LARGE_SCENERY_FLAG_HAS_SECONDARY_COLOUR },
|
||||||
{ "isAnimated", LARGE_SCENERY_FLAG_ANIMATED },
|
{ "isAnimated", LARGE_SCENERY_FLAG_ANIMATED },
|
||||||
{ "isPhotogenic", LARGE_SCENERY_FLAG_PHOTOGENIC } });
|
{ "isPhotogenic", LARGE_SCENERY_FLAG_PHOTOGENIC } });
|
||||||
|
@ -217,9 +219,8 @@ std::unique_ptr<rct_large_scenery_text> LargeSceneryObject::ReadJson3dFont(const
|
||||||
|
|
||||||
font->max_width = json_integer_value(json_object_get(j3dFont, "maxWidth"));
|
font->max_width = json_integer_value(json_object_get(j3dFont, "maxWidth"));
|
||||||
font->num_images = json_integer_value(json_object_get(j3dFont, "numImages"));
|
font->num_images = json_integer_value(json_object_get(j3dFont, "numImages"));
|
||||||
font->flags = ObjectJsonHelpers::GetFlags<uint8_t>(j3dFont, {
|
font->flags = ObjectJsonHelpers::GetFlags<uint8_t>(
|
||||||
{ "isVertical", LARGE_SCENERY_TEXT_FLAG_VERTICAL },
|
j3dFont, { { "isVertical", LARGE_SCENERY_TEXT_FLAG_VERTICAL }, { "isTwoLine", LARGE_SCENERY_TEXT_FLAG_TWO_LINE } });
|
||||||
{ "isTwoLine", LARGE_SCENERY_TEXT_FLAG_TWO_LINE } });
|
|
||||||
|
|
||||||
auto jGlyphs = json_object_get(j3dFont, "glyphs");
|
auto jGlyphs = json_object_get(j3dFont, "glyphs");
|
||||||
if (jGlyphs != nullptr)
|
if (jGlyphs != nullptr)
|
||||||
|
|
|
@ -9,12 +9,13 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <vector>
|
|
||||||
#include "../world/Location.hpp"
|
#include "../world/Location.hpp"
|
||||||
#include "../world/Scenery.h"
|
#include "../world/Scenery.h"
|
||||||
#include "SceneryObject.h"
|
#include "SceneryObject.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
class LargeSceneryObject final : public SceneryObject
|
class LargeSceneryObject final : public SceneryObject
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -24,9 +25,15 @@ private:
|
||||||
std::unique_ptr<rct_large_scenery_text> _3dFont;
|
std::unique_ptr<rct_large_scenery_text> _3dFont;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit LargeSceneryObject(const rct_object_entry &entry) : SceneryObject(entry) { }
|
explicit LargeSceneryObject(const rct_object_entry& entry)
|
||||||
|
: SceneryObject(entry)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void * GetLegacyData() override { return &_legacyType; }
|
void* GetLegacyData() override
|
||||||
|
{
|
||||||
|
return &_legacyType;
|
||||||
|
}
|
||||||
|
|
||||||
void ReadLegacy(IReadObjectContext* context, IStream* stream) override;
|
void ReadLegacy(IReadObjectContext* context, IStream* stream) override;
|
||||||
void ReadJson(IReadObjectContext* context, const json_t* root) override;
|
void ReadJson(IReadObjectContext* context, const json_t* root) override;
|
||||||
|
|
|
@ -7,14 +7,16 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include <algorithm>
|
#include "Object.h"
|
||||||
|
|
||||||
#include "../core/Memory.hpp"
|
#include "../core/Memory.hpp"
|
||||||
#include "../core/String.hpp"
|
#include "../core/String.hpp"
|
||||||
#include "../localisation/Language.h"
|
#include "../localisation/Language.h"
|
||||||
#include "../localisation/StringIds.h"
|
#include "../localisation/StringIds.h"
|
||||||
#include "Object.h"
|
|
||||||
#include "ObjectLimits.h"
|
#include "ObjectLimits.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
Object::Object(const rct_object_entry& entry)
|
Object::Object(const rct_object_entry& entry)
|
||||||
{
|
{
|
||||||
_objectEntry = entry;
|
_objectEntry = entry;
|
||||||
|
@ -102,8 +104,7 @@ void Object::SetSourceGame(const uint8_t sourceGame)
|
||||||
|
|
||||||
bool Object::IsRCT1Object()
|
bool Object::IsRCT1Object()
|
||||||
{
|
{
|
||||||
static const char _rct1Objects[][9] =
|
static const char _rct1Objects[][9] = {
|
||||||
{
|
|
||||||
"CLIFT1 ",
|
"CLIFT1 ",
|
||||||
"MONO1 ",
|
"MONO1 ",
|
||||||
"MONO2 ",
|
"MONO2 ",
|
||||||
|
@ -405,8 +406,7 @@ bool Object::IsRCT1Object()
|
||||||
|
|
||||||
bool Object::IsAAObject()
|
bool Object::IsAAObject()
|
||||||
{
|
{
|
||||||
static const char _aaObjects[][9] =
|
static const char _aaObjects[][9] = {
|
||||||
{
|
|
||||||
// Rides / vehicles / stalls
|
// Rides / vehicles / stalls
|
||||||
"BMFL ",
|
"BMFL ",
|
||||||
"BMRB ",
|
"BMRB ",
|
||||||
|
@ -521,8 +521,7 @@ bool Object::IsAAObject()
|
||||||
|
|
||||||
bool Object::IsLLObject()
|
bool Object::IsLLObject()
|
||||||
{
|
{
|
||||||
static const char _llObjects[][9] =
|
static const char _llObjects[][9] = {
|
||||||
{
|
|
||||||
// Rides / vehicles / stalls
|
// Rides / vehicles / stalls
|
||||||
"AML1 ",
|
"AML1 ",
|
||||||
"ARRT2 ",
|
"ARRT2 ",
|
||||||
|
@ -650,8 +649,7 @@ bool Object::IsLLObject()
|
||||||
|
|
||||||
bool Object::IsOpenRCT2OfficialObject()
|
bool Object::IsOpenRCT2OfficialObject()
|
||||||
{
|
{
|
||||||
static const char _openRCT2OfficialObjects[][9] =
|
static const char _openRCT2OfficialObjects[][9] = {
|
||||||
{
|
|
||||||
// Offical extended scenery set
|
// Offical extended scenery set
|
||||||
"XXBBBR01",
|
"XXBBBR01",
|
||||||
"TTRFTL02",
|
"TTRFTL02",
|
||||||
|
@ -698,7 +696,6 @@ bool Object::IsOpenRCT2OfficialObject()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef __WARN_SUGGEST_FINAL_METHODS__
|
#ifdef __WARN_SUGGEST_FINAL_METHODS__
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wsuggest-final-methods"
|
#pragma GCC diagnostic ignored "-Wsuggest-final-methods"
|
||||||
|
|
|
@ -9,13 +9,14 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string_view>
|
|
||||||
#include <vector>
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
#include "../core/Json.hpp"
|
#include "../core/Json.hpp"
|
||||||
#include "ImageTable.h"
|
#include "ImageTable.h"
|
||||||
#include "StringTable.h"
|
#include "StringTable.h"
|
||||||
|
|
||||||
|
#include <string_view>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
// First 0xF of rct_object_entry->flags
|
// First 0xF of rct_object_entry->flags
|
||||||
enum OBJECT_TYPE
|
enum OBJECT_TYPE
|
||||||
{
|
{
|
||||||
|
@ -68,14 +69,18 @@ enum OBJECT_SOURCE_GAME
|
||||||
* Object entry structure.
|
* Object entry structure.
|
||||||
* size: 0x10
|
* size: 0x10
|
||||||
*/
|
*/
|
||||||
struct rct_object_entry {
|
struct rct_object_entry
|
||||||
union {
|
{
|
||||||
|
union
|
||||||
|
{
|
||||||
uint8_t end_flag; // needed not to read past allocated buffer.
|
uint8_t end_flag; // needed not to read past allocated buffer.
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
};
|
};
|
||||||
union {
|
union
|
||||||
|
{
|
||||||
char nameWOC[12];
|
char nameWOC[12];
|
||||||
struct {
|
struct
|
||||||
|
{
|
||||||
char name[8];
|
char name[8];
|
||||||
uint32_t checksum;
|
uint32_t checksum;
|
||||||
};
|
};
|
||||||
|
@ -97,7 +102,8 @@ struct rct_object_entry {
|
||||||
};
|
};
|
||||||
assert_struct_size(rct_object_entry, 0x10);
|
assert_struct_size(rct_object_entry, 0x10);
|
||||||
|
|
||||||
struct rct_object_entry_group {
|
struct rct_object_entry_group
|
||||||
|
{
|
||||||
void** chunks;
|
void** chunks;
|
||||||
rct_object_entry* entries;
|
rct_object_entry* entries;
|
||||||
};
|
};
|
||||||
|
@ -105,14 +111,17 @@ struct rct_object_entry_group {
|
||||||
assert_struct_size(rct_object_entry_group, 8);
|
assert_struct_size(rct_object_entry_group, 8);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct rct_ride_filters {
|
struct rct_ride_filters
|
||||||
|
{
|
||||||
uint8_t category[2];
|
uint8_t category[2];
|
||||||
uint8_t ride_type;
|
uint8_t ride_type;
|
||||||
};
|
};
|
||||||
assert_struct_size(rct_ride_filters, 3);
|
assert_struct_size(rct_ride_filters, 3);
|
||||||
|
|
||||||
struct rct_object_filters {
|
struct rct_object_filters
|
||||||
union {
|
{
|
||||||
|
union
|
||||||
|
{
|
||||||
rct_ride_filters ride;
|
rct_ride_filters ride;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -150,9 +159,18 @@ private:
|
||||||
ImageTable _imageTable;
|
ImageTable _imageTable;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
StringTable & GetStringTable() { return _stringTable; }
|
StringTable& GetStringTable()
|
||||||
const StringTable & GetStringTable() const { return _stringTable; }
|
{
|
||||||
ImageTable & GetImageTable() { return _imageTable; }
|
return _stringTable;
|
||||||
|
}
|
||||||
|
const StringTable& GetStringTable() const
|
||||||
|
{
|
||||||
|
return _stringTable;
|
||||||
|
}
|
||||||
|
ImageTable& GetImageTable()
|
||||||
|
{
|
||||||
|
return _imageTable;
|
||||||
|
}
|
||||||
|
|
||||||
std::string GetOverrideString(uint8_t index) const;
|
std::string GetOverrideString(uint8_t index) const;
|
||||||
std::string GetString(uint8_t index) const;
|
std::string GetString(uint8_t index) const;
|
||||||
|
@ -169,29 +187,46 @@ public:
|
||||||
virtual ~Object();
|
virtual ~Object();
|
||||||
|
|
||||||
// Legacy data structures
|
// Legacy data structures
|
||||||
const char * GetIdentifier() const { return _identifier; }
|
const char* GetIdentifier() const
|
||||||
const rct_object_entry * GetObjectEntry() const { return &_objectEntry; }
|
{
|
||||||
|
return _identifier;
|
||||||
|
}
|
||||||
|
const rct_object_entry* GetObjectEntry() const
|
||||||
|
{
|
||||||
|
return &_objectEntry;
|
||||||
|
}
|
||||||
virtual void* GetLegacyData() abstract;
|
virtual void* GetLegacyData() abstract;
|
||||||
|
|
||||||
virtual void ReadJson(IReadObjectContext * /*context*/, const json_t * /*root*/) { }
|
virtual void ReadJson(IReadObjectContext* /*context*/, const json_t* /*root*/)
|
||||||
|
{
|
||||||
|
}
|
||||||
virtual void ReadLegacy(IReadObjectContext* context, IStream* stream) abstract;
|
virtual void ReadLegacy(IReadObjectContext* context, IStream* stream) abstract;
|
||||||
virtual void Load() abstract;
|
virtual void Load() abstract;
|
||||||
virtual void Unload() abstract;
|
virtual void Unload() abstract;
|
||||||
|
|
||||||
virtual void DrawPreview(rct_drawpixelinfo * /*dpi*/, int32_t /*width*/, int32_t /*height*/) const { }
|
virtual void DrawPreview(rct_drawpixelinfo* /*dpi*/, int32_t /*width*/, int32_t /*height*/) const
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
virtual uint8_t GetObjectType() const final { return _objectEntry.flags & 0x0F; }
|
virtual uint8_t GetObjectType() const final
|
||||||
|
{
|
||||||
|
return _objectEntry.flags & 0x0F;
|
||||||
|
}
|
||||||
virtual std::string GetName() const;
|
virtual std::string GetName() const;
|
||||||
virtual std::string GetName(int32_t language) const;
|
virtual std::string GetName(int32_t language) const;
|
||||||
|
|
||||||
virtual void SetRepositoryItem(ObjectRepositoryItem * /*item*/) const { }
|
virtual void SetRepositoryItem(ObjectRepositoryItem* /*item*/) const
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
const ImageTable & GetImageTable() const { return _imageTable; }
|
const ImageTable& GetImageTable() const
|
||||||
|
{
|
||||||
|
return _imageTable;
|
||||||
|
}
|
||||||
|
|
||||||
rct_object_entry GetScgWallsHeader();
|
rct_object_entry GetScgWallsHeader();
|
||||||
rct_object_entry GetScgPathXHeader();
|
rct_object_entry GetScgPathXHeader();
|
||||||
rct_object_entry CreateHeader(const char name[9], uint32_t flags, uint32_t checksum);
|
rct_object_entry CreateHeader(const char name[9], uint32_t flags, uint32_t checksum);
|
||||||
|
|
||||||
};
|
};
|
||||||
#ifdef __WARN_SUGGEST_FINAL_TYPES__
|
#ifdef __WARN_SUGGEST_FINAL_TYPES__
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include "ObjectFactory.h"
|
||||||
|
|
||||||
|
#include "../OpenRCT2.h"
|
||||||
#include "../core/Console.hpp"
|
#include "../core/Console.hpp"
|
||||||
#include "../core/File.h"
|
#include "../core/File.h"
|
||||||
#include "../core/FileStream.hpp"
|
#include "../core/FileStream.hpp"
|
||||||
|
@ -16,7 +19,6 @@
|
||||||
#include "../core/Path.hpp"
|
#include "../core/Path.hpp"
|
||||||
#include "../core/String.hpp"
|
#include "../core/String.hpp"
|
||||||
#include "../core/Zip.h"
|
#include "../core/Zip.h"
|
||||||
#include "../OpenRCT2.h"
|
|
||||||
#include "../rct12/SawyerChunkReader.h"
|
#include "../rct12/SawyerChunkReader.h"
|
||||||
#include "BannerObject.h"
|
#include "BannerObject.h"
|
||||||
#include "EntranceObject.h"
|
#include "EntranceObject.h"
|
||||||
|
@ -26,7 +28,6 @@
|
||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
#include "ObjectLimits.h"
|
#include "ObjectLimits.h"
|
||||||
#include "ObjectList.h"
|
#include "ObjectList.h"
|
||||||
#include "ObjectFactory.h"
|
|
||||||
#include "RideObject.h"
|
#include "RideObject.h"
|
||||||
#include "SceneryGroupObject.h"
|
#include "SceneryGroupObject.h"
|
||||||
#include "SmallSceneryObject.h"
|
#include "SmallSceneryObject.h"
|
||||||
|
@ -88,18 +89,24 @@ private:
|
||||||
bool _wasError = false;
|
bool _wasError = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool WasWarning() const { return _wasWarning; }
|
bool WasWarning() const
|
||||||
bool WasError() const { return _wasError; }
|
{
|
||||||
|
return _wasWarning;
|
||||||
|
}
|
||||||
|
bool WasError() const
|
||||||
|
{
|
||||||
|
return _wasError;
|
||||||
|
}
|
||||||
|
|
||||||
ReadObjectContext(
|
ReadObjectContext(
|
||||||
IObjectRepository& objectRepository,
|
IObjectRepository& objectRepository,
|
||||||
const std::string& objectName,
|
const std::string& objectName,
|
||||||
bool loadImages,
|
bool loadImages,
|
||||||
const IFileDataRetriever* fileDataRetriever)
|
const IFileDataRetriever* fileDataRetriever)
|
||||||
: _objectRepository(objectRepository),
|
: _objectRepository(objectRepository)
|
||||||
_fileDataRetriever(fileDataRetriever),
|
, _fileDataRetriever(fileDataRetriever)
|
||||||
_objectName(objectName),
|
, _objectName(objectName)
|
||||||
_loadImages(loadImages)
|
, _loadImages(loadImages)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +152,8 @@ public:
|
||||||
|
|
||||||
namespace ObjectFactory
|
namespace ObjectFactory
|
||||||
{
|
{
|
||||||
static Object * CreateObjectFromJson(IObjectRepository& objectRepository, const json_t * jRoot, const IFileDataRetriever * fileRetriever);
|
static Object*
|
||||||
|
CreateObjectFromJson(IObjectRepository& objectRepository, const json_t* jRoot, const IFileDataRetriever* fileRetriever);
|
||||||
|
|
||||||
static void ReadObjectLegacy(Object* object, IReadObjectContext* context, IStream* stream)
|
static void ReadObjectLegacy(Object* object, IReadObjectContext* context, IStream* stream)
|
||||||
{
|
{
|
||||||
|
@ -200,7 +208,8 @@ namespace ObjectFactory
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object * CreateObjectFromLegacyData(IObjectRepository& objectRepository, const rct_object_entry * entry, const void * data, size_t dataSize)
|
Object* CreateObjectFromLegacyData(
|
||||||
|
IObjectRepository& objectRepository, const rct_object_entry* entry, const void* data, size_t dataSize)
|
||||||
{
|
{
|
||||||
Guard::ArgumentNotNull(entry, GUARD_LINE);
|
Guard::ArgumentNotNull(entry, GUARD_LINE);
|
||||||
Guard::ArgumentNotNull(data, GUARD_LINE);
|
Guard::ArgumentNotNull(data, GUARD_LINE);
|
||||||
|
@ -228,7 +237,8 @@ namespace ObjectFactory
|
||||||
{
|
{
|
||||||
Object* result;
|
Object* result;
|
||||||
uint8_t objectType = object_entry_get_type(&entry);
|
uint8_t objectType = object_entry_get_type(&entry);
|
||||||
switch (objectType) {
|
switch (objectType)
|
||||||
|
{
|
||||||
case OBJECT_TYPE_RIDE:
|
case OBJECT_TYPE_RIDE:
|
||||||
result = new RideObject(entry);
|
result = new RideObject(entry);
|
||||||
break;
|
break;
|
||||||
|
@ -270,16 +280,26 @@ namespace ObjectFactory
|
||||||
|
|
||||||
static uint8_t ParseObjectType(const std::string& s)
|
static uint8_t ParseObjectType(const std::string& s)
|
||||||
{
|
{
|
||||||
if (s == "ride") return OBJECT_TYPE_RIDE;
|
if (s == "ride")
|
||||||
if (s == "footpath") return OBJECT_TYPE_PATHS;
|
return OBJECT_TYPE_RIDE;
|
||||||
if (s == "footpath_banner") return OBJECT_TYPE_BANNERS;
|
if (s == "footpath")
|
||||||
if (s == "footpath_item") return OBJECT_TYPE_PATH_BITS;
|
return OBJECT_TYPE_PATHS;
|
||||||
if (s == "scenery_small") return OBJECT_TYPE_SMALL_SCENERY;
|
if (s == "footpath_banner")
|
||||||
if (s == "scenery_large") return OBJECT_TYPE_LARGE_SCENERY;
|
return OBJECT_TYPE_BANNERS;
|
||||||
if (s == "scenery_wall") return OBJECT_TYPE_WALLS;
|
if (s == "footpath_item")
|
||||||
if (s == "scenery_group") return OBJECT_TYPE_SCENERY_GROUP;
|
return OBJECT_TYPE_PATH_BITS;
|
||||||
if (s == "park_entrance") return OBJECT_TYPE_PARK_ENTRANCE;
|
if (s == "scenery_small")
|
||||||
if (s == "water") return OBJECT_TYPE_WATER;
|
return OBJECT_TYPE_SMALL_SCENERY;
|
||||||
|
if (s == "scenery_large")
|
||||||
|
return OBJECT_TYPE_LARGE_SCENERY;
|
||||||
|
if (s == "scenery_wall")
|
||||||
|
return OBJECT_TYPE_WALLS;
|
||||||
|
if (s == "scenery_group")
|
||||||
|
return OBJECT_TYPE_SCENERY_GROUP;
|
||||||
|
if (s == "park_entrance")
|
||||||
|
return OBJECT_TYPE_PARK_ENTRANCE;
|
||||||
|
if (s == "water")
|
||||||
|
return OBJECT_TYPE_WATER;
|
||||||
return 0xFF;
|
return 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,7 +357,8 @@ namespace ObjectFactory
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object * CreateObjectFromJson(IObjectRepository& objectRepository, const json_t * jRoot, const IFileDataRetriever * fileRetriever)
|
Object*
|
||||||
|
CreateObjectFromJson(IObjectRepository& objectRepository, const json_t* jRoot, const IFileDataRetriever* fileRetriever)
|
||||||
{
|
{
|
||||||
log_verbose("CreateObjectFromJson(...)");
|
log_verbose("CreateObjectFromJson(...)");
|
||||||
|
|
||||||
|
@ -373,4 +394,4 @@ namespace ObjectFactory
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
} // namespace ObjectFactory
|
||||||
|
|
|
@ -9,9 +9,10 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string_view>
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
|
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
interface IObjectRepository;
|
interface IObjectRepository;
|
||||||
class Object;
|
class Object;
|
||||||
struct rct_object_entry;
|
struct rct_object_entry;
|
||||||
|
@ -19,9 +20,10 @@ struct rct_object_entry;
|
||||||
namespace ObjectFactory
|
namespace ObjectFactory
|
||||||
{
|
{
|
||||||
Object* CreateObjectFromLegacyFile(IObjectRepository& objectRepository, const utf8* path);
|
Object* CreateObjectFromLegacyFile(IObjectRepository& objectRepository, const utf8* path);
|
||||||
Object * CreateObjectFromLegacyData(IObjectRepository& objectRepository, const rct_object_entry * entry, const void * data, size_t dataSize);
|
Object* CreateObjectFromLegacyData(
|
||||||
|
IObjectRepository& objectRepository, const rct_object_entry* entry, const void* data, size_t dataSize);
|
||||||
Object* CreateObjectFromZipFile(IObjectRepository& objectRepository, const std::string_view& path);
|
Object* CreateObjectFromZipFile(IObjectRepository& objectRepository, const std::string_view& path);
|
||||||
Object* CreateObject(const rct_object_entry& entry);
|
Object* CreateObject(const rct_object_entry& entry);
|
||||||
|
|
||||||
Object* CreateObjectFromJsonFile(IObjectRepository& objectRepository, const std::string& path);
|
Object* CreateObjectFromJsonFile(IObjectRepository& objectRepository, const std::string& path);
|
||||||
}
|
} // namespace ObjectFactory
|
||||||
|
|
|
@ -9,10 +9,10 @@
|
||||||
|
|
||||||
#pragma warning(disable : 4706) // assignment within conditional expression
|
#pragma warning(disable : 4706) // assignment within conditional expression
|
||||||
|
|
||||||
#include <cstdlib>
|
#include "ObjectJsonHelpers.h"
|
||||||
#include <cstring>
|
|
||||||
#include <unordered_map>
|
|
||||||
#include "../Context.h"
|
#include "../Context.h"
|
||||||
|
#include "../PlatformEnvironment.h"
|
||||||
#include "../core/File.h"
|
#include "../core/File.h"
|
||||||
#include "../core/FileScanner.h"
|
#include "../core/FileScanner.h"
|
||||||
#include "../core/Math.hpp"
|
#include "../core/Math.hpp"
|
||||||
|
@ -22,11 +22,13 @@
|
||||||
#include "../drawing/ImageImporter.h"
|
#include "../drawing/ImageImporter.h"
|
||||||
#include "../interface/Cursors.h"
|
#include "../interface/Cursors.h"
|
||||||
#include "../localisation/Language.h"
|
#include "../localisation/Language.h"
|
||||||
#include "../PlatformEnvironment.h"
|
|
||||||
#include "../sprites.h"
|
#include "../sprites.h"
|
||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
#include "ObjectFactory.h"
|
#include "ObjectFactory.h"
|
||||||
#include "ObjectJsonHelpers.h"
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
using namespace OpenRCT2;
|
using namespace OpenRCT2;
|
||||||
using namespace OpenRCT2::Drawing;
|
using namespace OpenRCT2::Drawing;
|
||||||
|
@ -36,24 +38,18 @@ namespace ObjectJsonHelpers
|
||||||
bool GetBoolean(const json_t* obj, const std::string& name, bool defaultValue)
|
bool GetBoolean(const json_t* obj, const std::string& name, bool defaultValue)
|
||||||
{
|
{
|
||||||
auto value = json_object_get(obj, name.c_str());
|
auto value = json_object_get(obj, name.c_str());
|
||||||
return json_is_boolean(value) ?
|
return json_is_boolean(value) ? json_boolean_value(value) : defaultValue;
|
||||||
json_boolean_value(value) :
|
|
||||||
defaultValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetString(const json_t* value)
|
std::string GetString(const json_t* value)
|
||||||
{
|
{
|
||||||
return json_is_string(value) ?
|
return json_is_string(value) ? std::string(json_string_value(value)) : std::string();
|
||||||
std::string(json_string_value(value)) :
|
|
||||||
std::string();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetString(const json_t* obj, const std::string& name, const std::string& defaultValue)
|
std::string GetString(const json_t* obj, const std::string& name, const std::string& defaultValue)
|
||||||
{
|
{
|
||||||
auto value = json_object_get(obj, name.c_str());
|
auto value = json_object_get(obj, name.c_str());
|
||||||
return json_is_string(value) ?
|
return json_is_string(value) ? json_string_value(value) : defaultValue;
|
||||||
json_string_value(value) :
|
|
||||||
defaultValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t GetInteger(const json_t* obj, const std::string& name, const int32_t& defaultValue)
|
int32_t GetInteger(const json_t* obj, const std::string& name, const int32_t& defaultValue)
|
||||||
|
@ -62,8 +58,7 @@ namespace ObjectJsonHelpers
|
||||||
if (json_is_integer(value))
|
if (json_is_integer(value))
|
||||||
{
|
{
|
||||||
int64_t val = json_integer_value(value);
|
int64_t val = json_integer_value(value);
|
||||||
if (val >= std::numeric_limits<int32_t>::min() &&
|
if (val >= std::numeric_limits<int32_t>::min() && val <= std::numeric_limits<int32_t>::max())
|
||||||
val <= std::numeric_limits<int32_t>::max())
|
|
||||||
{
|
{
|
||||||
return static_cast<int32_t>(val);
|
return static_cast<int32_t>(val);
|
||||||
}
|
}
|
||||||
|
@ -74,9 +69,7 @@ namespace ObjectJsonHelpers
|
||||||
float GetFloat(const json_t* obj, const std::string& name, const float& defaultValue)
|
float GetFloat(const json_t* obj, const std::string& name, const float& defaultValue)
|
||||||
{
|
{
|
||||||
auto value = json_object_get(obj, name.c_str());
|
auto value = json_object_get(obj, name.c_str());
|
||||||
return json_is_number(value) ?
|
return json_is_number(value) ? json_number_value(value) : defaultValue;
|
||||||
json_number_value(value) :
|
|
||||||
defaultValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> GetJsonStringArray(const json_t* arr)
|
std::vector<std::string> GetJsonStringArray(const json_t* arr)
|
||||||
|
@ -121,8 +114,7 @@ namespace ObjectJsonHelpers
|
||||||
|
|
||||||
uint8_t ParseCursor(const std::string& s, uint8_t defaultValue)
|
uint8_t ParseCursor(const std::string& s, uint8_t defaultValue)
|
||||||
{
|
{
|
||||||
static const std::unordered_map<std::string, uint8_t> LookupTable
|
static const std::unordered_map<std::string, uint8_t> LookupTable{
|
||||||
{
|
|
||||||
{ "CURSOR_BLANK", CURSOR_BLANK },
|
{ "CURSOR_BLANK", CURSOR_BLANK },
|
||||||
{ "CURSOR_UP_ARROW", CURSOR_UP_ARROW },
|
{ "CURSOR_UP_ARROW", CURSOR_UP_ARROW },
|
||||||
{ "CURSOR_UP_DOWN_ARROW", CURSOR_UP_DOWN_ARROW },
|
{ "CURSOR_UP_DOWN_ARROW", CURSOR_UP_DOWN_ARROW },
|
||||||
|
@ -153,9 +145,7 @@ namespace ObjectJsonHelpers
|
||||||
};
|
};
|
||||||
|
|
||||||
auto result = LookupTable.find(s);
|
auto result = LookupTable.find(s);
|
||||||
return (result != LookupTable.end()) ?
|
return (result != LookupTable.end()) ? result->second : defaultValue;
|
||||||
result->second :
|
|
||||||
defaultValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rct_object_entry ParseObjectEntry(const std::string& s)
|
rct_object_entry ParseObjectEntry(const std::string& s)
|
||||||
|
@ -225,7 +215,8 @@ namespace ObjectJsonHelpers
|
||||||
return objectPath;
|
return objectPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::vector<rct_g1_element> LoadObjectImages(IReadObjectContext * context, const std::string &name, const std::vector<int32_t> &range)
|
static std::vector<rct_g1_element>
|
||||||
|
LoadObjectImages(IReadObjectContext* context, const std::string& name, const std::vector<int32_t>& range)
|
||||||
{
|
{
|
||||||
std::vector<rct_g1_element> result;
|
std::vector<rct_g1_element> result;
|
||||||
auto objectPath = FindLegacyObject(name);
|
auto objectPath = FindLegacyObject(name);
|
||||||
|
@ -397,10 +388,14 @@ namespace ObjectJsonHelpers
|
||||||
|
|
||||||
static uint8_t ParseStringId(const std::string& s)
|
static uint8_t ParseStringId(const std::string& s)
|
||||||
{
|
{
|
||||||
if (s == "name") return OBJ_STRING_ID_NAME;
|
if (s == "name")
|
||||||
if (s == "description") return OBJ_STRING_ID_DESCRIPTION;
|
return OBJ_STRING_ID_NAME;
|
||||||
if (s == "capacity") return OBJ_STRING_ID_CAPACITY;
|
if (s == "description")
|
||||||
if (s == "vehicleName") return OBJ_STRING_ID_VEHICLE_NAME;
|
return OBJ_STRING_ID_DESCRIPTION;
|
||||||
|
if (s == "capacity")
|
||||||
|
return OBJ_STRING_ID_CAPACITY;
|
||||||
|
if (s == "vehicleName")
|
||||||
|
return OBJ_STRING_ID_VEHICLE_NAME;
|
||||||
return OBJ_STRING_ID_UNKNOWN;
|
return OBJ_STRING_ID_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <initializer_list>
|
|
||||||
#include <string>
|
|
||||||
#include <utility>
|
|
||||||
#include <vector>
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
#include "../core/Json.hpp"
|
#include "../core/Json.hpp"
|
||||||
#include "../drawing/Drawing.h"
|
#include "../drawing/Drawing.h"
|
||||||
|
@ -20,6 +16,11 @@
|
||||||
#include "ImageTable.h"
|
#include "ImageTable.h"
|
||||||
#include "StringTable.h"
|
#include "StringTable.h"
|
||||||
|
|
||||||
|
#include <initializer_list>
|
||||||
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace ObjectJsonHelpers
|
namespace ObjectJsonHelpers
|
||||||
{
|
{
|
||||||
bool GetBoolean(const json_t* obj, const std::string& name, bool defaultValue = false);
|
bool GetBoolean(const json_t* obj, const std::string& name, bool defaultValue = false);
|
||||||
|
@ -34,8 +35,7 @@ namespace ObjectJsonHelpers
|
||||||
void LoadStrings(const json_t* root, StringTable& stringTable);
|
void LoadStrings(const json_t* root, StringTable& stringTable);
|
||||||
void LoadImages(IReadObjectContext* context, const json_t* root, ImageTable& imageTable);
|
void LoadImages(IReadObjectContext* context, const json_t* root, ImageTable& imageTable);
|
||||||
|
|
||||||
template<typename T>
|
template<typename T> static T GetFlags(const json_t* obj, std::initializer_list<std::pair<std::string, T>> list)
|
||||||
static T GetFlags(const json_t * obj, std::initializer_list<std::pair<std::string, T>> list)
|
|
||||||
{
|
{
|
||||||
T flags = 0;
|
T flags = 0;
|
||||||
for (const auto& item : list)
|
for (const auto& item : list)
|
||||||
|
|
|
@ -7,18 +7,19 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include <cstring>
|
#include "ObjectList.h"
|
||||||
|
|
||||||
#include "../Context.h"
|
#include "../Context.h"
|
||||||
|
#include "../Game.h"
|
||||||
#include "../core/Math.hpp"
|
#include "../core/Math.hpp"
|
||||||
#include "../core/Util.hpp"
|
#include "../core/Util.hpp"
|
||||||
#include "../Game.h"
|
|
||||||
#include "../object/Object.h"
|
#include "../object/Object.h"
|
||||||
#include "ObjectList.h"
|
|
||||||
#include "ObjectRepository.h"
|
|
||||||
#include "ObjectManager.h"
|
|
||||||
#include "../util/SawyerCoding.h"
|
#include "../util/SawyerCoding.h"
|
||||||
#include "../util/Util.h"
|
#include "../util/Util.h"
|
||||||
|
#include "ObjectManager.h"
|
||||||
|
#include "ObjectRepository.h"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
// 98DA00
|
// 98DA00
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
@ -58,8 +59,10 @@ bool object_entry_is_empty(const rct_object_entry *entry)
|
||||||
memcpy(&a, (uint8_t*)entry, 8);
|
memcpy(&a, (uint8_t*)entry, 8);
|
||||||
memcpy(&b, (uint8_t*)entry + 8, 8);
|
memcpy(&b, (uint8_t*)entry + 8, 8);
|
||||||
|
|
||||||
if (a == 0xFFFFFFFFFFFFFFFF && b == 0xFFFFFFFFFFFFFFFF) return true;
|
if (a == 0xFFFFFFFFFFFFFFFF && b == 0xFFFFFFFFFFFFFFFF)
|
||||||
if (a == 0 && b == 0) return true;
|
return true;
|
||||||
|
if (a == 0 && b == 0)
|
||||||
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,16 +121,21 @@ void get_type_entry_index(size_t index, uint8_t * outObjectType, uint8_t * outEn
|
||||||
uint8_t objectType = OBJECT_TYPE_RIDE;
|
uint8_t objectType = OBJECT_TYPE_RIDE;
|
||||||
for (size_t groupCount : object_entry_group_counts)
|
for (size_t groupCount : object_entry_group_counts)
|
||||||
{
|
{
|
||||||
if (index >= groupCount) {
|
if (index >= groupCount)
|
||||||
|
{
|
||||||
index -= groupCount;
|
index -= groupCount;
|
||||||
objectType++;
|
objectType++;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outObjectType != nullptr) *outObjectType = objectType;
|
if (outObjectType != nullptr)
|
||||||
if (outEntryIndex != nullptr) *outEntryIndex = (uint8_t)index;
|
*outObjectType = objectType;
|
||||||
|
if (outEntryIndex != nullptr)
|
||||||
|
*outEntryIndex = (uint8_t)index;
|
||||||
}
|
}
|
||||||
|
|
||||||
const rct_object_entry* get_loaded_object_entry(size_t index)
|
const rct_object_entry* get_loaded_object_entry(size_t index)
|
||||||
|
|
|
@ -7,27 +7,28 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include "ObjectManager.h"
|
||||||
|
|
||||||
|
#include "../Context.h"
|
||||||
|
#include "../ParkImporter.h"
|
||||||
|
#include "../core/Console.hpp"
|
||||||
|
#include "../core/Memory.hpp"
|
||||||
|
#include "../localisation/StringIds.h"
|
||||||
|
#include "FootpathItemObject.h"
|
||||||
|
#include "LargeSceneryObject.h"
|
||||||
|
#include "Object.h"
|
||||||
|
#include "ObjectList.h"
|
||||||
|
#include "ObjectRepository.h"
|
||||||
|
#include "SceneryGroupObject.h"
|
||||||
|
#include "SmallSceneryObject.h"
|
||||||
|
#include "WallObject.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include "../Context.h"
|
|
||||||
#include "../core/Console.hpp"
|
|
||||||
#include "../core/Memory.hpp"
|
|
||||||
#include "../localisation/StringIds.h"
|
|
||||||
#include "../ParkImporter.h"
|
|
||||||
#include "FootpathItemObject.h"
|
|
||||||
#include "LargeSceneryObject.h"
|
|
||||||
#include "Object.h"
|
|
||||||
#include "ObjectManager.h"
|
|
||||||
#include "ObjectRepository.h"
|
|
||||||
#include "SceneryGroupObject.h"
|
|
||||||
#include "SmallSceneryObject.h"
|
|
||||||
#include "WallObject.h"
|
|
||||||
|
|
||||||
#include "ObjectList.h"
|
|
||||||
|
|
||||||
class ObjectManager final : public IObjectManager
|
class ObjectManager final : public IObjectManager
|
||||||
{
|
{
|
||||||
|
@ -203,9 +204,7 @@ public:
|
||||||
for (size_t i = 0; i < numObjects; i++)
|
for (size_t i = 0; i < numObjects; i++)
|
||||||
{
|
{
|
||||||
const ObjectRepositoryItem* item = &_objectRepository->GetObjects()[i];
|
const ObjectRepositoryItem* item = &_objectRepository->GetObjects()[i];
|
||||||
if (item->LoadedObject != nullptr &&
|
if (item->LoadedObject != nullptr && item->LoadedObject->GetLegacyData() != nullptr && IsObjectCustom(item))
|
||||||
item->LoadedObject->GetLegacyData() != nullptr &&
|
|
||||||
IsObjectCustom(item))
|
|
||||||
{
|
{
|
||||||
objects.push_back(item);
|
objects.push_back(item);
|
||||||
}
|
}
|
||||||
|
@ -359,7 +358,8 @@ private:
|
||||||
if (loadedObject != nullptr)
|
if (loadedObject != nullptr)
|
||||||
{
|
{
|
||||||
rct_scenery_entry* sceneryEntry;
|
rct_scenery_entry* sceneryEntry;
|
||||||
switch (loadedObject->GetObjectType()) {
|
switch (loadedObject->GetObjectType())
|
||||||
|
{
|
||||||
case OBJECT_TYPE_SMALL_SCENERY:
|
case OBJECT_TYPE_SMALL_SCENERY:
|
||||||
sceneryEntry = (rct_scenery_entry*)loadedObject->GetLegacyData();
|
sceneryEntry = (rct_scenery_entry*)loadedObject->GetLegacyData();
|
||||||
sceneryEntry->small_scenery.scenery_tab_id = GetPrimarySceneryGroupEntryIndex(loadedObject);
|
sceneryEntry->small_scenery.scenery_tab_id = GetPrimarySceneryGroupEntryIndex(loadedObject);
|
||||||
|
@ -493,8 +493,7 @@ private:
|
||||||
return requiredObjects;
|
return requiredObjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename TFunc>
|
template<typename T, typename TFunc> static void ParallelFor(const std::vector<T>& items, TFunc func)
|
||||||
static void ParallelFor(const std::vector<T>& items, TFunc func)
|
|
||||||
{
|
{
|
||||||
auto partitions = std::thread::hardware_concurrency();
|
auto partitions = std::thread::hardware_concurrency();
|
||||||
auto partitionSize = (items.size() + (partitions - 1)) / partitions;
|
auto partitionSize = (items.size() + (partitions - 1)) / partitions;
|
||||||
|
@ -504,8 +503,7 @@ private:
|
||||||
auto begin = n * partitionSize;
|
auto begin = n * partitionSize;
|
||||||
auto end = std::min(items.size(), begin + partitionSize);
|
auto end = std::min(items.size(), begin + partitionSize);
|
||||||
threads.emplace_back(
|
threads.emplace_back(
|
||||||
[func](size_t pbegin, size_t pend)
|
[func](size_t pbegin, size_t pend) {
|
||||||
{
|
|
||||||
for (size_t i = pbegin; i < pend; i++)
|
for (size_t i = pbegin; i < pend; i++)
|
||||||
{
|
{
|
||||||
func(i);
|
func(i);
|
||||||
|
@ -530,10 +528,7 @@ private:
|
||||||
|
|
||||||
// Read objects
|
// Read objects
|
||||||
std::mutex commonMutex;
|
std::mutex commonMutex;
|
||||||
ParallelFor(
|
ParallelFor(requiredObjects, [this, &commonMutex, requiredObjects, &objects, &badObjects, &loadedObjects](size_t i) {
|
||||||
requiredObjects,
|
|
||||||
[this, &commonMutex, requiredObjects, &objects, &badObjects, &loadedObjects](size_t i)
|
|
||||||
{
|
|
||||||
auto ori = requiredObjects[i];
|
auto ori = requiredObjects[i];
|
||||||
Object* loadedObject = nullptr;
|
Object* loadedObject = nullptr;
|
||||||
if (ori != nullptr)
|
if (ori != nullptr)
|
||||||
|
|
|
@ -9,17 +9,20 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
#include "../object/Object.h"
|
#include "../object/Object.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
interface IObjectRepository;
|
interface IObjectRepository;
|
||||||
class Object;
|
class Object;
|
||||||
struct ObjectRepositoryItem;
|
struct ObjectRepositoryItem;
|
||||||
|
|
||||||
interface IObjectManager
|
interface IObjectManager
|
||||||
{
|
{
|
||||||
virtual ~IObjectManager() { }
|
virtual ~IObjectManager()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
virtual Object* GetLoadedObject(size_t index) abstract;
|
virtual Object* GetLoadedObject(size_t index) abstract;
|
||||||
virtual Object* GetLoadedObject(int32_t objectType, size_t index) abstract;
|
virtual Object* GetLoadedObject(int32_t objectType, size_t index) abstract;
|
||||||
|
|
|
@ -7,13 +7,12 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include <algorithm>
|
#include "ObjectRepository.h"
|
||||||
#include <memory>
|
|
||||||
#include <unordered_map>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "../common.h"
|
|
||||||
#include "../Context.h"
|
#include "../Context.h"
|
||||||
|
#include "../PlatformEnvironment.h"
|
||||||
|
#include "../common.h"
|
||||||
|
#include "../config/Config.h"
|
||||||
#include "../core/Console.hpp"
|
#include "../core/Console.hpp"
|
||||||
#include "../core/FileIndex.hpp"
|
#include "../core/FileIndex.hpp"
|
||||||
#include "../core/FileStream.hpp"
|
#include "../core/FileStream.hpp"
|
||||||
|
@ -23,25 +22,26 @@
|
||||||
#include "../core/MemoryStream.h"
|
#include "../core/MemoryStream.h"
|
||||||
#include "../core/Path.hpp"
|
#include "../core/Path.hpp"
|
||||||
#include "../core/String.hpp"
|
#include "../core/String.hpp"
|
||||||
#include "../PlatformEnvironment.h"
|
|
||||||
#include "../rct12/SawyerChunkReader.h"
|
|
||||||
#include "../rct12/SawyerChunkWriter.h"
|
|
||||||
#include "../scenario/ScenarioRepository.h"
|
|
||||||
#include "Object.h"
|
|
||||||
#include "ObjectFactory.h"
|
|
||||||
#include "ObjectManager.h"
|
|
||||||
#include "ObjectRepository.h"
|
|
||||||
#include "RideObject.h"
|
|
||||||
#include "StexObject.h"
|
|
||||||
|
|
||||||
#include "../config/Config.h"
|
|
||||||
#include "../localisation/Localisation.h"
|
#include "../localisation/Localisation.h"
|
||||||
#include "../localisation/LocalisationService.h"
|
#include "../localisation/LocalisationService.h"
|
||||||
#include "../object/Object.h"
|
#include "../object/Object.h"
|
||||||
#include "ObjectList.h"
|
|
||||||
#include "../platform/platform.h"
|
#include "../platform/platform.h"
|
||||||
|
#include "../rct12/SawyerChunkReader.h"
|
||||||
|
#include "../rct12/SawyerChunkWriter.h"
|
||||||
|
#include "../scenario/ScenarioRepository.h"
|
||||||
#include "../util/SawyerCoding.h"
|
#include "../util/SawyerCoding.h"
|
||||||
#include "../util/Util.h"
|
#include "../util/Util.h"
|
||||||
|
#include "Object.h"
|
||||||
|
#include "ObjectFactory.h"
|
||||||
|
#include "ObjectList.h"
|
||||||
|
#include "ObjectManager.h"
|
||||||
|
#include "RideObject.h"
|
||||||
|
#include "StexObject.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <memory>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
using namespace OpenRCT2;
|
using namespace OpenRCT2;
|
||||||
|
|
||||||
|
@ -78,16 +78,16 @@ private:
|
||||||
IObjectRepository& _objectRepository;
|
IObjectRepository& _objectRepository;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ObjectFileIndex(IObjectRepository& objectRepository, const IPlatformEnvironment& env) :
|
explicit ObjectFileIndex(IObjectRepository& objectRepository, const IPlatformEnvironment& env)
|
||||||
FileIndex("object index",
|
: FileIndex(
|
||||||
|
"object index",
|
||||||
MAGIC_NUMBER,
|
MAGIC_NUMBER,
|
||||||
VERSION,
|
VERSION,
|
||||||
env.GetFilePath(PATHID::CACHE_OBJECTS),
|
env.GetFilePath(PATHID::CACHE_OBJECTS),
|
||||||
std::string(PATTERN),
|
std::string(PATTERN),
|
||||||
std::vector<std::string>({
|
std::vector<std::string>({ env.GetDirectoryPath(DIRBASE::OPENRCT2, DIRID::OBJECT),
|
||||||
env.GetDirectoryPath(DIRBASE::OPENRCT2, DIRID::OBJECT),
|
env.GetDirectoryPath(DIRBASE::USER, DIRID::OBJECT) }))
|
||||||
env.GetDirectoryPath(DIRBASE::USER, DIRID::OBJECT) })),
|
, _objectRepository(objectRepository)
|
||||||
_objectRepository(objectRepository)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +128,8 @@ protected:
|
||||||
stream->WriteString(item.Path);
|
stream->WriteString(item.Path);
|
||||||
stream->WriteString(item.Name);
|
stream->WriteString(item.Name);
|
||||||
|
|
||||||
switch (object_entry_get_type(&item.ObjectEntry)) {
|
switch (object_entry_get_type(&item.ObjectEntry))
|
||||||
|
{
|
||||||
case OBJECT_TYPE_RIDE:
|
case OBJECT_TYPE_RIDE:
|
||||||
stream->WriteValue<uint8_t>(item.RideInfo.RideFlags);
|
stream->WriteValue<uint8_t>(item.RideInfo.RideFlags);
|
||||||
for (int32_t i = 0; i < MAX_CATEGORIES_PER_RIDE; i++)
|
for (int32_t i = 0; i < MAX_CATEGORIES_PER_RIDE; i++)
|
||||||
|
@ -159,7 +160,8 @@ protected:
|
||||||
item.Path = stream->ReadStdString();
|
item.Path = stream->ReadStdString();
|
||||||
item.Name = stream->ReadStdString();
|
item.Name = stream->ReadStdString();
|
||||||
|
|
||||||
switch (object_entry_get_type(&item.ObjectEntry)) {
|
switch (object_entry_get_type(&item.ObjectEntry))
|
||||||
|
{
|
||||||
case OBJECT_TYPE_RIDE:
|
case OBJECT_TYPE_RIDE:
|
||||||
item.RideInfo.RideFlags = stream->ReadValue<uint8_t>();
|
item.RideInfo.RideFlags = stream->ReadValue<uint8_t>();
|
||||||
for (int32_t i = 0; i < MAX_CATEGORIES_PER_RIDE; i++)
|
for (int32_t i = 0; i < MAX_CATEGORIES_PER_RIDE; i++)
|
||||||
|
@ -189,9 +191,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
bool IsTrackReadOnly(const std::string& path) const
|
bool IsTrackReadOnly(const std::string& path) const
|
||||||
{
|
{
|
||||||
return
|
return String::StartsWith(path, SearchPaths[0]) || String::StartsWith(path, SearchPaths[1]);
|
||||||
String::StartsWith(path, SearchPaths[0]) ||
|
|
||||||
String::StartsWith(path, SearchPaths[1]);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -204,8 +204,8 @@ class ObjectRepository final : public IObjectRepository
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ObjectRepository(const std::shared_ptr<IPlatformEnvironment>& env)
|
explicit ObjectRepository(const std::shared_ptr<IPlatformEnvironment>& env)
|
||||||
: _env(env),
|
: _env(env)
|
||||||
_fileIndex(*this, *env)
|
, _fileIndex(*this, *env)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,9 +375,7 @@ private:
|
||||||
|
|
||||||
void SortItems()
|
void SortItems()
|
||||||
{
|
{
|
||||||
std::sort(_items.begin(), _items.end(), [](const ObjectRepositoryItem &a,
|
std::sort(_items.begin(), _items.end(), [](const ObjectRepositoryItem& a, const ObjectRepositoryItem& b) -> bool {
|
||||||
const ObjectRepositoryItem &b) -> bool
|
|
||||||
{
|
|
||||||
return String::Compare(a.Name, b.Name) < 0;
|
return String::Compare(a.Name, b.Name) < 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -443,10 +441,8 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SaveObject(const utf8 * path,
|
static void
|
||||||
const rct_object_entry * entry,
|
SaveObject(const utf8* path, const rct_object_entry* entry, const void* data, size_t dataSize, bool fixChecksum = true)
|
||||||
const void * data, size_t dataSize,
|
|
||||||
bool fixChecksum = true)
|
|
||||||
{
|
{
|
||||||
if (fixChecksum)
|
if (fixChecksum)
|
||||||
{
|
{
|
||||||
|
@ -525,7 +521,8 @@ private:
|
||||||
{
|
{
|
||||||
// Allocate 11 extra bytes to manipulate the checksum
|
// Allocate 11 extra bytes to manipulate the checksum
|
||||||
uint8_t* salt = Memory::Allocate<uint8_t>(11);
|
uint8_t* salt = Memory::Allocate<uint8_t>(11);
|
||||||
if (outSize != nullptr) *outSize = 11;
|
if (outSize != nullptr)
|
||||||
|
*outSize = 11;
|
||||||
|
|
||||||
// Next work out which bits need to be flipped to make the current checksum match the one in the file
|
// Next work out which bits need to be flipped to make the current checksum match the one in the file
|
||||||
// The bitwise rotation compensates for the rotation performed during the checksum calculation*/
|
// The bitwise rotation compensates for the rotation performed during the checksum calculation*/
|
||||||
|
|
|
@ -9,12 +9,13 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <vector>
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
#include "../object/Object.h"
|
#include "../object/Object.h"
|
||||||
#include "../ride/Ride.h"
|
#include "../ride/Ride.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
interface IStream;
|
interface IStream;
|
||||||
class Object;
|
class Object;
|
||||||
namespace OpenRCT2
|
namespace OpenRCT2
|
||||||
|
@ -64,9 +65,7 @@ interface IObjectRepository
|
||||||
virtual void RegisterLoadedObject(const ObjectRepositoryItem* ori, Object* object) abstract;
|
virtual void RegisterLoadedObject(const ObjectRepositoryItem* ori, Object* object) abstract;
|
||||||
virtual void UnregisterLoadedObject(const ObjectRepositoryItem* ori, Object* object) abstract;
|
virtual void UnregisterLoadedObject(const ObjectRepositoryItem* ori, Object* object) abstract;
|
||||||
|
|
||||||
virtual void AddObject(const rct_object_entry * objectEntry,
|
virtual void AddObject(const rct_object_entry* objectEntry, const void* data, size_t dataSize) abstract;
|
||||||
const void * data,
|
|
||||||
size_t dataSize) abstract;
|
|
||||||
|
|
||||||
virtual void ExportPackedObject(IStream * stream) abstract;
|
virtual void ExportPackedObject(IStream * stream) abstract;
|
||||||
virtual void WritePackedObjects(IStream * stream, std::vector<const ObjectRepositoryItem*> & objects) abstract;
|
virtual void WritePackedObjects(IStream * stream, std::vector<const ObjectRepositoryItem*> & objects) abstract;
|
||||||
|
|
|
@ -9,24 +9,26 @@
|
||||||
|
|
||||||
#pragma warning(disable : 4706) // assignment within conditional expression
|
#pragma warning(disable : 4706) // assignment within conditional expression
|
||||||
|
|
||||||
#include <algorithm>
|
#include "RideObject.h"
|
||||||
#include <unordered_map>
|
|
||||||
|
#include "../OpenRCT2.h"
|
||||||
#include "../core/IStream.hpp"
|
#include "../core/IStream.hpp"
|
||||||
#include "../core/Math.hpp"
|
#include "../core/Math.hpp"
|
||||||
#include "../core/Memory.hpp"
|
#include "../core/Memory.hpp"
|
||||||
#include "../core/String.hpp"
|
#include "../core/String.hpp"
|
||||||
#include "../core/Util.hpp"
|
#include "../core/Util.hpp"
|
||||||
#include "../ride/RideGroupManager.h"
|
|
||||||
#include "../drawing/Drawing.h"
|
#include "../drawing/Drawing.h"
|
||||||
#include "../localisation/Language.h"
|
#include "../localisation/Language.h"
|
||||||
#include "../rct2/RCT2.h"
|
#include "../rct2/RCT2.h"
|
||||||
#include "../ride/Ride.h"
|
#include "../ride/Ride.h"
|
||||||
|
#include "../ride/RideGroupManager.h"
|
||||||
#include "../ride/ShopItem.h"
|
#include "../ride/ShopItem.h"
|
||||||
#include "../ride/Track.h"
|
#include "../ride/Track.h"
|
||||||
#include "../OpenRCT2.h"
|
|
||||||
#include "ObjectJsonHelpers.h"
|
#include "ObjectJsonHelpers.h"
|
||||||
#include "ObjectRepository.h"
|
#include "ObjectRepository.h"
|
||||||
#include "RideObject.h"
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
using namespace OpenRCT2;
|
using namespace OpenRCT2;
|
||||||
|
|
||||||
|
@ -164,12 +166,12 @@ void RideObject::Load()
|
||||||
rct_ride_entry_vehicle* vehicleEntry = &_legacyType.vehicles[i];
|
rct_ride_entry_vehicle* vehicleEntry = &_legacyType.vehicles[i];
|
||||||
if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_FLAT)
|
if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_FLAT)
|
||||||
{
|
{
|
||||||
// RCT2 calculates num_vertical_frames and num_horizontal_frames and overwrites these properties on the vehicle entry.
|
// RCT2 calculates num_vertical_frames and num_horizontal_frames and overwrites these properties on the vehicle
|
||||||
// Immediately afterwards, the two were multiplied in order to calculate base_num_frames and were never used again.
|
// entry. Immediately afterwards, the two were multiplied in order to calculate base_num_frames and were never used
|
||||||
// This has been changed to use the calculation results directly -
|
// again. This has been changed to use the calculation results directly - num_vertical_frames and
|
||||||
// num_vertical_frames and num_horizontal_frames are no longer set on the vehicle entry.
|
// num_horizontal_frames are no longer set on the vehicle entry. 0x6DE946
|
||||||
// 0x6DE946
|
vehicleEntry->base_num_frames
|
||||||
vehicleEntry->base_num_frames = CalculateNumVerticalFrames(vehicleEntry) * CalculateNumHorizontalFrames(vehicleEntry);
|
= CalculateNumVerticalFrames(vehicleEntry) * CalculateNumHorizontalFrames(vehicleEntry);
|
||||||
vehicleEntry->base_image_id = cur_vehicle_images_offset;
|
vehicleEntry->base_image_id = cur_vehicle_images_offset;
|
||||||
int32_t image_index = vehicleEntry->base_image_id;
|
int32_t image_index = vehicleEntry->base_image_id;
|
||||||
|
|
||||||
|
@ -177,8 +179,10 @@ void RideObject::Load()
|
||||||
{
|
{
|
||||||
int32_t b = vehicleEntry->base_num_frames * 32;
|
int32_t b = vehicleEntry->base_num_frames * 32;
|
||||||
|
|
||||||
if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_11) b /= 2;
|
if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_11)
|
||||||
if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_15) b /= 8;
|
b /= 2;
|
||||||
|
if (vehicleEntry->sprite_flags & VEHICLE_SPRITE_FLAG_15)
|
||||||
|
b /= 8;
|
||||||
|
|
||||||
image_index += b;
|
image_index += b;
|
||||||
|
|
||||||
|
@ -305,7 +309,8 @@ void RideObject::Load()
|
||||||
num_images *= 2;
|
num_images *= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gOpenRCT2NoGraphics) {
|
if (!gOpenRCT2NoGraphics)
|
||||||
|
{
|
||||||
set_vehicle_type_image_max_sizes(vehicleEntry, num_images);
|
set_vehicle_type_image_max_sizes(vehicleEntry, num_images);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -449,7 +454,8 @@ uint8_t RideObject::CalculateNumVerticalFrames(const rct_ride_entry_vehicle * ve
|
||||||
{
|
{
|
||||||
if (!(vehicleEntry->flags & VEHICLE_ENTRY_FLAG_SPINNING_ADDITIONAL_FRAMES))
|
if (!(vehicleEntry->flags & VEHICLE_ENTRY_FLAG_SPINNING_ADDITIONAL_FRAMES))
|
||||||
{
|
{
|
||||||
if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_VEHICLE_ANIMATION && vehicleEntry->animation != VEHICLE_ENTRY_ANIMATION_OBSERVATION_TOWER)
|
if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_VEHICLE_ANIMATION
|
||||||
|
&& vehicleEntry->animation != VEHICLE_ENTRY_ANIMATION_OBSERVATION_TOWER)
|
||||||
{
|
{
|
||||||
if (!(vehicleEntry->flags & VEHICLE_ENTRY_FLAG_DODGEM_INUSE_LIGHTS))
|
if (!(vehicleEntry->flags & VEHICLE_ENTRY_FLAG_DODGEM_INUSE_LIGHTS))
|
||||||
{
|
{
|
||||||
|
@ -620,8 +626,9 @@ void RideObject::ReadJson(IReadObjectContext * context, const json_t * root)
|
||||||
_presetColours = ReadJsonCarColours(json_object_get(properties, "carColours"));
|
_presetColours = ReadJsonCarColours(json_object_get(properties, "carColours"));
|
||||||
}
|
}
|
||||||
|
|
||||||
_legacyType.flags |= ObjectJsonHelpers::GetFlags<uint32_t>(properties, {
|
_legacyType.flags |= ObjectJsonHelpers::GetFlags<uint32_t>(
|
||||||
{ "noInversions", RIDE_ENTRY_FLAG_NO_INVERSIONS },
|
properties,
|
||||||
|
{ { "noInversions", RIDE_ENTRY_FLAG_NO_INVERSIONS },
|
||||||
{ "noBanking", RIDE_ENTRY_FLAG_NO_BANKED_TRACK },
|
{ "noBanking", RIDE_ENTRY_FLAG_NO_BANKED_TRACK },
|
||||||
{ "playDepartSound", RIDE_ENTRY_FLAG_PLAY_DEPART_SOUND },
|
{ "playDepartSound", RIDE_ENTRY_FLAG_PLAY_DEPART_SOUND },
|
||||||
// Skipping "disallowWandering", no vehicle sets this flag.
|
// Skipping "disallowWandering", no vehicle sets this flag.
|
||||||
|
@ -797,8 +804,9 @@ rct_ride_entry_vehicle RideObject::ReadJsonCar(const json_t * jCar)
|
||||||
}
|
}
|
||||||
|
|
||||||
auto jFrames = json_object_get(jCar, "frames");
|
auto jFrames = json_object_get(jCar, "frames");
|
||||||
car.sprite_flags = ObjectJsonHelpers::GetFlags<uint16_t>(jFrames, {
|
car.sprite_flags = ObjectJsonHelpers::GetFlags<uint16_t>(
|
||||||
{ "flat", VEHICLE_SPRITE_FLAG_FLAT },
|
jFrames,
|
||||||
|
{ { "flat", VEHICLE_SPRITE_FLAG_FLAT },
|
||||||
{ "gentleSlopes", VEHICLE_SPRITE_FLAG_GENTLE_SLOPES },
|
{ "gentleSlopes", VEHICLE_SPRITE_FLAG_GENTLE_SLOPES },
|
||||||
{ "steepSlopes", VEHICLE_SPRITE_FLAG_STEEP_SLOPES },
|
{ "steepSlopes", VEHICLE_SPRITE_FLAG_STEEP_SLOPES },
|
||||||
{ "verticalSlopes", VEHICLE_SPRITE_FLAG_VERTICAL_SLOPES },
|
{ "verticalSlopes", VEHICLE_SPRITE_FLAG_VERTICAL_SLOPES },
|
||||||
|
@ -815,8 +823,9 @@ rct_ride_entry_vehicle RideObject::ReadJsonCar(const json_t * jCar)
|
||||||
{ "curvedLiftHill", VEHICLE_SPRITE_FLAG_CURVED_LIFT_HILL },
|
{ "curvedLiftHill", VEHICLE_SPRITE_FLAG_CURVED_LIFT_HILL },
|
||||||
{ "VEHICLE_SPRITE_FLAG_15", VEHICLE_SPRITE_FLAG_15 } });
|
{ "VEHICLE_SPRITE_FLAG_15", VEHICLE_SPRITE_FLAG_15 } });
|
||||||
|
|
||||||
car.flags |= ObjectJsonHelpers::GetFlags<uint32_t>(jCar, {
|
car.flags |= ObjectJsonHelpers::GetFlags<uint32_t>(
|
||||||
{ "VEHICLE_ENTRY_FLAG_POWERED_RIDE_UNRESTRICTED_GRAVITY", VEHICLE_ENTRY_FLAG_POWERED_RIDE_UNRESTRICTED_GRAVITY },
|
jCar,
|
||||||
|
{ { "VEHICLE_ENTRY_FLAG_POWERED_RIDE_UNRESTRICTED_GRAVITY", VEHICLE_ENTRY_FLAG_POWERED_RIDE_UNRESTRICTED_GRAVITY },
|
||||||
{ "VEHICLE_ENTRY_FLAG_NO_UPSTOP_WHEELS", VEHICLE_ENTRY_FLAG_NO_UPSTOP_WHEELS },
|
{ "VEHICLE_ENTRY_FLAG_NO_UPSTOP_WHEELS", VEHICLE_ENTRY_FLAG_NO_UPSTOP_WHEELS },
|
||||||
{ "VEHICLE_ENTRY_FLAG_NO_UPSTOP_BOBSLEIGH", VEHICLE_ENTRY_FLAG_NO_UPSTOP_BOBSLEIGH },
|
{ "VEHICLE_ENTRY_FLAG_NO_UPSTOP_BOBSLEIGH", VEHICLE_ENTRY_FLAG_NO_UPSTOP_BOBSLEIGH },
|
||||||
{ "VEHICLE_ENTRY_FLAG_MINI_GOLF", VEHICLE_ENTRY_FLAG_MINI_GOLF },
|
{ "VEHICLE_ENTRY_FLAG_MINI_GOLF", VEHICLE_ENTRY_FLAG_MINI_GOLF },
|
||||||
|
@ -939,8 +948,7 @@ bool RideObject::IsRideTypeShopOrFacility(uint8_t rideType)
|
||||||
|
|
||||||
uint8_t RideObject::ParseRideType(const std::string& s)
|
uint8_t RideObject::ParseRideType(const std::string& s)
|
||||||
{
|
{
|
||||||
static const std::unordered_map<std::string, uint8_t> LookupTable
|
static const std::unordered_map<std::string, uint8_t> LookupTable{
|
||||||
{
|
|
||||||
{ "spiral_rc", RIDE_TYPE_SPIRAL_ROLLER_COASTER },
|
{ "spiral_rc", RIDE_TYPE_SPIRAL_ROLLER_COASTER },
|
||||||
{ "stand_up_rc", RIDE_TYPE_STAND_UP_ROLLER_COASTER },
|
{ "stand_up_rc", RIDE_TYPE_STAND_UP_ROLLER_COASTER },
|
||||||
{ "suspended_swinging_rc", RIDE_TYPE_SUSPENDED_SWINGING_COASTER },
|
{ "suspended_swinging_rc", RIDE_TYPE_SUSPENDED_SWINGING_COASTER },
|
||||||
|
@ -1022,15 +1030,12 @@ uint8_t RideObject::ParseRideType(const std::string &s)
|
||||||
{ "lim_launched_rc", RIDE_TYPE_LIM_LAUNCHED_ROLLER_COASTER },
|
{ "lim_launched_rc", RIDE_TYPE_LIM_LAUNCHED_ROLLER_COASTER },
|
||||||
};
|
};
|
||||||
auto result = LookupTable.find(s);
|
auto result = LookupTable.find(s);
|
||||||
return (result != LookupTable.end()) ?
|
return (result != LookupTable.end()) ? result->second : RIDE_TYPE_NULL;
|
||||||
result->second :
|
|
||||||
RIDE_TYPE_NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t RideObject::ParseRideCategory(const std::string& s)
|
uint8_t RideObject::ParseRideCategory(const std::string& s)
|
||||||
{
|
{
|
||||||
static const std::unordered_map<std::string, uint8_t> LookupTable
|
static const std::unordered_map<std::string, uint8_t> LookupTable{
|
||||||
{
|
|
||||||
{ "transport", RIDE_CATEGORY_TRANSPORT },
|
{ "transport", RIDE_CATEGORY_TRANSPORT },
|
||||||
{ "gentle", RIDE_CATEGORY_GENTLE },
|
{ "gentle", RIDE_CATEGORY_GENTLE },
|
||||||
{ "rollercoaster", RIDE_CATEGORY_ROLLERCOASTER },
|
{ "rollercoaster", RIDE_CATEGORY_ROLLERCOASTER },
|
||||||
|
@ -1039,15 +1044,12 @@ uint8_t RideObject::ParseRideCategory(const std::string &s)
|
||||||
{ "stall", RIDE_CATEGORY_SHOP },
|
{ "stall", RIDE_CATEGORY_SHOP },
|
||||||
};
|
};
|
||||||
auto result = LookupTable.find(s);
|
auto result = LookupTable.find(s);
|
||||||
return (result != LookupTable.end()) ?
|
return (result != LookupTable.end()) ? result->second : RIDE_CATEGORY_TRANSPORT;
|
||||||
result->second :
|
|
||||||
RIDE_CATEGORY_TRANSPORT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t RideObject::ParseShopItem(const std::string& s)
|
uint8_t RideObject::ParseShopItem(const std::string& s)
|
||||||
{
|
{
|
||||||
static const std::unordered_map<std::string, uint8_t> LookupTable
|
static const std::unordered_map<std::string, uint8_t> LookupTable{
|
||||||
{
|
|
||||||
{ "burger", SHOP_ITEM_BURGER },
|
{ "burger", SHOP_ITEM_BURGER },
|
||||||
{ "chips", SHOP_ITEM_CHIPS },
|
{ "chips", SHOP_ITEM_CHIPS },
|
||||||
{ "ice_cream", SHOP_ITEM_ICE_CREAM },
|
{ "ice_cream", SHOP_ITEM_ICE_CREAM },
|
||||||
|
@ -1087,15 +1089,12 @@ uint8_t RideObject::ParseShopItem(const std::string &s)
|
||||||
{ "sunglasses", SHOP_ITEM_SUNGLASSES },
|
{ "sunglasses", SHOP_ITEM_SUNGLASSES },
|
||||||
};
|
};
|
||||||
auto result = LookupTable.find(s);
|
auto result = LookupTable.find(s);
|
||||||
return (result != LookupTable.end()) ?
|
return (result != LookupTable.end()) ? result->second : SHOP_ITEM_NONE;
|
||||||
result->second :
|
|
||||||
SHOP_ITEM_NONE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
colour_t RideObject::ParseColour(const std::string& s)
|
colour_t RideObject::ParseColour(const std::string& s)
|
||||||
{
|
{
|
||||||
static const std::unordered_map<std::string, colour_t> LookupTable
|
static const std::unordered_map<std::string, colour_t> LookupTable{
|
||||||
{
|
|
||||||
{ "black", COLOUR_BLACK },
|
{ "black", COLOUR_BLACK },
|
||||||
{ "grey", COLOUR_GREY },
|
{ "grey", COLOUR_GREY },
|
||||||
{ "white", COLOUR_WHITE },
|
{ "white", COLOUR_WHITE },
|
||||||
|
@ -1130,7 +1129,5 @@ colour_t RideObject::ParseColour(const std::string &s)
|
||||||
{ "light_pink", COLOUR_LIGHT_PINK },
|
{ "light_pink", COLOUR_LIGHT_PINK },
|
||||||
};
|
};
|
||||||
auto result = LookupTable.find(s);
|
auto result = LookupTable.find(s);
|
||||||
return (result != LookupTable.end()) ?
|
return (result != LookupTable.end()) ? result->second : COLOUR_BLACK;
|
||||||
result->second :
|
|
||||||
COLOUR_BLACK;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,11 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include "../ride/Ride.h"
|
#include "../ride/Ride.h"
|
||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
class RideObject final : public Object
|
class RideObject final : public Object
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -22,9 +23,15 @@ private:
|
||||||
std::vector<std::array<sLocationXY8, 3>> _peepLoadingWaypoints[MAX_VEHICLES_PER_RIDE_ENTRY];
|
std::vector<std::array<sLocationXY8, 3>> _peepLoadingWaypoints[MAX_VEHICLES_PER_RIDE_ENTRY];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit RideObject(const rct_object_entry &entry) : Object(entry) { }
|
explicit RideObject(const rct_object_entry& entry)
|
||||||
|
: Object(entry)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void * GetLegacyData() override { return &_legacyType; }
|
void* GetLegacyData() override
|
||||||
|
{
|
||||||
|
return &_legacyType;
|
||||||
|
}
|
||||||
|
|
||||||
void ReadJson(IReadObjectContext* context, const json_t* root) override;
|
void ReadJson(IReadObjectContext* context, const json_t* root) override;
|
||||||
void ReadLegacy(IReadObjectContext* context, IStream* stream) override;
|
void ReadLegacy(IReadObjectContext* context, IStream* stream) override;
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
|
|
||||||
#pragma warning(disable : 4706) // assignment within conditional expression
|
#pragma warning(disable : 4706) // assignment within conditional expression
|
||||||
|
|
||||||
#include <unordered_map>
|
#include "SceneryGroupObject.h"
|
||||||
|
|
||||||
#include "../Context.h"
|
#include "../Context.h"
|
||||||
#include "../core/IStream.hpp"
|
#include "../core/IStream.hpp"
|
||||||
#include "../core/Memory.hpp"
|
#include "../core/Memory.hpp"
|
||||||
|
@ -20,7 +21,8 @@
|
||||||
#include "ObjectJsonHelpers.h"
|
#include "ObjectJsonHelpers.h"
|
||||||
#include "ObjectManager.h"
|
#include "ObjectManager.h"
|
||||||
#include "ObjectRepository.h"
|
#include "ObjectRepository.h"
|
||||||
#include "SceneryGroupObject.h"
|
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
using namespace OpenRCT2;
|
using namespace OpenRCT2;
|
||||||
|
|
||||||
|
@ -75,20 +77,34 @@ void SceneryGroupObject::UpdateEntryIndexes()
|
||||||
for (const auto& objectEntry : _items)
|
for (const auto& objectEntry : _items)
|
||||||
{
|
{
|
||||||
auto ori = objectRepository->FindObject(&objectEntry);
|
auto ori = objectRepository->FindObject(&objectEntry);
|
||||||
if (ori == nullptr) continue;
|
if (ori == nullptr)
|
||||||
if (ori->LoadedObject == nullptr) continue;
|
continue;
|
||||||
|
if (ori->LoadedObject == nullptr)
|
||||||
|
continue;
|
||||||
|
|
||||||
uint16_t sceneryEntry = objectManager->GetLoadedObjectEntryIndex(ori->LoadedObject);
|
uint16_t sceneryEntry = objectManager->GetLoadedObjectEntryIndex(ori->LoadedObject);
|
||||||
Guard::Assert(sceneryEntry != UINT8_MAX, GUARD_LINE);
|
Guard::Assert(sceneryEntry != UINT8_MAX, GUARD_LINE);
|
||||||
|
|
||||||
auto objectType = ori->ObjectEntry.flags & 0x0F;
|
auto objectType = ori->ObjectEntry.flags & 0x0F;
|
||||||
switch (objectType) {
|
switch (objectType)
|
||||||
case OBJECT_TYPE_SMALL_SCENERY: break;
|
{
|
||||||
case OBJECT_TYPE_PATH_BITS: sceneryEntry |= 0x100; break;
|
case OBJECT_TYPE_SMALL_SCENERY:
|
||||||
case OBJECT_TYPE_WALLS: sceneryEntry |= 0x200; break;
|
break;
|
||||||
case OBJECT_TYPE_LARGE_SCENERY: sceneryEntry |= 0x300; break;
|
case OBJECT_TYPE_PATH_BITS:
|
||||||
case OBJECT_TYPE_BANNERS: sceneryEntry |= 0x400; break;
|
sceneryEntry |= 0x100;
|
||||||
default: sceneryEntry = 0xFFFF; break;
|
break;
|
||||||
|
case OBJECT_TYPE_WALLS:
|
||||||
|
sceneryEntry |= 0x200;
|
||||||
|
break;
|
||||||
|
case OBJECT_TYPE_LARGE_SCENERY:
|
||||||
|
sceneryEntry |= 0x300;
|
||||||
|
break;
|
||||||
|
case OBJECT_TYPE_BANNERS:
|
||||||
|
sceneryEntry |= 0x400;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
sceneryEntry = 0xFFFF;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (sceneryEntry != 0xFFFF)
|
if (sceneryEntry != 0xFFFF)
|
||||||
{
|
{
|
||||||
|
@ -154,17 +170,28 @@ uint32_t SceneryGroupObject::ReadJsonEntertainerCostumes(const json_t * jCostume
|
||||||
|
|
||||||
uint32_t SceneryGroupObject::ParseEntertainerCostume(const std::string& s)
|
uint32_t SceneryGroupObject::ParseEntertainerCostume(const std::string& s)
|
||||||
{
|
{
|
||||||
if (s == "panda") return ENTERTAINER_COSTUME_PANDA;
|
if (s == "panda")
|
||||||
if (s == "tiger") return ENTERTAINER_COSTUME_TIGER;
|
return ENTERTAINER_COSTUME_PANDA;
|
||||||
if (s == "elephant") return ENTERTAINER_COSTUME_ELEPHANT;
|
if (s == "tiger")
|
||||||
if (s == "roman") return ENTERTAINER_COSTUME_ROMAN;
|
return ENTERTAINER_COSTUME_TIGER;
|
||||||
if (s == "gorilla") return ENTERTAINER_COSTUME_GORILLA;
|
if (s == "elephant")
|
||||||
if (s == "snowman") return ENTERTAINER_COSTUME_SNOWMAN;
|
return ENTERTAINER_COSTUME_ELEPHANT;
|
||||||
if (s == "knight") return ENTERTAINER_COSTUME_KNIGHT;
|
if (s == "roman")
|
||||||
if (s == "astronaut") return ENTERTAINER_COSTUME_ASTRONAUT;
|
return ENTERTAINER_COSTUME_ROMAN;
|
||||||
if (s == "bandit") return ENTERTAINER_COSTUME_BANDIT;
|
if (s == "gorilla")
|
||||||
if (s == "sheriff") return ENTERTAINER_COSTUME_SHERIFF;
|
return ENTERTAINER_COSTUME_GORILLA;
|
||||||
if (s == "pirate") return ENTERTAINER_COSTUME_PIRATE;
|
if (s == "snowman")
|
||||||
|
return ENTERTAINER_COSTUME_SNOWMAN;
|
||||||
|
if (s == "knight")
|
||||||
|
return ENTERTAINER_COSTUME_KNIGHT;
|
||||||
|
if (s == "astronaut")
|
||||||
|
return ENTERTAINER_COSTUME_ASTRONAUT;
|
||||||
|
if (s == "bandit")
|
||||||
|
return ENTERTAINER_COSTUME_BANDIT;
|
||||||
|
if (s == "sheriff")
|
||||||
|
return ENTERTAINER_COSTUME_SHERIFF;
|
||||||
|
if (s == "pirate")
|
||||||
|
return ENTERTAINER_COSTUME_PIRATE;
|
||||||
return ENTERTAINER_COSTUME_PANDA;
|
return ENTERTAINER_COSTUME_PANDA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,11 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include "../world/Scenery.h"
|
#include "../world/Scenery.h"
|
||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
struct ObjectRepositoryItem;
|
struct ObjectRepositoryItem;
|
||||||
|
|
||||||
class SceneryGroupObject final : public Object
|
class SceneryGroupObject final : public Object
|
||||||
|
@ -22,9 +23,15 @@ private:
|
||||||
std::vector<rct_object_entry> _items;
|
std::vector<rct_object_entry> _items;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SceneryGroupObject(const rct_object_entry &entry) : Object(entry) { }
|
explicit SceneryGroupObject(const rct_object_entry& entry)
|
||||||
|
: Object(entry)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void * GetLegacyData() override { return &_legacyType; }
|
void* GetLegacyData() override
|
||||||
|
{
|
||||||
|
return &_legacyType;
|
||||||
|
}
|
||||||
void ReadJson(IReadObjectContext* context, const json_t* root) override;
|
void ReadJson(IReadObjectContext* context, const json_t* root) override;
|
||||||
|
|
||||||
void ReadLegacy(IReadObjectContext* context, IStream* stream) override;
|
void ReadLegacy(IReadObjectContext* context, IStream* stream) override;
|
||||||
|
|
|
@ -7,9 +7,10 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "ObjectJsonHelpers.h"
|
|
||||||
#include "SceneryObject.h"
|
#include "SceneryObject.h"
|
||||||
|
|
||||||
|
#include "ObjectJsonHelpers.h"
|
||||||
|
|
||||||
void SceneryObject::SetPrimarySceneryGroup(const std::string& s)
|
void SceneryObject::SetPrimarySceneryGroup(const std::string& s)
|
||||||
{
|
{
|
||||||
if (!s.empty())
|
if (!s.empty())
|
||||||
|
|
|
@ -9,21 +9,31 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
class SceneryObject : public Object
|
class SceneryObject : public Object
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
rct_object_entry _primarySceneryGroupEntry = {};
|
rct_object_entry _primarySceneryGroupEntry = {};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SceneryObject(const rct_object_entry &entry) : Object(entry) { }
|
explicit SceneryObject(const rct_object_entry& entry)
|
||||||
|
: Object(entry)
|
||||||
|
{
|
||||||
|
}
|
||||||
virtual ~SceneryObject() = default;
|
virtual ~SceneryObject() = default;
|
||||||
|
|
||||||
const rct_object_entry * GetPrimarySceneryGroup() { return &_primarySceneryGroupEntry; }
|
const rct_object_entry* GetPrimarySceneryGroup()
|
||||||
|
{
|
||||||
|
return &_primarySceneryGroupEntry;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void SetPrimarySceneryGroup(const rct_object_entry * entry) { _primarySceneryGroupEntry = *entry; }
|
void SetPrimarySceneryGroup(const rct_object_entry* entry)
|
||||||
|
{
|
||||||
|
_primarySceneryGroupEntry = *entry;
|
||||||
|
}
|
||||||
void SetPrimarySceneryGroup(const std::string& s);
|
void SetPrimarySceneryGroup(const std::string& s);
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
#pragma warning(disable : 4706) // assignment within conditional expression
|
#pragma warning(disable : 4706) // assignment within conditional expression
|
||||||
|
|
||||||
|
#include "SmallSceneryObject.h"
|
||||||
|
|
||||||
#include "../core/IStream.hpp"
|
#include "../core/IStream.hpp"
|
||||||
#include "../core/Math.hpp"
|
#include "../core/Math.hpp"
|
||||||
#include "../core/Memory.hpp"
|
#include "../core/Memory.hpp"
|
||||||
|
@ -18,7 +20,6 @@
|
||||||
#include "../localisation/Language.h"
|
#include "../localisation/Language.h"
|
||||||
#include "../world/Scenery.h"
|
#include "../world/Scenery.h"
|
||||||
#include "../world/SmallScenery.h"
|
#include "../world/SmallScenery.h"
|
||||||
#include "SmallSceneryObject.h"
|
|
||||||
#include "ObjectJsonHelpers.h"
|
#include "ObjectJsonHelpers.h"
|
||||||
|
|
||||||
void SmallSceneryObject::ReadLegacy(IReadObjectContext* context, IStream* stream)
|
void SmallSceneryObject::ReadLegacy(IReadObjectContext* context, IStream* stream)
|
||||||
|
@ -104,8 +105,8 @@ void SmallSceneryObject::DrawPreview(rct_drawpixelinfo * dpi, int32_t width, int
|
||||||
int32_t y = (height / 2) + (_legacyType.small_scenery.height / 2);
|
int32_t y = (height / 2) + (_legacyType.small_scenery.height / 2);
|
||||||
y = std::min(y, height - 16);
|
y = std::min(y, height - 16);
|
||||||
|
|
||||||
if ((scenery_small_entry_has_flag(&_legacyType, SMALL_SCENERY_FLAG_FULL_TILE)) &&
|
if ((scenery_small_entry_has_flag(&_legacyType, SMALL_SCENERY_FLAG_FULL_TILE))
|
||||||
(scenery_small_entry_has_flag(&_legacyType, SMALL_SCENERY_FLAG_VOFFSET_CENTRE)))
|
&& (scenery_small_entry_has_flag(&_legacyType, SMALL_SCENERY_FLAG_VOFFSET_CENTRE)))
|
||||||
{
|
{
|
||||||
y -= 12;
|
y -= 12;
|
||||||
}
|
}
|
||||||
|
@ -233,7 +234,8 @@ void SmallSceneryObject::ReadJson(IReadObjectContext * context, const json_t * r
|
||||||
auto properties = json_object_get(root, "properties");
|
auto properties = json_object_get(root, "properties");
|
||||||
|
|
||||||
_legacyType.small_scenery.height = json_integer_value(json_object_get(properties, "height"));
|
_legacyType.small_scenery.height = json_integer_value(json_object_get(properties, "height"));
|
||||||
_legacyType.small_scenery.tool_id = ObjectJsonHelpers::ParseCursor(ObjectJsonHelpers::GetString(properties, "cursor"), CURSOR_STATUE_DOWN);
|
_legacyType.small_scenery.tool_id
|
||||||
|
= ObjectJsonHelpers::ParseCursor(ObjectJsonHelpers::GetString(properties, "cursor"), CURSOR_STATUE_DOWN);
|
||||||
_legacyType.small_scenery.price = json_integer_value(json_object_get(properties, "price"));
|
_legacyType.small_scenery.price = json_integer_value(json_object_get(properties, "price"));
|
||||||
_legacyType.small_scenery.removal_price = json_integer_value(json_object_get(properties, "removalPrice"));
|
_legacyType.small_scenery.removal_price = json_integer_value(json_object_get(properties, "removalPrice"));
|
||||||
_legacyType.small_scenery.animation_delay = json_integer_value(json_object_get(properties, "animationDelay"));
|
_legacyType.small_scenery.animation_delay = json_integer_value(json_object_get(properties, "animationDelay"));
|
||||||
|
@ -241,8 +243,9 @@ void SmallSceneryObject::ReadJson(IReadObjectContext * context, const json_t * r
|
||||||
_legacyType.small_scenery.num_frames = json_integer_value(json_object_get(properties, "numFrames"));
|
_legacyType.small_scenery.num_frames = json_integer_value(json_object_get(properties, "numFrames"));
|
||||||
|
|
||||||
// Flags
|
// Flags
|
||||||
_legacyType.small_scenery.flags = ObjectJsonHelpers::GetFlags<uint32_t>(properties, {
|
_legacyType.small_scenery.flags = ObjectJsonHelpers::GetFlags<uint32_t>(
|
||||||
{ "SMALL_SCENERY_FLAG_VOFFSET_CENTRE", SMALL_SCENERY_FLAG_VOFFSET_CENTRE },
|
properties,
|
||||||
|
{ { "SMALL_SCENERY_FLAG_VOFFSET_CENTRE", SMALL_SCENERY_FLAG_VOFFSET_CENTRE },
|
||||||
{ "requiresFlatSurface", SMALL_SCENERY_FLAG_REQUIRE_FLAT_SURFACE },
|
{ "requiresFlatSurface", SMALL_SCENERY_FLAG_REQUIRE_FLAT_SURFACE },
|
||||||
{ "isRotatable", SMALL_SCENERY_FLAG_ROTATABLE },
|
{ "isRotatable", SMALL_SCENERY_FLAG_ROTATABLE },
|
||||||
{ "isAnimated", SMALL_SCENERY_FLAG_ANIMATED },
|
{ "isAnimated", SMALL_SCENERY_FLAG_ANIMATED },
|
||||||
|
|
|
@ -9,10 +9,11 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include "../world/Scenery.h"
|
#include "../world/Scenery.h"
|
||||||
#include "SceneryObject.h"
|
#include "SceneryObject.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
class SmallSceneryObject final : public SceneryObject
|
class SmallSceneryObject final : public SceneryObject
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -20,9 +21,15 @@ private:
|
||||||
std::vector<uint8_t> _frameOffsets;
|
std::vector<uint8_t> _frameOffsets;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SmallSceneryObject(const rct_object_entry &entry) : SceneryObject(entry) { }
|
explicit SmallSceneryObject(const rct_object_entry& entry)
|
||||||
|
: SceneryObject(entry)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void * GetLegacyData() override { return &_legacyType; }
|
void* GetLegacyData() override
|
||||||
|
{
|
||||||
|
return &_legacyType;
|
||||||
|
}
|
||||||
|
|
||||||
void ReadLegacy(IReadObjectContext* context, IStream* stream) override;
|
void ReadLegacy(IReadObjectContext* context, IStream* stream) override;
|
||||||
void ReadJson(IReadObjectContext* context, const json_t* root) override;
|
void ReadJson(IReadObjectContext* context, const json_t* root) override;
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "../core/IStream.hpp"
|
|
||||||
#include "StexObject.h"
|
#include "StexObject.h"
|
||||||
|
|
||||||
|
#include "../core/IStream.hpp"
|
||||||
#include "../localisation/Localisation.h"
|
#include "../localisation/Localisation.h"
|
||||||
|
|
||||||
void StexObject::ReadLegacy(IReadObjectContext* context, IStream* stream)
|
void StexObject::ReadLegacy(IReadObjectContext* context, IStream* stream)
|
||||||
|
|
|
@ -9,9 +9,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Object.h"
|
|
||||||
|
|
||||||
#include "../scenario/Scenario.h"
|
#include "../scenario/Scenario.h"
|
||||||
|
#include "Object.h"
|
||||||
|
|
||||||
class StexObject final : public Object
|
class StexObject final : public Object
|
||||||
{
|
{
|
||||||
|
@ -19,9 +18,15 @@ private:
|
||||||
rct_stex_entry _legacyType = {};
|
rct_stex_entry _legacyType = {};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit StexObject(const rct_object_entry &entry) : Object(entry) { }
|
explicit StexObject(const rct_object_entry& entry)
|
||||||
|
: Object(entry)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void * GetLegacyData() override { return &_legacyType; }
|
void* GetLegacyData() override
|
||||||
|
{
|
||||||
|
return &_legacyType;
|
||||||
|
}
|
||||||
|
|
||||||
void ReadLegacy(IReadObjectContext* context, IStream* stream) override;
|
void ReadLegacy(IReadObjectContext* context, IStream* stream) override;
|
||||||
void Load() override;
|
void Load() override;
|
||||||
|
|
|
@ -7,17 +7,18 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include <algorithm>
|
#include "StringTable.h"
|
||||||
|
|
||||||
#include "../core/IStream.hpp"
|
#include "../core/IStream.hpp"
|
||||||
#include "../core/String.hpp"
|
#include "../core/String.hpp"
|
||||||
#include "../localisation/Language.h"
|
#include "../localisation/Language.h"
|
||||||
#include "../localisation/LanguagePack.h"
|
#include "../localisation/LanguagePack.h"
|
||||||
#include "../localisation/LocalisationService.h"
|
#include "../localisation/LocalisationService.h"
|
||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
#include "StringTable.h"
|
|
||||||
|
|
||||||
static constexpr const uint8_t RCT2ToOpenRCT2LanguageId[] =
|
#include <algorithm>
|
||||||
{
|
|
||||||
|
static constexpr const uint8_t RCT2ToOpenRCT2LanguageId[] = {
|
||||||
LANGUAGE_ENGLISH_UK,
|
LANGUAGE_ENGLISH_UK,
|
||||||
LANGUAGE_ENGLISH_US,
|
LANGUAGE_ENGLISH_US,
|
||||||
LANGUAGE_FRENCH,
|
LANGUAGE_FRENCH,
|
||||||
|
@ -53,10 +54,8 @@ void StringTable::Read(IReadObjectContext * context, IStream * stream, uint8_t i
|
||||||
RCT2LanguageId rct2LanguageId;
|
RCT2LanguageId rct2LanguageId;
|
||||||
while ((rct2LanguageId = (RCT2LanguageId)stream->ReadValue<uint8_t>()) != RCT2_LANGUAGE_ID_END)
|
while ((rct2LanguageId = (RCT2LanguageId)stream->ReadValue<uint8_t>()) != RCT2_LANGUAGE_ID_END)
|
||||||
{
|
{
|
||||||
uint8_t languageId =
|
uint8_t languageId = (rct2LanguageId <= RCT2_LANGUAGE_ID_PORTUGUESE) ? RCT2ToOpenRCT2LanguageId[rct2LanguageId]
|
||||||
(rct2LanguageId <= RCT2_LANGUAGE_ID_PORTUGUESE) ?
|
: LANGUAGE_UNDEFINED;
|
||||||
RCT2ToOpenRCT2LanguageId[rct2LanguageId] :
|
|
||||||
LANGUAGE_UNDEFINED;
|
|
||||||
StringTableEntry entry{};
|
StringTableEntry entry{};
|
||||||
entry.Id = id;
|
entry.Id = id;
|
||||||
entry.LanguageId = languageId;
|
entry.LanguageId = languageId;
|
||||||
|
@ -118,8 +117,7 @@ void StringTable::SetString(uint8_t id, uint8_t language, const std::string &tex
|
||||||
void StringTable::Sort()
|
void StringTable::Sort()
|
||||||
{
|
{
|
||||||
auto targetLanguage = LocalisationService_GetCurrentLanguage();
|
auto targetLanguage = LocalisationService_GetCurrentLanguage();
|
||||||
std::sort(_strings.begin(), _strings.end(), [targetLanguage](const StringTableEntry &a, const StringTableEntry &b) -> bool
|
std::sort(_strings.begin(), _strings.end(), [targetLanguage](const StringTableEntry& a, const StringTableEntry& b) -> bool {
|
||||||
{
|
|
||||||
if (a.Id == b.Id)
|
if (a.Id == b.Id)
|
||||||
{
|
{
|
||||||
if (a.LanguageId == b.LanguageId)
|
if (a.LanguageId == b.LanguageId)
|
||||||
|
|
|
@ -9,11 +9,12 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
#include "../localisation/Language.h"
|
#include "../localisation/Language.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
interface IReadObjectContext;
|
interface IReadObjectContext;
|
||||||
interface IStream;
|
interface IStream;
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,13 @@
|
||||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include "WallObject.h"
|
||||||
|
|
||||||
#include "../core/IStream.hpp"
|
#include "../core/IStream.hpp"
|
||||||
#include "../drawing/Drawing.h"
|
#include "../drawing/Drawing.h"
|
||||||
#include "../interface/Cursors.h"
|
#include "../interface/Cursors.h"
|
||||||
#include "../localisation/Language.h"
|
#include "../localisation/Language.h"
|
||||||
#include "ObjectJsonHelpers.h"
|
#include "ObjectJsonHelpers.h"
|
||||||
#include "WallObject.h"
|
|
||||||
|
|
||||||
void WallObject::ReadLegacy(IReadObjectContext* context, IStream* stream)
|
void WallObject::ReadLegacy(IReadObjectContext* context, IStream* stream)
|
||||||
{
|
{
|
||||||
|
@ -87,29 +88,28 @@ void WallObject::ReadJson(IReadObjectContext * context, const json_t * root)
|
||||||
{
|
{
|
||||||
auto properties = json_object_get(root, "properties");
|
auto properties = json_object_get(root, "properties");
|
||||||
|
|
||||||
_legacyType.wall.tool_id = ObjectJsonHelpers::ParseCursor(ObjectJsonHelpers::GetString(properties, "cursor"), CURSOR_FENCE_DOWN);
|
_legacyType.wall.tool_id
|
||||||
|
= ObjectJsonHelpers::ParseCursor(ObjectJsonHelpers::GetString(properties, "cursor"), CURSOR_FENCE_DOWN);
|
||||||
_legacyType.wall.height = json_integer_value(json_object_get(properties, "height"));
|
_legacyType.wall.height = json_integer_value(json_object_get(properties, "height"));
|
||||||
_legacyType.wall.price = json_integer_value(json_object_get(properties, "price"));
|
_legacyType.wall.price = json_integer_value(json_object_get(properties, "price"));
|
||||||
|
|
||||||
auto jScrollingMode = json_object_get(properties, "scrollingMode");
|
auto jScrollingMode = json_object_get(properties, "scrollingMode");
|
||||||
_legacyType.wall.scrolling_mode = jScrollingMode != nullptr ?
|
_legacyType.wall.scrolling_mode = jScrollingMode != nullptr ? json_integer_value(jScrollingMode) : -1;
|
||||||
json_integer_value(jScrollingMode) :
|
|
||||||
-1;
|
|
||||||
|
|
||||||
SetPrimarySceneryGroup(ObjectJsonHelpers::GetString(json_object_get(properties, "sceneryGroup")));
|
SetPrimarySceneryGroup(ObjectJsonHelpers::GetString(json_object_get(properties, "sceneryGroup")));
|
||||||
|
|
||||||
// Flags
|
// Flags
|
||||||
_legacyType.wall.flags = ObjectJsonHelpers::GetFlags<uint8_t>(properties, {
|
_legacyType.wall.flags = ObjectJsonHelpers::GetFlags<uint8_t>(
|
||||||
{ "hasPrimaryColour", WALL_SCENERY_HAS_PRIMARY_COLOUR },
|
properties,
|
||||||
|
{ { "hasPrimaryColour", WALL_SCENERY_HAS_PRIMARY_COLOUR },
|
||||||
{ "hasSecondaryColour", WALL_SCENERY_HAS_SECONDARY_COLOUR },
|
{ "hasSecondaryColour", WALL_SCENERY_HAS_SECONDARY_COLOUR },
|
||||||
{ "hasTernaryColour", WALL_SCENERY_HAS_TERNARY_COLOUR },
|
{ "hasTernaryColour", WALL_SCENERY_HAS_TERNARY_COLOUR },
|
||||||
{ "hasGlass", WALL_SCENERY_HAS_GLASS },
|
{ "hasGlass", WALL_SCENERY_HAS_GLASS },
|
||||||
{ "isBanner", WALL_SCENERY_IS_BANNER },
|
{ "isBanner", WALL_SCENERY_IS_BANNER },
|
||||||
{ "isDoor", WALL_SCENERY_IS_DOOR },
|
{ "isDoor", WALL_SCENERY_IS_DOOR },
|
||||||
{ "isLongDoorAnimation", WALL_SCENERY_LONG_DOOR_ANIMATION } });
|
{ "isLongDoorAnimation", WALL_SCENERY_LONG_DOOR_ANIMATION } });
|
||||||
_legacyType.wall.flags2 = ObjectJsonHelpers::GetFlags<uint8_t>(properties, {
|
_legacyType.wall.flags2 = ObjectJsonHelpers::GetFlags<uint8_t>(
|
||||||
{ "isOpaque", WALL_SCENERY_2_IS_OPAQUE },
|
properties, { { "isOpaque", WALL_SCENERY_2_IS_OPAQUE }, { "isAnimated", WALL_SCENERY_2_ANIMATED } });
|
||||||
{ "isAnimated", WALL_SCENERY_2_ANIMATED }});
|
|
||||||
|
|
||||||
// HACK To avoid 'negated' properties in JSON, handle this separately until
|
// HACK To avoid 'negated' properties in JSON, handle this separately until
|
||||||
// flag is inverted in this code base.
|
// flag is inverted in this code base.
|
||||||
|
@ -122,8 +122,8 @@ void WallObject::ReadJson(IReadObjectContext * context, const json_t * root)
|
||||||
// JSON and handle this on load. We should change code base in future to reflect the JSON.
|
// JSON and handle this on load. We should change code base in future to reflect the JSON.
|
||||||
if (!(_legacyType.wall.flags & WALL_SCENERY_HAS_PRIMARY_COLOUR))
|
if (!(_legacyType.wall.flags & WALL_SCENERY_HAS_PRIMARY_COLOUR))
|
||||||
{
|
{
|
||||||
if ((_legacyType.wall.flags & WALL_SCENERY_HAS_SECONDARY_COLOUR) ||
|
if ((_legacyType.wall.flags & WALL_SCENERY_HAS_SECONDARY_COLOUR)
|
||||||
(_legacyType.wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR))
|
|| (_legacyType.wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR))
|
||||||
{
|
{
|
||||||
_legacyType.wall.flags2 |= WALL_SCENERY_2_NO_SELECT_PRIMARY_COLOUR;
|
_legacyType.wall.flags2 |= WALL_SCENERY_2_NO_SELECT_PRIMARY_COLOUR;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "SceneryObject.h"
|
|
||||||
|
|
||||||
#include "../world/Scenery.h"
|
#include "../world/Scenery.h"
|
||||||
|
#include "SceneryObject.h"
|
||||||
|
|
||||||
class WallObject final : public SceneryObject
|
class WallObject final : public SceneryObject
|
||||||
{
|
{
|
||||||
|
@ -19,9 +18,15 @@ private:
|
||||||
rct_scenery_entry _legacyType = {};
|
rct_scenery_entry _legacyType = {};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit WallObject(const rct_object_entry &entry) : SceneryObject(entry) { }
|
explicit WallObject(const rct_object_entry& entry)
|
||||||
|
: SceneryObject(entry)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void * GetLegacyData() override { return &_legacyType; }
|
void* GetLegacyData() override
|
||||||
|
{
|
||||||
|
return &_legacyType;
|
||||||
|
}
|
||||||
|
|
||||||
void ReadLegacy(IReadObjectContext* context, IStream* stream) override;
|
void ReadLegacy(IReadObjectContext* context, IStream* stream) override;
|
||||||
void ReadJson(IReadObjectContext* context, const json_t* root) override;
|
void ReadJson(IReadObjectContext* context, const json_t* root) override;
|
||||||
|
|
|
@ -9,13 +9,15 @@
|
||||||
|
|
||||||
#pragma warning(disable : 4706) // assignment within conditional expression
|
#pragma warning(disable : 4706) // assignment within conditional expression
|
||||||
|
|
||||||
#include <memory>
|
#include "WaterObject.h"
|
||||||
|
|
||||||
|
#include "../OpenRCT2.h"
|
||||||
#include "../core/IStream.hpp"
|
#include "../core/IStream.hpp"
|
||||||
#include "../localisation/Language.h"
|
#include "../localisation/Language.h"
|
||||||
#include "../localisation/StringIds.h"
|
#include "../localisation/StringIds.h"
|
||||||
#include "../OpenRCT2.h"
|
|
||||||
#include "ObjectJsonHelpers.h"
|
#include "ObjectJsonHelpers.h"
|
||||||
#include "WaterObject.h"
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
void WaterObject::ReadLegacy(IReadObjectContext* context, IStream* stream)
|
void WaterObject::ReadLegacy(IReadObjectContext* context, IStream* stream)
|
||||||
{
|
{
|
||||||
|
@ -56,22 +58,13 @@ void WaterObject::DrawPreview(rct_drawpixelinfo * dpi, int32_t width, int32_t he
|
||||||
void WaterObject::ReadJson([[maybe_unused]] IReadObjectContext* context, const json_t* root)
|
void WaterObject::ReadJson([[maybe_unused]] IReadObjectContext* context, const json_t* root)
|
||||||
{
|
{
|
||||||
auto properties = json_object_get(root, "properties");
|
auto properties = json_object_get(root, "properties");
|
||||||
_legacyType.flags = ObjectJsonHelpers::GetFlags<uint16_t>(properties, {
|
_legacyType.flags = ObjectJsonHelpers::GetFlags<uint16_t>(properties, { { "allowDucks", WATER_FLAGS_ALLOW_DUCKS } });
|
||||||
{ "allowDucks", WATER_FLAGS_ALLOW_DUCKS }});
|
|
||||||
|
|
||||||
ObjectJsonHelpers::LoadStrings(root, GetStringTable());
|
ObjectJsonHelpers::LoadStrings(root, GetStringTable());
|
||||||
|
|
||||||
// Images which are actually palette data
|
// Images which are actually palette data
|
||||||
static const char * paletteNames[] =
|
static const char* paletteNames[]
|
||||||
{
|
= { "general", "waves-0", "waves-1", "waves-2", "sparkles-0", "sparkles-1", "sparkles-2" };
|
||||||
"general",
|
|
||||||
"waves-0",
|
|
||||||
"waves-1",
|
|
||||||
"waves-2",
|
|
||||||
"sparkles-0",
|
|
||||||
"sparkles-1",
|
|
||||||
"sparkles-2"
|
|
||||||
};
|
|
||||||
for (auto paletteName : paletteNames)
|
for (auto paletteName : paletteNames)
|
||||||
{
|
{
|
||||||
auto jPalettes = json_object_get(properties, "palettes");
|
auto jPalettes = json_object_get(properties, "palettes");
|
||||||
|
|
|
@ -9,19 +9,26 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <tuple>
|
|
||||||
#include "../world/Water.h"
|
#include "../world/Water.h"
|
||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
|
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
class WaterObject final : public Object
|
class WaterObject final : public Object
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
rct_water_type _legacyType = {};
|
rct_water_type _legacyType = {};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit WaterObject(const rct_object_entry &entry) : Object(entry) { }
|
explicit WaterObject(const rct_object_entry& entry)
|
||||||
|
: Object(entry)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void * GetLegacyData() override { return &_legacyType; }
|
void* GetLegacyData() override
|
||||||
|
{
|
||||||
|
return &_legacyType;
|
||||||
|
}
|
||||||
|
|
||||||
void ReadJson(IReadObjectContext* context, const json_t* root) override;
|
void ReadJson(IReadObjectContext* context, const json_t* root) override;
|
||||||
void ReadLegacy(IReadObjectContext* context, IStream* stream) override;
|
void ReadLegacy(IReadObjectContext* context, IStream* stream) override;
|
||||||
|
|
Loading…
Reference in New Issue