- sector object sprite list

This commit is contained in:
Christoph Oelckers 2021-11-02 18:45:21 +01:00
parent 2a7d0e6fe3
commit 74fce3bf58
6 changed files with 76 additions and 79 deletions

View file

@ -1693,6 +1693,8 @@ struct SECTOR_OBJECTstruct
vec3_t pmid;
};
DSWActor* so_actors[MAX_SO_SPRITE]; // hold the actors of the object
int vel, // velocity
vel_tgt, // target velocity
player_xoff, // player x offset from the xmid
@ -1722,7 +1724,6 @@ struct SECTOR_OBJECTstruct
flags;
short sector[MAX_SO_SECTOR], // hold the sector numbers of the sector object
sp_num[MAX_SO_SPRITE], // hold the sprite numbers of the object
xorig[MAX_SO_POINTS], // save the original x & y location of each wall so it can be
yorig[MAX_SO_POINTS], // refreshed
sectnum, // current secnum of midpoint

View file

@ -5027,9 +5027,9 @@ void DoPlayerBeginOperate(PLAYERp pp)
DoPlayerOperateMatch(pp, true);
// look for gun before trying to using it
for (i = 0; sop->sp_num[i] != -1; i++)
for (i = 0; sop->so_actors[i] != nullptr; i++)
{
if (sprite[sop->sp_num[i]].statnum == STAT_SO_SHOOT_POINT)
if (sop->so_actors[i]->s().statnum == STAT_SO_SHOOT_POINT)
{
SET(sop->flags, SOBJ_HAS_WEAPON);
break;
@ -5113,9 +5113,9 @@ void DoPlayerBeginRemoteOperate(PLAYERp pp, SECTOR_OBJECTp sop)
DoPlayerOperateMatch(pp, true);
// look for gun before trying to using it
for (i = 0; sop->sp_num[i] != -1; i++)
for (i = 0; sop->so_actors[i] != nullptr; i++)
{
if (sprite[sop->sp_num[i]].statnum == STAT_SO_SHOOT_POINT)
if (sop->so_actors[i]->s().statnum == STAT_SO_SHOOT_POINT)
{
SET(sop->flags, SOBJ_HAS_WEAPON);
break;

View file

@ -634,18 +634,14 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, SECTOR_OBJECTstruc
}
if (arc.BeginObject(keyname))
{
int sp_cnt;
for (sp_cnt = 0; w.sp_num[sp_cnt] != -1 && sp_cnt < (int)countof(w.sp_num); sp_cnt++) {}
arc("num_sectors", w.num_sectors, def->num_sectors)
("num_walls", w.num_walls, def->num_walls)
("num_sp", sp_cnt)
("clipbox_num", w.clipbox_num, def->clipbox_num)
.Array("sectp", w.sectp, def->sectp, w.num_sectors)
.Array("sector", w.sector, def->sector, w.num_sectors) // is this really different from sectp?
.Array("zorig_floor", w.zorig_floor, def->zorig_floor, w.num_sectors)
.Array("zorig_ceiling", w.zorig_ceiling, def->zorig_ceiling, w.num_sectors)
.Array("sp_num", w.sp_num, def->sp_num, countof(w.sp_num))
.Array("sp_num", w.so_actors, def->so_actors, countof(w.so_actors))
.Array("xorig", w.xorig, def->xorig, w.num_walls)
.Array("yorig", w.yorig, def->yorig, w.num_walls)
("controller", w.controller, def->controller)

View file

@ -674,9 +674,9 @@ void KillSprite(int16_t SpriteNum)
for (sop = SectorObject; sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++)
{
for (sn = 0; sop->sp_num[sn] != -1; sn++)
for (sn = 0; sop->so_actors[sn] != nullptr; sn++)
{
if (sop->sp_num[sn] == SpriteNum)
if (sop->so_actors[sn] == actor)
{
FoundSpriteNdx = sn;
}
@ -686,13 +686,13 @@ void KillSprite(int16_t SpriteNum)
{
// back up sn so it points to the last valid sprite num
sn--;
ASSERT(sop->sp_num[sn] >= 0);
ASSERT(sop->so_actors[sn] != nullptr);
so_stopspriteinterpolation(sop, actor);
// replace the one to be deleted with the last ndx
sop->sp_num[FoundSpriteNdx] = sop->sp_num[sn];
sop->so_actors[FoundSpriteNdx] = sop->so_actors[sn];
// the last ndx is not -1
sop->sp_num[sn] = -1;
sop->so_actors[sn] = nullptr;
break;
}

View file

@ -963,15 +963,13 @@ SectorObjectSetupBounds(SECTOR_OBJECTp sop)
// place all sprites on list
int sn;
for (sn = 0; sn < (int)SIZ(sop->sp_num); sn++)
for (sn = 0; sn < (int)SIZ(sop->so_actors); sn++)
{
if (sop->sp_num[sn] == -1)
if (sop->so_actors[sn] == nullptr)
break;
}
ASSERT(sn < (int)SIZ(sop->sp_num) - 1);
sop->sp_num[sn] = itActor->GetSpriteIndex();
sop->so_actors[sn] = itActor;
so_setspriteinterpolation(sop, itActor);
@ -1005,10 +1003,10 @@ cont:
int zmid = -9999999;
// choose the lowest sprite for the zmid
for (i = 0; sop->sp_num[i] != -1; i++)
for (i = 0; sop->so_actors[i] != nullptr; i++)
{
sp = &sprite[sop->sp_num[i]];
u = User[sop->sp_num[i]].Data();
sp = &sop->so_actors[i]->s();
u = sop->so_actors[i]->u();
if (sp->z > zmid)
zmid = sp->z;
@ -1018,10 +1016,10 @@ cont:
sop->zmid = zmid;
for (i = 0; sop->sp_num[i] != -1; i++)
{
sp = &sprite[sop->sp_num[i]];
u = User[sop->sp_num[i]].Data();
for (i = 0; sop->so_actors[i] != nullptr; i++)
{
sp = &sop->so_actors[i]->s();
u = sop->so_actors[i]->u();
u->sz = sop->zmid - sp->z;
}
@ -1056,6 +1054,7 @@ SetupSectorObject(short sectnum, short tag)
void DoAutoTurretObject(SECTOR_OBJECTp sop);
memset(sop->sectp, 0, sizeof(sop->sectp));
memset(sop->so_actors, 0, sizeof(sop->so_actors));
sop->crush_z = 0;
sop->drive_angspeed = 0;
sop->drive_angslide = 0;
@ -1794,11 +1793,11 @@ PlayerPart:
}
}
for (i = 0; sop->sp_num[i] != -1; i++)
{
sp = &sprite[sop->sp_num[i]];
u = User[sop->sp_num[i]].Data();
auto actor = &swActors[u->SpriteNum];
for (i = 0; sop->so_actors[i] != nullptr; i++)
{
auto actor = sop->so_actors[i];
sp = &actor->s();
u = actor->u();
// if its a player sprite || NOT attached
if (!u || u->PlayerP || !TEST(u->Flags, SPR_SO_ATTACHED))
@ -1877,14 +1876,14 @@ PlayerPart:
// Does not necessarily move with the sector so must accout for
// moving across sectors
if (sop->xmid < MAXSO) // special case for operating SO's
setspritez(sop->sp_num[i], &sp->pos);
SetActorZ(sop->so_actors[i], &sp->pos);
}
u->oangdiff += getincangle(oldang, sp->ang);
if (TEST(sp->extra, SPRX_BLADE))
{
DoBladeDamage(sop->sp_num[i]);
DoBladeDamage(sop->so_actors[i]->GetSpriteIndex());
}
}
@ -2026,9 +2025,9 @@ void KillSectorObjectSprites(SECTOR_OBJECTp sop)
USERp u;
int i;
for (i = 0; sop->sp_num[i] != -1; i++)
for (i = 0; sop->so_actors[i] != nullptr; i++)
{
auto actor = &swActors[sop->sp_num[i]];
auto actor = sop->so_actors[i];
sp = &actor->s();
u = actor->u();
@ -2043,7 +2042,7 @@ void KillSectorObjectSprites(SECTOR_OBJECTp sop)
}
// clear the list
sop->sp_num[0] = -1;
sop->so_actors[0] = nullptr;
}
void UpdateSectorObjectSprites(SECTOR_OBJECTp sop)
@ -2051,11 +2050,12 @@ void UpdateSectorObjectSprites(SECTOR_OBJECTp sop)
SPRITEp sp;
int i;
for (i = 0; sop->sp_num[i] != -1; i++)
{
sp = &sprite[sop->sp_num[i]];
for (i = 0; sop->so_actors[i] != nullptr; i++)
{
auto actor = sop->so_actors[i];
sp = &actor->s();
setspritez(sop->sp_num[i], &sp->pos);
SetActorZ(actor, &sp->pos);
}
}
@ -2923,7 +2923,6 @@ void
DoAutoTurretObject(SECTOR_OBJECTp sop)
{
auto actor = sop->sp_child;
SPRITEp shootp;
USERp u = actor->u();
short delta_ang;
int diff;
@ -2945,12 +2944,13 @@ DoAutoTurretObject(SECTOR_OBJECTp sop)
if (MoveSkip2 == 0)
{
for (i = 0; sop->sp_num[i] != -1; i++)
for (i = 0; sop->so_actors[i] != nullptr; i++)
{
if (sprite[sop->sp_num[i]].statnum == STAT_SO_SHOOT_POINT)
{
shootp = &sprite[sop->sp_num[i]];
auto sActor = sop->so_actors[i];
auto shootp = &sActor->s();
if (shootp->statnum == STAT_SO_SHOOT_POINT)
{
if (!FAFcansee(shootp->x, shootp->y, shootp->z-Z(4), shootp->sectnum,
u->targetActor->s().x, u->targetActor->s().y, ActorUpper(u->targetActor), u->targetActor->s().sectnum))
{
@ -2970,13 +2970,13 @@ DoAutoTurretObject(SECTOR_OBJECTp sop)
if (u->Counter == 0)
{
shootp = nullptr;
for (i = 0; sop->sp_num[i] != -1; i++)
{
if (sprite[sop->sp_num[i]].statnum == STAT_SO_SHOOT_POINT)
{
shootp = &sprite[sop->sp_num[i]];
for (i = 0; sop->so_actors[i] != nullptr; i++)
{
auto sActor = sop->so_actors[i];
auto shootp = &sActor->s();
if (shootp->statnum == STAT_SO_SHOOT_POINT)
{
if (SP_TAG5(shootp))
u->Counter = SP_TAG5(shootp);
else

View file

@ -11335,14 +11335,14 @@ AddSpriteToSectorObject(short SpriteNum, SECTOR_OBJECTp sop)
}
// find a free place on this list
for (sn = 0; sn < SIZ(sop->sp_num); sn++)
for (sn = 0; sn < SIZ(sop->so_actors); sn++)
{
if (sop->sp_num[sn] == -1)
if (sop->so_actors[sn] == nullptr)
break;
}
ASSERT(sn < SIZ(sop->sp_num) - 1);
sop->sp_num[sn] = actor->GetSpriteIndex();
if (sn >= SIZ(sop->so_actors) - 1) return 0;
sop->so_actors[sn] = actor;
so_setspriteinterpolation(sop, actor);
SET(u->Flags, SPR_ON_SO_SECTOR|SPR_SO_ATTACHED);
@ -11362,7 +11362,6 @@ SpawnBigGunFlames(int16_t Weapon, int16_t Operator, SECTOR_OBJECTp sop)
USERp u;
SPRITEp exp;
USERp eu;
short explosion;
unsigned sn;
bool smallflames = false;
@ -11375,13 +11374,13 @@ SpawnBigGunFlames(int16_t Weapon, int16_t Operator, SECTOR_OBJECTp sop)
sp = &sprite[Weapon];
u = User[Weapon].Data();
explosion = SpawnSprite(STAT_MISSILE, MICRO_EXP, s_BigGunFlame, sp->sectnum,
auto expActor = SpawnActor(STAT_MISSILE, MICRO_EXP, s_BigGunFlame, sp->sectnum,
sp->x, sp->y, sp->z, sp->ang, 0);
exp = &sprite[explosion];
eu = User[explosion].Data();
exp = &expActor->s();
eu = expActor->u();
exp->hitag = LUMINOUS; //Always full brightness
SetOwner(Operator, explosion);
SetOwner(&swActors[Operator], expActor);
exp->shade = -40;
if (smallflames)
{
@ -11402,15 +11401,16 @@ SpawnBigGunFlames(int16_t Weapon, int16_t Operator, SECTOR_OBJECTp sop)
SET(exp->cstat, CSTAT_SPRITE_YFLIP);
// place all sprites on list
for (sn = 0; sn < SIZ(sop->sp_num); sn++)
{
if (sop->sp_num[sn] == -1)
break;
}
for (sn = 0; sn < SIZ(sop->so_actors); sn++)
{
if (sop->so_actors[sn] == nullptr)
break;
}
ASSERT(sn < SIZ(sop->sp_num) - 1);
sop->sp_num[sn] = explosion;
so_setspriteinterpolation(sop, &swActors[explosion]);
if (sn >= SIZ(sop->so_actors) - 1) return -1;
sop->so_actors[sn] = expActor;
so_setspriteinterpolation(sop, expActor);
SET(eu->Flags, TEST(u->Flags, SPR_ON_SO_SECTOR|SPR_SO_ATTACHED));
@ -11431,7 +11431,7 @@ SpawnBigGunFlames(int16_t Weapon, int16_t Operator, SECTOR_OBJECTp sop)
eu->sy = u->sy;
eu->sz = u->sz;
return explosion;
return expActor->GetSpriteIndex();
}
int
@ -18260,12 +18260,12 @@ InitSobjGun(PLAYERp pp)
SPRITEp sp;
bool first = false;
for (i = 0; pp->sop->sp_num[i] != -1; i++)
for (i = 0; pp->sop->so_actors[i] != nullptr; i++)
{
if (sprite[pp->sop->sp_num[i]].statnum == STAT_SO_SHOOT_POINT)
auto actor = pp->sop->so_actors[i];
sp = &actor->s();
if (sp->statnum == STAT_SO_SHOOT_POINT)
{
sp = &sprite[pp->sop->sp_num[i]];
// match when firing
if (SP_TAG2(sp))
{
@ -18543,12 +18543,12 @@ InitTurretMgun(SECTOR_OBJECTp sop)
PlaySound(DIGI_BOATFIRE, &sop->pmid, v3df_dontpan|v3df_doppler);
for (i = 0; sop->sp_num[i] != -1; i++)
for (i = 0; sop->so_actors[i] != nullptr; i++)
{
if (sprite[sop->sp_num[i]].statnum == STAT_SO_SHOOT_POINT)
auto actor = sop->so_actors[i];
sp = &actor->s();
if (sp->statnum == STAT_SO_SHOOT_POINT)
{
sp = &sprite[sop->sp_num[i]];
nx = sp->x;
ny = sp->y;
daz = nz = sp->z;
@ -18605,7 +18605,7 @@ InitTurretMgun(SECTOR_OBJECTp sop)
if (RANDOM_P2(1024) < 400)
{
InitTracerAutoTurret(sop->sp_num[i], -1,
InitTracerAutoTurret(sop->so_actors[i]->GetSpriteIndex(), -1,
xvect>>4, yvect>>4, zvect>>4);
}