- findplayer

This commit is contained in:
Christoph Oelckers 2020-10-23 17:44:45 +02:00
parent fa5b48d270
commit 6adc2f8e55
7 changed files with 38 additions and 37 deletions

View file

@ -1559,7 +1559,7 @@ bool queball(DDukeActor *actor, int pocket, int queball, int stripeball)
if (j > -64 && j < 64) if (j > -64 && j < 64)
{ {
int l; int l;
findplayer(sa, &l); findplayer(act2, &l);
if (x > l) break; if (x > l) break;
} }
} }
@ -1708,7 +1708,7 @@ void recon(DDukeActor *actor, int explosion, int firelaser, int attacksnd, int p
} }
int x; int x;
int p = findplayer(&actor->s, &x); int p = findplayer(actor, &x);
auto Owner = actor->GetOwner(); auto Owner = actor->GetOwner();
// 3 = findplayerz, 4 = shoot // 3 = findplayerz, 4 = shoot
@ -1902,7 +1902,7 @@ void reactor(DDukeActor* actor, int REACTOR, int REACTOR2, int REACTORBURNT, int
} }
int x; int x;
int p = findplayer(&actor->s, &x); int p = findplayer(actor, &x);
t[2]++; t[2]++;
if (t[2] == 4) t[2] = 0; if (t[2] == 4) t[2] = 0;
@ -2374,7 +2374,7 @@ bool bloodpool(DDukeActor* actor, bool puke, int TIRE)
makeitfall(actor); makeitfall(actor);
int x; int x;
int p = findplayer(&actor->s, &x); int p = findplayer(actor, &x);
s->z = actor->floorz - (FOURSLEIGHT); s->z = actor->floorz - (FOURSLEIGHT);
@ -2880,7 +2880,7 @@ void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6)
} }
if ((!checkstat || !statstate) && (ud.monsters_off == 0 && sc->floorpal == 0 && (sc->floorstat & 1) && rnd(8))) if ((!checkstat || !statstate) && (ud.monsters_off == 0 && sc->floorpal == 0 && (sc->floorstat & 1) && rnd(8)))
{ {
int p = findplayer(&actor->s, &x); int p = findplayer(actor, &x);
if (x < 20480) if (x < 20480)
{ {
j = s->ang; j = s->ang;
@ -3307,7 +3307,7 @@ void handle_se03(DDukeActor *actor)
int sh = s->hitag; int sh = s->hitag;
if (t[4] == 0) return; if (t[4] == 0) return;
int x, p = findplayer(&actor->s, &x); int x, p = findplayer(actor, &x);
int palvals = s->owner; // this type hijacks the Owner field!!! int palvals = s->owner; // this type hijacks the Owner field!!!
@ -3432,7 +3432,7 @@ void handle_se05(DDukeActor* actor, int FIRELASER)
int sh = s->hitag; int sh = s->hitag;
int j, l, m; int j, l, m;
int x, p = findplayer(&actor->s, &x); int x, p = findplayer(actor, &x);
if (x < 8192) if (x < 8192)
{ {
j = s->ang; j = s->ang;
@ -4480,7 +4480,7 @@ void handle_se27(DDukeActor* actor)
actor->tempang = s->ang; actor->tempang = s->ang;
p = findplayer(&actor->s, &x); p = findplayer(actor, &x);
if (ps[p].GetActor()->s.extra > 0 && myconnectindex == screenpeek) if (ps[p].GetActor()->s.extra > 0 && myconnectindex == screenpeek)
{ {
if (t[0] < 0) if (t[0] < 0)

View file

@ -1103,7 +1103,7 @@ static void movetripbomb(DDukeActor *actor)
if (actor->temp_data[0] < 32) if (actor->temp_data[0] < 32)
{ {
findplayer(&actor->s, &x); findplayer(actor, &x);
if (x > 768) actor->temp_data[0]++; if (x > 768) actor->temp_data[0]++;
else if (actor->temp_data[0] > 16) actor->temp_data[0]++; else if (actor->temp_data[0] > 16) actor->temp_data[0]++;
} }
@ -1295,7 +1295,7 @@ static void moveviewscreen(DDukeActor* actor)
else else
{ {
int x; int x;
findplayer(&actor->s, &x); findplayer(actor, &x);
if (x < 2048) if (x < 2048)
{ {
@ -1326,7 +1326,7 @@ static void movesidebolt(DDukeActor* actor)
int x; int x;
int sect = s->sectnum; int sect = s->sectnum;
auto p = findplayer(&actor->s, &x); auto p = findplayer(actor, &x);
if (x > 20480) return; if (x > 20480) return;
CLEAR_THE_BOLT2: CLEAR_THE_BOLT2:
@ -1369,7 +1369,7 @@ static void movebolt(DDukeActor *actor)
int x; int x;
int sect = s->sectnum; int sect = s->sectnum;
auto p = findplayer(&actor->s, &x); auto p = findplayer(actor, &x);
if (x > 20480) return; if (x > 20480) return;
if (t[3] == 0) if (t[3] == 0)
@ -1541,7 +1541,7 @@ void movestandables_d(void)
WATERBUBBLEMAKER)) WATERBUBBLEMAKER))
{ {
int x; int x;
int p = findplayer(&act->s, &x); int p = findplayer(act, &x);
execute(act, p, x); execute(act, p, x);
} }
} }
@ -1984,7 +1984,7 @@ void moveweapons_d(void)
case SHOTSPARK1: case SHOTSPARK1:
{ {
int x; int x;
int p = findplayer(&act->s, &x); int p = findplayer(act, &x);
execute(act, p, x); execute(act, p, x);
break; break;
} }
@ -2364,7 +2364,7 @@ static void greenslime(DDukeActor *actor)
} }
int x; int x;
int p = findplayer(&actor->s, &x); int p = findplayer(actor, &x);
if (x > 20480) if (x > 20480)
{ {
@ -2741,7 +2741,7 @@ static void flamethrowerflame(DDukeActor *actor)
int* t = &actor->temp_data[0]; int* t = &actor->temp_data[0];
int sect = s->sectnum; int sect = s->sectnum;
int x; int x;
int p = findplayer(&actor->s, &x); int p = findplayer(actor, &x);
execute(actor, p, x); execute(actor, p, x);
t[0]++; t[0]++;
if (sector[sect].lotag == 2) if (sector[sect].lotag == 2)
@ -2857,7 +2857,7 @@ static void heavyhbomb(DDukeActor *actor)
return; return;
} }
int p = findplayer(&actor->s, &x); int p = findplayer(actor, &x);
if (x < 1220) s->cstat &= ~257; if (x < 1220) s->cstat &= ~257;
else s->cstat |= 257; else s->cstat |= 257;
@ -3226,7 +3226,7 @@ void moveactors_d(void)
} }
// #endif // #endif
p = findplayer(&act->s, &x); p = findplayer(act, &x);
execute(act, p, x); execute(act, p, x);
} }
@ -3242,7 +3242,7 @@ void moveactors_d(void)
static void fireflyflyingeffect(DDukeActor *actor) static void fireflyflyingeffect(DDukeActor *actor)
{ {
auto t = &actor->temp_data[0]; auto t = &actor->temp_data[0];
int x, p = findplayer(&actor->s, &x); int x, p = findplayer(actor, &x);
execute(actor, p, x); execute(actor, p, x);
auto Owner = actor->GetOwner(); auto Owner = actor->GetOwner();
@ -3365,7 +3365,7 @@ void moveexplosions_d(void) // STATNUM 5
case INNERJAW: case INNERJAW:
case INNERJAW + 1: case INNERJAW + 1:
p = findplayer(&act->s, &x); p = findplayer(act, &x);
if (x < 512) if (x < 512)
{ {
SetPlayerPal(&ps[p], PalEntry(32, 32, 0, 0)); SetPlayerPal(&ps[p], PalEntry(32, 32, 0, 0));
@ -3441,7 +3441,7 @@ void moveexplosions_d(void) // STATNUM 5
case FORCERIPPLE: case FORCERIPPLE:
case TRANSPORTERSTAR: case TRANSPORTERSTAR:
case TRANSPORTERBEAM: case TRANSPORTERBEAM:
p = findplayer(&act->s, &x); p = findplayer(act, &x);
execute(act, p, x); execute(act, p, x);
continue; continue;
@ -3543,7 +3543,7 @@ static void handle_se28(DDukeActor* actor)
if (t[0] == 0) if (t[0] == 0)
{ {
int x; int x;
int p = findplayer(&actor->s, &x); int p = findplayer(actor, &x);
if (x > 15500) if (x > 15500)
return; return;
t[0] = 1; t[0] = 1;
@ -3593,7 +3593,7 @@ static void handle_se28(DDukeActor* actor)
fi.spawn(j, SMALLSMOKE); fi.spawn(j, SMALLSMOKE);
int x; int x;
int p = findplayer(&actor->s, &x); int p = findplayer(actor, &x);
auto psa = ps[p].GetActor(); auto psa = ps[p].GetActor();
x = ldist(psa, act2); x = ldist(psa, act2);
if (x < 768) if (x < 768)

View file

@ -940,7 +940,7 @@ static void movebolt(DDukeActor* actor)
int x; int x;
int sect = s->sectnum; int sect = s->sectnum;
auto p = findplayer(&actor->s, &x); auto p = findplayer(actor, &x);
if (x > 20480) return; if (x > 20480) return;
if (t[3] == 0) if (t[3] == 0)
@ -1091,7 +1091,7 @@ void movestandables_r(void)
CEILINGSTEAM)) CEILINGSTEAM))
{ {
int x; int x;
int p = findplayer(&act->s, &x); int p = findplayer(act, &x);
execute(act, p, x); execute(act, p, x);
} }
} }
@ -1563,7 +1563,7 @@ void moveweapons_r(void)
case SHOTSPARK1: case SHOTSPARK1:
{ {
int x; int x;
int p = findplayer(&proj->s, &x); int p = findplayer(proj, &x);
execute(proj, p, x); execute(proj, p, x);
continue; continue;
} }
@ -2499,7 +2499,7 @@ void rr_specialstats()
if (s->picnum == RRTILE296) if (s->picnum == RRTILE296)
{ {
int x; int x;
int p = findplayer(&act->s, &x); int p = findplayer(act, &x);
if (x < 2047) if (x < 2047)
{ {
DukeStatIterator it2(108); DukeStatIterator it2(108);
@ -2549,7 +2549,7 @@ static void heavyhbomb(DDukeActor *actor)
return; return;
} }
int p = findplayer(&actor->s, &x); int p = findplayer(actor, &x);
if (x < 1220) s->cstat &= ~257; if (x < 1220) s->cstat &= ~257;
else s->cstat |= 257; else s->cstat |= 257;
@ -3125,7 +3125,7 @@ void moveactors_r(void)
} }
// #endif // #endif
p = findplayer(&act->s,&x); p = findplayer(act,&x);
execute(act,p,x); execute(act,p,x);
if (deleteafterexecute) deletesprite(act); if (deleteafterexecute) deletesprite(act);
@ -3231,7 +3231,7 @@ void moveexplosions_r(void) // STATNUM 5
case INNERJAW: case INNERJAW:
case INNERJAW + 1: case INNERJAW + 1:
p = findplayer(&act->s, &x); p = findplayer(act, &x);
if (x < 512) if (x < 512)
{ {
SetPlayerPal(&ps[p], PalEntry(32, 32, 0, 0)); SetPlayerPal(&ps[p], PalEntry(32, 32, 0, 0));
@ -3346,7 +3346,7 @@ void moveexplosions_r(void) // STATNUM 5
case FORCERIPPLE: case FORCERIPPLE:
case TRANSPORTERSTAR: case TRANSPORTERSTAR:
case TRANSPORTERBEAM: case TRANSPORTERBEAM:
p = findplayer(&act->s, &x); p = findplayer(act, &x);
execute(act, p, x); execute(act, p, x);
continue; continue;

View file

@ -93,7 +93,7 @@ bool GameInterface::CanSave()
{ {
if (ud.recstat == 2 || gamestate != GS_LEVEL) return false; if (ud.recstat == 2 || gamestate != GS_LEVEL) return false;
auto &myplayer = ps[myconnectindex]; auto &myplayer = ps[myconnectindex];
return (sprite[myplayer.i].extra > 0); return (myplayer.GetActor()->s.extra > 0);
} }
bool GameInterface::StartGame(FNewGameStartup& gs) bool GameInterface::StartGame(FNewGameStartup& gs)

View file

@ -274,9 +274,9 @@ inline void getglobalz(int act)
getglobalz(&hittype[act]); getglobalz(&hittype[act]);
} }
inline int findplayer(DDukeActor* act, int* x) inline int findplayer(spritetype* act, int* x)
{ {
return findplayer(&act->s, x); return findplayer(&hittype[act - sprite], x);
} }
inline void operatesectors(int s, DDukeActor* i) inline void operatesectors(int s, DDukeActor* i)

