fix conflicts for minimap spinouts + some refactoring

This commit is contained in:
Alug committed 2025-03-16 11:05:23 +01:00
1 parent 21c267b319
commit 30deff7697
8 files changed
+69 -546

No files matched your search

+1 -1
View File
@@ -108,7 +108,7 @@ UINT32 playerpingtable[MAXPLAYERS]; //table of player latency values.
static tic_t reference_lag;
static UINT8 spike_time;
tic_t lowest_lag;
tic_t simulated_lag; // just for ping readout without netticbuffer added
tic_t simulated_lag;
boolean server_lagless;
static void Lagless_OnChange(void)
+1 -8
View File
@@ -551,17 +551,10 @@ typedef struct player_s
UINT8 splitscreenindex;
<<<<<<< HEAD
<<<<<<< HEAD
tic_t driftsparkGrowTimer;
=======
=======
UINT8 doiconspin; // A boolean in practice. Tells the game to continue spinning the minimap icons.
>>>>>>> 432dcd3a3 (Refactor to prevent desynchs)
fixed_t spinoutrot; // When a player spins out, this value increments modulus 360.
#ifdef HWRENDER
>>>>>>> 052dcb263 (Add a cvar for minimap icon spinouts)
fixed_t fovadd; // adjust FOV for hw rendering
} player_t;
-25
View File
@@ -518,31 +518,6 @@ consvar_t cv_ydeadzone[MAXSPLITSCREENPLAYERS] = {
static CV_PossibleValue_t driftsparkpulse_t[] = {{0, "MIN"}, {FRACUNIT*3, "MAX"}, {0, NULL}};
consvar_t cv_driftsparkpulse = {"driftsparkpulse", "1.4", CV_FLOAT | CV_SAVE, driftsparkpulse_t, NULL, 0, NULL, NULL, 0, 0, NULL};
<<<<<<< HEAD
=======
static CV_PossibleValue_t stretchfactor_t[] = {
{0, "Off"}, {FRACUNIT/8, "0.125"}, {FRACUNIT/4, "0.250"},
{3*FRACUNIT/8, "0.375"}, {FRACUNIT/2, "0.500"}, {5*FRACUNIT/8, "0.625"},
{3*FRACUNIT/4, "0.750"}, {7*FRACUNIT/8, "0.875"}, {FRACUNIT, "Max"}, {0, NULL}};
consvar_t cv_gravstretch = {"gravstretch", "0", CV_SAVE, stretchfactor_t, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t slamsound_t[] = {{0, "Off"}, {1, "On"}, {0, NULL}};
consvar_t cv_slamsound = {"slamsound", "1", CV_SAVE, slamsound_t, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t sloperolldist_cons_t[] = {
/*{256, "256"},*/ {512, "512"}, {768, "768"},
{1024, "1024"}, {1536, "1536"}, {2048, "2048"},
{3072, "3072"}, {4096, "4096"}, {6144, "6144"},
{8192, "8192"}, {0, "Infinite"}, {0, NULL}};
consvar_t cv_sloperolldist = {"sloperolldist", "Infinite", CV_SAVE, sloperolldist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t sloperoll_cons_t[] = {{0, "Off"}, {1, "Players"}, {2, "Everything"}, {0, NULL}};
consvar_t cv_spriteroll = {"spriteroll", "On", CV_SAVE|CV_CALL, CV_OnOff, PDistort_menu_Onchange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_sloperoll = {"sloperoll", "Off", CV_SAVE|CV_CALL, sloperoll_cons_t, PDistort_menu_Onchange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_sparkroll = {"sparkroll", "Off", CV_SAVE|CV_CALL, CV_OnOff, PDistort_menu_Onchange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_sliptideroll = {"sliptideroll", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_spinoutroll = {"spinoutroll", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
>>>>>>> 052dcb263 (Add a cvar for minimap icon spinouts)
consvar_t cv_cechotoggle = {"show_cecho", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
#if MAXPLAYERS > 16
+39 -60
View File
@@ -135,6 +135,7 @@ static CV_PossibleValue_t sloperoll_cons_t[] = {{0, "Off"}, {1, "Players"}, {2,
consvar_t cv_sloperoll = {"sloperoll", "Off", CV_SAVE|CV_CALL, sloperoll_cons_t, PDistort_menu_Onchange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_sparkroll = {"sparkroll", "Off", CV_SAVE|CV_CALL, CV_OnOff, PDistort_menu_Onchange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_sliptideroll = {"sliptideroll", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_spinoutroll = {"spinoutroll", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
//hardcode saltyhop mhhm
static void saltyhop_onchange(void);
@@ -5397,8 +5398,6 @@ void K_KartPlayerHUDUpdate(player_t *player)
player->kartstuff[k_cardanimation] = 0;
}
<<<<<<< HEAD
<<<<<<< HEAD
static boolean K_SpeedLinesShouldBlend(player_t *player)
{
fixed_t percentspeed = 0;
@@ -5474,13 +5473,7 @@ static inline void K_SpawnNormalSpeedLines(player_t *player, boolean synched)
fast->blendmode = AST_ADD;
}
}
=======
#define SPINOUTROTSPEED (24 * FRACUNIT)
#define MAXSPINROT (360 * FRACUNIT)
>>>>>>> 052dcb263 (Add a cvar for minimap icon spinouts)
=======
>>>>>>> 432dcd3a3 (Refactor to prevent desynchs)
/** \brief Decreases various kart timers and powers per frame. Called in P_PlayerThink in p_user.c
\param player player object passed from P_PlayerThink
@@ -5603,8 +5596,6 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
player->powers[pw_flashing]--;
}
player->doiconspin = 0;
if (player->kartstuff[k_spinouttimer])
{
if ((P_IsObjectOnGround(player->mo) || ((player->kartstuff[k_spinouttype]+1)/2 == 1)) // spinouttype 1 and 2 - explosion and spb
@@ -5616,8 +5607,6 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
if (player->kartstuff[k_spinouttimer] == 0)
player->kartstuff[k_spinouttype] = 0; // Reset type
}
player->doiconspin = 1;
}
else
{
@@ -8811,7 +8800,9 @@ static void K_DrawKartPositionNum(INT32 num)
}
if (splitscreen || cv_smallposnum.value || wheeloffs)
{
scale /= 2;
}
W = FixedMul(W<<FRACBITS, scale)>>FRACBITS;
@@ -8900,7 +8891,9 @@ static void K_DrawKartPositionNum(INT32 num)
}
}
else
{
localpatch = kp_positionnum[num % 10][0];
}
V_DrawFixedPatch((fx<<FRACBITS) + ((overtake && flipdraw) ? (SHORT(localpatch->width)*scale/2) : 0), (fy<<FRACBITS) + ((overtake && flipvdraw) ? (SHORT(localpatch->height)*scale/2) : 0), scale, V_HUDTRANSHALF|fflags, localpatch, NULL);
// ^ if we overtake as p1 or p3 in splitscren, we shift it so that it doesn't go off screen.
@@ -10091,18 +10084,27 @@ static void K_drawKartMinimapHead(mobj_t *mo, INT32 x, INT32 y, INT32 flags)
// The number being divided by is for how fast it moves.
// The higher the number, the slower it moves.
// am xpos & ypos are the icon's starting position. Withouht
// am xpos & ypos are the icon's starting position. Without
// it, they wouldn't 'spawn' on the top-right side of the HUD.
UINT8 skin = 0;
boolean skinlocal = mo->skinlocal;
UINT8 skinnum = 0;
const boolean skinlocal = mo->skinlocal;
const skin_t *skin = (skin_t*)(mo->localskin ? mo->localskin : mo->skin);
fixed_t amnumxpos, amnumypos;
INT32 amxpos, amypos, wntdamxpos, wntdamypos;
fixed_t scale = FRACUNIT;
patch_t *minimaphead = NULL;
#ifdef ROTSPRITE
angle_t rollangle = 0;
INT32 rot = 0;
#endif
if (mo->skin)
skin = ((skin_t*)(mo->localskin ? mo->localskin : mo->skin))-(skinlocal ? localskins : skins);
skinnum = (skin-(skinlocal ? localskins : skins));
minimaphead = (skinlocal ? localfacemmapprefix : facemmapprefix)[skinnum];
amnumxpos = (FixedMul(lerp(mo->old_x, mo->x), minimapinfo.zoom) - minimapinfo.offs_x);
amnumypos = -(FixedMul(lerp(mo->old_y, mo->y), minimapinfo.zoom) - minimapinfo.offs_y);
@@ -10110,8 +10112,8 @@ static void K_drawKartMinimapHead(mobj_t *mo, INT32 x, INT32 y, INT32 flags)
if (encoremode)
amnumxpos = -amnumxpos;
amxpos = amnumxpos + ((x + (SHORT(minimapinfo.minimap_pic->width)-SHORT((skinlocal ? localfacemmapprefix : facemmapprefix)[skin]->width)) / 2)<<FRACBITS);
amypos = amnumypos + ((y + (SHORT(minimapinfo.minimap_pic->height)-SHORT((skinlocal ? localfacemmapprefix : facemmapprefix)[skin]->height)) / 2)<<FRACBITS);
amxpos = amnumxpos + ((x + (SHORT(minimapinfo.minimap_pic->width)-SHORT(minimaphead->width)) / 2)<<FRACBITS);
amypos = amnumypos + ((y + (SHORT(minimapinfo.minimap_pic->height)-SHORT(minimaphead->height)) / 2)<<FRACBITS);
if (cv_showminimapnames.value && mo->player && !(modeattacking || gamestate == GS_TIMEATTACK))
{
@@ -10125,61 +10127,38 @@ static void K_drawKartMinimapHead(mobj_t *mo, INT32 x, INT32 y, INT32 flags)
if (cv_minihead.value)
{
amxpos += (SHORT((skinlocal ? localfacemmapprefix : facemmapprefix)[skin]->width) / 4)<<FRACBITS;
amypos += (SHORT((skinlocal ? localfacemmapprefix : facemmapprefix)[skin]->height) / 4)<<FRACBITS;
amxpos += (SHORT(minimaphead->width) / 4)<<FRACBITS;
amypos += (SHORT(minimaphead->height) / 4)<<FRACBITS;
scale /= 2;
}
#ifdef ROTSPRITE
if (cv_spinoutroll.value && mo->player)
{
// Rotate counterclockwise.
rollangle = FixedAngle(mo->player->spinoutrot * -1);
rot = R_GetRollAngle(rollangle);
if (rot)
{
minimaphead = W_CachePatchNameRotated(skin->facemmap, rot, PU_STATIC);
}
}
#endif
if (!mo->color) // 'default' color
V_DrawSciencePatch(amxpos, amypos, flags, ((skinlocal) ? localfacemmapprefix : facemmapprefix)[skin], scale);
V_DrawSciencePatch(amxpos, amypos, flags, minimaphead, scale);
else
{
patch_t *minimaphead;
#ifdef ROTSPRITE
angle_t rollangle;
INT32 rot;
rot = 0;
if (mo->player)
{
// Rotate counterclockwise.
rollangle = FixedAngle(mo->player->spinoutrot * -1);
rot = R_GetRollAngle(rollangle);
}
if ((cv_spriteroll.value) && (cv_spinoutroll.value) && (rot))
{
minimaphead = W_CachePatchNameRotated(((skin_t*)(mo->localskin ? mo->localskin : mo->skin))->facemmap, rot, PU_STATIC);
}
else
#endif
{
minimaphead = ((skinlocal) ? localfacemmapprefix : facemmapprefix)[skin];
}
UINT8 *colormap;
if (mo->colorized)
colormap = R_GetTranslationColormap(TC_RAINBOW, mo->color, GTC_CACHE);
else
colormap = R_GetLocalTranslationColormap(mo->skin, mo->localskin, mo->color, GTC_CACHE, skinlocal);
<<<<<<< HEAD
V_DrawFixedPatch(amxpos, amypos, scale, flags, ((skinlocal) ? localfacemmapprefix : facemmapprefix)[skin], colormap);
V_DrawFixedPatch(amxpos, amypos, scale, flags, minimaphead, colormap);
=======
if (cv_minihead.value)
V_DrawFixedPatch(amxpos + (2*FRACUNIT), amypos + (2*FRACUNIT), FRACUNIT/2, flags, minimaphead, colormap);
else
V_DrawFixedPatch(amxpos, amypos, FRACUNIT, flags, minimaphead, colormap);
if (cv_showminimapnames.value && !(modeattacking || gamestate == GS_TIMEATTACK))
{
const char *player_name = va("%c%s", V_GetSkincolorChar(mo->color), player_names[mo->player - players]);
V_DrawCenteredSmallStringAtFixed(amxpos + (4*FRACUNIT), amypos - (3*FRACUNIT), V_ALLOWLOWERCASE|flags, player_name);
}
>>>>>>> 052dcb263 (Add a cvar for minimap icon spinouts)
if (mo->player
&& ((G_RaceGametype() && mo->player->kartstuff[k_position] == spbplace)
|| (G_BattleGametype() && K_IsPlayerWanted(mo->player))))
+8 -52
View File
@@ -2274,7 +2274,6 @@ static menuitem_t OP_PlayerDistortMenu[] =
{
{IT_HEADER, NULL, "Sprite Distortion", NULL, 0},
<<<<<<< HEAD
{IT_STRING | IT_CVAR, NULL, "Sprite Slope Rotation", &cv_sloperoll, 15},
{IT_STRING | IT_CVAR, NULL, "Slope Rotation Distance", &cv_sloperolldist, 30},
@@ -2287,19 +2286,6 @@ static menuitem_t OP_PlayerDistortMenu[] =
{IT_STRING | IT_CVAR, NULL, "Saltyhop", &cv_saltyhop, 120},
{IT_STRING | IT_CVAR, NULL, "Saltyhop Sound Effect", &cv_saltyhopsfx, 135},
{IT_STRING | IT_CVAR, NULL, "Saltyhop Squish", &cv_saltysquish, 150},
=======
{IT_STRING | IT_CVAR, NULL, "Sprite Rotation", &cv_spriteroll, 15},
{IT_STRING | IT_CVAR, NULL, "Sprite Slope Rotation", &cv_sloperoll, 30},
{IT_STRING | IT_CVAR, NULL, "Slope Rotation Distance", &cv_sloperolldist, 45},
{IT_STRING | IT_CVAR, NULL, "Rotate Players when Sliptiding", &cv_sliptideroll, 60},
{IT_STRING | IT_CVAR, NULL, "Rotate Sparks and Boost Trails", &cv_sparkroll, 75},
{IT_STRING | IT_CVAR, NULL, "Spin Minimap Icons", &cv_spinoutroll, 90},
{IT_STRING | IT_CVAR, NULL, "Player Stretch Factor", &cv_gravstretch, 105},
{IT_STRING | IT_CVAR, NULL, "Squish Sound Effect", &cv_slamsound, 120},
{IT_STRING | IT_CVAR, NULL, "Saltyhop", &cv_saltyhop, 135},
{IT_STRING | IT_CVAR, NULL, "Saltyhop Sound Effect", &cv_saltyhopsfx, 150},
{IT_STRING | IT_CVAR, NULL, "Saltyhop Squish", &cv_saltysquish, 165},
>>>>>>> 052dcb263 (Add a cvar for minimap icon spinouts)
};
static const char* OP_PlayerDistortTooltips[] =
@@ -2309,11 +2295,7 @@ static const char* OP_PlayerDistortTooltips[] =
"Distance object rotation should be visable.",
"Player rotation when sliptiding.",
"Rotation of a player's boost trails and drift sparks.",
<<<<<<< HEAD
"Should banans rotate when thrown?\nAnd should they stay rotated when on the ground?.",
=======
"Erratically rotate player icons during spinouts.",
>>>>>>> 052dcb263 (Add a cvar for minimap icon spinouts)
"Player squash and stretch.",
"Player landing sound effect.",
"Kart hopping while drifting. This is purely visual.",
@@ -2328,11 +2310,7 @@ enum
slrotatedist,
sliptide,
sparkrotate,
<<<<<<< HEAD
bananrotat,
=======
iconspinout,
>>>>>>> 052dcb263 (Add a cvar for minimap icon spinouts)
stretchyplayer,
squishsound,
salthmmm,
@@ -2371,15 +2349,16 @@ static menuitem_t OP_SaturnHudMenu[] =
{IT_STRING | IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 135},
{IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 140},
{IT_STRING | IT_CVAR, NULL, "Spin Minimap Icons", &cv_spinoutroll, 150},
{IT_STRING | IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 150},
{IT_STRING | IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 160},
{IT_STRING | IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 160},
{IT_STRING | IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 170},
{IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 170},
{IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 175},
{IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 180},
{IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 185},
{IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 185},
{IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 195},
};
static const char* OP_SaturnHudTooltips[] =
@@ -2403,6 +2382,7 @@ static const char* OP_SaturnHudTooltips[] =
"Show the big Cecho Messages.",
"Show player names on the minimap.",
"Minimize the player icons on the minimap.",
"Erratically rotate player icons during spinouts.",
"Make the Intermission screen look like in beta versions of Kart!\nEither with background or just the rest.",
"Show the Director Toggle prompt when spectating.",
"Nametag Options.",
@@ -2431,6 +2411,7 @@ enum
sh_cechotogle,
sh_mapname,
sh_smallmap,
sh_iconspinout,
sh_betainter,
sh_directorhud,
sh_nametagmen,
@@ -3487,33 +3468,8 @@ void Moviemode_option_Onchange(void)
void PDistort_menu_Onchange(void)
{
<<<<<<< HEAD
OP_PlayerDistortMenu[slrotatedist].status =
(cv_sloperoll.value) ? IT_STRING | IT_CVAR : IT_GRAYEDOUT;
=======
if (!cv_spriteroll.value)
{
OP_PlayerDistortMenu[sloperotate].status = IT_GRAYEDOUT;
OP_PlayerDistortMenu[sliptide].status = IT_GRAYEDOUT;
OP_PlayerDistortMenu[iconspinout].status = IT_GRAYEDOUT;
}
else
{
OP_PlayerDistortMenu[sloperotate].status = IT_STRING | IT_CVAR;
OP_PlayerDistortMenu[sliptide].status = IT_STRING | IT_CVAR;
OP_PlayerDistortMenu[iconspinout].status = IT_STRING | IT_CVAR;
}
if ((cv_sloperoll.value) && (cv_spriteroll.value)) //enable/disable sloperotate distance
OP_PlayerDistortMenu[slrotatedist].status = IT_STRING | IT_CVAR;
else
OP_PlayerDistortMenu[slrotatedist].status = IT_GRAYEDOUT;
if ((cv_sloperoll.value == 2) && (cv_spriteroll.value)) //enable/disable sparkroll depending on which setting
OP_PlayerDistortMenu[sparkrotate].status = IT_STRING | IT_CVAR;
else
OP_PlayerDistortMenu[sparkrotate].status = IT_GRAYEDOUT;
>>>>>>> 052dcb263 (Add a cvar for minimap icon spinouts)
}
void Bird_menu_Onchange(void)
-1
View File
@@ -10728,7 +10728,6 @@ void P_SpawnPlayer(INT32 playernum)
p->hitemtimer = 0;
p->hitemvictim = 255;
p->doiconspin = 0;
p->spinoutrot = 0;
if (G_BattleGametype()) // SRB2kart
+11 -396
View File
@@ -4430,394 +4430,9 @@ DoABarrelRoll (player_t *player)
player->tilt = slope;
}
<<<<<<< HEAD
=======
/* set follower state with our weird hacks
the reason we do this is to avoid followers ever using actions (majormods, yikes!)
without having to touch p_mobj.c.
so we give it 1more tic and change the state when tic == 1 instead of 0
cool beans?
cool beans.
*/
static void P_SetFollowerState(mobj_t *f, statenum_t state)
{
if (f == NULL || P_MobjWasRemoved(f) == true)
{
// safety net
return;
}
// No, do NOT set the follower to S_NULL. Set it to S_INVISIBLE.
if (state == S_NULL)
{
state = S_INVISIBLE;
f->threshold = 1; // Threshold = 1 means stop doing anything related to setting states, so that we don't get out of S_INVISIBLE
}
// extravalue2 stores the last "first state" we used.
// because states default to idlestates, if we use an animation that uses an "ongoing" state line, don't reset it!
// this prevents it from looking very dumb
if (state == (statenum_t)f->extravalue2)
{
return;
}
// we will save the state into extravalue2.
f->extravalue2 = state;
P_SetMobjStateNF(f, state);
if (f->state->tics > 0)
{
f->tics++;
}
}
UINT8 K_GetEffectiveFollowerColor(UINT8 followercolor, follower_t *follower, UINT8 playercolor, skin_t *playerskin)
{
if (followercolor == SKINCOLOR_NONE && follower != NULL) // "Default"
{
followercolor = follower->defaultcolor;
}
if (followercolor > SKINCOLOR_NONE && followercolor < MAXSKINCOLORS) // bog standard
{
return followercolor;
}
if (playercolor == SKINCOLOR_NONE) // get default color
{
if (playerskin == NULL)
{
// Nothing from this line down is valid if playerskin is invalid, just guess Sonic?
playerskin = &skins[0];
}
playercolor = playerskin->prefcolor;
}
if (followercolor == FOLLOWERCOLOR_OPPOSITE) // "Opposite"
{
return KartColor_Opposite[playercolor];
}
// "Match"
return playercolor;
}
static void K_UpdateFollowerState(mobj_t *f, statenum_t state, followerstate_t type)
{
if (f == NULL || P_MobjWasRemoved(f) == true)
{
// safety net
return;
}
if (f->extravalue1 != (INT32)type)
{
P_SetFollowerState(f, state);
f->extravalue1 = type;
}
}
//
//P_HandleFollower
//
//Handle the follower's spawning and moving along with the player. Do note that some of the stuff like the removal if a player doesn't exist anymore is handled in MT_FOLLOWER's thinker.
static void P_HandleFollower(player_t *player)
{
follower_t fl;
angle_t an;
fixed_t zoffs;
fixed_t ourheight;
fixed_t sx, sy, sz, deltaz;
fixed_t fh = INT32_MIN, ch = INT32_MAX;
angle_t destAngle;
INT32 angleDiff;
UINT16 color;
if (!player->followerready)
return; // we aren't ready to perform anything follower related yet.
// How about making sure our follower exists and is added before trying to spawn it n' all?
if (player->followerskin > numfollowers-1 || player->followerskin < -1)
{
//CONS_Printf("Follower skin invlaid. Setting to -1.\n");
player->followerskin = -1;
return;
}
// don't do anything if we can't have a follower to begin with.
// (It gets removed under those conditions)
if (player->spectator || player->followerskin < 0
|| player->mo == NULL || P_MobjWasRemoved(player->mo))
{
if (player->follower)
{
P_RemoveMobj(player->follower);
P_SetTarget(&player->follower, NULL);
}
return;
}
// Before we do anything, let's be sure of where we're supposed to be
fl = followers[player->followerskin];
an = player->mo->angle + fl.atangle;
zoffs = fl.zoffs;
// do you like angle maths? I certainly don't...
sx = player->mo->x + player->mo->momx + FixedMul(FixedMul(player->mo->scale, fl.dist), FINECOSINE((an) >> ANGLETOFINESHIFT));
sy = player->mo->y + player->mo->momy + FixedMul(FixedMul(player->mo->scale, fl.dist), FINESINE((an) >> ANGLETOFINESHIFT));
// interp info helps with stretchy fix
deltaz = (player->mo->z - player->mo->old_z);
// for the z coordinate, don't be a doof like Steel and forget that MFE_VERTICALFLIP exists :P
sz = player->mo->z + player->mo->momz + FixedMul(player->mo->scale, zoffs * P_MobjFlip(player->mo));
ourheight = FixedMul(fl.height, player->mo->scale);
if (player->mo->eflags & MFE_VERTICALFLIP)
{
sz += ourheight;
}
fh = player->mo->floorz;
ch = player->mo->ceilingz - ourheight;
switch (fl.mode)
{
case FOLLOWERMODE_GROUND:
{
if (player->mo->eflags & MFE_VERTICALFLIP)
{
sz = ch;
}
else
{
sz = fh;
}
break;
}
case FOLLOWERMODE_FLOAT:
default:
{
// finally, add a cool floating effect to the z height.
// not stolen from k_kart I swear!!
fixed_t sine = FixedMul(fl.bobamp,
FINESINE(((
FixedMul(4 * M_TAU_FIXED, fl.bobspeed) * leveltime
) >> ANGLETOFINESHIFT) & FINEMASK));
sz += FixedMul(player->mo->scale, sine) * P_MobjFlip(player->mo);
break;
}
}
// Set follower colour
color = K_GetEffectiveFollowerColor(player->followercolor, &fl, player->skincolor, &skins[player->skin]);
if (!player->follower) // follower doesn't exist / isn't valid
{
//CONS_Printf("Spawning follower...\n");
// so let's spawn one!
P_SetTarget(&player->follower, P_SpawnMobj(sx, sy, sz, MT_FOLLOWER));
if (player->follower == NULL)
return;
K_UpdateFollowerState(player->follower, fl.idlestate, FOLLOWERSTATE_IDLE);
P_SetTarget(&player->follower->target, player->mo); // we need that to know when we need to disappear
player->follower->angle = player->follower->old_angle = player->mo->angle;
}
else // follower exists, woo!
{
// first of all, handle states following the same model as above:
if (player->follower->tics == 1)
P_SetFollowerState(player->follower, player->follower->state->nextstate);
// Spawn Follower Shadow
player->follower->haveshadow = true;
player->follower->shadowscale = FRACUNIT;
// move the follower next to us (yes, this is really basic maths but it looks pretty damn clean in practice)!
player->follower->momx = FixedDiv(sx - player->follower->x, fl.horzlag);
player->follower->momy = FixedDiv(sy - player->follower->y, fl.horzlag);
player->follower->z += FixedDiv(deltaz, fl.vertlag);
if (fl.mode == FOLLOWERMODE_GROUND)
{
sector_t *sec = player->follower->subsector->sector;
fh = min(fh, P_GetFloorZ(player->follower, sec, sx, sy, NULL));
ch = max(ch, P_GetCeilingZ(player->follower, sec, sx, sy, NULL) - ourheight);
if (P_IsObjectOnGround(player->mo) == false)
{
// In the air, match their momentum.
player->follower->momz = player->mo->momz;
if (player->follower->z <= sz) // Don't go under the floor please
player->follower->z = sz;
}
else
{
fixed_t fg = P_GetMobjGravity(player->mo);
fixed_t fz = P_GetMobjZMovement(player->follower);
player->follower->momz = fz;
// Player is on the ground ... try to get the follower
// back to the ground also if it is above it.
if (player->follower->z > sz) // Don't go under the floor please
player->follower->momz += FixedDiv(fg * 6, fl.vertlag); // Scaled against the default value of vertlag
// Other wise match current floor
player->follower->momz = sz - player->follower->z;
}
}
else
{
player->follower->momz = FixedDiv(sz - player->follower->z, fl.vertlag);
}
if (player->mo->colorized)
player->follower->color = player->mo->color;
else
player->follower->color = color;
player->follower->colorized = player->mo->colorized;
P_SetScale(player->follower, FixedMul(fl.scale, player->mo->scale));
K_GenericExtraFlagsNoZAdjust(player->follower, player->mo); // Not K_MatchGenericExtraFlag because the Z adjust it has only works properly if master & mo have the same Z height.
// For comeback in battle.
player->follower->flags2 = (player->follower->flags2 & ~MF2_SHADOW)|(player->mo->flags2 & MF2_SHADOW);
// Make the follower invisible if we no contest'd rather than removing it. No one will notice the diff seriously.
if (player->pflags & PF_TIMEOVER) // there is more to it than that to check for a full no contest but this isn't used for anything else.
player->follower->flags2 |= MF2_DONTDRAW;
if (cv_hidefollowers.value) // hide em for people who don't want them
player->follower->flags2 |= MF2_DONTDRAW;
// if we're moving let's make the angle the direction we're moving towards. This is to avoid drifting / reverse looking awkward.
if (FixedHypot(player->follower->momx, player->follower->momy) >= player->mo->scale)
{
destAngle = R_PointToAngle2(0, 0, player->follower->momx, player->follower->momy);
}
else
{
// Face the player's angle when standing still.
destAngle = player->mo->angle;
}
/*// Sal: Turn the follower around when looking backwards.
if ( player->cmd.buttons & BT_LOOKBACK )
{
destAngle += ANGLE_180;
}*/
// Sal: Smoothly rotate angle to the destination value.
angleDiff = AngleDeltaSigned(destAngle, player->follower->angle);
if (angleDiff != 0)
{
player->follower->angle += FixedDiv(angleDiff, fl.anglelag);
}
// Ground follower slope rotation
if (fl.mode == FOLLOWERMODE_GROUND)
{
K_CalculateFollowerSlope(
player->follower,
player->follower->x, player->follower->y, player->follower->z,
player->follower->radius, ourheight,
(player->mo->eflags & MFE_VERTICALFLIP),
false
);
}
if (player->follower->threshold)
{
// Threshold means the follower was "despanwed" with S_NULL.
return;
}
// However with how the code is factored, this is just a special case of S_INVISBLE to avoid having to add other player variables.
// handle follower animations. Could probably be better...
// Squish
if (player->kartstuff[k_squishedtimer] > 0)
{
// cancel hit confirm
player->follower->movecount = 0;
player->follower->cvmem = 0;
if (player->kartstuff[k_squishedtimer] > 1)
player->follower->spriteyscale = FRACUNIT/4;
else
player->follower->spriteyscale = FRACUNIT;
K_UpdateFollowerState(player->follower, fl.hurtstate, FOLLOWERSTATE_HURT);
}
else if (P_PlayerInPain(player) == true || player->mo->state == &states[S_KART_SPIN] || player->mo->health <= 0)
{
// hurt or dead
// cancel hit confirm
player->follower->movecount = 0;
player->follower->cvmem = 0;
// spin out
player->follower->angle = player->frameangle;
K_UpdateFollowerState(player->follower, fl.hurtstate, FOLLOWERSTATE_HURT);
if (player->mo->health <= 0)
{
// if dead, follow the player's z momentum exactly so they both look like they die at the same speed.
player->follower->momz = player->mo->momz;
}
}
else if (player->exiting)
{
// win/ loss animations
if (K_IsPlayerLosing(player))
{
// L
K_UpdateFollowerState(player->follower, fl.losestate, FOLLOWERSTATE_LOSE);
}
else
{
// W
K_UpdateFollowerState(player->follower, fl.winstate, FOLLOWERSTATE_WIN);
}
}
else if (player->follower->movecount)
{
K_UpdateFollowerState(player->follower, fl.hitconfirmstate, FOLLOWERSTATE_HITCONFIRM);
player->follower->movecount--;
}
else if (player->speed > 10*player->mo->scale) // animation for moving fast enough
{
K_UpdateFollowerState(player->follower, fl.followstate, FOLLOWERSTATE_FOLLOW);
}
else
{
K_UpdateFollowerState(player->follower, fl.idlestate, FOLLOWERSTATE_IDLE);
}
}
}
#define SPINOUTROTSPEED (24 * FRACUNIT)
#define MAXSPINROT (360 * FRACUNIT)
>>>>>>> 432dcd3a3 (Refactor to prevent desynchs)
//
// P_PlayerThink
//
@@ -4961,25 +4576,17 @@ void P_PlayerThink(player_t *player)
}
}
// If it is set, start subtracting
// Don't allow it to go back to 0
if (player->exiting > 1 && (player->exiting < raceexittime+2 || !G_RaceGametype())) // SRB2kart - "&& player->exiting > 1"
player->exiting--;
if (player->exiting && exitcountdown)
player->exiting = 99; // SRB2kart
if ((player->doiconspin) && (player->spinoutrot == 0))
if (player->kartstuff[k_spinouttimer] && (player->spinoutrot == 0))
{
player->spinoutrot = SPINOUTROTSPEED;
}
// MKWii-styled icon spinouts: do a full 360 rotation before stopping.
if ((player->spinoutrot) && (player->spinoutrot < MAXSPINROT))
if (player->spinoutrot && (player->spinoutrot < MAXSPINROT))
{
if ((player->spinoutrot + SPINOUTROTSPEED) >= MAXSPINROT)
{
if (player->doiconspin)
if (player->kartstuff[k_spinouttimer])
{
player->spinoutrot = (player->spinoutrot + SPINOUTROTSPEED) % MAXSPINROT;
}
@@ -4994,6 +4601,14 @@ void P_PlayerThink(player_t *player)
}
}
// If it is set, start subtracting
// Don't allow it to go back to 0
if (player->exiting > 1 && (player->exiting < raceexittime+2 || !G_RaceGametype())) // SRB2kart - "&& player->exiting > 1"
player->exiting--;
if (player->exiting && exitcountdown)
player->exiting = 99; // SRB2kart
if (player->exiting == 2 || exitcountdown == 2)
{
if (cv_playersforexit.value) // Count to be sure everyone's exited
+9 -3
View File
@@ -1125,12 +1125,15 @@ lumpnum_t W_CheckNumForName(const char *name)
break; //found it
}
if (check == INT16_MAX) return LUMPERROR;
if (check == INT16_MAX)
{
return LUMPERROR;
}
else
{
// Update the cache.
lumpnumcacheindex = (lumpnumcacheindex + 1) & (LUMPNUMCACHESIZE - 1);
memset(lumpnumcache[lumpnumcacheindex].lumpname, '\0', 32);
memset(lumpnumcache[lumpnumcacheindex].lumpname, '\0', LUMPNUMCACHENAME);
strncpy(lumpnumcache[lumpnumcacheindex].lumpname, name, 8);
lumpnumcache[lumpnumcacheindex].lumpnum = (i<<16)+check;
@@ -1174,7 +1177,10 @@ lumpnum_t W_CheckNumForLongName(const char *name)
}
}
if (check == INT16_MAX) return LUMPERROR;
if (check == INT16_MAX)
{
return LUMPERROR;
}
else
{
if (strlen(name) < 32)