From 5e9ea2429be2739bc964a51c5252f2a7e5e49f55 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 21 Oct 2024 06:23:05 +0200 Subject: [PATCH 01/13] replace those two P_MobjWasRemoved with simple null check insteead since those may actually segfault if null anyways --- src/lua_maplib.c | 2 +- src/p_mobj.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lua_maplib.c b/src/lua_maplib.c index d92cd1f8b..a6bca2ff6 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -281,7 +281,7 @@ static int lib_iterateSectorThinglist(lua_State *L) if (!lua_isnil(L, 1)) { thing = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); - if (P_MobjWasRemoved(thing)) + if (!thing) return luaL_error(L, "current entry in thinglist was removed; avoid calling P_RemoveMobj on entries!"); thing = thing->snext; } diff --git a/src/p_mobj.c b/src/p_mobj.c index 4a71c4f6f..8682cc7dd 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3411,7 +3411,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) I_Assert(mobj->player != NULL); I_Assert(!P_MobjWasRemoved(mobj)); - if (P_MobjWasRemoved(mobj)) + if (!mobj) return; P_MobjCheckWater(mobj); @@ -11247,7 +11247,8 @@ void P_SpawnMapThing(mapthing_t *mthing) mobj = P_SpawnMobj(x, y, z, i); - if (!mobj || P_MobjWasRemoved(mobj)) { + if (!mobj || P_MobjWasRemoved(mobj)) + { CONS_Alert(CONS_ERROR, "Failed to spawn map thing #%d at %d, %d. This will crash vanilla clients!\n", mthing->type, x>>FRACBITS, y>>FRACBITS); return; } From 393c0be4073944d7afb473dc8036ee25255454c3 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 21 Oct 2024 14:19:35 +0200 Subject: [PATCH 02/13] Revert "attempt to optimize some p_maputl stuff" This reverts commit 81d415c5ba9bc62b7344f5e10d0573e70c975ae9. --- src/p_maputl.c | 93 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 65 insertions(+), 28 deletions(-) diff --git a/src/p_maputl.c b/src/p_maputl.c index f2fc0867e..3c91dc922 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -35,23 +35,33 @@ void P_ClosestPointOnLine(fixed_t x, fixed_t y, line_t *line, vertex_t *result) fixed_t dy = line->dy; // Determine t (the length of the vector from �Line[0]� to �p�) + fixed_t cx, cy; + fixed_t vx, vy; fixed_t magnitude; fixed_t t; + //Sub (p, &Line[0], &c); + cx = x - startx; + cy = y - starty; + + //Sub (&Line[1], &Line[0], &V); + vx = dx; + vy = dy; + //Normalize (&V, &V); magnitude = R_PointToDist2(line->v2->x, line->v2->y, startx, starty); - dx = FixedDiv(dx, magnitude); - dy = FixedDiv(dy, magnitude); + vx = FixedDiv(vx, magnitude); + vy = FixedDiv(vy, magnitude); - t = (FixedMul(dx, (x - startx)) + FixedMul(dy, (y - starty))); + t = (FixedMul(vx, cx) + FixedMul(vy, cy)); // Return the point between �Line[0]� and �Line[1]� - dx = FixedMul(dx, t); - dy = FixedMul(dy, t); + vx = FixedMul(vx, t); + vy = FixedMul(vy, t); //Add (&Line[0], &V, out); - result->x = startx + dx; - result->y = starty + dy; + result->x = startx + vx; + result->y = starty + vy; return; } @@ -69,15 +79,28 @@ void P_ClosestPointOnLine3D(fixed_t x, fixed_t y, fixed_t z, line_t *line, verte fixed_t dz = line->v2->z - line->v1->z; // Determine t (the length of the vector from �Line[0]� to �p�) + fixed_t cx, cy, cz; + fixed_t vx, vy, vz; fixed_t magnitude; fixed_t t; - magnitude = R_PointToDist2(0, line->v2->z, R_PointToDist2(line->v2->x, line->v2->y, startx, starty), startz); - dx = FixedDiv(dx, magnitude); - dy = FixedDiv(dy, magnitude); - dz = FixedDiv(dz, magnitude); + //Sub (p, &Line[0], &c); + cx = x - startx; + cy = y - starty; + cz = z - startz; - t = (FixedMul(dx, (x - startx)) + FixedMul(dy, (y - starty)) + FixedMul(dz, (z - startz))); + //Sub (&Line[1], &Line[0], &V); + vx = dx; + vy = dy; + vz = dz; + + //Normalize (&V, &V); + magnitude = R_PointToDist2(0, line->v2->z, R_PointToDist2(line->v2->x, line->v2->y, startx, starty), startz); + vx = FixedDiv(vx, magnitude); + vy = FixedDiv(vy, magnitude); + vz = FixedDiv(vz, magnitude); + + t = (FixedMul(vx, cx) + FixedMul(vy, cy) + FixedMul(vz, cz)); // Set closest point to the end if it extends past -Red if (t <= 0) @@ -96,14 +119,14 @@ void P_ClosestPointOnLine3D(fixed_t x, fixed_t y, fixed_t z, line_t *line, verte } // Return the point between �Line[0]� and �Line[1]� - dx = FixedMul(dx, t); - dy = FixedMul(dy, t); - dz = FixedMul(dz, t); + vx = FixedMul(vx, t); + vy = FixedMul(vy, t); + vz = FixedMul(vz, t); //Add (&Line[0], &V, out); - result->x = startx + dx; - result->y = starty + dy; - result->z = startz + dz; + result->x = startx + vx; + result->y = starty + vy; + result->z = startz + vz; return; } @@ -113,16 +136,21 @@ 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, left, right; + if (!line->dx) return x <= line->v1->x ? line->dy > 0 : line->dy < 0; if (!line->dy) return y <= line->v1->y ? line->dx < 0 : line->dx > 0; - x -= line->v1->x; - y -= line->v1->y; + dx = (x - line->v1->x); + dy = (y - line->v1->y); - return FixedMul(y, line->dx>>FRACBITS) < FixedMul(line->dy>>FRACBITS, x) ? 0 : 1; + left = FixedMul(line->dy>>FRACBITS, dx); + right = FixedMul(dy, line->dx>>FRACBITS); + + return right < left ? 0 : 1; } // @@ -182,22 +210,28 @@ 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, left, right; + if (!line->dx) return x <= line->x ? line->dy > 0 : line->dy < 0; if (!line->dy) return y <= line->y ? line->dx < 0 : line->dx > 0; - x -= line->x; - y -= line->y; + dx = (x - line->x); + dy = (y - line->y); // try to quickly decide by looking at sign bits - if ((line->dy ^ line->dx ^ x ^ y) & 0x80000000) - return ((line->dy ^ x) & 0x80000000) ? 1 : 0; + if ((line->dy ^ line->dx ^ dx ^ dy) & 0x80000000) + return ((line->dy ^ dx) & 0x80000000) ? 1 : 0; - return FixedMul(y>>8, line->dx>>8) < FixedMul(line->dy>>8, x>>8) ? 0 : 1; + left = FixedMul(line->dy>>8, dx>>8); + right = FixedMul(dy>>8, line->dx>>8); + + return right < left ? 0 : 1; } + // // P_MakeDivline // @@ -216,14 +250,17 @@ void P_MakeDivline(line_t *li, divline_t *dl) // fixed_t P_InterceptVector(divline_t *v2, divline_t *v1) { - fixed_t den; + fixed_t frac, num, den; den = FixedMul(v1->dy>>8, v2->dx) - FixedMul(v1->dx>>8, v2->dy); if (!den) return 0; - return (FixedDiv(FixedMul((v1->x - v2->x)>>8, v1->dy) + FixedMul((v2->y - v1->y)>>8, v1->dx), den)); + num = FixedMul((v1->x - v2->x)>>8, v1->dy) + FixedMul((v2->y - v1->y)>>8, v1->dx); + frac = FixedDiv(num, den); + + return frac; } // From dba7a7dc3cb55ea4d8885f28e29edf3d22eeaef9 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 21 Oct 2024 15:37:34 +0200 Subject: [PATCH 03/13] prevent map command crash from maps with invalid or non existing mapinfo --- src/d_netcmd.c | 8 ++++++++ src/g_game.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index e54251125..281fb8856 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2983,6 +2983,14 @@ static void Command_Map_f(void) // G_TOLFlag handles both multiplayer gametype and ignores it for !multiplayer else { + if (!mapheaderinfo[newmapnum-1] || mapheaderinfo[newmapnum-1] == NULL) + { + CONS_Alert(CONS_WARNING, M_GetText("Invalid mapheaderinfo for Course %s (%s)\n"), realmapname, G_BuildMapName(newmapnum)); + Z_Free(realmapname); + Z_Free(mapname); + return; + } + if (!(mapheaderinfo[newmapnum-1]->typeoflevel & G_TOLFlag(newgametype))) { CONS_Alert(CONS_WARNING, M_GetText("Course %s (%s) doesn't support %s mode!\n(Use -force to override)\n"), realmapname, G_BuildMapName(newmapnum), diff --git a/src/g_game.c b/src/g_game.c index 2d2fe7bb6..8d1aca0ad 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4635,7 +4635,7 @@ INT32 G_FindMapByNameOrCode(const char *mapname, char **realmapnamep) if (mapname[0] == '*') // current map return gamemap; else if (mapname[0] == '?') - return G_RandMap(G_TOLFlag(gametype), prevmap, false, 0, false, NULL); + return G_RandMap(G_TOLFlag(gametype), gamemap-1, false, 0, false, NULL); else if (mapname[0] == '+' && mapheaderinfo[gamemap-1]) // next map { newmapnum = mapheaderinfo[gamemap-1]->nextlevel; From 970251ced39497bb71ed506f2cd88e78c9a4a8c7 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 21 Oct 2024 17:01:20 +0200 Subject: [PATCH 04/13] also check here ig? --- src/g_game.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 8d1aca0ad..e310de57d 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4542,8 +4542,7 @@ INT32 G_FindMap(const char *mapname, char **foundmapnamep, break; } } - else - if (apromapnum == 0 || wanttable) + else if (apromapnum == 0 || wanttable) { /* LEVEL 1--match keywords verbatim */ if (( aprop = strcasestr(realmapname, mapname) )) @@ -4634,7 +4633,7 @@ INT32 G_FindMapByNameOrCode(const char *mapname, char **realmapnamep) { if (mapname[0] == '*') // current map return gamemap; - else if (mapname[0] == '?') + else if (mapname[0] == '?' && mapheaderinfo[gamemap-1]) return G_RandMap(G_TOLFlag(gametype), gamemap-1, false, 0, false, NULL); else if (mapname[0] == '+' && mapheaderinfo[gamemap-1]) // next map { From f149d058a16b929f722b3b19ea1bb7b2053296f6 Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 21 Oct 2024 18:06:35 +0300 Subject: [PATCH 05/13] Fix off-by-one error in lib_setSfxInfo --- src/lua_infolib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_infolib.c b/src/lua_infolib.c index 8754176ed..46b451ccc 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -940,7 +940,7 @@ static int lib_setSfxInfo(lua_State *L) if (lua_isnumber(L, 2)) { - int j = lua_tointeger(L, 2) - 1; + int j = lua_tointeger(L, 2); // Read and Write enums were combined, need to do this switch now switch (j) From 63568e3861e8bbfd77edc15631a8aaeaa9ac17a9 Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 21 Oct 2024 18:40:16 +0300 Subject: [PATCH 06/13] Fix off-by-one error for using '?' as map name --- src/g_game.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index e310de57d..be26239fa 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4634,7 +4634,7 @@ INT32 G_FindMapByNameOrCode(const char *mapname, char **realmapnamep) if (mapname[0] == '*') // current map return gamemap; else if (mapname[0] == '?' && mapheaderinfo[gamemap-1]) - return G_RandMap(G_TOLFlag(gametype), gamemap-1, false, 0, false, NULL); + return G_RandMap(G_TOLFlag(gametype), gamemap-1, false, 0, false, NULL)+1; else if (mapname[0] == '+' && mapheaderinfo[gamemap-1]) // next map { newmapnum = mapheaderinfo[gamemap-1]->nextlevel; From 664bd2de3f59b919bf54ab4e4b373d1cfd9ec4dd Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 20 Oct 2024 19:44:52 +0200 Subject: [PATCH 07/13] dont draw fadescreen when minimap iss active --- src/hu_stuff.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index d8e345ba7..e68888c84 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2617,7 +2617,8 @@ static void HU_DrawRankings(void) boolean completed[MAXPLAYERS]; UINT32 whiteplayer = MAXPLAYERS; - V_DrawFadeScreen(0xFF00, 16); // A little more readable, and prevents cheating the fades under other circumstances. + if (!automapactive) + V_DrawFadeScreen(0xFF00, 16); // A little more readable, and prevents cheating the fades under other circumstances. if (cons_menuhighlight.value) hilicol = cons_menuhighlight.value; From 7223581539e9fda04c7622e717e28288c25440b4 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 21 Oct 2024 18:10:18 +0200 Subject: [PATCH 08/13] Clarify we're calculating a cross product --- src/r_main.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_main.h b/src/r_main.h index 0bfa8bfa5..22c073992 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -81,8 +81,8 @@ FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSegSide(fixed_t x, fixed_t fixed_t ldx = line->v2->x - lx; fixed_t ldy = line->v2->y - ly; - // heavily optimized version of R_PointOnSide, stolen from GZDoom. - return (INT64)(y - ly) * ldx + (INT64)(lx - x) * ldy > 0; + // use cross product to determine side quickly + return (INT64)(y - ly) * ldx - (INT64)(x - lx) * ldy > 0; } angle_t R_PointToAngle(fixed_t x, fixed_t y); From 7a3d958fc15edbdaf76da5e46687091644ab4b46 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 21 Oct 2024 18:43:01 +0200 Subject: [PATCH 09/13] tab pls --- src/r_things.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_things.c b/src/r_things.c index d533c572a..f083c62a2 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -3287,7 +3287,7 @@ static int skinSortFunc(const void *a, const void *b) //tbh i have no clue what void sortSkinGrid(void) { //CONS_Printf("Sorting skin list (%d)...\n", cv_skinselectgridsort.value); - qs22j(skinsorted, numskins, sizeof(UINT8), skinSortFunc); + qs22j(skinsorted, numskins, sizeof(UINT8), skinSortFunc); } // From 884a6da2bd32648fa65b8036b1077212f9e46a50 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 21 Oct 2024 21:05:05 +0200 Subject: [PATCH 10/13] dont use cv_sloperolldist in splitscreen + save some assignments and one fixedhypot call also use tabs lul --- src/k_kart.c | 87 +++++++++++++++++++++++++--------------------------- src/p_mobj.c | 7 +---- 2 files changed, 42 insertions(+), 52 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index b5a70ec4d..c146a632b 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3308,56 +3308,55 @@ static void K_QuiteSaltyHop(player_t *p) void K_RollMobjBySlopes(mobj_t* mo, boolean usedistance) { - I_Assert(mo->subsector != NULL); - I_Assert(mo->subsector->sector != NULL); + I_Assert(mo->subsector != NULL); + I_Assert(mo->subsector->sector != NULL); - angle_t an; - boolean flip = mo->eflags & MFE_VERTICALFLIP; - fixed_t m_dist = R_PointToDist(mo->x, mo->y); - fixed_t rolldist = cv_sloperolldist.value * mapobjectscale; + angle_t an; + boolean flip = mo->eflags & MFE_VERTICALFLIP; + fixed_t m_dist = usedistance ? R_PointToDist(mo->x, mo->y) : 0; + fixed_t rolldist = cv_sloperolldist.value * mapobjectscale; - // lifted from hw_md2 - if (mo->standingslope) - { - fixed_t tempz = mo->standingslope->normal.z; - fixed_t tempy = mo->standingslope->normal.y; - fixed_t tempx = mo->standingslope->normal.x; - fixed_t tempangle = -(R_PointToAngle2( - 0, 0, FixedSqrt(FixedMul(tempy, tempy) + FixedMul(tempz, tempz)), tempx)); + // lifted from hw_md2 + if (mo->standingslope) + { + fixed_t tempz = mo->standingslope->normal.z; + fixed_t tempy = mo->standingslope->normal.y; + fixed_t tempx = mo->standingslope->normal.x; + fixed_t tempangle = -(R_PointToAngle2(0, 0, FixedSqrt(FixedMul(tempy, tempy) + FixedMul(tempz, tempz)), tempx)); - // admittedly this is a very hacky way to do the pitch and roll easing + // admittedly this is a very hacky way to do the pitch and roll easing - // pitch - if ((!usedistance) || (m_dist <= (rolldist))) - { - an = (INT32)((angle_t)tempangle - mo->pitch_sprite) / SLOPEROLL_DIV; + // pitch + if ((!usedistance) || (m_dist <= (rolldist))) + { + an = (INT32)((angle_t)tempangle - mo->pitch_sprite) / SLOPEROLL_DIV; - mo->pitch_sprite = an ? mo->pitch_sprite + an : (angle_t)tempangle; - } - else - mo->pitch_sprite = FixedAngle(0); + mo->pitch_sprite = an ? mo->pitch_sprite + an : (angle_t)tempangle; + } + else + mo->pitch_sprite = FixedAngle(0); - mo->slopepitch = flip ? InvAngle(mo->pitch_sprite) : mo->pitch_sprite; + mo->slopepitch = flip ? InvAngle(mo->pitch_sprite) : mo->pitch_sprite; - // roll - tempangle = (R_PointToAngle2(0, 0, tempz, tempy)); + // roll + tempangle = (R_PointToAngle2(0, 0, tempz, tempy)); - if ((!usedistance) || (m_dist <= (rolldist))) - { - an = (INT32)((angle_t)tempangle - mo->roll_sprite) / SLOPEROLL_DIV; + if (!usedistance || (m_dist <= (rolldist))) + { + an = (INT32)((angle_t)tempangle - mo->roll_sprite) / SLOPEROLL_DIV; - mo->roll_sprite = an ? mo->roll_sprite + an : (angle_t)tempangle; - } - else - mo->roll_sprite = FixedAngle(0); + mo->roll_sprite = an ? mo->roll_sprite + an : (angle_t)tempangle; + } + else + mo->roll_sprite = FixedAngle(0); - mo->sloperoll = flip ? InvAngle(mo->roll_sprite) : mo->roll_sprite; - } - else if (P_IsObjectOnGround(mo)) - { - mo->sloperoll = FixedAngle(0); - mo->slopepitch = FixedAngle(0); - } + mo->sloperoll = flip ? InvAngle(mo->roll_sprite) : mo->roll_sprite; + } + else if (P_IsObjectOnGround(mo)) + { + mo->sloperoll = FixedAngle(0); + mo->slopepitch = FixedAngle(0); + } } void K_SpawnBoostTrail(player_t *player) @@ -6503,14 +6502,10 @@ void K_MoveKartPlayer(player_t *player, boolean onground) player->mo->spriteyscale = player->mo->realyscale; } - boolean usedist = false; - - if (cv_sloperolldist.value > 0) - usedist = true; - if ((cv_spriteroll.value) && (cv_sloperoll.value)) + if (cv_spriteroll.value && cv_sloperoll.value) { if ((!player->mo->salty_jump)) // seeing a character rotate mid-hop looks really janky - K_RollMobjBySlopes(player->mo, usedist); + K_RollMobjBySlopes(player->mo, (cv_sloperolldist.value && !splitscreen)); } else { diff --git a/src/p_mobj.c b/src/p_mobj.c index 8682cc7dd..a43742e79 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6030,17 +6030,12 @@ static void P_KoopaThinker(mobj_t *koopa) // void P_RollPitchMobj(mobj_t* mobj) { - boolean usedist = false; - if (P_MobjWasRemoved(mobj)) return; - if (cv_sloperolldist.value > 0) - usedist = true; - if (cv_spriteroll.value && cv_sloperoll.value == 2) { - K_RollMobjBySlopes(mobj, usedist); + K_RollMobjBySlopes(mobj, cv_sloperolldist.value && !splitscreen); } else { From 1b512edc56f5b2408d408347e4b6886ebc16a876 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 21 Oct 2024 21:28:01 +0200 Subject: [PATCH 11/13] add proper null check here too --- src/k_kart.c | 6 +++--- src/p_mobj.c | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index c146a632b..a8bce6fa9 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3312,9 +3312,9 @@ void K_RollMobjBySlopes(mobj_t* mo, boolean usedistance) I_Assert(mo->subsector->sector != NULL); angle_t an; - boolean flip = mo->eflags & MFE_VERTICALFLIP; - fixed_t m_dist = usedistance ? R_PointToDist(mo->x, mo->y) : 0; - fixed_t rolldist = cv_sloperolldist.value * mapobjectscale; + const boolean flip = mo->eflags & MFE_VERTICALFLIP; + const fixed_t m_dist = usedistance ? R_PointToDist(mo->x, mo->y) : 0; + const fixed_t rolldist = cv_sloperolldist.value * mapobjectscale; // lifted from hw_md2 if (mo->standingslope) diff --git a/src/p_mobj.c b/src/p_mobj.c index a43742e79..6d97a0f57 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6030,7 +6030,7 @@ static void P_KoopaThinker(mobj_t *koopa) // void P_RollPitchMobj(mobj_t* mobj) { - if (P_MobjWasRemoved(mobj)) + if (!mobj || P_MobjWasRemoved(mobj)) return; if (cv_spriteroll.value && cv_sloperoll.value == 2) @@ -6281,6 +6281,7 @@ void P_MobjThinker(mobj_t *mobj) P_RemoveMobj(mobj); return; } + P_RollPitchMobj(mobj); break; case MT_SMOLDERING: From 6f9d41eadb04e0028304ead9a630a271a78840fa Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 21 Oct 2024 22:38:45 +0200 Subject: [PATCH 12/13] fix R_ThingVisible those are "eflags" in kart smh --- src/r_things.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index f083c62a2..94d77c641 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2777,10 +2777,10 @@ boolean R_ThingVisible (mobj_t *thing) if (splitscreen) { - if ((viewssnum == 0 && (thing->renderflags & MFE_DRAWONLYFORP1)) - || (viewssnum == 1 && (thing->renderflags & MFE_DRAWONLYFORP2)) - || (viewssnum == 2 && (thing->renderflags & MFE_DRAWONLYFORP2)) - || (viewssnum == 3 && (thing->renderflags & MFE_DRAWONLYFORP4))) + if ((viewssnum == 0 && (thing->eflags & MFE_DRAWONLYFORP1)) + || (viewssnum == 1 && (thing->eflags & MFE_DRAWONLYFORP2)) + || (viewssnum == 2 && (thing->eflags & MFE_DRAWONLYFORP2)) + || (viewssnum == 3 && (thing->eflags & MFE_DRAWONLYFORP4))) return true; } From f47c663f79d2445153fbe6bb107cf98609b01919 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 21 Oct 2024 22:47:32 +0200 Subject: [PATCH 13/13] remove renderflags those literally did nothing --- src/hardware/hw_main.c | 17 ++--------------- src/p_mobj.h | 1 + src/r_defs.h | 8 -------- src/r_things.c | 17 ++--------------- 4 files changed, 5 insertions(+), 38 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index e021c3dbf..b62290157 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4836,21 +4836,8 @@ void HWR_ProjectSprite(mobj_t *thing) } #endif - if (thing->renderflags & RF_ABSOLUTEOFFSETS) - { - spr_offset = interp.spritexoffset; - spr_topoffset = interp.spriteyoffset; - } - else - { - SINT8 flipoffset = 1; - - if ((thing->renderflags & RF_FLIPOFFSETS) && flip) - flipoffset = -1; - - spr_offset += interp.spritexoffset * flipoffset; - spr_topoffset += interp.spriteyoffset * flipoffset; - } + spr_offset += interp.spritexoffset; + spr_topoffset += interp.spriteyoffset; if (papersprite) { diff --git a/src/p_mobj.h b/src/p_mobj.h index 7a8151dc3..4ca34e16e 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -261,6 +261,7 @@ typedef enum { PCF_SPLASH = 1<<4, // Splashed on the ground, return to the ceiling after the animation's over PCF_THUNK = 1<<5, // Ran the thinker this tic. } precipflag_t; + // Map Object definition. typedef struct mobj_s { diff --git a/src/r_defs.h b/src/r_defs.h index 71e13e4d4..bc95649bb 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -687,14 +687,6 @@ typedef struct #pragma pack() #endif -typedef enum // trimmed since its only real use here is for xscale/yscale -{ - RF_HORIZONTALFLIP = 0x0001, // Flip sprite horizontally - RF_VERTICALFLIP = 0x0002, // Flip sprite vertically - RF_ABSOLUTEOFFSETS = 0x0004, // Sprite uses the object's offsets absolutely, instead of relatively - RF_FLIPOFFSETS = 0x0008, // Relative object offsets are flipped with the sprite -} renderflags_t; - typedef enum { SRF_SINGLE = 0, // 0-angle for all rotations diff --git a/src/r_things.c b/src/r_things.c index 94d77c641..7c9aba09c 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1378,21 +1378,8 @@ static void R_ProjectSprite(mobj_t *thing) if (spritexscale < 1 || spriteyscale < 1) return; - if (thing->renderflags & RF_ABSOLUTEOFFSETS) - { - spr_offset = interp.spritexoffset; - spr_topoffset = interp.spriteyoffset; - } - else - { - SINT8 flipoffset = 1; - - if ((thing->renderflags & RF_FLIPOFFSETS) && flip) - flipoffset = -1; - - spr_offset += interp.spritexoffset * flipoffset; - spr_topoffset += interp.spriteyoffset * flipoffset; - } + spr_offset += interp.spritexoffset; + spr_topoffset += interp.spriteyoffset; if (flip) offset = spr_offset - spr_width;