mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-25 07:44:38 +01:00
clang-format object
This commit is contained in:
committed by
Hielke Morsink
parent
e32189fd98
commit
a6a12af1ec
@@ -9,7 +9,8 @@
|
||||
|
||||
#pragma warning(disable : 4706) // assignment within conditional expression
|
||||
|
||||
#include <unordered_map>
|
||||
#include "SceneryGroupObject.h"
|
||||
|
||||
#include "../Context.h"
|
||||
#include "../core/IStream.hpp"
|
||||
#include "../core/Memory.hpp"
|
||||
@@ -20,11 +21,12 @@
|
||||
#include "ObjectJsonHelpers.h"
|
||||
#include "ObjectManager.h"
|
||||
#include "ObjectRepository.h"
|
||||
#include "SceneryGroupObject.h"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
void SceneryGroupObject::ReadLegacy(IReadObjectContext * context, IStream * stream)
|
||||
void SceneryGroupObject::ReadLegacy(IReadObjectContext* context, IStream* stream)
|
||||
{
|
||||
stream->Seek(6, STREAM_SEEK_CURRENT);
|
||||
stream->Seek(0x80 * 2, STREAM_SEEK_CURRENT);
|
||||
@@ -56,7 +58,7 @@ void SceneryGroupObject::Unload()
|
||||
_legacyType.image = 0;
|
||||
}
|
||||
|
||||
void SceneryGroupObject::DrawPreview(rct_drawpixelinfo * dpi, int32_t width, int32_t height) const
|
||||
void SceneryGroupObject::DrawPreview(rct_drawpixelinfo* dpi, int32_t width, int32_t height) const
|
||||
{
|
||||
int32_t x = width / 2;
|
||||
int32_t y = height / 2;
|
||||
@@ -72,23 +74,37 @@ void SceneryGroupObject::UpdateEntryIndexes()
|
||||
auto objectManager = context->GetObjectManager();
|
||||
|
||||
_legacyType.entry_count = 0;
|
||||
for (const auto &objectEntry : _items)
|
||||
for (const auto& objectEntry : _items)
|
||||
{
|
||||
auto ori = objectRepository->FindObject(&objectEntry);
|
||||
if (ori == nullptr) continue;
|
||||
if (ori->LoadedObject == nullptr) continue;
|
||||
if (ori == nullptr)
|
||||
continue;
|
||||
if (ori->LoadedObject == nullptr)
|
||||
continue;
|
||||
|
||||
uint16_t sceneryEntry = objectManager->GetLoadedObjectEntryIndex(ori->LoadedObject);
|
||||
Guard::Assert(sceneryEntry != UINT8_MAX, GUARD_LINE);
|
||||
|
||||
auto objectType = ori->ObjectEntry.flags & 0x0F;
|
||||
switch (objectType) {
|
||||
case OBJECT_TYPE_SMALL_SCENERY: break;
|
||||
case OBJECT_TYPE_PATH_BITS: sceneryEntry |= 0x100; 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;
|
||||
switch (objectType)
|
||||
{
|
||||
case OBJECT_TYPE_SMALL_SCENERY:
|
||||
break;
|
||||
case OBJECT_TYPE_PATH_BITS:
|
||||
sceneryEntry |= 0x100;
|
||||
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)
|
||||
{
|
||||
@@ -98,12 +114,12 @@ void SceneryGroupObject::UpdateEntryIndexes()
|
||||
}
|
||||
}
|
||||
|
||||
void SceneryGroupObject::SetRepositoryItem(ObjectRepositoryItem * item) const
|
||||
void SceneryGroupObject::SetRepositoryItem(ObjectRepositoryItem* item) const
|
||||
{
|
||||
item->SceneryGroupInfo.Entries = _items;
|
||||
}
|
||||
|
||||
std::vector<rct_object_entry> SceneryGroupObject::ReadItems(IStream * stream)
|
||||
std::vector<rct_object_entry> SceneryGroupObject::ReadItems(IStream* stream)
|
||||
{
|
||||
auto items = std::vector<rct_object_entry>();
|
||||
while (stream->ReadValue<uint8_t>() != 0xFF)
|
||||
@@ -115,7 +131,7 @@ std::vector<rct_object_entry> SceneryGroupObject::ReadItems(IStream * stream)
|
||||
return items;
|
||||
}
|
||||
|
||||
void SceneryGroupObject::ReadJson(IReadObjectContext * context, const json_t * root)
|
||||
void SceneryGroupObject::ReadJson(IReadObjectContext* context, const json_t* root)
|
||||
{
|
||||
auto properties = json_object_get(root, "properties");
|
||||
_legacyType.priority = json_integer_value(json_object_get(properties, "priority"));
|
||||
@@ -137,7 +153,7 @@ void SceneryGroupObject::ReadJson(IReadObjectContext * context, const json_t * r
|
||||
ObjectJsonHelpers::LoadImages(context, root, GetImageTable());
|
||||
}
|
||||
|
||||
uint32_t SceneryGroupObject::ReadJsonEntertainerCostumes(const json_t * jCostumes)
|
||||
uint32_t SceneryGroupObject::ReadJsonEntertainerCostumes(const json_t* jCostumes)
|
||||
{
|
||||
uint32_t costumes = 0;
|
||||
auto szCostumes = ObjectJsonHelpers::GetJsonStringArray(jCostumes);
|
||||
@@ -152,27 +168,38 @@ uint32_t SceneryGroupObject::ReadJsonEntertainerCostumes(const json_t * jCostume
|
||||
return costumes;
|
||||
}
|
||||
|
||||
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 == "tiger") return ENTERTAINER_COSTUME_TIGER;
|
||||
if (s == "elephant") return ENTERTAINER_COSTUME_ELEPHANT;
|
||||
if (s == "roman") return ENTERTAINER_COSTUME_ROMAN;
|
||||
if (s == "gorilla") return ENTERTAINER_COSTUME_GORILLA;
|
||||
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;
|
||||
if (s == "panda")
|
||||
return ENTERTAINER_COSTUME_PANDA;
|
||||
if (s == "tiger")
|
||||
return ENTERTAINER_COSTUME_TIGER;
|
||||
if (s == "elephant")
|
||||
return ENTERTAINER_COSTUME_ELEPHANT;
|
||||
if (s == "roman")
|
||||
return ENTERTAINER_COSTUME_ROMAN;
|
||||
if (s == "gorilla")
|
||||
return ENTERTAINER_COSTUME_GORILLA;
|
||||
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;
|
||||
}
|
||||
|
||||
std::vector<rct_object_entry> SceneryGroupObject::ReadJsonEntries(const json_t * jEntries)
|
||||
std::vector<rct_object_entry> SceneryGroupObject::ReadJsonEntries(const json_t* jEntries)
|
||||
{
|
||||
std::vector<rct_object_entry> entries;
|
||||
size_t index;
|
||||
json_t * jEntry;
|
||||
json_t* jEntry;
|
||||
json_array_foreach(jEntries, index, jEntry)
|
||||
{
|
||||
auto entryId = json_string_value(jEntry);
|
||||
|
||||
Reference in New Issue
Block a user