- StarQueue

This commit is contained in:
Christoph Oelckers 2021-11-02 22:05:24 +01:00
parent bd161f155c
commit dfc557e0ec
3 changed files with 17 additions and 21 deletions

View file

@ -2352,14 +2352,13 @@ int DoPlayerGrabStar(PLAYERp pp)
{ {
SPRITEp sp = nullptr; SPRITEp sp = nullptr;
int i; int i;
extern short StarQueue[MAX_STAR_QUEUE];
// MUST check exact z's of each star or it will never work // MUST check exact z's of each star or it will never work
for (i = 0; i < MAX_STAR_QUEUE; i++) for (i = 0; i < MAX_STAR_QUEUE; i++)
{ {
if (StarQueue[i] >= 0) if (StarQueue[i] != nullptr)
{ {
sp = &sprite[StarQueue[i]]; sp = &StarQueue[i]->s();
if (FindDistance3D(sp->x - pp->posx, sp->y - pp->posy, sp->z - pp->posz + Z(12)) < 500) if (FindDistance3D(sp->x - pp->posx, sp->y - pp->posy, sp->z - pp->posz + Z(12)) < 500)
{ {
@ -2373,8 +2372,8 @@ int DoPlayerGrabStar(PLAYERp pp)
// Pull a star out of wall and up your ammo // Pull a star out of wall and up your ammo
PlayerUpdateAmmo(pp, WPN_STAR, 1); PlayerUpdateAmmo(pp, WPN_STAR, 1);
PlaySound(DIGI_ITEM, sp, v3df_none); PlaySound(DIGI_ITEM, sp, v3df_none);
KillSprite(StarQueue[i]); KillActor(StarQueue[i]);
StarQueue[i] = -1; StarQueue[i] = nullptr;
if (TEST(pp->WpnFlags, BIT(WPN_STAR))) if (TEST(pp->WpnFlags, BIT(WPN_STAR)))
return true; return true;
SET(pp->WpnFlags, BIT(WPN_STAR)); SET(pp->WpnFlags, BIT(WPN_STAR));

View file

@ -74,7 +74,7 @@ int ShellCount = 0;
//short Zombies = 0; //short Zombies = 0;
short StarQueueHead=0; short StarQueueHead=0;
short StarQueue[MAX_STAR_QUEUE]; DSWActor* StarQueue[MAX_STAR_QUEUE];
short HoleQueueHead=0; short HoleQueueHead=0;
short HoleQueue[MAX_HOLE_QUEUE]; short HoleQueue[MAX_HOLE_QUEUE];
short WallBloodQueueHead=0; short WallBloodQueueHead=0;
@ -19993,8 +19993,8 @@ void SpriteQueueDelete(DSWActor* actor)
int SpriteNum = actor->GetSpriteIndex(); int SpriteNum = actor->GetSpriteIndex();
for (i = 0; i < MAX_STAR_QUEUE; i++) for (i = 0; i < MAX_STAR_QUEUE; i++)
if (StarQueue[i] == SpriteNum) if (StarQueue[i] == actor)
StarQueue[i] = -1; StarQueue[i] = nullptr;
for (i = 0; i < MAX_HOLE_QUEUE; i++) for (i = 0; i < MAX_HOLE_QUEUE; i++)
if (HoleQueue[i] == SpriteNum) if (HoleQueue[i] == SpriteNum)
@ -20030,7 +20030,7 @@ void QueueReset(void)
for (i = 0; i < MAX_STAR_QUEUE; i++) for (i = 0; i < MAX_STAR_QUEUE; i++)
StarQueue[i] = -1; StarQueue[i] = nullptr;
for (i = 0; i < MAX_HOLE_QUEUE; i++) for (i = 0; i < MAX_HOLE_QUEUE; i++)
HoleQueue[i] = -1; HoleQueue[i] = -1;
@ -20092,29 +20092,26 @@ int QueueStar(short SpriteNum)
} }
// can and should kill the user portion of the star // can and should kill the user portion of the star
if (StarQueue[StarQueueHead] == -1) if (StarQueue[StarQueueHead] == nullptr)
{ {
// new star // new star
User[SpriteNum].Clear(); actor->clearUser();
change_actor_stat(actor, STAT_STAR_QUEUE); change_actor_stat(actor, STAT_STAR_QUEUE);
StarQueue[StarQueueHead] = SpriteNum; StarQueue[StarQueueHead] = actor;
} }
else else
{ {
// move old star to new stars place // move old star to new stars place
osp = &sprite[StarQueue[StarQueueHead]]; osp = &StarQueue[StarQueueHead]->s();
osp->x = sp->x; osp->pos = sp->pos;
osp->y = sp->y; ChangeActorSect(StarQueue[StarQueueHead], sp->sectnum);
osp->z = sp->z;
changespritesect(StarQueue[StarQueueHead], sp->sectnum);
KillActor(actor); KillActor(actor);
SpriteNum = StarQueue[StarQueueHead]; actor = StarQueue[StarQueueHead];
ASSERT(sprite[SpriteNum].statnum != MAXSTATUS);
} }
StarQueueHead = (StarQueueHead+1) & (MAX_STAR_QUEUE-1); StarQueueHead = (StarQueueHead+1) & (MAX_STAR_QUEUE-1);
return SpriteNum; return actor->GetSpriteIndex();
} }
int QueueHole(short hit_sect, short hit_wall, int hit_x, int hit_y, int hit_z) int QueueHole(short hit_sect, short hit_wall, int hit_x, int hit_y, int hit_z)

View file

@ -59,7 +59,7 @@ enum
extern short StarQueueHead; extern short StarQueueHead;
extern short StarQueue[MAX_STAR_QUEUE]; extern DSWActor* StarQueue[MAX_STAR_QUEUE];
extern short HoleQueueHead; extern short HoleQueueHead;
extern short HoleQueue[MAX_HOLE_QUEUE]; extern short HoleQueue[MAX_HOLE_QUEUE];
extern short WallBloodQueueHead; extern short WallBloodQueueHead;