Skip to content

Commit

Permalink
Heretic/Doom alpha sight checks with fixes by RH
Browse files Browse the repository at this point in the history
  • Loading branch information
viciious committed Jan 26, 2024
1 parent 6137e06 commit 6748293
Show file tree
Hide file tree
Showing 5 changed files with 357 additions and 142 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ OBJS = \
p_base.o \
p_user.o \
p_sight.o \
p_sight2.o \
p_shoot.o \
p_move.o \
p_change.o \
Expand Down
45 changes: 45 additions & 0 deletions p_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,51 @@ typedef struct

void P_SlideMove (pslidemove_t *sm);



/*
===============================================================================
P_SIGHT
===============================================================================
*/

#define MAXINTERCEPTS 32

// CALICO: removed type punning by bringing back intercept_t
typedef struct
{
union
{
mobj_t* mo;
line_t* line;
} d;
fixed_t frac;
sector_t *front, *back; // a line if front != NULL
} intercept_t;

typedef struct
{
int16_t x, y, dx, dy;
} i16divline_t;

typedef struct
{
int numintercepts;
intercept_t intercepts[MAXINTERCEPTS];

fixed_t sightzstart; // eye z of looker
fixed_t topslope, bottomslope; // slopes to top and bottom of target

i16divline_t strace; // from t1 to t2
fixed_t t2x, t2y;
} sightWork_t;

boolean PTR_SightTraverse(sightWork_t *sw, intercept_t * in);
boolean PS_SightBlockLinesIterator(sightWork_t *sw, int x, int y);
boolean PS_SightPathTraverse(sightWork_t *sw);

#endif /* __P_LOCAL__ */


24 changes: 6 additions & 18 deletions p_shoot.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,6 @@
// tracing. If no thing is targeted along the entire range, the first line
// that blocks the midpoint of the shootdiv will be hit.

// CALICO: removed type punning by bringing back intercept_t
typedef struct intercept_s
{
union ptr_u
{
mobj_t* mo;
line_t* line;
} d;
fixed_t frac;
boolean isaline;
} intercept_t;

typedef struct
{
mobj_t *shooter;
Expand Down Expand Up @@ -256,7 +244,7 @@ static boolean PA_ShootThing(shootWork_t *sw, mobj_t *th, fixed_t interceptfrac)
//
// Process an intercept
//
#define COPY_INTERCEPT(dst,src) do { (dst)->d.line = (src)->d.line, (dst)->frac = (src)->frac, (dst)->isaline = (src)->isaline; } while(0)
#define COPY_INTERCEPT(dst,src) do { (dst)->d.line = (src)->d.line, (dst)->frac = (src)->frac, (dst)->front = (src)->front; } while(0)
static boolean PA_DoIntercept(shootWork_t *sw, intercept_t *in)
{
intercept_t temp;
Expand All @@ -271,7 +259,7 @@ static boolean PA_DoIntercept(shootWork_t *sw, intercept_t *in)
if(in->frac == 0 || in->frac >= FRACUNIT)
return true;

if(in->isaline)
if(in->front)
return PA_ShootLine(sw, in->d.line, in->frac);
return PA_ShootThing(sw, in->d.mo, in->frac);
}
Expand Down Expand Up @@ -320,7 +308,7 @@ static boolean PA_CrossSubsector(shootWork_t *sw, int bspnum)
continue;

in.d.mo = thing;
in.isaline = false;
in.front = NULL;
in.frac = frac;

if(!PA_DoIntercept(sw, &in))
Expand Down Expand Up @@ -353,7 +341,7 @@ static boolean PA_CrossSubsector(shootWork_t *sw, int bspnum)
continue;

in.d.line = line;
in.isaline = true;
in.front = (void*)1;
in.frac = frac;

if(!PA_DoIntercept(sw, &in))
Expand Down Expand Up @@ -436,7 +424,7 @@ void P_Shoot2(lineattack_t *la)
// cross everything
sw.old_intercept.d.line = NULL;
sw.old_intercept.frac = 0;
sw.old_intercept.isaline = false;
sw.old_intercept.front = NULL;

PA_CrossBSPNode(&sw, numnodes - 1);

Expand All @@ -445,7 +433,7 @@ void P_Shoot2(lineattack_t *la)
{
intercept_t in;
in.d.mo = NULL;
in.isaline = false;
in.front = NULL;
in.frac = FRACUNIT;
PA_DoIntercept(&sw, &in);
}
Expand Down
Loading

0 comments on commit 6748293

Please sign in to comment.