From 14400097dd87ba83f5a3726589be8a6484194ffb 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 dc58f2e35..d1acade4c 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -44,6 +44,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}; @@ -3495,8 +3517,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 4845696f3..6c6215926 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 85db5afc6..97fd46e51 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3175,6 +3175,8 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) G_AddMapToBuffer(gamemap-1); + K_LoadExtraVFX(); + return true; }