From b76ce23ed2e79f78acfec3ee578879cbaf04f5a8 Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 25 Jul 2024 19:02:39 +0300 Subject: [PATCH] Make drift stars not use hardcode freeslots --- src/dehacked.c | 8 -------- src/info.c | 34 +--------------------------------- src/info.h | 10 ---------- src/k_kart.c | 12 ++++++++++-- src/lua_script.c | 15 +++++++++++++-- src/lua_script.h | 1 + 6 files changed, 25 insertions(+), 55 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 8fe562aab..0b9a6ada5 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -6508,12 +6508,6 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_WATERTRAILUNDERLAY3", "S_WATERTRAILUNDERLAY4", "S_WATERTRAILUNDERLAY5", - - // Star Smoke - "S_DRIFTSTAR1", - "S_DRIFTSTAR2", - "S_DRIFTSTAR3", - "S_DRIFTSTAR4", }; // RegEx to generate this from info.h: ^\tMT_([^,]+), --> \t"MT_\1", @@ -7311,8 +7305,6 @@ static const char *const MOBJTYPE_LIST[] = { // array length left dynamic for s "MT_WATERTRAIL", "MT_WATERTRAILUNDERLAY", - - "MT_STARDUST", }; static const char *const MOBJFLAG_LIST[] = { diff --git a/src/info.c b/src/info.c index 8e0bd979a..9726a670e 100644 --- a/src/info.c +++ b/src/info.c @@ -66,7 +66,7 @@ char sprnames[NUMSPRITES + 1][5] = "CNDL","DOCH","DUCK","GTRE","CHES","CHIM","DRGN","LZMN","PGSS","ZTCH", "MKMA","MKMP","RTCH","BOWL","BOWH","BRRL","BRRR","HRSE","TOAH","BFRT", "OFRT","RFRT","PFRT","ASPK","HBST","HBSO","HBSF","WBLZ","WBLN","OPUL", - "TGEM","TCOI","FWRK","XMS4","XMS5","VIEW","WTRL","DSTR" + "TGEM","TCOI","FWRK","XMS4","XMS5","VIEW","WTRL", }; // Doesn't work with g++, needs actionf_p1 (don't modify this comment) @@ -3422,11 +3422,6 @@ state_t states[NUMSTATES] = {SPR_WTRL, FF_TRANS50|FF_PAPERSPRITE|7, 2, {NULL}, 0, 0, S_INVISIBLE}, // S_WATERTRAILUNDERLAY3 {SPR_WTRL, FF_TRANS50|FF_PAPERSPRITE|8, 2, {NULL}, 0, 0, S_INVISIBLE}, // S_WATERTRAILUNDERLAY4 {SPR_WTRL, FF_TRANS50|FF_PAPERSPRITE|9, 2, {NULL}, 0, 0, S_INVISIBLE}, // S_WATERTRAILUNDERLAY5 - - {SPR_DSTR, 0, 3, {NULL}, 0, 0, S_DRIFTSTAR2}, // S_DRIFTSTAR1 - {SPR_DSTR, 1, 3, {NULL}, 0, 0, S_DRIFTSTAR3}, // S_DRIFTSTAR2 - {SPR_DSTR, FF_TRANS20|2, 3, {NULL}, 0, 0, S_DRIFTSTAR4}, // S_DRIFTSTAR3 - {SPR_DSTR, FF_TRANS20|3, 3, {NULL}, 0, 0, S_NULL}, // S_DRIFTSTAR4 }; mobjinfo_t mobjinfo[NUMMOBJTYPES] = @@ -20274,33 +20269,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = MF_NOBLOCKMAP|MF_NOCLIP|MF_NOGRAVITY|MF_SCENERY|MF_DONTENCOREMAP, // flags S_NULL // raisestate }, - - { // MT_STARDUST - -1, // doomednum - S_DRIFTSTAR1, // spawnstate - 1000, // spawnhealth - S_NULL, // seestate - sfx_None, // seesound - 8, // reactiontime - sfx_None, // attacksound - S_NULL, // painstate - 12, // painchance - sfx_None, // painsound - S_NULL, // meleestate - S_NULL, // missilestate - S_NULL, // deathstate - S_NULL, // xdeathstate - sfx_None, // deathsound - 8, // speed - 8*FRACUNIT, // radius - 15*FRACUNIT, // height - 0, // display offset - 100, // mass - 0, // damage - sfx_None, // activesound - MF_NOBLOCKMAP|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_FLOAT|MF_SCENERY|MF_DONTENCOREMAP, // flags - S_NULL // raisestate - }, }; diff --git a/src/info.h b/src/info.h index e18c24cc3..d663a91a0 100644 --- a/src/info.h +++ b/src/info.h @@ -1020,8 +1020,6 @@ typedef enum sprite SPR_WTRL, // Water Trail - SPR_DSTR, // Star Dust - SPR_FIRSTFREESLOT, SPR_LASTFREESLOT = SPR_FIRSTFREESLOT + NUMSPRITEFREESLOTS - 1, NUMSPRITES @@ -4321,12 +4319,6 @@ typedef enum state S_WATERTRAILUNDERLAY4, S_WATERTRAILUNDERLAY5, - // Star Smoke - S_DRIFTSTAR1, - S_DRIFTSTAR2, - S_DRIFTSTAR3, - S_DRIFTSTAR4, - S_FIRSTFREESLOT, S_LASTFREESLOT = S_FIRSTFREESLOT + NUMSTATEFREESLOTS - 1, NUMSTATES @@ -5141,8 +5133,6 @@ typedef enum mobj_type MT_WATERTRAIL, MT_WATERTRAILUNDERLAY, - MT_STARDUST, - MT_FIRSTFREESLOT, MT_LASTFREESLOT = MT_FIRSTFREESLOT + NUMMOBJFREESLOTS - 1, NUMMOBJTYPES diff --git a/src/k_kart.c b/src/k_kart.c index 81e49cf12..724abab79 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3495,7 +3495,15 @@ void K_DriftDustHandling(mobj_t *spawner) fixed_t spawny = P_RandomRange(-spawnrange, spawnrange)<x + spawnx, spawner->y + spawny, spawner->z, (spawner->player ? MT_STARDUST : MT_DRIFTDUST)); // only sparkle for players otherwise throw normal dust + mobjtype_t stardust = LUA_EvalMathEx("MT_STARDUST", NULL); + boolean havestardust = true; + if (!stardust) + { + stardust = MT_DRIFTDUST; + havestardust = false; + } + + dust = P_SpawnMobj(spawner->x + spawnx, spawner->y + spawny, spawner->z, (spawner->player ? stardust : MT_DRIFTDUST)); // only sparkle for players otherwise throw normal dust dust->momx = FixedMul(spawner->momx + (P_RandomRange(-speedrange, speedrange)<scale)/4); dust->momy = FixedMul(spawner->momy + (P_RandomRange(-speedrange, speedrange)<scale)/4); dust->momz = P_MobjFlip(spawner) * (P_RandomRange(1, 4) * (spawner->scale)); @@ -3508,7 +3516,7 @@ void K_DriftDustHandling(mobj_t *spawner) K_MatchGenericExtraFlags(dust, spawner); - if (dust->type == MT_STARDUST) + if (havestardust && dust->type == stardust) { if (!P_MobjWasRemoved(spawner) && spawner->player && spawner->player->mo) { diff --git a/src/lua_script.c b/src/lua_script.c index 75019ecda..193556b5a 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -364,7 +364,7 @@ void LUA_DumpFile(const char *filename) } #endif -fixed_t LUA_EvalMath(const char *word) +fixed_t LUA_EvalMathEx(const char *word, const char **error) { char buf[1024], *b; const char *p; @@ -401,7 +401,7 @@ fixed_t LUA_EvalMath(const char *word) p = lua_tostring(mL, -1); while (*p++ != ':' && *p) ; p += 3; // "1: " - CONS_Alert(CONS_WARNING, "%s\n", p); + if (error) *error = p; } else res = lua_tointeger(mL, -1); @@ -409,6 +409,17 @@ fixed_t LUA_EvalMath(const char *word) return res; } +fixed_t LUA_EvalMath(const char *word) +{ + const char *error = NULL; + fixed_t res = LUA_EvalMathEx(word, &error); + + if (error) + CONS_Alert(CONS_WARNING, "%s\n", error); + + return res; +} + void LUA_InvalidateMathlibCache(const char *name) { // No state => no cache => nothing to invalidate :3 diff --git a/src/lua_script.h b/src/lua_script.h index 9903315c2..9513f0b11 100644 --- a/src/lua_script.h +++ b/src/lua_script.h @@ -44,6 +44,7 @@ void LUA_LoadLump(UINT16 wad, UINT16 lump); #ifdef LUA_ALLOW_BYTECODE void LUA_DumpFile(const char *filename); #endif +fixed_t LUA_EvalMathEx(const char *word, const char **error); fixed_t LUA_EvalMath(const char *word); // Need better name for this ;-;