Split up misc list access to be type specific (#13870)

* Split up misc list access to be type specific

Took the opertunity to use a fold expression to simplify the code

* Increment network version
This commit is contained in:
Duncan 2021-01-21 08:29:02 +00:00 committed by GitHub
parent cf83752ce4
commit 3321720d4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 41 deletions

View File

@ -34,7 +34,7 @@
// This string specifies which version of network stream current build uses.
// It is used for making sure only compatible builds get connected, even within
// single OpenRCT2 version.
#define NETWORK_STREAM_VERSION "11"
#define NETWORK_STREAM_VERSION "12"
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION
static Peep* _pickup_peep = nullptr;

View File

@ -623,57 +623,28 @@ void ExplosionFlare::Update()
}
}
/**
*
* rct2: 0x006731CD
*/
static void sprite_misc_update(MiscEntity* sprite)
template<typename T> void MiscUpdateAllType()
{
switch (sprite->SubType)
for (auto misc : EntityList<T>(EntityListId::Misc))
{
case MiscEntityType::SteamParticle:
sprite->As<SteamParticle>()->Update();
break;
case MiscEntityType::MoneyEffect:
sprite->As<MoneyEffect>()->Update();
break;
case MiscEntityType::CrashedVehicleParticle:
sprite->As<VehicleCrashParticle>()->Update();
break;
case MiscEntityType::ExplosionCloud:
sprite->As<ExplosionCloud>()->Update();
break;
case MiscEntityType::CrashSplash:
sprite->As<CrashSplashParticle>()->Update();
break;
case MiscEntityType::ExplosionFlare:
sprite->As<ExplosionFlare>()->Update();
break;
case MiscEntityType::JumpingFountainWater:
case MiscEntityType::JumpingFountainSnow:
sprite->As<JumpingFountain>()->Update();
break;
case MiscEntityType::Balloon:
sprite->As<Balloon>()->Update();
break;
case MiscEntityType::Duck:
sprite->As<Duck>()->Update();
break;
default:
break;
misc->Update();
}
}
template<typename... T> void MiscUpdateAllTypes()
{
(MiscUpdateAllType<T>(), ...);
}
/**
*
* rct2: 0x00672AA4
*/
void sprite_misc_update_all()
{
for (auto entity : EntityList<MiscEntity>(EntityListId::Misc))
{
sprite_misc_update(entity);
}
MiscUpdateAllTypes<
SteamParticle, MoneyEffect, VehicleCrashParticle, ExplosionCloud, CrashSplashParticle, ExplosionFlare, JumpingFountain,
Balloon, Duck>();
}
// Performs a search to ensure that insert keeps next_in_quadrant in sprite_index order