From 6b23c70e3732dcc6a9439e8848783a27af1226d0 Mon Sep 17 00:00:00 2001 From: Anonimus Date: Thu, 6 Mar 2025 07:26:37 -0500 Subject: [PATCH 1/3] Add a cvar for minimap icon spinouts --- src/d_player.h | 5 ++++ src/g_game.c | 25 +++++++++++++++++ src/g_game.h | 1 + src/k_kart.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/m_menu.c | 47 ++++++++++++++++++++++++++++++++ src/p_setup.c | 5 ++++ src/r_main.c | 1 + 7 files changed, 158 insertions(+) diff --git a/src/d_player.h b/src/d_player.h index 0991144fb..9924a1807 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -551,8 +551,13 @@ typedef struct player_s UINT8 splitscreenindex; +<<<<<<< HEAD tic_t driftsparkGrowTimer; +======= + 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; diff --git a/src/g_game.c b/src/g_game.c index 2cb8a93bc..c1f406225 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -517,6 +517,31 @@ 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 diff --git a/src/g_game.h b/src/g_game.h index fa427b752..deec04226 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -180,6 +180,7 @@ extern consvar_t cv_sliptideroll; extern consvar_t cv_slamsound; extern consvar_t cv_sloperolldist; extern consvar_t cv_sparkroll; +extern consvar_t cv_spinoutroll; extern consvar_t cv_cechotoggle; diff --git a/src/k_kart.c b/src/k_kart.c index 5d6f040f7..969a743ef 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -5425,6 +5425,7 @@ void K_KartPlayerHUDUpdate(player_t *player) player->kartstuff[k_cardanimation] = 0; } +<<<<<<< HEAD static boolean K_SpeedLinesShouldBlend(player_t *player) { fixed_t percentspeed = 0; @@ -5503,6 +5504,10 @@ FUNCINLINE static ATTRINLINE void K_SpawnNormalSpeedLines(player_t *player, bool fast->blendmode = AST_ADD; } } +======= +#define SPINOUTROTSPEED (24 * FRACUNIT) +#define MAXSPINROT (360 * FRACUNIT) +>>>>>>> 052dcb263 (Add a cvar for minimap icon spinouts) /** \brief Decreases various kart timers and powers per frame. Called in P_PlayerThink in p_user.c @@ -5626,6 +5631,10 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) player->powers[pw_flashing]--; } + boolean doiconspin; + + doiconspin = false; + if (player->kartstuff[k_spinouttimer]) { if ((P_IsObjectOnGround(player->mo) || ((player->kartstuff[k_spinouttype]+1)/2 == 1)) // spinouttype 1 and 2 - explosion and spb @@ -5637,6 +5646,8 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) if (player->kartstuff[k_spinouttimer] == 0) player->kartstuff[k_spinouttype] = 0; // Reset type } + + doiconspin = true; } else { @@ -5653,6 +5664,31 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) } } + if ((doiconspin) && (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 + SPINOUTROTSPEED) >= MAXSPINROT) + { + if (doiconspin) + { + player->spinoutrot = (player->spinoutrot + SPINOUTROTSPEED) % MAXSPINROT; + } + else + { + player->spinoutrot = 0; + } + } + else + { + player->spinoutrot += SPINOUTROTSPEED; + } + } + /*if (player->kartstuff[k_thunderanim]) player->kartstuff[k_thunderanim]--;*/ @@ -10150,14 +10186,52 @@ static void K_drawKartMinimapHead(mobj_t *mo, INT32 x, INT32 y, INT32 flags) V_DrawSciencePatch(amxpos, amypos, flags, ((skinlocal) ? localfacemmapprefix : facemmapprefix)[skin], 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); +======= + + 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)))) diff --git a/src/m_menu.c b/src/m_menu.c index 4d8517e2d..eb6816ac7 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2288,6 +2288,7 @@ 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}, @@ -2300,6 +2301,19 @@ 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,7 +2323,11 @@ 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.", @@ -2324,7 +2342,11 @@ enum slrotatedist, sliptide, sparkrotate, +<<<<<<< HEAD bananrotat, +======= + iconspinout, +>>>>>>> 052dcb263 (Add a cvar for minimap icon spinouts) stretchyplayer, squishsound, salthmmm, @@ -3479,8 +3501,33 @@ 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) diff --git a/src/p_setup.c b/src/p_setup.c index 2af8e37a9..938c2f5fc 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2264,12 +2264,17 @@ static void P_LevelInitStuff(boolean reloadinggamestate) players[i].realtime = racecountdown = exitcountdown = 0; +<<<<<<< HEAD for (INT32 j = 0; j < LAP__MAX; j++) { players[i].laptime[j] = 0; } players[i].driftsparkGrowTimer = 0; +======= + // Neptune + players[i].spinoutrot = 0; +>>>>>>> 052dcb263 (Add a cvar for minimap icon spinouts) players[i].gotcontinue = false; diff --git a/src/r_main.c b/src/r_main.c index ddbda9cc3..aa28078ae 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1566,6 +1566,7 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_sliptideroll); CV_RegisterVar(&cv_sloperolldist); CV_RegisterVar(&cv_sparkroll); + CV_RegisterVar(&cv_spinoutroll); CV_RegisterVar(&cv_showhud); CV_RegisterVar(&cv_translucenthud); From f55fdbf630a4d0b691f979345185f88da5d0ef4b Mon Sep 17 00:00:00 2001 From: Anonimus Date: Sat, 8 Mar 2025 17:36:50 -0500 Subject: [PATCH 2/3] Refactor to prevent desynchs --- src/d_player.h | 4 + src/k_kart.c | 34 +--- src/p_mobj.c | 3 + src/p_setup.c | 3 + src/p_user.c | 413 +++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 428 insertions(+), 29 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 9924a1807..4c2cd7268 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -551,10 +551,14 @@ 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) diff --git a/src/k_kart.c b/src/k_kart.c index 969a743ef..23dbdf060 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -5425,6 +5425,7 @@ void K_KartPlayerHUDUpdate(player_t *player) player->kartstuff[k_cardanimation] = 0; } +<<<<<<< HEAD <<<<<<< HEAD static boolean K_SpeedLinesShouldBlend(player_t *player) { @@ -5509,6 +5510,8 @@ FUNCINLINE static ATTRINLINE void K_SpawnNormalSpeedLines(player_t *player, bool #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 @@ -5631,9 +5634,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) player->powers[pw_flashing]--; } - boolean doiconspin; - - doiconspin = false; + player->doiconspin = 0; if (player->kartstuff[k_spinouttimer]) { @@ -5647,7 +5648,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) player->kartstuff[k_spinouttype] = 0; // Reset type } - doiconspin = true; + player->doiconspin = 1; } else { @@ -5664,31 +5665,6 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) } } - if ((doiconspin) && (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 + SPINOUTROTSPEED) >= MAXSPINROT) - { - if (doiconspin) - { - player->spinoutrot = (player->spinoutrot + SPINOUTROTSPEED) % MAXSPINROT; - } - else - { - player->spinoutrot = 0; - } - } - else - { - player->spinoutrot += SPINOUTROTSPEED; - } - } - /*if (player->kartstuff[k_thunderanim]) player->kartstuff[k_thunderanim]--;*/ diff --git a/src/p_mobj.c b/src/p_mobj.c index 3f90d8bb0..a95789f46 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10733,6 +10733,9 @@ void P_SpawnPlayer(INT32 playernum) p->hitemtimer = 0; p->hitemvictim = 255; + p->doiconspin = 0; + p->spinoutrot = 0; + if (G_BattleGametype()) // SRB2kart { mobj_t *overheadarrow = P_SpawnMobj(mobj->x, mobj->y, mobj->z + P_GetPlayerHeight(p)+16*FRACUNIT, MT_PLAYERARROW); diff --git a/src/p_setup.c b/src/p_setup.c index 938c2f5fc..967c964f3 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2264,6 +2264,7 @@ static void P_LevelInitStuff(boolean reloadinggamestate) players[i].realtime = racecountdown = exitcountdown = 0; +<<<<<<< HEAD <<<<<<< HEAD for (INT32 j = 0; j < LAP__MAX; j++) { @@ -2276,6 +2277,8 @@ static void P_LevelInitStuff(boolean reloadinggamestate) players[i].spinoutrot = 0; >>>>>>> 052dcb263 (Add a cvar for minimap icon spinouts) +======= +>>>>>>> 432dcd3a3 (Refactor to prevent desynchs) players[i].gotcontinue = false; players[i].xtralife = players[i].deadtimer = players[i].numboxes = players[i].totalring = players[i].laps = 0; diff --git a/src/p_user.c b/src/p_user.c index 890fa2e5f..a9ea372ac 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4430,6 +4430,394 @@ 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 // @@ -4581,6 +4969,31 @@ void P_PlayerThink(player_t *player) if (player->exiting && exitcountdown) player->exiting = 99; // SRB2kart + if ((player->doiconspin) && (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 + SPINOUTROTSPEED) >= MAXSPINROT) + { + if (player->doiconspin) + { + player->spinoutrot = (player->spinoutrot + SPINOUTROTSPEED) % MAXSPINROT; + } + else + { + player->spinoutrot = 0; + } + } + else + { + player->spinoutrot += SPINOUTROTSPEED; + } + } + if (player->exiting == 2 || exitcountdown == 2) { if (cv_playersforexit.value) // Count to be sure everyone's exited From bbd967adadaf0458e1207043fab6f8ec5e97b848 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 15 Mar 2025 16:26:43 +0100 Subject: [PATCH 3/3] fix conflicts for minimap spinouts + some refactoring --- src/d_clisrv.c | 2 +- src/d_player.h | 9 +- src/g_game.c | 25 --- src/k_kart.c | 99 +++++------- src/m_menu.c | 60 +------- src/p_mobj.c | 1 - src/p_user.c | 407 ++----------------------------------------------- src/w_wad.c | 12 +- 8 files changed, 69 insertions(+), 546 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index a17a4219b..c8a66e3a0 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -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) diff --git a/src/d_player.h b/src/d_player.h index 4c2cd7268..7ecef63de 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -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; diff --git a/src/g_game.c b/src/g_game.c index c1f406225..2cb8a93bc 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -517,31 +517,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 diff --git a/src/k_kart.c b/src/k_kart.c index 23dbdf060..dd3466c4e 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -140,6 +140,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); @@ -5425,8 +5426,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; @@ -5505,13 +5504,7 @@ FUNCINLINE static ATTRINLINE void K_SpawnNormalSpeedLines(player_t *player, bool 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 @@ -5634,8 +5627,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 @@ -5647,8 +5638,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 { @@ -8838,7 +8827,9 @@ static void K_DrawKartPositionNum(INT32 num) } if (splitscreen || cv_smallposnum.value || wheeloffs) + { scale /= 2; + } W = FixedMul(W<>FRACBITS; @@ -8927,7 +8918,9 @@ static void K_DrawKartPositionNum(INT32 num) } } else + { localpatch = kp_positionnum[num % 10][0]; + } V_DrawFixedPatch((fx<width)*scale/2) : 0), (fy<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. @@ -10120,18 +10113,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); @@ -10139,8 +10141,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)<height)-SHORT((skinlocal ? localfacemmapprefix : facemmapprefix)[skin]->height)) / 2)<width)-SHORT(minimaphead->width)) / 2)<height)-SHORT(minimaphead->height)) / 2)<player && !(modeattacking || gamestate == GS_TIMEATTACK)) { @@ -10153,61 +10155,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)<height) / 4)<width) / 4)<height) / 4)<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)))) diff --git a/src/m_menu.c b/src/m_menu.c index eb6816ac7..18c72f9ca 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2288,7 +2288,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}, @@ -2301,19 +2300,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[] = @@ -2323,11 +2309,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.", @@ -2342,11 +2324,7 @@ enum slrotatedist, sliptide, sparkrotate, -<<<<<<< HEAD bananrotat, -======= - iconspinout, ->>>>>>> 052dcb263 (Add a cvar for minimap icon spinouts) stretchyplayer, squishsound, salthmmm, @@ -2385,15 +2363,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[] = @@ -2417,6 +2396,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.", @@ -2445,6 +2425,7 @@ enum sh_cechotogle, sh_mapname, sh_smallmap, + sh_iconspinout, sh_betainter, sh_directorhud, sh_nametagmen, @@ -3501,33 +3482,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) diff --git a/src/p_mobj.c b/src/p_mobj.c index a95789f46..111dc6558 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10733,7 +10733,6 @@ void P_SpawnPlayer(INT32 playernum) p->hitemtimer = 0; p->hitemvictim = 255; - p->doiconspin = 0; p->spinoutrot = 0; if (G_BattleGametype()) // SRB2kart diff --git a/src/p_user.c b/src/p_user.c index a9ea372ac..dacd18868 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -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 diff --git a/src/w_wad.c b/src/w_wad.c index 82d71c814..8760fc8de 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -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)