-floatified findplayer and findotherplayer.

This commit is contained in:
Christoph Oelckers 2022-09-12 18:26:27 +02:00
parent 68bc812681
commit 13fc658c1f
3 changed files with 25 additions and 23 deletions

View file

@ -384,7 +384,7 @@ void movedummyplayers(void)
void moveplayers(void)
{
int otherx;
double other;
DukeStatIterator iti(STAT_PLAYER);
while (auto act = iti.Next())
@ -404,14 +404,14 @@ void moveplayers(void)
else
{
if (ud.multimode > 1)
otherp = findotherplayer(pn, &otherx);
otherp = findotherplayer(pn, &other);
else
{
otherp = pn;
otherx = 0;
other = 0;
}
execute(act, pn, otherx);
execute(act, pn, other * worldtoint);
if (ud.multimode > 1)
{
@ -420,7 +420,7 @@ void moveplayers(void)
{
if (act->spr.yrepeat > 32 && psp->spr.yrepeat < 32)
{
if (otherx < 1400 && p->knee_incs == 0)
if (other < 1400/16. && p->knee_incs == 0)
{
p->knee_incs = 1;
p->weapon_pos = -1;
@ -501,7 +501,7 @@ void moveplayers(void)
}
else
{
act->set_int_ang(2047 - (p->angle.ang.Buildang()));
act->spr.angle = DAngle360 - minAngle - p->angle.ang;
SetActor(act, act->spr.pos);
}
}
@ -3066,7 +3066,7 @@ void handle_se30(DDukeActor *actor, int JIBS6)
DukeSectIterator it(Owner->sector());
while (auto a2 = it.Next())
{
if (a2->spr.statnum == 1 && badguy(a2) && a2->spr.picnum != SECTOREFFECTOR && a2->spr.picnum != LOCATORS)
if (a2->spr.statnum == STAT_ACTOR && badguy(a2) && a2->spr.picnum != SECTOREFFECTOR && a2->spr.picnum != LOCATORS)
{
// if(a2->spr.sector != actor->spr.sector)
{
@ -4127,7 +4127,7 @@ void handle_se20(DDukeActor* actor)
DukeSectIterator it(actor->sector());
while (auto a2 = it.Next())
{
if (a2->spr.statnum != 3 && a2->vel.Z == 0)
if (a2->spr.statnum != STAT_EFFECTOR && a2->vel.Z == 0)
{
actor->spr.pos += vec;
if (a2->sector()->floorstat & CSTAT_SECTOR_SLOPE)

View file

@ -130,7 +130,7 @@ void playerAimDown(int snum, ESyncBits actions);
void tracers(int x1, int y1, int z1, int x2, int y2, int z2, int n);
DDukeActor* aim(DDukeActor* s, int aang);
void checkweapons(player_struct* const p);
int findotherplayer(int p, int* d);
int findotherplayer(int p, double* d);
void quickkill(player_struct* p);
int setpal(player_struct* p);
int madenoise(int playerNum);
@ -140,11 +140,13 @@ void shootbloodsplat(DDukeActor* i, int p, int sx, int sy, int sz, int sa, int a
void breakwall(int newpn, DDukeActor* spr, walltype* dawallnum);
int callsound(sectortype* sectnum,DDukeActor* snum, bool endstate = false);
int hitasprite(DDukeActor* snum,DDukeActor **hitSprite);
int findplayer(const DDukeActor* s, int* dist);
inline int findplayer(const DDukeActor* s, double* dist)
int findplayer(const DDukeActor* s, double* dist);
inline int findplayer(const DDukeActor* s, int* dist)
{
int dd, p = findplayer(s, &dd);
*dist = dd * inttoworld;
double dd;
int p = findplayer(s, &dd);
*dist = dd * worldtoint;
return p;
}
void operatejaildoors(int hitag);

View file

@ -219,24 +219,24 @@ bool isanearoperator(int lotag)
//
//---------------------------------------------------------------------------
int findplayer(const DDukeActor* actor, int* d)
int findplayer(const DDukeActor* actor, double* d)
{
int j, closest_player;
int x, closest;
const auto s = actor->int_pos();
int x;
const auto s = actor->spr.pos;
if (ud.multimode < 2)
{
if (d) *d = abs(ps[myconnectindex].player_int_opos().X - s.X) + abs(ps[myconnectindex].player_int_opos().Y - s.Y) + ((abs(ps[myconnectindex].player_int_opos().Z - s.Z + (28 << 8))) >> 4);
if (d) *d = abs(ps[myconnectindex].opos.X - s.X) + abs(ps[myconnectindex].opos.Y - s.Y) + abs(ps[myconnectindex].opos.Z - s.Z + 28);
return myconnectindex;
}
closest = 0x7fffffff;
double closest = 0x7fffffff;
closest_player = 0;
for (j = connecthead; j >= 0; j = connectpoint2[j])
{
x = abs(ps[j].player_int_opos().X - s.X) + abs(ps[j].player_int_opos().Y - s.Y) + ((abs(ps[j].player_int_opos().Z - s.Z + (28 << 8))) >> 4);
x = abs(ps[j].opos.X - s.X) + abs(ps[j].opos.Y - s.Y) + abs(ps[j].opos.Z - s.Z + 28);
if (x < closest && ps[j].GetActor()->spr.extra > 0)
{
closest_player = j;
@ -254,18 +254,18 @@ int findplayer(const DDukeActor* actor, int* d)
//
//---------------------------------------------------------------------------
int findotherplayer(int p, int* d)
int findotherplayer(int p, double* d)
{
int j, closest_player;
int x, closest;
int x;
closest = 0x7fffffff;
double closest = 0x7fffffff;
closest_player = p;
for (j = connecthead; j >= 0; j = connectpoint2[j])
if (p != j && ps[j].GetActor()->spr.extra > 0)
{
x = abs(ps[j].player_int_opos().X - ps[p].player_int_pos().X) + abs(ps[j].player_int_opos().Y - ps[p].player_int_pos().Y) + (abs(ps[j].player_int_opos().Z - ps[p].player_int_pos().Z) >> 4);
x = abs(ps[j].opos.X - ps[p].pos.X) + abs(ps[j].opos.Y - ps[p].pos.Y) + abs(ps[j].opos.Z - ps[p].pos.Z);
if (x < closest)
{