move saltyhop stuff into seperate struct

no functional change, just as little cleaner lookin
+ reduce size by using stdbools boolean
This commit is contained in:
Alug committed 2025-09-20 16:34:35 +02:00
1 parent 7c490de93e
commit e9fc57b97d
3 files changed
+43 -44

No files matched your search

+31 -37
View File
@@ -91,16 +91,10 @@ static void saltyhop_onchange(void)
{
player_t *player = &players[i];
if (!player || !playeringame[i] || P_MobjWasRemoved(player->mo))
if (!player || P_MobjWasRemoved(player->mo))
continue;
player->mo->salty_jump = false;
player->mo->salty_zoffset = 0;
player->mo->salty_momz = 0;
player->mo->salty_ready = false;
player->mo->salty_tapping = false;
player->mo->init_salty = false;
memset(&player->mo->salty, 0, sizeof(player->mo->salty));
}
}
@@ -3339,70 +3333,70 @@ static void K_QuiteSaltyHop(player_t *player)
return;
// what the fuck is this haya
//fixed_t mos = FRACUNIT; // doesnt work correctly if it isnt :/
mobj_t *pmo = player->mo;
salty_t *psalt = &pmo->salty;
const boolean onground = P_IsObjectOnGround(pmo);
// ready?
if (!player->kartstuff[k_jmp])
{
pmo->salty_ready = true;
pmo->salty_tapping = false;
psalt->ready = true;
psalt->tapping = false;
}
else if (pmo->salty_ready)
else if (psalt->ready)
{
pmo->salty_ready = false;
pmo->salty_tapping = true;
psalt->ready = false;
psalt->tapping = true;
}
else
{
pmo->salty_tapping = false;
psalt->tapping = false;
}
// GO!
if (!pmo->init_salty)
if (!psalt->init)
{
pmo->salty_jump = false;
pmo->salty_zoffset = 0;
pmo->salty_momz = 0;
pmo->init_salty = true;
psalt->jump = false;
psalt->zoffset = 0;
psalt->momz = 0;
psalt->init = true;
}
else if (pmo->salty_jump)
else if (psalt->jump)
{
if (pmo->eflags & MFE_JUSTHITFLOOR)
{
pmo->salty_zoffset = 0;
psalt->zoffset = 0;
}
else if (onground)
{
pmo->salty_zoffset += pmo->salty_momz;
pmo->salty_momz -= (FRACUNIT*3/2);
psalt->zoffset += psalt->momz;
psalt->momz -= (FRACUNIT*3/2);
}
else
{
pmo->salty_zoffset *= (49/50)*FRACUNIT;
pmo->salty_momz = 0;
psalt->zoffset *= (49/50)*FRACUNIT;
psalt->momz = 0;
}
if (pmo->salty_zoffset <= 0)
if (psalt->zoffset <= 0)
{
if (cv_saltyhopsfx.value && !(pmo->eflags & MFE_JUSTHITFLOOR) && onground)
S_StartSound(pmo, sfx_s268);
pmo->salty_jump = false;
pmo->salty_zoffset = 0;
pmo->salty_momz = 0;
psalt->jump = false;
psalt->zoffset = 0;
psalt->momz = 0;
// shlamma damma
if (cv_saltysquish.value)
pmo->stretchslam += 8*FRACUNIT;
}
else if (cv_saltysquish.value && pmo->salty_zoffset >= 0)
else if (cv_saltysquish.value && psalt->zoffset >= 0)
{
// goofy ahh hack
pmo->spriteyscale += (FRACUNIT/8);
pmo->spritexscale -= (FRACUNIT/8);
}
pmo->spriteyoffset = FixedMul(pmo->salty_zoffset, cv_saltyheight.value);
pmo->spriteyoffset = FixedMul(psalt->zoffset, cv_saltyheight.value);
if (cv_saltyhopsfx.value)
{
@@ -3412,11 +3406,11 @@ static void K_QuiteSaltyHop(player_t *player)
S_StopSoundByID(pmo, sfx_drift);
}
}
else if (pmo->salty_tapping && onground && !player->kartstuff[k_spinouttimer] && !player->kartstuff[k_squishedtimer])
else if (psalt->tapping && onground && !player->kartstuff[k_spinouttimer] && !player->kartstuff[k_squishedtimer])
{
pmo->salty_jump = true;
pmo->salty_zoffset = 0;
pmo->salty_momz = 6*FRACUNIT;
psalt->jump = true;
psalt->zoffset = 0;
psalt->momz = 6*FRACUNIT;
if (cv_saltyhopsfx.value)
S_StartSound(pmo, sfx_s25a);
}
@@ -3443,7 +3437,7 @@ boolean K_ShouldSlopeRoll(mobj_t *mobj)
return false;
// seeing a character rotate mid-hop looks really janky
if (!cv_saltyroll.value && mobj->player && mobj->player->mo->salty_jump)
if (!cv_saltyroll.value && mobj->player && mobj->player->mo->salty.jump)
return false;
return K_CheckSlopeRollDist(mobj);
+11 -6
View File
@@ -266,6 +266,16 @@ typedef enum {
PCF_THUNK = 1<<5, // Ran the thinker this tic.
} precipflag_t;
typedef struct salty_s
{
bool init;
bool ready;
bool tapping;
fixed_t zoffset;
fixed_t momz;
bool jump;
} salty_t;
// Map Object definition.
typedef struct mobj_s
{
@@ -407,12 +417,7 @@ typedef struct mobj_s
tic_t slamsoundtimer; // Funni slam sound when landing
// saltyhop! hardcode edition
boolean salty_ready;
boolean salty_tapping;
fixed_t salty_zoffset;
fixed_t salty_momz;
boolean salty_jump;
boolean init_salty;
salty_t salty;
// WARNING: New fields must be added separately to savegame and Lua.
boolean islocal; // BEWARE: islocal does not exist in vanilla, strictly to be used for locally loaded addons to not cause desynchs with the mobj linedef trigger check. DO NOT USE THIS IN ACTUAL ADDONS YOU INTEND TO USE ON YOUR SERVER
+1 -1
View File
@@ -4505,7 +4505,7 @@ static void P_DoFunnyDance(player_t *player)
{
fixed_t bpm; // 140bpm ish
if (player->spectator || !player->mo || player->kartstuff[k_respawn] || player->mo->salty_jump) // this looks jank as hell during hop
if (player->spectator || !player->mo || player->kartstuff[k_respawn] || player->mo->salty.jump) // this looks jank as hell during hop
return;
player->squishdance.bounce = 0;