Compare commits

...
7 Commits
Author SHA1 Message Date
alufolie91 2bc9f32074 simpler fix for localskin minimap angle display crash 2026-10-12 15:15:26 +02:00
alufolie91 f0703dc5e1 fix crash when applying localskin midgame 2026-10-08 09:27:47 +02:00
alufolie91 7ca73cdfdb fix another "0 as null pointer" case 2026-10-08 09:27:44 +02:00
alufolie91 c01d6eccf6 fix arithmetic on NULL pointer when drawing 3d models
caused by localskin code.... sigh......
noticed this while messing with dynamic allocated (local)skins
2026-10-08 09:27:42 +02:00
alufolie91 4ba3eec1e3 cleanup squishdance stuff a bit
we dont need all those things saved per player really lol
2026-10-08 09:27:37 +02:00
alufolie91 601f384314 cleanup saltyhop a little, move it to player struct 2026-10-08 09:27:32 +02:00
alufolie91 19fc0da296 fix localskin menu not showing localskin 3d models
this should use the skins localnumber not the "actual" skinnumber
yeah localskin code still sucks....
fixes https://github.com/Indev450/SRB2Kart-Saturn/issues/230
2026-10-04 01:01:11 +02:00
8 changed files with 85 additions and 97 deletions

No files matched your search

