From be43f4d5281e708c04394e5f5832045c7754fb2e Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 29 Jul 2024 01:04:46 +0300 Subject: [PATCH] Only do lookup for mobjtype and states for drift stars and water trails at map load --- src/k_kart.c | 44 +++++++++++++++++++++++++------------------- src/k_kart.h | 2 ++ src/p_setup.c | 2 ++ 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index fbf2f7600..435e742aa 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -46,6 +46,28 @@ #include "hardware/hw_main.h" #endif +// Not sure if thats best place for that +static mobjtype_t stardust = 0; +static mobjtype_t watertrailunderlay = 0, watertrail = 0; +static statenum_t watertrailunderlay_minstate = 0, watertrailunderlay_maxstate = 0; +static statenum_t watertrail_minstate = 0, watertrail_maxstate = 0; + +void K_LoadExtraVFX(void) +{ +#define LOADVFX(var, name) if (!var) var = LUA_GetConstant(name); + + LOADVFX(stardust, "MT_STARDUST"); + + LOADVFX(watertrail, "MT_WATERTRAIL"); + LOADVFX(watertrailunderlay, "MT_WATERTRAILUNDERLAY"); + LOADVFX(watertrail_minstate, "S_WATERTRAIL1"); + LOADVFX(watertrail_maxstate, "S_WATERTRAILLAST"); + LOADVFX(watertrailunderlay_minstate, "S_WATERTRAILUNDERLAY1"); + LOADVFX(watertrailunderlay_maxstate, "S_WATERTRAILUNDERLAYLAST"); + +#undef LOAD +} + // Hud offset cvars #define IMPL_HUD_OFFSET_X(name)\ consvar_t cv_##name##_xoffset = {"hud_" #name "_xoffset", "0", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -3499,8 +3521,9 @@ void K_DriftDustHandling(mobj_t *spawner) fixed_t spawny = P_RandomRange(-spawnrange, spawnrange)< watertrail_maxstate && watertrailunderlay_minstate > watertrailunderlay_maxstate)) // Check if some of these were freeslot'd in wrong order + (watertrail_minstate > watertrail_maxstate && watertrailunderlay_minstate > watertrailunderlay_maxstate)) // Check if some of these were freeslot'd in wrong order return; fixed_t runSpeed = 14 * mobj->scale; diff --git a/src/k_kart.h b/src/k_kart.h index c251c7228..c0c928fba 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -11,6 +11,8 @@ #define KART_FULLTURN 800 +void K_LoadExtraVFX(void); + extern UINT8 colortranslations[MAXTRANSLATIONS][16]; extern const char *KartColor_Names[MAXSKINCOLORS]; extern const UINT8 KartColor_Opposite[MAXSKINCOLORS*2]; diff --git a/src/p_setup.c b/src/p_setup.c index b87d11881..234d0d27b 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3109,6 +3109,8 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) G_AddMapToBuffer(gamemap-1); + K_LoadExtraVFX(); + return true; }