From 865c3cfaec6ce6c1bcbfd3b612e6943c8a513dd0 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 10 Mar 2025 14:04:16 +0100 Subject: [PATCH] kill bunch of crap --- src/byteptr.h | 30 ++++++++++++++++++++++++++++++ src/d_clisrv.c | 28 +++++++++++++--------------- src/d_main.c | 4 ++-- src/d_netcmd.c | 6 +++--- src/dehacked.c | 4 ++++ src/doomdef.h | 2 +- src/g_game.c | 22 +++++++++++----------- src/hu_stuff.c | 2 +- src/info.c | 4 ++++ src/info.h | 4 ++++ src/k_kart.c | 4 ---- src/m_cheat.c | 2 +- src/p_maputl.c | 23 +++++++++++++++-------- src/p_mobj.c | 28 +++++++++++++++++----------- src/p_tick.c | 34 +++++++++++++++++++--------------- src/p_user.c | 19 +++++++++---------- 16 files changed, 134 insertions(+), 82 deletions(-) diff --git a/src/byteptr.h b/src/byteptr.h index 42bd44736..0345038b8 100644 --- a/src/byteptr.h +++ b/src/byteptr.h @@ -14,12 +14,17 @@ #ifndef __BYTEPTR_H__ #define __BYTEPTR_H__ +#if defined (__alpha__) || defined (__arm__) || defined (__mips__) || defined (__ia64__) || defined (__clang__) +#define DEALIGNED +#endif + #include "endian.h" #ifndef SRB2_BIG_ENDIAN // // Little-endian machines // +#ifdef DEALIGNED #define WRITEUINT8(p,b) do { UINT8 *p_tmp = (void *)p; const UINT8 tv = ( UINT8)(b); memcpy(p, &tv, sizeof( UINT8)); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITESINT8(p,b) do { SINT8 *p_tmp = (void *)p; const SINT8 tv = ( UINT8)(b); memcpy(p, &tv, sizeof( UINT8)); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITEINT16(p,b) do { INT16 *p_tmp = (void *)p; const INT16 tv = ( INT16)(b); memcpy(p, &tv, sizeof( INT16)); p_tmp++; p = (void *)p_tmp; } while (0) @@ -29,8 +34,20 @@ #define WRITECHAR(p,b) do { char *p_tmp = (void *)p; const char tv = ( char)(b); memcpy(p, &tv, sizeof( char)); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITEFIXED(p,b) do { fixed_t *p_tmp = (void *)p; const fixed_t tv = (fixed_t)(b); memcpy(p, &tv, sizeof(fixed_t)); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITEANGLE(p,b) do { angle_t *p_tmp = (void *)p; const angle_t tv = (angle_t)(b); memcpy(p, &tv, sizeof(angle_t)); p_tmp++; p = (void *)p_tmp; } while (0) +#else +#define WRITEUINT8(p,b) do { UINT8 *p_tmp = ( UINT8 *)p; *p_tmp = ( UINT8)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITESINT8(p,b) do { SINT8 *p_tmp = ( SINT8 *)p; *p_tmp = ( SINT8)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEINT16(p,b) do { INT16 *p_tmp = ( INT16 *)p; *p_tmp = ( INT16)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEUINT16(p,b) do { UINT16 *p_tmp = ( UINT16 *)p; *p_tmp = ( UINT16)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEINT32(p,b) do { INT32 *p_tmp = ( INT32 *)p; *p_tmp = ( INT32)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEUINT32(p,b) do { UINT32 *p_tmp = ( UINT32 *)p; *p_tmp = ( UINT32)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITECHAR(p,b) do { char *p_tmp = ( char *)p; *p_tmp = ( char)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEFIXED(p,b) do { fixed_t *p_tmp = (fixed_t *)p; *p_tmp = (fixed_t)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEANGLE(p,b) do { angle_t *p_tmp = (angle_t *)p; *p_tmp = (angle_t)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#endif #ifdef __GNUC__ +#ifdef DEALIGNED #define READUINT8(p) ({ UINT8 *p_tmp = (void *)p; UINT8 b; memcpy(&b, p, sizeof( UINT8)); p_tmp++; p = (void *)p_tmp; b; }) #define READSINT8(p) ({ SINT8 *p_tmp = (void *)p; SINT8 b; memcpy(&b, p, sizeof( SINT8)); p_tmp++; p = (void *)p_tmp; b; }) #define READINT16(p) ({ INT16 *p_tmp = (void *)p; INT16 b; memcpy(&b, p, sizeof( INT16)); p_tmp++; p = (void *)p_tmp; b; }) @@ -41,6 +58,17 @@ #define READFIXED(p) ({ fixed_t *p_tmp = (void *)p; fixed_t b; memcpy(&b, p, sizeof(fixed_t)); p_tmp++; p = (void *)p_tmp; b; }) #define READANGLE(p) ({ angle_t *p_tmp = (void *)p; angle_t b; memcpy(&b, p, sizeof(angle_t)); p_tmp++; p = (void *)p_tmp; b; }) #else +#define READUINT8(p) ({ UINT8 *p_tmp = ( UINT8 *)p; UINT8 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READSINT8(p) ({ SINT8 *p_tmp = ( SINT8 *)p; SINT8 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READINT16(p) ({ INT16 *p_tmp = ( INT16 *)p; INT16 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READUINT16(p) ({ UINT16 *p_tmp = ( UINT16 *)p; UINT16 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READINT32(p) ({ INT32 *p_tmp = ( INT32 *)p; INT32 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READUINT32(p) ({ UINT32 *p_tmp = ( UINT32 *)p; UINT32 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READCHAR(p) ({ char *p_tmp = ( char *)p; char b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READFIXED(p) ({ fixed_t *p_tmp = (fixed_t *)p; fixed_t b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READANGLE(p) ({ angle_t *p_tmp = (angle_t *)p; angle_t b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#endif +#else #define READUINT8(p) *(( UINT8 *)p)++ #define READSINT8(p) *(( SINT8 *)p)++ #define READINT16(p) *(( INT16 *)p)++ @@ -123,6 +151,8 @@ FUNCINLINE static ATTRINLINE UINT32 readulong(void *ptr) #define READANGLE(p) ({ angle_t *p_tmp = (angle_t *)p; angle_t b = readulong(p); p_tmp++; p = (void *)p_tmp; b; }) #endif //SRB2_BIG_ENDIAN +#undef DEALIGNED + #define WRITESTRINGN(p, s, n) do { \ size_t tmp_i; \ \ diff --git a/src/d_clisrv.c b/src/d_clisrv.c index c3d58e58e..f411a55e9 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -6498,21 +6498,19 @@ boolean TryRunTics(tic_t realtics) } #endif - ticking = neededtic > gametic; - - if (ticking) + if (neededtic > gametic) { - if (realtics) - hu_stopped = false; + hu_stopped = false; } if (player_joining) { - if (realtics) - hu_stopped = true; + hu_stopped = true; return false; } + ticking = neededtic > gametic; + if (ticking) { // run the count * tics @@ -6822,14 +6820,6 @@ void NetUpdate(void) if (realtics <= 0) // nothing new to update return; - if (realtics > 5) - { - if (server) - realtics = 1; - else - realtics = 5; - } - #ifdef DEDICATEDIDLETIME if (server && dedicated && gamestate == GS_LEVEL) { @@ -6878,6 +6868,14 @@ void NetUpdate(void) } #endif + if (realtics > 5) + { + if (server) + realtics = 1; + else + realtics = 5; + } + gametime = nowtime; UpdatePingTable(); diff --git a/src/d_main.c b/src/d_main.c index 315c8d5d9..c64220236 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -882,7 +882,7 @@ void D_SRB2Loop(void) // Use the time before sleep for frameskip calculations: // post-sleep time is literally being intentionally wasted - deltasecs = (double)((INT64)finishprecise - enterprecise) / I_GetPrecisePrecision(); + deltasecs = (double)((INT64)(finishprecise - enterprecise)) / I_GetPrecisePrecision(); deltatics = deltasecs * NEWTICRATE; // If time spent this game loop exceeds a single tic, @@ -916,7 +916,7 @@ void D_SRB2Loop(void) } // Capture the time once more to get the real delta time. finishprecise = I_GetPreciseTime(); - deltasecs = (double)((INT64)finishprecise - enterprecise) / I_GetPrecisePrecision(); + deltasecs = (double)((INT64)(finishprecise - enterprecise)) / I_GetPrecisePrecision(); deltatics = deltasecs * NEWTICRATE; } } diff --git a/src/d_netcmd.c b/src/d_netcmd.c index e9fc195cf..5d316aff2 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -263,8 +263,8 @@ consvar_t cv_competitionboxes = {"competitionboxes", "Random", CV_NETVAR|CV_CHEA #ifdef SEENAMES static CV_PossibleValue_t seenames_cons_t[] = {{0, "Off"}, {1, "Colorless"}, {2, "Team"}, {3, "Ally/Foe"}, {0, NULL}}; consvar_t cv_seenames = {"seenames", "Off", CV_SAVE, seenames_cons_t, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_allowseenames = {"allowseenames", "No", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; #endif -consvar_t cv_allowseenames = {"allowseenames", "No", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; // bruh // these are just meant to be saved to the config consvar_t cv_playername = {"name", "Sonic", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Name_OnChange, 0, NULL, NULL, 0, 0, NULL}; @@ -777,9 +777,9 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_showping); CV_RegisterVar(&cv_pingmeasurement); -//#ifdef SEENAMES // bruh again +#ifdef SEENAMES CV_RegisterVar(&cv_allowseenames); -//#endif +#endif CV_RegisterVar(&cv_dummyconsvar); diff --git a/src/dehacked.c b/src/dehacked.c index d5976d51c..8be5e9191 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -6404,7 +6404,9 @@ const char *const STATE_LIST[] = { // array length left dynamic for sanity testi "S_OPAQUESMOKE4", "S_OPAQUESMOKE5", +#ifdef SEENAMES "S_NAMECHECK", +#endif }; // RegEx to generate this from info.h: ^\tMT_([^,]+), --> \t"MT_\1", @@ -7196,7 +7198,9 @@ const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity t "MT_KARMAFIREWORK", +#ifdef SEENAMES "MT_NAMECHECK", +#endif }; const char *const MOBJFLAG_LIST[] = { diff --git a/src/doomdef.h b/src/doomdef.h index 15b38977d..3ed71d446 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -605,7 +605,7 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; //#define DUMPCONSISTENCY /// See name of player in your crosshair -//#define SEENAMES +#define SEENAMES /// Allow loading of savegames between different versions of the game. /// \note XMOD port. diff --git a/src/g_game.c b/src/g_game.c index c8a654c42..ae77faebc 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1148,27 +1148,27 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) //{ SRB2kart - Drift support // Not grouped with the rest of turn stuff because it needs to know what buttons you're pressing for rubber-burn turn // limit turning to angleturn[1] to stop mouselook letting you look too fast - if (cmd->angleturn > (INT16)(angleturn[1])) - cmd->angleturn = (INT16)(angleturn[1]); - else if (cmd->angleturn < (INT16)(-angleturn[1])) - cmd->angleturn = (INT16)(-angleturn[1]); + if (cmd->angleturn > (angleturn[1])) + cmd->angleturn = (angleturn[1]); + else if (cmd->angleturn < (-angleturn[1])) + cmd->angleturn = (-angleturn[1]); - if (cmd->driftturn > (INT16)(angleturn[1])) - cmd->driftturn = (INT16)(angleturn[1]); - else if (cmd->driftturn < (INT16)(-angleturn[1])) - cmd->driftturn = (INT16)(-angleturn[1]); + if (cmd->driftturn > (angleturn[1])) + cmd->driftturn = (angleturn[1]); + else if (cmd->driftturn < (-angleturn[1])) + cmd->driftturn = (-angleturn[1]); if (player->mo) cmd->angleturn = K_GetKartTurnValue(player, cmd->angleturn); - cmd->angleturn *= (INT16)realtics; + cmd->angleturn *= realtics; // SRB2kart - no additional angle if not moving if (((player->mo && player->speed > 0) // Moving || (leveltime > starttime && (cmd->buttons & BT_ACCELERATE && cmd->buttons & BT_BRAKE)) // Rubber-burn turn || (player->kartstuff[k_respawn]) // Respawning || (player->spectator || objectplacing))) // Not a physical player - lang += (angle_t)(cmd->angleturn<<16); + lang += (cmd->angleturn<<16); cmd->angleturn = (INT16)(lang >> 16); cmd->latency = modeattacking ? 0 : (leveltime & 0xFF); // Send leveltime when this tic was generated to the server for control lag calculations @@ -4688,7 +4688,7 @@ void G_ReadDemoTiccmd(ticcmd_t *cmd, INT32 playernum) || (players[displayplayers[0]].kartstuff[k_respawn]) // Respawning || (players[displayplayers[0]].spectator || objectplacing)) // Not a physical player && !(players[displayplayers[0]].kartstuff[k_spinouttimer] && players[displayplayers[0]].kartstuff[k_sneakertimer])) // Spinning and boosting cancels out spinout - localangle[0] += (angle_t)(cmd->angleturn<<16); + localangle[0] += (cmd->angleturn<<16); if (!(demoflags & DF_GHOST) && *demobuf.p == DEMOMARKER) { diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 1e446b5be..b59f52070 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2374,7 +2374,7 @@ Ping_gfx_color (int lag) static const UINT8 * Ping_gfx_colormap (UINT32 lag, boolean gentleman) { - UINT8 *colormap = NULL; + const UINT8 *colormap = NULL; if (K_UseColorHud()) colormap = R_GetTranslationColormap(TC_RAINBOW, Ping_gfx_color(lag), GTC_CACHE); diff --git a/src/info.c b/src/info.c index eb7234014..1fb5d4e22 100644 --- a/src/info.c +++ b/src/info.c @@ -3406,7 +3406,9 @@ state_t states[NUMSTATES] = {SPR_SMOK, 3, 7, {NULL}, 0, 0, S_OPAQUESMOKE5}, // S_OPAQUESMOKE4 {SPR_SMOK, 4, 8, {NULL}, 0, 0, S_NULL}, // S_OPAQUESMOKE5 +#ifdef SEENAMES {SPR_NULL, 0, 1, {NULL}, 0, 0, S_NULL}, // S_NAMECHECK +#endif }; mobjinfo_t mobjinfo[NUMMOBJTYPES] = @@ -20172,6 +20174,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = // ============================================================================================================================// +#ifdef SEENAMES { // MT_NAMECHECK -1, // doomednum S_NAMECHECK, // spawnstate @@ -20198,6 +20201,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = MF_NOBLOCKMAP|MF_MISSILE|MF_NOGRAVITY|MF_NOSECTOR, // flags S_NULL // raisestate }, +#endif }; diff --git a/src/info.h b/src/info.h index 71259498d..228fd9aea 100644 --- a/src/info.h +++ b/src/info.h @@ -4300,7 +4300,9 @@ typedef enum state S_OPAQUESMOKE4, S_OPAQUESMOKE5, +#ifdef SEENAMES S_NAMECHECK, +#endif S_FIRSTFREESLOT, S_LASTFREESLOT = S_FIRSTFREESLOT + NUMSTATEFREESLOTS - 1, @@ -5109,7 +5111,9 @@ typedef enum mobj_type MT_KARMAFIREWORK, +#ifdef SEENAMES MT_NAMECHECK, +#endif MT_FIRSTFREESLOT, MT_LASTFREESLOT = MT_FIRSTFREESLOT + NUMMOBJFREESLOTS - 1, diff --git a/src/k_kart.c b/src/k_kart.c index 3658bb0ea..179a6f724 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -10584,10 +10584,6 @@ static void K_drawKartMinimap(void) { if (localplayers[i] == -1) continue; // this doesn't interest us - - if ((players[i].kartstuff[k_hyudorotimer] > 0) && (leveltime & 1)) - continue; - K_drawKartMinimapHead(players[localplayers[i]].mo, x, y, splitflags); } } diff --git a/src/m_cheat.c b/src/m_cheat.c index 90e0f90cd..5f8648cbd 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -1092,7 +1092,7 @@ void OP_ObjectplaceMovement(player_t *player) ticcmd_t *cmd = &player->cmd; if (!player->climbing && (netgame || (player->pflags & PF_SPINNING))) - player->mo->angle = (angle_t)(cmd->angleturn<<16 /* not FRACBITS */); + player->mo->angle = (cmd->angleturn<<16 /* not FRACBITS */); ticruned++; if (!(cmd->angleturn & TICCMD_RECEIVED)) diff --git a/src/p_maputl.c b/src/p_maputl.c index 02369675c..a88545135 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -136,7 +136,7 @@ void P_ClosestPointOnLine3D(fixed_t x, fixed_t y, fixed_t z, line_t *line, verte // INT32 P_PointOnLineSide(fixed_t x, fixed_t y, const line_t *line) { - fixed_t dx, dy; + fixed_t dx, dy, left, right; if (!line->dx) return x <= line->v1->x ? line->dy > 0 : line->dy < 0; @@ -147,7 +147,10 @@ INT32 P_PointOnLineSide(fixed_t x, fixed_t y, const line_t *line) dx = (x - line->v1->x); dy = (y - line->v1->y); - return FixedMul(dy, line->dx>>FRACBITS) >= FixedMul(line->dy>>FRACBITS, dx) ? 1 : 0; + left = FixedMul(line->dy>>FRACBITS, dx); + right = FixedMul(dy, line->dx>>FRACBITS); + + return right < left ? 0 : 1; } // @@ -207,7 +210,7 @@ INT32 P_BoxOnLineSide(fixed_t *tmbox, const line_t *ld) // static INT32 P_PointOnDivlineSide(fixed_t x, fixed_t y, divline_t *line) { - fixed_t dx, dy; + fixed_t dx, dy, left, right; if (!line->dx) return x <= line->x ? line->dy > 0 : line->dy < 0; @@ -218,13 +221,17 @@ static INT32 P_PointOnDivlineSide(fixed_t x, fixed_t y, divline_t *line) dx = (x - line->x); dy = (y - line->y); - // Try to quickly decide by looking at sign bits. - // also use a mask to avoid branch prediction - INT32 mask = ((line->dy ^ line->dx ^ dx ^ dy) & 0x80000000); - return ((mask & ((line->dy ^ dx) & 0x80000000)) | // (left is negative) - (~mask & (FixedMul(dy>>8, line->dx>>8) >= FixedMul(line->dy>>8, dx>>8)))) ? 1 : 0; + // try to quickly decide by looking at sign bits + if ((line->dy ^ line->dx ^ dx ^ dy) & 0x80000000) + return ((line->dy ^ dx) & 0x80000000) ? 1 : 0; + + left = FixedMul(line->dy>>8, dx>>8); + right = FixedMul(dy>>8, line->dx>>8); + + return right < left ? 0 : 1; } + // // P_MakeDivline // diff --git a/src/p_mobj.c b/src/p_mobj.c index aab623a61..868f86e16 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -126,11 +126,10 @@ static void P_CycleMobjState(mobj_t *mobj) // // P_CycleMobjState for players. // -static void P_CyclePlayerMobjState(mobj_t *mobj, boolean animonly) +static void P_CyclePlayerMobjState(mobj_t *mobj) { // state animations - if (!animonly) - P_CycleStateAnimation(mobj); + P_CycleStateAnimation(mobj); // cycle through states, // calling action functions at transitions @@ -3631,7 +3630,17 @@ static void P_PlayerMobjThinker(mobj_t *mobj) } animonly: - P_CyclePlayerMobjState(mobj, true); + // cycle through states, + // calling action functions at transitions + if (mobj->tics != -1) + { + mobj->tics--; + + // you can cycle through multiple states in a tic + if (!mobj->tics) + if (!P_SetPlayerMobjState(mobj, mobj->state->nextstate)) + return; // freed itself + } } static void P_CalculatePrecipFloor(precipmobj_t *mobj, boolean spawn) @@ -9298,7 +9307,7 @@ void P_MobjThinker(mobj_t *mobj) // Can end up here if a player dies. if (mobj->player) - P_CyclePlayerMobjState(mobj, false); + P_CyclePlayerMobjState(mobj); else P_CycleMobjState(mobj); @@ -10359,7 +10368,7 @@ consvar_t cv_suddendeath = {"suddendeath", "Off", CV_NETVAR|CV_CHEAT|CV_NOSHOWHE void P_SpawnPrecipitation(void) { INT32 i, j, mrand; - fixed_t basex, basey, x, y, z, height; + fixed_t basex, basey, x, y, z; subsector_t *precipsector = NULL; precipmobj_t *rainmo = NULL; @@ -10367,7 +10376,7 @@ void P_SpawnPrecipitation(void) return; const fixed_t precipmoscale = (cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT); - const INT32 density = (cv_lessprecip.value ? 2 : 1); + const INT32 density = (cv_lessprecip.value ? 2 : 1); // only spawn half as much // Use the blockmap to narrow down our placing patterns for (i = 0; i < bmapwidth*bmapheight; i += density) @@ -10396,11 +10405,8 @@ void P_SpawnPrecipitation(void) if (precipsector->sector->ceilingpic != skyflatnum) continue; - height = precipsector->sector->ceilingheight - precipsector->sector->floorheight; - height = FixedDiv(height, mapobjectscale); - // Exists, but is too small for reasonable precipitation. - if (height < 64<sector->floorheight <= precipsector->sector->ceilingheight - (32<references) // Usually gets cleared up in one frame; what's going on here, then? CONS_Printf("Number of potentially faulty references: %d\n", thinker->references); #endif - - if (thinker->references != 0) + if (thinker->references) return; + /* Remove from main thinker list */ + thinker_t *next = thinker->next; + /* Note that currentthinker is guaranteed to point to us, + * and since we're freeing our memory, we had better change that. So + * point it to thinker->prev, so the iterator will correctly move on to + * thinker->prev->next = thinker->next */ + (next->prev = currentthinker = thinker->prev)->next = next; R_DestroyLevelInterpolators(thinker); - /* Note that currentthinker is guaranteed to point to us, - * and since we're freeing our memory, we had better change that. So - * point it to thinker->prev, so the iterator will correctly move on to - * thinker->prev->next = thinker->next */ - currentthinker = thinker->prev; - - /* Remove from main thinker list */ - P_UnlinkThinker(thinker); + if (thinker->cachable == true) + { + // put cachable thinkers in the mobj cache, so we can avoid allocations + ((mobj_t *)thinker)->hnext = mobjcache; + mobjcache = (mobj_t *)thinker; + } + else + { + Z_Free(thinker); + } } // @@ -436,10 +444,6 @@ static void P_DeviceRumbleTick(void) low = high = FRACUNIT / 64; } } - else if (player->kartstuff[k_growshrinktimer] > 0 && P_IsObjectOnGround(player->mo)) - { - low = FRACUNIT / 256; - } else if ((player->kartstuff[k_bananadrag] > TICRATE) && P_IsObjectOnGround(player->mo) && player->speed != 0) { @@ -473,7 +477,7 @@ void P_RunChaseCameras(void) player_t *p = &players[displayplayers[i]]; camera_t *cam = &camera[i]; - if (p->mo && p->kartstuff[k_throwdir] != 0) + if (cv_verticallook.value && leveltime > starttime && p->mo && p->kartstuff[k_respawn] == 0 && p->kartstuff[k_throwdir] != 0) { if (p->speed < 6 * p->mo->scale && abs(cam->dpad_y_held) < 2*TICRATE) cam->dpad_y_held += intsign(p->kartstuff[k_throwdir]); diff --git a/src/p_user.c b/src/p_user.c index ce95e8ad8..70249fb4b 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1920,12 +1920,12 @@ static void P_3dMovement(player_t *player) if (analogmove) { - movepushangle = (angle_t)(cmd->angleturn<<16 /* not FRACBITS */); + movepushangle = (cmd->angleturn<<16 /* not FRACBITS */); } else { if (player->kartstuff[k_drift] != 0) - movepushangle = (player->mo->angle-(ANGLE_45/5)*(angle_t)player->kartstuff[k_drift]); + movepushangle = player->mo->angle-(ANGLE_45/5)*player->kartstuff[k_drift]; else if (player->kartstuff[k_spinouttimer] || player->kartstuff[k_wipeoutslow]) // if spun out, use the boost angle movepushangle = (angle_t)player->kartstuff[k_boostangle]; else @@ -1991,7 +1991,7 @@ static void P_3dMovement(player_t *player) // SRB2Kart: pogo spring and speed bumps are supposed to control like you're on the ground onground = (P_IsObjectOnGround(player->mo) || (player->kartstuff[k_pogospring])); - player->aiming = (angle_t)cmd->aiming<aiming = cmd->aiming<exiting || mapreset) || (P_PlayerInPain(player) && !onground))) @@ -2123,10 +2123,9 @@ static void P_SpectatorMovement(player_t *player) // Aiming needed for SEENAMES, etc. // We may not need to fire as a spectator, but this is still handy! - player->aiming = (angle_t)cmd->aiming<aiming = cmd->aiming<mo->momx = player->mo->momy = player->mo->momz = 0; - if (cmd->forwardmove != 0) { P_Thrust(player->mo, player->mo->angle, cmd->forwardmove*mapobjectscale); @@ -2304,7 +2303,7 @@ static void P_MovePlayer(player_t *player) { // KART: Don't directly apply angleturn! It may have been either A) forged by a malicious client, or B) not be a smooth turn due to a player dropping frames. // Instead, turn the player only up to the amount they're supposed to turn accounting for latency. Allow exactly 1 extra turn unit to try to keep old replays synced. - angle_diff = cmd->angleturn - (INT16)(player->mo->angle>>16); + angle_diff = cmd->angleturn - (player->mo->angle>>16); max_left_turn = player->lturn_max[(leveltime + MAXPREDICTTICS - cmd->latency) % MAXPREDICTTICS]; max_right_turn = player->rturn_max[(leveltime + MAXPREDICTTICS - cmd->latency) % MAXPREDICTTICS]; @@ -2317,13 +2316,13 @@ static void P_MovePlayer(player_t *player) else { // Try to keep normal turning as accurate to 1.0.1 as possible to reduce replay desyncs. - player->mo->angle = (angle_t)cmd->angleturn<<16; + player->mo->angle = cmd->angleturn<<16; add_delta = false; } //CONS_Printf("applied turn: %d\n", angle_diff); if (add_delta) { - player->mo->angle += (angle_t)angle_diff<<16; + player->mo->angle += angle_diff<<16; player->mo->angle &= ~0xFFFF; // Try to keep the turning somewhat similar to how it was before? //CONS_Printf("leftover turn (%s): %5d or %4d%%\n", // player_names[player-players], @@ -3380,7 +3379,7 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) cam->aiming = cmd->aiming << FRACBITS; } - cam->angle = (angle_t)cmd->angleturn << 16; + cam->angle = cmd->angleturn << 16; // camera movement: if (!cam->button_a_held) @@ -3437,7 +3436,7 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) if (abs(smooth) < abs(aiming)) { - cam->aiming -= (angle_t)(smooth * intsign(aiming)); + cam->aiming -= smooth * intsign(aiming); } else {