- removed index based version of SpawnUser.

This commit is contained in:
Christoph Oelckers 2021-11-03 20:51:21 +01:00
parent 3a3c6a4395
commit cd8e8e4f67
4 changed files with 13 additions and 27 deletions

View file

@ -1840,7 +1840,7 @@ int NewStateGroup_(short SpriteNum, STATEp SpriteGroup[]);
int NewStateGroup_(USERp user, STATEp SpriteGroup[]);
int NewStateGroup(DSWActor* actor, STATEp SpriteGroup[]);
void SectorMidPoint(short sectnum, int *xmid, int *ymid, int *zmid);
USERp SpawnUser(short SpriteNum, short id, STATEp state);
//USERp SpawnUser(short SpriteNum, short id, STATEp state);
USERp SpawnUser(DSWActor* actor, short id, STATEp state);
short ActorFindTrack(DSWActor* actor, int8_t player_dir, int track_type, short *track_point_num, short *track_dir);

View file

@ -873,18 +873,16 @@ void change_actor_stat(DSWActor* actor, int stat, bool quick)
}
}
USERp
SpawnUser(short SpriteNum, short id, STATEp state)
USERp SpawnUser(DSWActor* actor, short id, STATEp state)
{
auto actor = &swActors[SpriteNum];
SPRITEp sp = &actor->s();
USERp u;
ASSERT(!Prediction);
User[SpriteNum].Clear(); // make sure to delete old, stale content first!
User[SpriteNum].Alloc();
User[actor->GetSpriteIndex()].Clear(); // make sure to delete old, stale content first!
User[actor->GetSpriteIndex()].Alloc();
u = actor->u();
PRODUCTION_ASSERT(u != nullptr);
@ -902,8 +900,8 @@ SpawnUser(short SpriteNum, short id, STATEp state)
u->targetActor = Player[0].Actor();
u->Radius = 220;
u->Sibling = -1;
u->SpriteP = &sprite[SpriteNum];
u->SpriteNum = SpriteNum;
u->SpriteP = &actor->s();
u->SpriteNum = actor->GetSpriteIndex();
u->WaitTics = 0;
u->OverlapZ = Z(4);
u->bounce = 0;
@ -935,12 +933,6 @@ SpawnUser(short SpriteNum, short id, STATEp state)
return u;
}
USERp
SpawnUser(DSWActor* actor, short id, STATEp state)
{
return SpawnUser(actor->GetSpriteIndex(), id, state);
}
SECT_USERp GetSectUser(short sectnum)
{
SECT_USERp sectu;
@ -960,7 +952,6 @@ SECT_USERp GetSectUser(short sectnum)
int16_t SpawnSprite(short stat, short id, STATEp state, short sectnum, int x, int y, int z, int init_ang, int vel)
{
SPRITEp sp;
int16_t SpriteNum;
USERp u;
if (sectnum < 0)
@ -968,13 +959,9 @@ int16_t SpawnSprite(short stat, short id, STATEp state, short sectnum, int x, in
ASSERT(!Prediction);
// PRODUCTION_ASSERT(sectnum >= 0 && sectnum < MAXSECTORS);
auto spawnedActor = InsertActor(sectnum, stat);
SpriteNum = COVERinsertsprite(sectnum, stat);
ASSERT(SpriteNum >= 0 && SpriteNum <= MAXSPRITES);
sp = &sprite[SpriteNum];
sp = &spawnedActor->s();
sp->pal = 0;
sp->x = x;
@ -982,7 +969,7 @@ int16_t SpawnSprite(short stat, short id, STATEp state, short sectnum, int x, in
sp->z = z;
sp->cstat = 0;
u = SpawnUser(SpriteNum, id, state);
u = SpawnUser(spawnedActor, id, state);
// be careful State can be nullptr
if (u->State)
@ -1006,7 +993,7 @@ int16_t SpawnSprite(short stat, short id, STATEp state, short sectnum, int x, in
sp->yoffset = 0;
sp->clipdist = 0;
return SpriteNum;
return spawnedActor->GetSpriteIndex();
}
DSWActor* SpawnActor(short stat, short id, STATEp state, short sectnum, int x, int y, int z, int ang, int vel)

View file

@ -1133,7 +1133,6 @@ SetupSectorObject(short sectnum, short tag)
while (auto actor = it.Next())
{
SPRITEp sp = &actor->s();
int SpriteNum = actor->GetSpriteIndex();
if (sp->statnum == STAT_ST1)
{
@ -1193,7 +1192,7 @@ SetupSectorObject(short sectnum, short tag)
{
USERp u;
change_actor_stat(actor, STAT_NO_STATE);
u = SpawnUser(SpriteNum, 0, nullptr);
u = SpawnUser(actor, 0, nullptr);
u->ActorActionFunc = nullptr;
}
break;

View file

@ -11287,7 +11287,7 @@ AddSpriteToSectorObject(short SpriteNum, SECTOR_OBJECTp sop)
// make sure it has a user
if (!u)
{
u = SpawnUser(SpriteNum, 0, nullptr);
u = SpawnUser(actor, 0, nullptr);
}
// find a free place on this list
@ -11838,7 +11838,7 @@ DoFireball(DSWActor* actor)
if (TEST(hsp->extra, SPRX_BURNABLE))
{
if (!hu)
hu = SpawnUser(short(sp - sprite), hsp->picnum, nullptr);
hu = SpawnUser(&swActors[short(sp - sprite)], hsp->picnum, nullptr);
SpawnFireballFlames(Weapon, short(hsp - sprite));
hit_burn = true;
}