1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-20 05:23:04 +01:00

clang-format object

This commit is contained in:
clang-format
2018-06-22 23:03:20 +02:00
committed by Hielke Morsink
parent e32189fd98
commit a6a12af1ec
42 changed files with 1452 additions and 1283 deletions

View File

@@ -7,18 +7,20 @@
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#include <unordered_map>
#include "FootpathItemObject.h"
#include "../core/IStream.hpp"
#include "../drawing/Drawing.h"
#include "../interface/Cursors.h"
#include "../localisation/Localisation.h"
#include "../object/Object.h"
#include "../object/ObjectRepository.h"
#include "ObjectList.h"
#include "FootpathItemObject.h"
#include "ObjectJsonHelpers.h"
#include "ObjectList.h"
void FootpathItemObject::ReadLegacy(IReadObjectContext * context, IStream * stream)
#include <unordered_map>
void FootpathItemObject::ReadLegacy(IReadObjectContext* context, IStream* stream)
{
stream->Seek(6, STREAM_SEEK_CURRENT);
_legacyType.path_bit.flags = stream->ReadValue<uint16_t>();
@@ -50,9 +52,8 @@ void FootpathItemObject::ReadLegacy(IReadObjectContext * context, IStream * stre
if (item != nullptr)
{
auto sourceGame = object_entry_get_source_game(&item->ObjectEntry);
if (sourceGame == OBJECT_SOURCE_WACKY_WORLDS ||
sourceGame == OBJECT_SOURCE_TIME_TWISTER ||
sourceGame == OBJECT_SOURCE_CUSTOM)
if (sourceGame == OBJECT_SOURCE_WACKY_WORLDS || sourceGame == OBJECT_SOURCE_TIME_TWISTER
|| sourceGame == OBJECT_SOURCE_CUSTOM)
{
auto scgPathX = Object::GetScgPathXHeader();
SetPrimarySceneryGroup(&scgPathX);
@@ -78,40 +79,46 @@ void FootpathItemObject::Unload()
_legacyType.image = 0;
}
void FootpathItemObject::DrawPreview(rct_drawpixelinfo * dpi, int32_t width, int32_t height) const
void FootpathItemObject::DrawPreview(rct_drawpixelinfo* dpi, int32_t width, int32_t height) const
{
int32_t x = width / 2;
int32_t y = height / 2;
gfx_draw_sprite(dpi, _legacyType.image, x - 22, y - 24, 0);
}
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 == "bin") 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;
if (s == "lamp")
return PATH_BIT_DRAW_TYPE_LIGHTS;
if (s == "bin")
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;
}
void FootpathItemObject::ReadJson(IReadObjectContext * context, const json_t * root)
void FootpathItemObject::ReadJson(IReadObjectContext* context, const json_t* root)
{
auto properties = json_object_get(root, "properties");
_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"));
SetPrimarySceneryGroup(ObjectJsonHelpers::GetString(json_object_get(properties, "sceneryGroup")));
// Flags
_legacyType.path_bit.flags = ObjectJsonHelpers::GetFlags<uint16_t>(properties, {
{ "isBin", PATH_BIT_FLAG_IS_BIN },
{ "isBench", PATH_BIT_FLAG_IS_BENCH },
{ "isBreakable", PATH_BIT_FLAG_BREAKABLE },
{ "isLamp", PATH_BIT_FLAG_LAMP },
{ "isJumpingFountainWater", PATH_BIT_FLAG_JUMPING_FOUNTAIN_WATER },
{ "isJumpingFountainSnow", PATH_BIT_FLAG_JUMPING_FOUNTAIN_SNOW },
{ "isTelevision", PATH_BIT_FLAG_IS_QUEUE_SCREEN }});
_legacyType.path_bit.flags = ObjectJsonHelpers::GetFlags<uint16_t>(
properties,
{ { "isBin", PATH_BIT_FLAG_IS_BIN },
{ "isBench", PATH_BIT_FLAG_IS_BENCH },
{ "isBreakable", PATH_BIT_FLAG_BREAKABLE },
{ "isLamp", PATH_BIT_FLAG_LAMP },
{ "isJumpingFountainWater", PATH_BIT_FLAG_JUMPING_FOUNTAIN_WATER },
{ "isJumpingFountainSnow", PATH_BIT_FLAG_JUMPING_FOUNTAIN_SNOW },
{ "isTelevision", PATH_BIT_FLAG_IS_QUEUE_SCREEN } });
// HACK To avoid 'negated' properties in JSON, handle these separately until
// flags are inverted in this code base.