From cf8aaf7ff274030d53ad777446f1b056c80870d6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 1 Nov 2021 09:10:19 +0100 Subject: [PATCH] - JS_ProcessEchoSpot + UnlockKeyLock --- source/games/sw/src/game.h | 2 +- source/games/sw/src/jsector.cpp | 23 ++++++++++------------- source/games/sw/src/rotator.cpp | 13 ------------- source/games/sw/src/sector.cpp | 2 +- source/games/sw/src/slidor.cpp | 13 ------------- source/games/sw/src/vator.cpp | 26 -------------------------- 6 files changed, 12 insertions(+), 67 deletions(-) diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 5d1df768d..276b8b8e0 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -598,7 +598,7 @@ int QueueFootPrint(short hit_sprite); // Weapon.c int QueueGeneric(short SpriteNum, short pic); // Weapon.c int QueueLoWangs(short SpriteNum); // Weapon.c int SpawnShell(short SpriteNum, short ShellNum); // Weapon.c -void UnlockKeyLock(short key_num, short hit_sprite); // JSector.c +void UnlockKeyLock(short key_num, DSWActor* actor); // JSector.c #define MAX_PAIN 5 extern int PlayerPainVocs[MAX_PAIN]; diff --git a/source/games/sw/src/jsector.cpp b/source/games/sw/src/jsector.cpp index f240c98cd..a455365f8 100644 --- a/source/games/sw/src/jsector.cpp +++ b/source/games/sw/src/jsector.cpp @@ -478,7 +478,6 @@ void drawroomstotile(int daposx, int daposy, int daposz, void JS_ProcessEchoSpot() { - int i; SPRITEp tp; int j,dist; PLAYERp pp = Player+screenpeek; @@ -486,12 +485,12 @@ JS_ProcessEchoSpot() bool reverb_set = false; // Process echo sprites - StatIterator it(STAT_ECHO); - while ((i = it.NextIndex()) >= 0) + SWStatIterator it(STAT_ECHO); + while (auto actor = it.Next()) { dist = 0x7fffffff; - tp = &sprite[i]; + tp = &actor->s(); j = abs(tp->x - pp->posx); j += abs(tp->y - pp->posy); @@ -940,11 +939,9 @@ JAnalyzeSprites(tspriteptr_t tspr) //////////////////////////////////////////////////////////////////////////////////////////////// -void -UnlockKeyLock(short key_num, short hit_sprite) +void UnlockKeyLock(short key_num, DSWActor* hitActor) { - SPRITEp sp; - int SpriteNum = 0, color = 0; + int color = 0; // Get palette by looking at key number switch (key_num - 1) @@ -975,10 +972,10 @@ UnlockKeyLock(short key_num, short hit_sprite) break; } - StatIterator it(STAT_DEFAULT); - while ((SpriteNum = it.NextIndex()) >= 0) + SWStatIterator it(STAT_DEFAULT); + while (auto itActor = it.Next()) { - sp = &sprite[SpriteNum]; + auto sp = &itActor->s(); switch (sp->picnum) { @@ -986,7 +983,7 @@ UnlockKeyLock(short key_num, short hit_sprite) if (sp->pal == color) { PlaySound(DIGI_UNLOCK, sp, v3df_doppler | v3df_dontpan); - if (SpriteNum == hit_sprite) + if (itActor == hitActor) sp->picnum = SKEL_UNLOCKED; } break; @@ -1001,7 +998,7 @@ UnlockKeyLock(short key_num, short hit_sprite) if (sp->pal == color) { PlaySound(DIGI_RAMUNLOCK, sp, v3df_doppler | v3df_dontpan); - if (SpriteNum == hit_sprite) + if (itActor == hitActor) sp->picnum = CARD_UNLOCKED; else sp->picnum = CARD_UNLOCKED+1; diff --git a/source/games/sw/src/rotator.cpp b/source/games/sw/src/rotator.cpp index fa4df078f..32f65ad74 100644 --- a/source/games/sw/src/rotator.cpp +++ b/source/games/sw/src/rotator.cpp @@ -199,19 +199,6 @@ DoRotatorMatch(PLAYERp pp, short match, bool manual) key_num = SectUser[sectnum]->number; -#if 0 - if (pp->HasKey[key_num - 1]) - { - int i; - for (i=0; istag == SECT_LOCK_DOOR && SectUser[i]->number == key_num) - SectUser[i]->number = 0; // unlock all doors of this type - } - UnlockKeyLock(key_num); - } - else -#endif { PutStringInfo(pp, quoteMgr.GetQuote(QUOTE_DOORMSG + key_num - 1)); return -1; diff --git a/source/games/sw/src/sector.cpp b/source/games/sw/src/sector.cpp index d467e3356..ec2bc9128 100644 --- a/source/games/sw/src/sector.cpp +++ b/source/games/sw/src/sector.cpp @@ -1841,7 +1841,7 @@ OperateSprite(short SpriteNum, short player_is_operating) if (SectUser[i].Data() && SectUser[i]->stag == SECT_LOCK_DOOR && SectUser[i]->number == key_num) SectUser[i]->number = 0; // unlock all doors of this type } - UnlockKeyLock(key_num, SpriteNum); + UnlockKeyLock(key_num, actor); } return true; diff --git a/source/games/sw/src/slidor.cpp b/source/games/sw/src/slidor.cpp index 5d2c2e2f6..e54a2bba6 100644 --- a/source/games/sw/src/slidor.cpp +++ b/source/games/sw/src/slidor.cpp @@ -195,19 +195,6 @@ DoSlidorMatch(PLAYERp pp, short match, bool manual) key_num = SectUser[sectnum]->number; -#if 0 - if (pp->HasKey[key_num - 1]) - { - int i; - for (i=0; istag == SECT_LOCK_DOOR && SectUser[i]->number == key_num) - SectUser[i]->number = 0; // unlock all doors of this type - } - UnlockKeyLock(key_num); - } - else -#endif { PutStringInfo(pp, quoteMgr.GetQuote(QUOTE_DOORMSG + key_num - 1)); return -1; diff --git a/source/games/sw/src/vator.cpp b/source/games/sw/src/vator.cpp index 12f1baa7c..58a0c1790 100644 --- a/source/games/sw/src/vator.cpp +++ b/source/games/sw/src/vator.cpp @@ -185,19 +185,6 @@ short DoVatorOperate(PLAYERp pp, short sectnum) key_num = SectUser[sectnum]->number; -#if 0 - if (pp->HasKey[key_num - 1]) - { - int i; - for (i=0; istag == SECT_LOCK_DOOR && SectUser[i]->number == key_num) - SectUser[i]->number = 0; // unlock all doors of this type - } - UnlockKeyLock(key_num); - } - else -#endif { PutStringInfo(pp, quoteMgr.GetQuote(QUOTE_DOORMSG + key_num - 1)); return false; @@ -254,19 +241,6 @@ DoVatorMatch(PLAYERp pp, short match) key_num = SectUser[sectnum]->number; -#if 0 - if (pp->HasKey[key_num - 1]) - { - int i; - for (i=0; istag == SECT_LOCK_DOOR && SectUser[i]->number == key_num) - SectUser[i]->number = 0; // unlock all doors of this type - } - UnlockKeyLock(key_num); - } - else -#endif { PutStringInfo(pp, quoteMgr.GetQuote(QUOTE_DOORMSG + key_num - 1)); return -1;