1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-19 21:13:05 +01:00
Files
OpenRCT2/src/openrct2/object/PeepNamesObject.cpp
Aaron van Geffen 931f0705ce Introduce PeepNamesObjects for 'real' names of peeps (#22758)
* Add initial PeepNamesObject implementation

* Add peep names object to default objects

* Append peep names object to object list for older saves

* Deduplicate AppendRequiredObjects functions

* Remove built-in 'real name' tables

* Increment park version; introduce kPeepNamesObjectsVersion

* Update objects dependency to v1.4.8
2024-09-29 15:05:55 +02:00

49 lines
1.5 KiB
C++

/*****************************************************************************
* Copyright (c) 2014-2024 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#include "PeepNamesObject.h"
#include "../Context.h"
#include "../PlatformEnvironment.h"
#include "../core/Json.hpp"
using namespace OpenRCT2;
void PeepNamesObject::Load()
{
}
void PeepNamesObject::Unload()
{
}
void PeepNamesObject::ReadJson(IReadObjectContext* context, json_t& root)
{
Guard::Assert(root.is_object(), "PeepNamesObject::ReadJson expects parameter root to be an object");
PopulateTablesFromJson(context, root);
Guard::Assert(root["given_names"].is_array(), "PeepNamesObject::ReadJson expects given_names to be an array");
_givenNames = root["given_names"].get<std::vector<std::string>>();
std::sort(_givenNames.begin(), _givenNames.end());
Guard::Assert(root["surnames"].is_array(), "PeepNamesObject::ReadJson expects surnames to be an array");
_surnames = root["surnames"].get<std::vector<std::string>>();
std::sort(_surnames.begin(), _surnames.end());
}
std::string PeepNamesObject::GetGivenNameAt(size_t index) const
{
return _givenNames[index % _givenNames.size()];
}
std::string PeepNamesObject::GetSurnameAt(size_t index) const
{
return _surnames[index % _surnames.size()];
}