Initialize track data table at compile time

This commit is contained in:
ζeh Matt 2022-02-02 21:10:04 +02:00
parent 5157b57a15
commit aed98b5d82
No known key found for this signature in database
GPG Key ID: 18CE582C71A225B0
3 changed files with 9 additions and 8 deletions

View File

@ -416,7 +416,6 @@ namespace OpenRCT2
}
_env->SetBasePath(DIRBASE::RCT2, rct2InstallPath);
}
TrackMetaData::Init();
_objectRepository = CreateObjectRepository(_env);
_objectManager = CreateObjectManager(*_objectRepository);

View File

@ -5702,15 +5702,13 @@ namespace OpenRCT2
{
namespace TrackMetaData
{
static std::vector<TrackElementDescriptor> _trackElementDescriptors;
void Init()
static constexpr auto BuildDescriptorTable()
{
_trackElementDescriptors.clear();
_trackElementDescriptors.reserve(TrackElemType::Count);
std::array<TrackElementDescriptor, TrackElemType::Count> res{};
TrackElementDescriptor desc;
for (int i = 0; i < TrackElemType::Count; i++)
{
TrackElementDescriptor& desc = res[i];
desc.Description = RideConfigurationStringIds[i];
desc.AlternativeType = AlternativeTrackTypes[i];
desc.Block = const_cast<rct_preview_track*>(TrackBlocks[i]);
@ -5729,12 +5727,17 @@ namespace OpenRCT2
desc.SequenceElementAllowedWallEdges[j] = TrackSequenceElementAllowedWallEdges[i][j];
desc.SequenceProperties[j] = TrackSequenceProperties[i][j];
}
_trackElementDescriptors.push_back(desc);
}
return res;
}
static constexpr auto _trackElementDescriptors = BuildDescriptorTable();
const TrackElementDescriptor& GetTrackElementDescriptor(const uint32_t type)
{
return _trackElementDescriptors[type];
}
} // namespace TrackMetaData
} // namespace OpenRCT2

View File

@ -97,7 +97,6 @@ namespace OpenRCT2
{
namespace TrackMetaData
{
void Init();
const TrackElementDescriptor& GetTrackElementDescriptor(const uint32_t type);
} // namespace TrackMetaData
} // namespace OpenRCT2