+12 -3
View File
@@ -361,11 +361,17 @@ typedef struct squishdance_s
{
tic_t countdown; // hold "custom 3" for 2 seconds to engange le dance
tic_t time;
fixed_t work;
fixed_t ang;
fixed_t bounce; // hehe squishy
} squishdance_t;
typedef struct salty_s
{
bool ready;
bool tapping;
fixed_t zoffset;
fixed_t momz;
bool jump;
} salty_t;
// ========================================================================
// PLAYER STRUCTURE
// ========================================================================
@@ -561,6 +567,9 @@ typedef struct player_s
fixed_t spinoutrot; // When a player spins out, this value increments modulus 360.
// saltyhop! hardcode edition
salty_t salty;
squishdance_t squishdance;
fixed_t fovadd; // adjust FOV for hw rendering
+3 -3
View File
@@ -1146,8 +1146,8 @@ void HWR_DrawMD2(gl_vissprite_t *spr)
// Look at HWR_ProjectSprite for more
{
md2_t *md2s;
int skinnum;
md2_t *md2s = NULL;
int skinnum = 0;
patch_t *gpatch, *blendgpatch;
GLPatch_t *hwrPatch = NULL, *hwrBlendPatch = NULL;
INT32 durs = spr->mobj->state->tics;
@@ -1221,7 +1221,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr)
skinnum = (skin_t *)spr->mobj->localskin - skins;
}
}
else
else if (spr->mobj->skin)
{
md2s = md2_playermodels;
skinnum = (skin_t *)spr->mobj->skin - skins;
+1 -3
View File
@@ -3829,10 +3829,8 @@ static void K_drawKartMinimap(void)
}
else
{
const INT32 skinnum = K_GetMobjLocalSkinNum(mobj->skin, mobj->localskin, mobj->skinlocal);
// special case if startcolor is not the default (160 / Green)
if (skinnum && skins[skinnum].starttranscolor != skins[0].starttranscolor)
if (K_GetMobjSkin(mobj)->starttranscolor != skins[0].starttranscolor)
{
colormap = R_GetTranslationColormap(TC_DEFAULT, mobj->color, GTC_CACHE);
}
+50 -64
View File
@@ -71,12 +71,11 @@ consvar_t cv_stairjank = {"stairjank", "Off", CV_SAVE|CV_CALL, CV_OnOff, PDistor
consvar_t cv_stairjanksfx = {"stairjanksfx", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
//hardcode saltyhop mhhm
static void saltyhop_onchange(void);
consvar_t cv_saltyhop = {"hardcodehop", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, saltyhop_onchange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_saltyhop = {"hardcodehop", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_saltyhopsfx = {"hardcodehopsfx", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_saltysquish = {"hardcodehopsquish", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t saltyheight_t[] = {{FRACUNIT/4, "MIN"}, {2*FRACUNIT, "MAX"}, {0, NULL}};
consvar_t cv_saltyheight = {"hardcodehopheight", "1", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, saltyheight_t, saltyhop_onchange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_saltyheight = {"hardcodehopheight", "1", CV_FLOAT|CV_SAVE, saltyheight_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_saltyroll = {"hardcodehoproll", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_squishdance = {"squishdance", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -84,23 +83,6 @@ consvar_t cv_squishdance = {"squishdance", "On", CV_SAVE, CV_OnOff, NULL, 0, NUL
static CV_PossibleValue_t squishdancespeed_cons_t[] = {{20, "MIN"}, {280, "MAX"}, {0, NULL}};
consvar_t cv_squishdancespeed = {"squishdance_speed", "140", CV_SAVE, squishdancespeed_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
static void saltyhop_onchange(void)
{
// reset everything when toggling saltyhop
if (gamestate != GS_LEVEL)
return;
for (INT32 i = 0; i < MAXPLAYERS; i++)
{
player_t *player = &players[i];
if (!player || P_MobjWasRemoved(player->mo))
continue;
memset(&player->mo->salty, 0, sizeof(player->mo->salty));
}
}
// SOME IMPORTANT VARIABLES DEFINED IN DOOMDEF.H:
// gamespeed is cc (0 for easy, 1 for normal, 2 for hard)
// franticitems is Frantic Mode items, bool
@@ -2194,7 +2176,7 @@ static void K_GetKartBoostPower(player_t *player)
// Technically, all mobjs that think can cause desynchs if they are spawned conditionally, so best we can do
// is to hide them if you are in saltyhop jump
if (dust && player->mo->salty.jump)
if (dust && player->salty.jump)
dust->flags2 |= MF2_DONTDRAW;
if (leveltime % 6 == 0)
@@ -3404,88 +3386,92 @@ static void K_SaltySquish(player_t *player)
static void K_QuiteSaltyHop(player_t *player)
{
if (!cv_saltyhop.value)
return;
I_Assert(player != NULL);
I_Assert(!P_MobjWasRemoved(player->mo));
// what the fuck is this haya
mobj_t *pmo = player->mo;
salty_t *psalt = &pmo->salty;
salty_t *psalty = &player->salty;
if (!cv_saltyhop.value)
{
// reset before we leave
psalty->jump = psalty->ready = psalty->tapping = false;
psalty->momz = psalty->zoffset = 0;
return;
}
const boolean onground = P_IsObjectOnGround(pmo);
// ready?
if (!player->kartstuff[k_jmp])
{
psalt->ready = true;
psalt->tapping = false;
psalty->ready = true;
psalty->tapping = false;
}
else if (psalt->ready)
else if (psalty->ready)
{
psalt->ready = false;
psalt->tapping = true;
psalty->ready = false;
psalty->tapping = true;
}
else
{
psalt->tapping = false;
psalty->tapping = false;
}
// GO!
if (!psalt->init)
{
psalt->jump = false;
psalt->zoffset = 0;
psalt->momz = 0;
psalt->init = true;
}
else if (psalt->jump)
if (psalty->jump)
{
if (pmo->eflags & MFE_JUSTHITFLOOR)
{
psalt->zoffset = 0;
psalty->zoffset = 0;
}
else if (onground)
{
psalt->zoffset += psalt->momz;
psalt->momz -= (FRACUNIT*3/2);
psalty->zoffset += psalty->momz;
psalty->momz -= (FRACUNIT*3/2);
}
else
{
psalt->zoffset *= (49/50)*FRACUNIT;
psalt->momz = 0;
//psalty->zoffset *= (49/50)*FRACUNIT; // this just rounds down to 0 lol
psalty->zoffset = 0;
psalty->momz = 0;
}
if (psalt->zoffset <= 0)
if (psalty->zoffset <= 0)
{
if (cv_saltyhopsfx.value && !(pmo->eflags & MFE_JUSTHITFLOOR) && onground)
S_StartSound(pmo, sfx_s268);
psalt->jump = false;
psalt->zoffset = 0;
psalt->momz = 0;
psalty->jump = false;
psalty->zoffset = 0;
psalty->momz = 0;
// shlamma damma
if (cv_saltysquish.value)
pmo->stretchslam += 8*FRACUNIT;
}
else if (cv_saltysquish.value && psalt->zoffset >= 0)
else if (psalty->zoffset > 0)
{
// goofy ahh hack
pmo->spriteyscale += (FRACUNIT/8);
pmo->spritexscale -= (FRACUNIT/8);
if (cv_saltysquish.value)
{
// goofy ahh hack
pmo->spriteyscale += (FRACUNIT/8);
pmo->spritexscale -= (FRACUNIT/8);
}
}
pmo->spriteyoffset += FixedMul(psalt->zoffset, cv_saltyheight.value);
pmo->spriteyoffset += FixedMul(psalty->zoffset, cv_saltyheight.value);
if (cv_saltyhopsfx.value)
{
if (S_SoundPlaying(pmo, sfx_screec))
S_StopSoundByID(pmo, sfx_screec);
if (S_SoundPlaying(pmo, sfx_drift))
S_StopSoundByID(pmo, sfx_drift);
}
// Stop any and all drift sounds when hopping.
if (S_SoundPlaying(pmo, sfx_screec))
S_StopSoundByID(pmo, sfx_screec);
if (S_SoundPlaying(pmo, sfx_drift))
S_StopSoundByID(pmo, sfx_drift);
}
else if (psalt->tapping && onground && !player->kartstuff[k_spinouttimer] && !player->kartstuff[k_squishedtimer])
else if (psalty->tapping && onground && !player->kartstuff[k_spinouttimer] && !player->kartstuff[k_squishedtimer])
{
psalt->jump = true;
psalt->zoffset = 0;
psalt->momz = 6*FRACUNIT;
psalty->jump = true;
psalty->zoffset = 0;
psalty->momz = 6*FRACUNIT;
if (cv_saltyhopsfx.value)
S_StartSound(pmo, sfx_s25a);
}
@@ -3512,7 +3498,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->salty.jump)
return false;
return K_CheckSlopeRollDist(mobj);
+1 -1
View File
@@ -100,7 +100,7 @@ static UINT8 cheatf_devmode(void)
if (menuactive && currentMenu != &MainDef)
return 0; // Only on the main menu!
S_StartSound(0, sfx_itemup);
S_StartSound(NULL, sfx_itemup);
// Just unlock all the things and turn on -debug and console devmode.
G_SetGameModified(false, false); // might need to revist the latter later
+2 -1
View File
@@ -9929,6 +9929,7 @@ static void M_DrawLocalSkinMenu(void)
V_DrawFill(mx + 220 - (charw/2), my+54, charw, 84, 239);
#undef charw
// FIXME: is skins[displayskin.localnum] even correct?
UINT8 *colormap = R_GetLocalTranslationColormap(&skins[displayskin.localnum], (displayskin.localskin ? &localskins[displayskin.localnum] : NULL), cv_playercolor.value, GTC_MENUCACHE, displayskin.localskin);
V_DrawMappedPatch(mx, my+50, 0, (patch_t *)W_CachePatchName(displayskin.facewant, PU_PATCH), colormap);
@@ -9946,7 +9947,7 @@ static void M_DrawLocalSkinMenu(void)
my += 120;
#ifdef HWRENDER
md2_t *md2 = (displayskin.localskin ? &md2_localplayermodels[skintodisplay] : &md2_playermodels[skintodisplay]);
md2_t *md2 = (displayskin.localskin ? &md2_localplayermodels[displayskin.localnum] : &md2_playermodels[skintodisplay]);
// if we have 3d models enabled and a model exists
// try to show it instead of the sprite
-12
View File
@@ -266,15 +266,6 @@ 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
@@ -412,9 +403,6 @@ typedef struct mobj_s
tic_t slamsoundtimer; // Funni slam sound when landing
// saltyhop! hardcode edition
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
} mobj_t;
+16 -10
View File
@@ -4516,27 +4516,33 @@ static void DoABarrelRoll(player_t *player)
static void P_DoFunnyDance(player_t *player)
{
fixed_t bpm; // 140bpm ish
fixed_t work, ang, bounce; // hehe squishy
if (player->spectator || !player->mo || player->kartstuff[k_respawn] || player->mo->salty.jump) // this looks jank as hell during hop
I_Assert(player != NULL);
I_Assert(!P_MobjWasRemoved(player->mo));
if (player->spectator)
return;
player->squishdance.bounce = 0;
// this looks jank as hell during hop or respawn
if (player->kartstuff[k_respawn] || player->salty.jump)
return;
// bpm = FixedDiv((60*TICRATE)<<FRACBITS, FLOAT_TO_FIXED(mapmusic.bpm)); << maybe can get the tempo and beat detection lib to work for bpm autodetection
bpm = FixedDiv((60*TICRATE)<<FRACBITS, FLOAT_TO_FIXED((float)cv_squishdancespeed.value));
bpm = ((60*TICRATE) / (cv_squishdancespeed.value)) << FRACBITS;
player->squishdance.work = (player->squishdance.time << FRACBITS) % bpm;
work = (player->squishdance.time << FRACBITS) % bpm;
if (player->squishdance.time >= (FRACUNIT >> 1)) // prevent overflow jump - takes about 15 minutes
player->squishdance.time = (player->squishdance.work >> FRACBITS);
player->squishdance.time = (work >> FRACBITS);
player->squishdance.work = FixedDiv(player->squishdance.work*180, bpm);
work = FixedDiv(work*180, bpm);
player->squishdance.ang = ((FixedAngle(player->squishdance.work) >> ANGLETOFINESHIFT) & FINEMASK);
player->squishdance.bounce = ((FINESINE(player->squishdance.ang) - FRACUNIT/2) / 2);
ang = ((FixedAngle(work) >> ANGLETOFINESHIFT) & FINEMASK);
bounce = ((FINESINE(ang) - FRACUNIT/2) / 2);
player->mo->spritexscale -= player->squishdance.bounce;
player->mo->spriteyscale += player->squishdance.bounce;
player->mo->spritexscale -= bounce;
player->mo->spriteyscale += bounce;
player->squishdance.time++;
}