From 6f0c477e85d5254a260378fc2e3c78923b5af4ab Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 5 Nov 2021 00:03:08 +0100 Subject: [PATCH] - getting rid of COVERinsertsprite, plus cleanup. --- source/games/sw/src/break.cpp | 2 -- source/games/sw/src/game.h | 1 - source/games/sw/src/rooms.cpp | 7 +------ source/games/sw/src/sprite.cpp | 7 ++----- source/games/sw/src/track.cpp | 11 ++++------- source/games/sw/src/weapon.cpp | 10 +++++----- source/games/sw/src/zombie.cpp | 4 ---- 7 files changed, 12 insertions(+), 30 deletions(-) diff --git a/source/games/sw/src/break.cpp b/source/games/sw/src/break.cpp index 65fedd8c6..8372e4523 100644 --- a/source/games/sw/src/break.cpp +++ b/source/games/sw/src/break.cpp @@ -938,8 +938,6 @@ int AutoBreakSprite(DSWActor* breakActor, short type) if (!break_info) { - //DSPRINTF(ds,"Break Info not found - sprite %d", bp - sprite); - MONO_PRINT(ds); return false; } diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 5bcef4295..b41892dec 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -2123,7 +2123,6 @@ void SetSpikeActive(DSWActor*); // spike.c #define NTAG_SEARCH_HI 2 #define NTAG_SEARCH_LO_HI 3 -int COVERinsertsprite(short sectnum, short statnum); //returns (short)spritenum; DSWActor* InsertActor(int sectnum, int statnum); void AudioUpdate(void); // stupid diff --git a/source/games/sw/src/rooms.cpp b/source/games/sw/src/rooms.cpp index 3eaf133af..12259284a 100644 --- a/source/games/sw/src/rooms.cpp +++ b/source/games/sw/src/rooms.cpp @@ -55,11 +55,6 @@ SAVE save; bool FAF_DebugView = false; DSWActor* InsertActor(int sectnum, int stat) -{ - return &swActors[COVERinsertsprite(sectnum, stat)]; -} - -int COVERinsertsprite(short sectnum, short stat) { short spnum; spnum = insertsprite(sectnum, stat); @@ -82,7 +77,7 @@ int COVERinsertsprite(short sectnum, short stat) pSprite->hitag = 0; pSprite->extra = 0; - return spnum; + return &swActors[spnum]; } bool FAF_Sector(short sectnum) diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index a45d78da3..8a91d4742 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -2764,15 +2764,12 @@ void SpriteSetup(void) case SPRI_CLIMB_MARKER: { - short ns; - SPRITEp np; - // setup climb marker change_actor_stat(actor, STAT_CLIMB_MARKER); // make a QUICK_LADDER sprite automatically - ns = COVERinsertsprite(sp->sectnum, STAT_QUICK_LADDER); - np = &sprite[ns]; + auto ns = InsertActor(sp->sectnum, STAT_QUICK_LADDER); + auto np = &ns->s(); np->cstat = 0; np->extra = 0; diff --git a/source/games/sw/src/track.cpp b/source/games/sw/src/track.cpp index f807ba7f8..e23c719e6 100644 --- a/source/games/sw/src/track.cpp +++ b/source/games/sw/src/track.cpp @@ -327,13 +327,10 @@ int TrackClonePoint(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum], np; - short New; - New = COVERinsertsprite(sp->sectnum, sp->statnum); + auto actorNew = InsertActor(sp->sectnum, sp->statnum); - ASSERT(New != -1); - - np = &sprite[New]; + np = &actorNew->s(); np->cstat = np->extra = 0; np->x = sp->x; @@ -343,7 +340,7 @@ TrackClonePoint(short SpriteNum) np->lotag = sp->lotag; np->hitag = sp->hitag; - return New; + return actorNew->GetSpriteIndex(); } void QuickJumpSetup(short stat, short lotag, short type) @@ -1847,7 +1844,7 @@ PlayerPart: if (TEST(sop->flags, SOBJ_DONT_ROTATE)) continue; - // IS part of a sector - sprite can do things based on the + // IS part of a sector, sprite can do things based on the // current sector it is in if (TEST(wall[sector[sp->sectnum].wallptr].extra, WALLFX_LOOP_DONT_SPIN)) continue; diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index 87da5d939..61344d967 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -12671,7 +12671,7 @@ int DoSerpRing(DSWActor* actor) DISTANCE(sp->x, sp->y, u->targetActor->s().x, u->targetActor->s().y, dist, a,b,c); // if ((dist ok and random ok) OR very few skulls left) - if ((dist < 18000 && (RANDOM_P2(2048<<5)>>5) < 16) || User[sp->owner]->Counter < 4) + if ((dist < 18000 && (RANDOM_P2(2048<<5)>>5) < 16) || ou->Counter < 4) { int sectnum = sp->sectnum; updatesector(sp->x,sp->y,§num); @@ -12836,7 +12836,7 @@ int InitSerpRing(DSWActor* actor) USER* u = actor->u(); SPRITEp sp = &actor->s(), np; USERp nu; - short ang, ang_diff, ang_start, missiles, New; + short ang, ang_diff, ang_start, missiles; short max_missiles; const int SERP_RING_DIST = 2800; // Was 3500 @@ -19886,10 +19886,10 @@ void QueueGeneric(DSWActor* actor, short pic) #if 0 int -DoShellShrap(short SpriteNum) +DoShellShrap(DSWActor* actor) { - SPRITEp sp = &sprite[SpriteNum]; - USERp u = User[SpriteNum].Data(); + SPRITEp sp = &actor->s(); + USERp u = actor->u(); // If the shell doesn't fall in the allowable range, kill it. if (u->ShellNum < (ShellCount-MAXSHELLS)) diff --git a/source/games/sw/src/zombie.cpp b/source/games/sw/src/zombie.cpp index 7a70ef406..6ad143d69 100644 --- a/source/games/sw/src/zombie.cpp +++ b/source/games/sw/src/zombie.cpp @@ -790,7 +790,6 @@ void SpawnZombie(PLAYERp pp, DSWActor* weaponActor) np->pal = nu->spal = ownerActor->u()->spal; np->ang = RANDOM_P2(2048); SetupZombie(actorNew); - //np->shade = sprite[pp->PlayerSprite].shade; np->shade = -10; SET(nu->Flags2, SPR2_DONT_TARGET_OWNER); SET(np->cstat, CSTAT_SPRITE_TRANSLUCENT); @@ -810,10 +809,8 @@ void SpawnZombie(PLAYERp pp, DSWActor* weaponActor) void SpawnZombie2(DSWActor* actor) { SPRITEp sp = &actor->s(); - short New; SPRITEp np; USERp nu; - short owner; SECT_USERp sectu = SectUser[sp->sectnum].Data(); SECTORp sectp = §or[sp->sectnum]; @@ -848,7 +845,6 @@ void SpawnZombie2(DSWActor* actor) np->pal = nu->spal = ownerActor->u()->spal; np->ang = RANDOM_P2(2048); SetupZombie(actorNew); - //np->shade = sprite[pp->PlayerSprite].shade; np->shade = -10; SET(nu->Flags2, SPR2_DONT_TARGET_OWNER); SET(np->cstat, CSTAT_SPRITE_TRANSLUCENT);