View file

@ -142,7 +142,7 @@ void shootbloodsplat(int i, int p, int sx, int sy, int sz, int sa, int atwith, i
void breakwall(short newpn, short spr, short dawallnum); void breakwall(short newpn, short spr, short dawallnum);
int callsound(int sectnum,DDukeActor* snum); int callsound(int sectnum,DDukeActor* snum);
int hitasprite(int snum,short *hitSprite); int hitasprite(int snum,short *hitSprite);
int findplayer(const spritetype* s, int* dist); int findplayer(const DDukeActor* s, int* dist);
void operatejaildoors(int hitag); void operatejaildoors(int hitag);
void allignwarpelevators(void); void allignwarpelevators(void);
bool isablockdoor(int tileNum); bool isablockdoor(int tileNum);

View file

@ -211,10 +211,11 @@ bool isanearoperator(int lotag)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
int findplayer(const spritetype* s, int* d) int findplayer(const DDukeActor* actor, int* d)
{ {
short j, closest_player; short j, closest_player;
int x, closest; int x, closest;
auto s = &actor->s.pos;
if (ud.multimode < 2) if (ud.multimode < 2)
{ {
@ -228,7 +229,7 @@ int findplayer(const spritetype* s, int* d)
for (j = connecthead; j >= 0; j = connectpoint2[j]) for (j = connecthead; j >= 0; j = connectpoint2[j])
{ {
x = abs(ps[j].oposx - s->x) + abs(ps[j].oposy - s->y) + ((abs(ps[j].oposz - s->z + (28 << 8))) >> 4); x = abs(ps[j].oposx - s->x) + abs(ps[j].oposy - s->y) + ((abs(ps[j].oposz - s->z + (28 << 8))) >> 4);
if (x < closest && sprite[ps[j].i].extra > 0) if (x < closest && ps[j].GetActor()->s.extra > 0)
{ {
closest_player = j; closest_player = j;
closest = x; closest = x;