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
This commit is contained in:
Aaron van Geffen authored and GitHub committed 2024-09-29 15:05:55 +02:00
1 parent 0f58efe198
commit 931f0705ce
31 files changed
+148 -1097

No files matched your search

+2 -2
View File
@@ -68,9 +68,9 @@ set(TITLE_SEQUENCE_VERSION "0.4.14")
set(TITLE_SEQUENCE_URL "https://github.com/OpenRCT2/title-sequences/releases/download/v${TITLE_SEQUENCE_VERSION}/title-sequences.zip")
set(TITLE_SEQUENCE_SHA1 "6c04781b959b468e1f65ec2d2f21f5aaa5e5724d")
set(OBJECTS_VERSION "1.4.7")
set(OBJECTS_VERSION "1.4.8")
set(OBJECTS_URL "https://github.com/OpenRCT2/objects/releases/download/v${OBJECTS_VERSION}/objects.zip")
set(OBJECTS_SHA1 "322de669d4b277fceff0d3f123fbc54785dceb4d")
set(OBJECTS_SHA1 "405aef518945e617b2750be9128796daa70dba19")
set(OPENSFX_VERSION "1.0.5")
set(OPENSFX_URL "https://github.com/OpenRCT2/OpenSoundEffects/releases/download/v${OPENSFX_VERSION}/opensound.zip")
+2
View File
@@ -3746,6 +3746,8 @@ STR_6672 :Toggle between showing ‘real’ names of staff and staff numbers
STR_6673 :Transparent
# Used as part of a sentence (see https://github.com/OpenRCT2/OpenRCT2/issues/22072).
STR_6674 :{MONTH}, Year {COMMA16}
STR_6675 :Peep Names
STR_6676 :At least one peep names object must be selected
#############
# Scenarios #
+2
View File
@@ -4,6 +4,7 @@
- Feature: [#15642] Track design placement can now use construction modifier keys (ctrl/shift).
- Feature: [#21521] [Plugin] Add hook 'park.guest.softcap.calculate' called before calculating the soft guest cap.
- Feature: [#22694] Park graphs have tooltips and can be resized like finance graphs.
- Feature: [#22758] The table of ‘real’ peep names can now be changed using Peep Names objects.
- Improved: [#22470] Android: automatically detect RCT2 installs in /sdcard/rct2.
- Improved: [#22777] Add long flat-to-steep track pieces to the Wooden and Classic Wooden Roller Coasters.
- Change: [#22494] Themes window now displays colours and checkboxes vertically.
@@ -25,6 +26,7 @@
- Fix: [#22729] Invisibility settings persist after reloading OpenRCT2.
- Fix: [#22734] Support clearance above steep Side-Friction track is too low.
- Fix: [#22774] Fix entities leaving stale pixels on the screen when the framerate is uncapped.
- Fix: [objects#346] Invalid refund price for Brick Base Block scenery item.
0.4.14 (2024-09-01)
------------------------------------------------------------------------
+2 -2
View File
@@ -45,8 +45,8 @@
<LibsSha1 Condition="'$(Platform)'=='Win32'">9984c1e317dcfb3aaf8e17f1db2ebb0f771e2373</LibsSha1>
<TitleSequencesUrl>https://github.com/OpenRCT2/title-sequences/releases/download/v0.4.14/title-sequences.zip</TitleSequencesUrl>
<TitleSequencesSha1>6c04781b959b468e1f65ec2d2f21f5aaa5e5724d</TitleSequencesSha1>
<ObjectsUrl>https://github.com/OpenRCT2/objects/releases/download/v1.4.7/objects.zip</ObjectsUrl>
<ObjectsSha1>322de669d4b277fceff0d3f123fbc54785dceb4d</ObjectsSha1>
<ObjectsUrl>https://github.com/OpenRCT2/objects/releases/download/v1.4.8/objects.zip</ObjectsUrl>
<ObjectsSha1>405aef518945e617b2750be9128796daa70dba19</ObjectsSha1>
<OpenSFXUrl>https://github.com/OpenRCT2/OpenSoundEffects/releases/download/v1.0.5/opensound.zip</OpenSFXUrl>
<OpenSFXSha1>b1b1f1b241d2cbff63a1889c4dc5a09bdf769bfb</OpenSFXSha1>
<OpenMSXUrl>https://github.com/OpenRCT2/OpenMusic/releases/download/v1.6/openmusic.zip</OpenMSXUrl>
+1
View File
@@ -514,6 +514,7 @@ namespace OpenRCT2
STR_OBJECT_SELECTION_ONLY_STRINGID = 6655,
STR_OBJECT_SELECTION_PATH_EXTRAS = 3190,
STR_OBJECT_SELECTION_PATH_SIGNS = 3188,
STR_OBJECT_SELECTION_PEEP_NAMES = 6675,
STR_OBJECT_SELECTION_RIDE_VEHICLES_ATTRACTIONS = 3184,
STR_OBJECT_SELECTION_SCENERY_GROUPS = 3191,
STR_OBJECT_SELECTION_SELECTION_SIZE = 3164,
@@ -183,6 +183,7 @@ namespace OpenRCT2::Ui::Windows
{ STR_OBJECT_SELECTION_PARK_ENTRANCE, ObjectType::ParkEntrance, SPR_TAB_PARK, kEntrancesObjectSubTabs },
{ STR_OBJECT_SELECTION_TERRAIN_SURFACES, ObjectType::TerrainSurface, SPR_G2_TAB_LAND, kTerrainObjectSubTabs },
{ STR_OBJECT_SELECTION_MUSIC, ObjectType::Music, SPR_TAB_MUSIC_0, {} },
{ STR_OBJECT_SELECTION_PEEP_NAMES, ObjectType::PeepNames, SPR_TAB_GUESTS_0, {} },
};
// clang-format on
+5
View File
@@ -435,6 +435,11 @@ namespace OpenRCT2::Editor
return { ObjectType::TerrainEdge, STR_AT_LEAST_ONE_TERRAIN_EDGE_OBJECT_MUST_BE_SELECTED };
}
if (!EditorCheckObjectGroupAtLeastOneSelected(ObjectType::PeepNames))
{
return { ObjectType::PeepNames, STR_AT_LEAST_ONE_PEEP_NAMES_OBJECT_MUST_BE_SELECTED };
}
if (!isTrackDesignerManager)
{
if (!EditorCheckObjectGroupAtLeastOneSelected(ObjectType::ParkEntrance))
@@ -610,6 +610,10 @@ ResultWithMessage WindowEditorObjectSelectionSelectObject(
// Replace old palette with newly selected palette immediately.
ReplaceSelectedWaterPalette(item);
}
else if (objectType == ObjectType::PeepNames)
{
PeepUpdateNames();
}
if (isMasterObject != 0 && !(flags & INPUT_FLAG_EDITOR_OBJECT_1))
{
-1
View File
@@ -38,7 +38,6 @@
#include "../peep/GuestPathfinding.h"
#include "../peep/PeepAnimationData.h"
#include "../peep/PeepSpriteIds.h"
#include "../peep/RealNames.h"
#include "../profiling/Profiling.h"
#include "../ride/Ride.h"
#include "../ride/RideData.h"
@@ -1307,6 +1307,7 @@ constexpr std::array _objectTypeNames = {
"Footpath Surface",
"Footpath Railings",
"Audio",
"Guest Names",
};
static_assert(_objectTypeNames.size() == EnumValue(ObjectType::Count));
+2 -2
View File
@@ -329,6 +329,7 @@
<ClInclude Include="object\FootpathEntry.h" />
<ClInclude Include="object\PathAdditionEntry.h" />
<ClInclude Include="object\PathAdditionObject.h" />
<ClInclude Include="object\PeepNamesObject.h" />
<ClInclude Include="object\FootpathObject.h" />
<ClInclude Include="object\FootpathRailingsObject.h" />
<ClInclude Include="object\FootpathSurfaceObject.h" />
@@ -389,7 +390,6 @@
<ClInclude Include="peep\PeepAnimationData.h" />
<ClInclude Include="peep\PeepSpriteIds.h" />
<ClInclude Include="peep\PeepThoughts.h" />
<ClInclude Include="peep\RealNames.h" />
<ClInclude Include="peep\RideUseSystem.h" />
<ClInclude Include="PlatformEnvironment.h" />
<ClInclude Include="platform\Crash.h" />
@@ -863,6 +863,7 @@
<ClCompile Include="object\ObjectManager.cpp" />
<ClCompile Include="object\ObjectRepository.cpp" />
<ClCompile Include="object\ObjectTypes.cpp" />
<ClCompile Include="object\PeepNamesObject.cpp" />
<ClCompile Include="object\ResourceTable.cpp" />
<ClCompile Include="object\RideObject.cpp" />
<ClCompile Include="object\SceneryGroupObject.cpp" />
@@ -987,7 +988,6 @@
<ClCompile Include="peep\GuestPathfinding.cpp" />
<ClCompile Include="peep\PeepAnimationData.cpp" />
<ClCompile Include="peep\PeepThoughts.cpp" />
<ClCompile Include="peep\RealNames.cpp" />
<ClCompile Include="peep\RideUseSystem.cpp" />
<ClCompile Include="PlatformEnvironment.cpp" />
<ClCompile Include="platform\Crash.cpp" />
+12 -6
View File
@@ -9,10 +9,12 @@
#include "Formatting.h"
#include "../Context.h"
#include "../Diagnostic.h"
#include "../config/Config.h"
#include "../core/String.hpp"
#include "../peep/RealNames.h"
#include "../object/ObjectManager.h"
#include "../object/PeepNamesObject.h"
#include "../util/Util.h"
#include "Currency.h"
#include "FormatCodes.h"
@@ -289,11 +291,15 @@ namespace OpenRCT2
{
if (IsRealNameStringId(id))
{
auto realNameIndex = id - kRealNameStart;
ss << real_names[realNameIndex % std::size(real_names)];
ss << ' ';
ss << real_name_initials[(realNameIndex >> 10) % std::size(real_name_initials)];
ss << '.';
auto& objManager = GetContext()->GetObjectManager();
auto* peepNamesObj = static_cast<PeepNamesObject*>(objManager.GetLoadedObject(ObjectType::PeepNames, 0));
if (peepNamesObj != nullptr)
{
auto realNameIndex = id - kRealNameStart;
ss << peepNamesObj->GetGivenNameAt(realNameIndex);
ss << ' ';
ss << peepNamesObj->GetSurnameAt(realNameIndex >> 10);
}
}
}
+3
View File
@@ -15,3 +15,6 @@ using StringId = uint16_t;
constexpr StringId STR_NONE = 0xFFFF;
constexpr StringId STR_EMPTY = 0;
constexpr uint16_t kRealNameStart = 0xA000;
constexpr uint16_t kRealNameEnd = 0xDFFF;
+2
View File
@@ -1694,6 +1694,8 @@ enum : StringId
STR_DATE_FORMAT_MY_SENTENCE = 6674,
STR_AT_LEAST_ONE_PEEP_NAMES_OBJECT_MUST_BE_SELECTED = 6676,
// Have to include resource strings (from scenarios and objects) for the time being now that language is partially working
/* MAX_STR_COUNT = 32768 */ // MAX_STR_COUNT - upper limit for number of strings, not the current count strings
};
+3
View File
@@ -144,6 +144,9 @@ const std::string_view DefaultSelectedObjects[] = {
"rct2.footpath_railings.concrete_green",
"rct2.footpath_railings.space",
"rct2.footpath_railings.wood",
// Peep name objects
"rct2.peep_names.original",
};
const std::string_view DesignerSelectedObjects[] = {
+1 -1
View File
@@ -12,5 +12,5 @@
#include "Object.h"
extern const std::string_view MinimumRequiredObjects[2];
extern const std::string_view DefaultSelectedObjects[114];
extern const std::string_view DefaultSelectedObjects[115];
extern const std::string_view DesignerSelectedObjects[39];
+6
View File
@@ -36,6 +36,7 @@
#include "ObjectLimits.h"
#include "ObjectList.h"
#include "PathAdditionObject.h"
#include "PeepNamesObject.h"
#include "RideObject.h"
#include "SceneryGroupObject.h"
#include "SmallSceneryObject.h"
@@ -384,6 +385,9 @@ namespace OpenRCT2::ObjectFactory
case ObjectType::Audio:
result = std::make_unique<AudioObject>();
break;
case ObjectType::PeepNames:
result = std::make_unique<PeepNamesObject>();
break;
default:
throw std::runtime_error("Invalid object type");
}
@@ -424,6 +428,8 @@ namespace OpenRCT2::ObjectFactory
return ObjectType::FootpathRailings;
if (s == "audio")
return ObjectType::Audio;
if (s == "peep_names")
return ObjectType::PeepNames;
return ObjectType::None;
}
+1
View File
@@ -31,5 +31,6 @@ constexpr uint16_t kMaxMusicObjects = 255;
constexpr uint16_t kMaxFootpathSurfaceObjects = 255;
constexpr uint16_t kMaxFootpathRailingsObjects = 255;
constexpr uint16_t kMaxAudioObjects = 255;
constexpr uint16_t kMaxPeepNamesObjects = 1;
constexpr uint8_t kDatNameLength = 8;
+1 -1
View File
@@ -36,7 +36,7 @@ static constexpr std::array<int32_t, EnumValue(ObjectType::Count)> kObjectEntryG
kMaxScenarioTextObjects, // scenario text
kMaxTerrainSurfaceObjects, kMaxTerrainEdgeObjects, kMaxStationObjects,
kMaxMusicObjects, kMaxFootpathSurfaceObjects, kMaxFootpathRailingsObjects,
kMaxAudioObjects,
kMaxAudioObjects, kMaxPeepNamesObjects,
};
static_assert(std::size(kObjectEntryGroupCounts) == EnumValue(ObjectType::Count));
+2
View File
@@ -33,6 +33,7 @@ constexpr std::array kAllObjectTypes = {
ObjectType::FootpathSurface,
ObjectType::FootpathRailings,
ObjectType::Audio,
ObjectType::PeepNames,
};
static_assert(kAllObjectTypes.size() == EnumValue(ObjectType::Count));
@@ -43,6 +44,7 @@ static constexpr std::array<const ObjectType, kNumTransientObjectTypes> kTransie
ObjectType::Banners, ObjectType::Paths, ObjectType::PathAdditions, ObjectType::SceneryGroup,
ObjectType::ParkEntrance, ObjectType::Water, ObjectType::TerrainSurface, ObjectType::TerrainEdge,
ObjectType::Station, ObjectType::Music, ObjectType::FootpathSurface, ObjectType::FootpathRailings,
ObjectType::PeepNames,
};
// Object types that cannot be saved in a park file.
+2 -1
View File
@@ -39,12 +39,13 @@ enum class ObjectType : uint8_t
FootpathSurface,
FootpathRailings,
Audio,
PeepNames,
Count,
None = 255
};
static constexpr size_t kNumTransientObjectTypes = 16;
static constexpr size_t kNumTransientObjectTypes = 17;
static constexpr size_t kNumIntransientObjectTypes = 2;
bool ObjectTypeIsTransient(ObjectType type);
+48
View File
@@ -0,0 +1,48 @@
/*****************************************************************************
* 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()];
}
+31
View File
@@ -0,0 +1,31 @@
/*****************************************************************************
* 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.
*****************************************************************************/
#pragma once
#include "../core/IStream.hpp"
#include "Object.h"
#include <string>
#include <vector>
class PeepNamesObject final : public Object
{
private:
std::vector<std::string> _givenNames;
std::vector<std::string> _surnames;
public:
void ReadJson(IReadObjectContext* context, json_t& root) override;
void Load() override;
void Unload() override;
std::string GetGivenNameAt(size_t index) const;
std::string GetSurnameAt(size_t index) const;
};
+7
View File
@@ -373,6 +373,13 @@ namespace OpenRCT2
}
}
});
if (version < kPeepNamesObjectsVersion)
{
AppendRequiredObjects(
requiredObjects, ObjectType::PeepNames, std::vector<std::string>({ "rct2.peep_names.original" }));
}
RequiredObjects = std::move(requiredObjects);
}
else
+3 -2
View File
@@ -11,10 +11,10 @@ namespace OpenRCT2
struct GameState_t;
// Current version that is saved.
constexpr uint32_t PARK_FILE_CURRENT_VERSION = 38;
constexpr uint32_t PARK_FILE_CURRENT_VERSION = 39;
// The minimum version that is forwards compatible with the current version.
constexpr uint32_t PARK_FILE_MIN_VERSION = 38;
constexpr uint32_t PARK_FILE_MIN_VERSION = 39;
// The minimum version that is backwards compatible with the current version.
// If this is increased beyond 0, uncomment the checks in ParkFile.cpp and Context.cpp!
@@ -30,6 +30,7 @@ namespace OpenRCT2
constexpr uint16_t kGigaCoasterInversions = 31;
constexpr uint16_t kWoodenFlatToSteepVersion = 37;
constexpr uint16_t k16BitParkHistoryVersion = 38;
constexpr uint16_t kPeepNamesObjectsVersion = 39;
} // namespace OpenRCT2
class ParkFileExporter
File diff suppressed because it is too large. Load diff
-19
View File
@@ -1,19 +0,0 @@
/*****************************************************************************
* 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.
*****************************************************************************/
#pragma once
#include <cstdint>
constexpr uint16_t kRealNameStart = 0xA000;
constexpr uint16_t kRealNameEnd = 0xDFFF;
// Real name data
extern const char real_name_initials[16];
extern const char* real_names[1024];
+1 -15
View File
@@ -1483,21 +1483,6 @@ namespace OpenRCT2::RCT1
}
}
void AppendRequiredObjects(ObjectList& objectList, ObjectType objectType, const RCT12::EntryList& entryList)
{
AppendRequiredObjects(objectList, objectType, entryList.GetEntries());
}
void AppendRequiredObjects(ObjectList& objectList, ObjectType objectType, const std::vector<std::string>& objectNames)
{
for (const auto& objectName : objectNames)
{
auto descriptor = ObjectEntryDescriptor(objectName);
descriptor.Type = objectType;
objectList.Add(descriptor);
}
}
ObjectList GetRequiredObjects()
{
ObjectList result;
@@ -1515,6 +1500,7 @@ namespace OpenRCT2::RCT1
AppendRequiredObjects(result, ObjectType::TerrainEdge, _terrainEdgeEntries);
AppendRequiredObjects(result, ObjectType::FootpathSurface, _footpathSurfaceEntries);
AppendRequiredObjects(result, ObjectType::FootpathRailings, _footpathRailingsEntries);
AppendRequiredObjects(result, ObjectType::PeepNames, std::vector<std::string>({ "rct2.peep_names.original" }));
RCT12AddDefaultObjects(result);
return result;
}
+1 -1
View File
@@ -817,7 +817,7 @@ void RCT12AddDefaultObjects(ObjectList& objectList)
}
}
static void AppendRequiredObjects(ObjectList& objectList, ObjectType objectType, const std::vector<std::string>& objectNames)
void AppendRequiredObjects(ObjectList& objectList, ObjectType objectType, const std::vector<std::string>& objectNames)
{
for (const auto& objectName : objectNames)
{
+1
View File
@@ -914,6 +914,7 @@ std::string_view GetStationIdentifierFromStyle(uint8_t style);
uint8_t GetStationStyleFromIdentifier(u8string_view identifier);
std::optional<uint8_t> GetStyleFromMusicIdentifier(std::string_view identifier);
void RCT12AddDefaultObjects(ObjectList& objectList);
void AppendRequiredObjects(ObjectList& objectList, ObjectType objectType, const std::vector<std::string>& objectNames);
void AppendRequiredObjects(ObjectList& objectList, ObjectType objectType, const OpenRCT2::RCT12::EntryList& entryList);
bool IsUserStringID(StringId stringId);
+1
View File
@@ -1859,6 +1859,7 @@ namespace OpenRCT2::RCT2
AppendRequiredObjects(objectList, ObjectType::TerrainSurface, _terrainSurfaceEntries);
AppendRequiredObjects(objectList, ObjectType::TerrainEdge, _terrainEdgeEntries);
AppendRequiredObjects(objectList, ObjectType::PeepNames, std::vector<std::string>({ "rct2.peep_names.original" }));
RCT12AddDefaultObjects(objectList);
return objectList;
}