2017-06-01 21:55:10 +02:00
|
|
|
#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers
|
2016-06-25 03:52:58 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
|
|
|
*
|
|
|
|
* OpenRCT2 is the work of many authors, a full list can be found in contributors.md
|
|
|
|
* For more information, visit https://github.com/OpenRCT2/OpenRCT2
|
|
|
|
*
|
|
|
|
* OpenRCT2 is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* A full copy of the GNU General Public License can be found in licence.txt
|
|
|
|
*****************************************************************************/
|
|
|
|
#pragma endregion
|
|
|
|
|
2016-07-04 19:53:35 +02:00
|
|
|
#include "../core/Memory.hpp"
|
|
|
|
#include "../core/String.hpp"
|
2017-10-19 10:01:05 +02:00
|
|
|
#include "../localisation/language.h"
|
|
|
|
#include "../localisation/string_ids.h"
|
2016-06-25 03:52:58 +02:00
|
|
|
#include "Object.h"
|
|
|
|
|
2016-07-04 19:53:35 +02:00
|
|
|
|
2016-06-25 15:44:04 +02:00
|
|
|
Object::Object(const rct_object_entry &entry)
|
2016-06-25 03:52:58 +02:00
|
|
|
{
|
2016-06-25 15:44:04 +02:00
|
|
|
_objectEntry = entry;
|
2016-07-04 19:53:35 +02:00
|
|
|
|
|
|
|
char name[9] = { 0 };
|
|
|
|
Memory::Copy(name, entry.name, 8);
|
|
|
|
_identifier = String::Duplicate(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
Object::~Object()
|
|
|
|
{
|
|
|
|
Memory::Free(_identifier);
|
|
|
|
}
|
|
|
|
|
|
|
|
const utf8 * Object::GetOverrideString(uint8 index) const
|
|
|
|
{
|
|
|
|
const char * identifier = GetIdentifier();
|
|
|
|
rct_string_id stringId = language_get_object_override_string_id(identifier, index);
|
|
|
|
|
|
|
|
const utf8 * result = nullptr;
|
|
|
|
if (stringId != STR_NONE)
|
|
|
|
{
|
|
|
|
result = language_get_string(stringId);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
const utf8 * Object::GetString(uint8 index) const
|
|
|
|
{
|
2017-11-22 16:52:07 +01:00
|
|
|
auto sz = GetOverrideString(index);
|
|
|
|
if (sz == nullptr && index == OBJ_STRING_ID_VEHICLE_NAME)
|
|
|
|
{
|
|
|
|
// If no vehicle name is specified, fall back to the ride name. This is also required if we fall back
|
|
|
|
// to the .DAT name (which does not contain separate ride and vehicle names).
|
|
|
|
return GetName();
|
|
|
|
}
|
|
|
|
else if (sz == nullptr)
|
2016-07-04 19:53:35 +02:00
|
|
|
{
|
|
|
|
sz = GetStringTable()->GetString(index);
|
|
|
|
}
|
|
|
|
return sz != nullptr ? sz : "";
|
|
|
|
}
|
|
|
|
|
2017-12-01 11:54:25 +01:00
|
|
|
rct_object_entry Object::GetScgWallsHeader()
|
|
|
|
{
|
|
|
|
return Object::CreateHeader("SCGWALLS", 207140231, 3518650219);
|
|
|
|
}
|
|
|
|
|
|
|
|
rct_object_entry Object::GetScgPathXHeader()
|
|
|
|
{
|
|
|
|
return Object::CreateHeader("SCGPATHX", 207140231, 890227440);
|
|
|
|
}
|
|
|
|
|
|
|
|
rct_object_entry Object::CreateHeader(const char name[9], uint32 flags, uint32 checksum)
|
|
|
|
{
|
|
|
|
rct_object_entry header = { 0 };
|
|
|
|
header.flags = flags;
|
|
|
|
Memory::Copy(header.name, name, 8);
|
|
|
|
header.checksum = checksum;
|
|
|
|
return header;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-23 10:14:28 +01:00
|
|
|
#ifdef __WARN_SUGGEST_FINAL_METHODS__
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Wsuggest-final-methods"
|
|
|
|
#endif
|
|
|
|
|
2016-07-04 19:53:35 +02:00
|
|
|
const utf8 * Object::GetName() const
|
|
|
|
{
|
|
|
|
return GetString(OBJ_STRING_ID_NAME);
|
2016-06-25 03:52:58 +02:00
|
|
|
}
|
2017-11-23 10:14:28 +01:00
|
|
|
|
|
|
|
#ifdef __WARN_SUGGEST_FINAL_METHODS__
|
|
|
|
#pragma GCC diagnostic pop
|
|
|
|
#endif
|