- changed furthestcanseepoint return value

This does not need to return a sector - the caller merely expects success or failure.
This commit is contained in:
Christoph Oelckers 2021-11-18 00:07:38 +01:00
parent 4823152107
commit d405da9195
3 changed files with 8 additions and 18 deletions

View file

@ -5098,16 +5098,17 @@ int furthestangle(DDukeActor *actor, int angs)
//---------------------------------------------------------------------------
//
//
// return value was changed to what its only caller really expects
//
//---------------------------------------------------------------------------
int furthestcanseepoint(DDukeActor *actor, DDukeActor* tosee, int* dax, int* day)
{
auto s = actor->s;
int j, hitsect, angincs;
int j, angincs;
int hx, hy, hz, d, da;//, d, cd, ca,tempx,tempy,cx,cy;
DDukeActor* dd;
sectortype* hitsect;
if ((actor->temp_data[0] & 63)) return -1;
@ -5118,21 +5119,21 @@ int furthestcanseepoint(DDukeActor *actor, DDukeActor* tosee, int* dax, int* day
auto ts = tosee->s;
for (j = ts->ang; j < (2048 + ts->ang); j += (angincs - (krand() & 511)))
{
hitscanw(ts->x, ts->y, ts->z - (16 << 8), ts->sectnum, bcos(j), bsin(j), 16384 - (krand() & 32767),
hitscan(ts->x, ts->y, ts->z - (16 << 8), ts->sectnum, bcos(j), bsin(j), 16384 - (krand() & 32767),
&hitsect, nullptr, &dd, &hx, &hy, &hz, CLIPMASK1);
d = abs(hx - ts->x) + abs(hy - ts->y);
da = abs(hx - s->x) + abs(hy - s->y);
if (d < da)
if (cansee(hx, hy, hz, hitsect, s->x, s->y, s->z - (16 << 8), s->sectnum))
if (cansee(hx, hy, hz, sectnum(hitsect), s->x, s->y, s->z - (16 << 8), s->sectnum))
{
*dax = hx;
*day = hy;
return hitsect;
return 1;
}
}
return -1;
return 0;
}
//---------------------------------------------------------------------------

View file

@ -197,17 +197,6 @@ inline void getzrange_ex(int x, int y, int z, int sectnum, int32_t* ceilz, Colli
florhit.setFromEngine(fh);
}
inline int hitscanw(int x, int y, int z, int sectnum, int32_t vx, int32_t vy, int32_t vz,
int* hitsect, int* hitwall, DDukeActor** hitspr, int* hitx, int* hity, int* hitz, uint32_t cliptype)
{
short hitsprt, hitsct, hitwal;
int res = ::hitscan(x, y, z, sectnum, vx, vy, vz, &hitsct, &hitwal, &hitsprt, hitx, hity, hitz, cliptype);
if (hitspr) *hitspr = hitsprt == -1 ? nullptr : &hittype[hitsprt];
if (hitsect) *hitsect = hitsct;
if (hitwall) *hitwall = hitwal;
return res;
}
inline int hitscan(int x, int y, int z, int sectnum, int32_t vx, int32_t vy, int32_t vz,
sectortype** hitsect, walltype** hitwall, DDukeActor** hitspr, int* hitx, int* hity, int* hitz, uint32_t cliptype)
{

View file

@ -1483,7 +1483,7 @@ static bool ifcansee(DDukeActor* actor, int pnum)
{
// search around for target player
// also modifies 'target' x&y if found.
j = furthestcanseepoint(actor, tosee, &actor->lastvx, &actor->lastvy) != -1;
j = furthestcanseepoint(actor, tosee, &actor->lastvx, &actor->lastvy);
}
else
{