From f294ea157f989e75d7425d18df573aba8af6bce7 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 13 Feb 2024 10:50:11 +0100 Subject: [PATCH] more things --- src/doomdata.h | 14 +++++++------- src/p_mobj.c | 47 ++++++++++++++++++++++++++------------------- src/r_things.c | 46 -------------------------------------------- src/r_things.h | 2 -- src/sdl/sdl_sound.c | 2 +- src/tables.c | 6 +++--- 6 files changed, 38 insertions(+), 79 deletions(-) diff --git a/src/doomdata.h b/src/doomdata.h index 3958e4656..6319238b7 100644 --- a/src/doomdata.h +++ b/src/doomdata.h @@ -65,7 +65,7 @@ enum typedef struct { INT16 x, y; -} mapvertex_t; +}ATTRPACK mapvertex_t; // A SideDef, defining the visual appearance of a wall, // by setting textures and offsets. @@ -75,7 +75,7 @@ typedef struct char toptexture[8], bottomtexture[8], midtexture[8]; // Front sector, towards viewer. INT16 sector; -} mapsidedef_t; +} ATTRPACK mapsidedef_t; // A LineDef, as used for editing, and as input // to the BSP builder. @@ -87,7 +87,7 @@ typedef struct INT16 tag; // sidenum[1] will be 0xffff if one sided UINT16 sidenum[2]; -} maplinedef_t; +} ATTRPACK maplinedef_t; // // LineDef attributes. @@ -148,7 +148,7 @@ typedef struct INT16 lightlevel; INT16 special; INT16 tag; -} mapsector_t; +} ATTRPACK mapsector_t; // SubSector, as generated by BSP. typedef struct @@ -156,7 +156,7 @@ typedef struct UINT16 numsegs; // Index of first one, segs are stored sequentially. UINT16 firstseg; -} mapsubsector_t; +} ATTRPACK mapsubsector_t; // LineSeg, generated by splitting LineDefs @@ -168,7 +168,7 @@ typedef struct INT16 linedef; INT16 side; INT16 offset; -} mapseg_t; +} ATTRPACK mapseg_t; // BSP node structure. @@ -186,7 +186,7 @@ typedef struct // If NF_SUBSECTOR it's a subsector, else it's a node of another subtree. UINT16 children[2]; -} mapnode_t; +} ATTRPACK mapnode_t; #if defined(_MSC_VER) #pragma pack() diff --git a/src/p_mobj.c b/src/p_mobj.c index 65ba5e6c9..fe226b054 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -5972,11 +5972,10 @@ void P_RunOverlays(void) { // run overlays mobj_t *mo, *next = NULL; + fixed_t destx,desty,zoffs; for (mo = overlaycap; mo; mo = next) { - fixed_t zoffs; - I_Assert(!P_MobjWasRemoved(mo)); // grab next in chain, then unset the chain target @@ -5985,12 +5984,31 @@ void P_RunOverlays(void) if (!mo->target) continue; + if (!splitscreen /*&& rendermode != render_soft*/) + { + angle_t viewingangle; + + if (players[displayplayers[0]].awayviewtics) + viewingangle = R_PointToAngle2(mo->target->x, mo->target->y, players[displayplayers[0]].awayviewmobj->x, players[displayplayers[0]].awayviewmobj->y); + else if (!camera[0].chase && players[displayplayers[0]].mo) + viewingangle = R_PointToAngle2(mo->target->x, mo->target->y, players[displayplayers[0]].mo->x, players[displayplayers[0]].mo->y); + else + viewingangle = R_PointToAngle2(mo->target->x, mo->target->y, camera[0].x, camera[0].y); + + if (!(mo->state->frame & FF_ANIMATE) && mo->state->var1) + viewingangle += ANGLE_180; + destx = mo->target->x + P_ReturnThrustX(mo->target, viewingangle, FixedMul(FRACUNIT/4, mo->scale)); + desty = mo->target->y + P_ReturnThrustY(mo->target, viewingangle, FixedMul(FRACUNIT/4, mo->scale)); + } + else + { + destx = mo->target->x; + desty = mo->target->y; + } mo->eflags = (mo->eflags & ~MFE_VERTICALFLIP) | (mo->target->eflags & MFE_VERTICALFLIP); mo->scale = mo->destscale = mo->target->scale; - mo->old_scale = mo->target->old_scale; mo->angle = mo->target->angle; - mo->old_angle = (mo->target->player ? mo->target->player->old_frameangle : mo->target->old_angle) + mo->movedir; if ((mo->flags & MF_DONTENCOREMAP) != (mo->target->flags & MF_DONTENCOREMAP)) mo->flags ^= MF_DONTENCOREMAP; @@ -6003,26 +6021,15 @@ void P_RunOverlays(void) zoffs = 0; P_UnsetThingPosition(mo); - mo->x = mo->target->x; - mo->y = mo->target->y; - mo->old_x = mo->target->old_x; - mo->old_y = mo->target->old_y; + mo->x = destx; + mo->y = desty; mo->radius = mo->target->radius; mo->height = mo->target->height; if (mo->eflags & MFE_VERTICALFLIP) - { - mo->z = mo->target->z + mo->target->height - mo->height - zoffs; - if (mo->scale == mo->old_scale) - mo->old_z = mo->target->old_z + mo->target->height - mo->height - zoffs; - else // Interpolate height scale changes - mo and mo->target have the same scales here, so don't interpolate them individually - mo->old_z = mo->target->old_z + FixedMul(mo->target->height - mo->height, FixedDiv(mo->old_scale, mo->scale)) - zoffs; - } + mo->z = (mo->target->z + mo->target->height - mo->height) - zoffs; else - { - mo->z = mo->target->z + zoffs; - mo->old_z = mo->target->old_z + zoffs; - } - if (!(mo->state->frame & FF_ANIMATE) && mo->state->var1) + mo->z = mo->target->z + zoffs; + if (mo->state->var1) P_SetUnderlayPosition(mo); else P_SetThingPosition(mo); diff --git a/src/r_things.c b/src/r_things.c index 0f93f7368..d23f86617 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1367,8 +1367,6 @@ static void R_ProjectSprite(mobj_t *thing) this_scale = interp.scale; // transform the origin point - if (thing->type == MT_OVERLAY) // Handle overlays - R_ThingOffsetOverlay(thing, &interp.x, &interp.y); tr_x = interp.x - viewx; tr_y = interp.y - viewy; @@ -2961,50 +2959,6 @@ void R_ClipSprites(void) } } -// Offsets MT_OVERLAY towards the camera at render-time - Works in splitscreen! -// The &x and &y arguments should be pre-interpolated, and will be modified -void R_ThingOffsetOverlay(mobj_t *thing, fixed_t *x, fixed_t *y) -{ - mobj_t *mobj = thing; - INT16 offset = 0; // Offset towards or away from the camera, and how much - fixed_t offsetscale = thing->scale; // Occasionally needs to be interpolated - angle_t viewingangle; - UINT8 looplimit = 255; // Prevent infinite loops - A chain of 255 connected overlays is enough for any sane use case - -#ifdef PARANOIA - if (P_MobjWasRemoved(mobj) || !x || !y) - I_Error("R_ThingOffsetOverlay: thing, x, or y is invalid"); -#endif - - do // Get the overlay's offset - { - // Does the overlay use FF_ANIMATE? If not, if var1 is non-zero, it's an underlay instead of an overlay - if (!(mobj->state->frame & FF_ANIMATE) && mobj->state->var1) - offset += 1; // Underlay below the target, away from the camera - else - offset -= 1; // Overlay on top of the target, towards the camera - - looplimit -= 1; - mobj = mobj->target; - } while (!P_MobjWasRemoved(mobj) && mobj->type == MT_OVERLAY && looplimit > 0); // Handle overlays following other overlays - - // Does the offset scale need to be interpolated? - if (thing->scale != thing->old_scale && R_UsingFrameInterpolation() && !paused) - { - interpmobjstate_t interp = {0}; - R_InterpolateMobjState(thing, rendertimefrac, &interp); - offsetscale = interp.scale; - } - - - // Get the angle from the camera to the X and Y coordinates - viewingangle = R_PointToAngle(*x, *y); - - // Finally, offset the X and Y coordinates towards or away from the camera - *x += P_ReturnThrustX(thing, viewingangle, FixedMul(offset * (FRACUNIT/4), offsetscale)); - *y += P_ReturnThrustY(thing, viewingangle, FixedMul(offset * (FRACUNIT/4), offsetscale)); -} - // // R_DrawMasked // diff --git a/src/r_things.h b/src/r_things.h index 820528757..e6470a952 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -191,8 +191,6 @@ void R_ClipSprites(void); UINT8 *R_GetSpriteTranslation(vissprite_t *vis); -void R_ThingOffsetOverlay (mobj_t *thing, fixed_t *outx, fixed_t *outy); - // ---------- // DRAW NODES // ---------- diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index 33aea5d20..2f8fa7b5d 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -246,7 +246,7 @@ typedef struct Uint16 samples; // number of samples Uint16 dummy; // 0 Uint8 data[0]; // data; -} dssfx_t; +} ATTRPACK dssfx_t; #ifdef _MSC_VER #pragma pack() diff --git a/src/tables.c b/src/tables.c index 2c7659871..71b74636c 100644 --- a/src/tables.c +++ b/src/tables.c @@ -26,7 +26,7 @@ #include "tables.h" -FUNCMATH FUNCINLINE inline unsigned SlopeDiv(unsigned num, unsigned den) +unsigned SlopeDiv(unsigned num, unsigned den) { unsigned ans; num <<= (FINE_FRACBITS-FRACBITS); @@ -37,7 +37,7 @@ FUNCMATH FUNCINLINE inline unsigned SlopeDiv(unsigned num, unsigned den) return ans <= SLOPERANGE ? ans : SLOPERANGE; } -FUNCMATH FUNCINLINE inline UINT64 SlopeDivEx(unsigned int num, unsigned int den) +UINT64 SlopeDivEx(unsigned int num, unsigned int den) { UINT64 ans; if (den < 512) @@ -367,7 +367,7 @@ boolean FV3_IntersectedPolygon(const vector3_t *vPoly, const vector3_t *vLine, c // // Rotates a vector around another vector // -FUNCINLINE inline void FV3_Rotate(vector3_t *rotVec, const vector3_t *axisVec, const angle_t angle) +void FV3_Rotate(vector3_t *rotVec, const vector3_t *axisVec, const angle_t angle) { // Rotate the point (x,y,z) around the vector (u,v,w) fixed_t ux = FixedMul(axisVec->x, rotVec->x);