- updatesectorz with DVector3.

This commit is contained in:
Christoph Oelckers 2022-08-17 19:03:13 +02:00
parent 643d3e7eba
commit 21944d5ac2
2 changed files with 9 additions and 2 deletions

View file

@ -124,6 +124,13 @@ inline void updatesectorz(int x, int y, int z, sectortype** const sectp)
*sectp = sectno == -1 ? nullptr : &sector[sectno];
}
inline void updatesectorz(const DVector3& pos, sectortype** const sectp)
{
int sectno = *sectp ? sector.IndexOf(*sectp) : -1;
updatesectorz(int(pos.X * worldtoint), int(pos.Y * worldtoint), int(pos.Z * zworldtoint), &sectno);
*sectp = sectno == -1 ? nullptr : &sector[sectno];
}
inline void updatesectorneighbor(int x, int y, sectortype** const sect, int maxDistance = MAXUPDATESECTORDIST)
{
int sectno = *sect? sector.IndexOf(*sect) : -1;

View file

@ -816,13 +816,13 @@ void SpawnZombie2(DSWActor* actor)
if (FAF_ConnectArea(actor->sector()))
{
auto newsect = actor->sector();
updatesectorz(actor->int_pos().X, actor->int_pos().Y, actor->int_pos().Z + Z(10), &newsect);
updatesectorz(actor->spr.pos.plusZ(10), &newsect);
if (SectorIsUnderwaterArea(newsect))
return;
}
auto actorNew = SpawnActor(STAT_ENEMY, ZOMBIE_RUN_R0, s_ZombieRun[0], actor->sector(), actor->int_pos().X, actor->int_pos().Y, actor->int_pos().Z, actor->int_ang(), 0);
auto actorNew = SpawnActor(STAT_ENEMY, ZOMBIE_RUN_R0, s_ZombieRun[0], actor->sector(), actor->spr.pos, actor->spr.angle, 0);
actorNew->user.Counter3 = 0;
SetOwner(ownerActor, actorNew);
actorNew->spr.pal = actorNew->user.spal = ownerActor->user.spal;