From c2828fe2e3964599f451c78885916e4aa030d224 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 16 Oct 2020 07:12:35 +0200 Subject: [PATCH] fixed undefined end of list behavior of iterators Also fixed a few warnings --- source/blood/src/nnexts.cpp | 4 ++-- source/common/engine/sc_man.cpp | 2 +- source/core/iterators.h | 9 +++++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/source/blood/src/nnexts.cpp b/source/blood/src/nnexts.cpp index 9a44742f7..b69ddad14 100644 --- a/source/blood/src/nnexts.cpp +++ b/source/blood/src/nnexts.cpp @@ -1567,10 +1567,10 @@ void trPlayerCtrlGiveStuff(XSPRITE* pXSource, PLAYER* pPlayer, TRPLAYERCTRL* pCt case 1: // give N weapon and default ammo for it case 2: // give just N ammo for selected weapon if (weapon <= 0 || weapon > 13) { - Printf(PRINT_HIGH, "Weapon #%d is out of a weapons range!"); + Printf(PRINT_HIGH, "Weapon #%d is out of a weapons range!", weapon); break; } else if (pXSource->data2 == 2 && pXSource->data4 == 0) { - Printf(PRINT_HIGH, "Zero ammo for weapon #%d is specified!"); + Printf(PRINT_HIGH, "Zero ammo for weapon #%d is specified!", weapon); break; } switch (weapon) { diff --git a/source/common/engine/sc_man.cpp b/source/common/engine/sc_man.cpp index e3225d396..495ef2493 100644 --- a/source/common/engine/sc_man.cpp +++ b/source/common/engine/sc_man.cpp @@ -529,7 +529,7 @@ bool FScanner::ScanString (bool tokens) LastGotLine = Line; // In case the generated scanner does not use marker, avoid compiler warnings. - marker; + // marker; #include "sc_man_scanner.h" LastGotToken = tokens; return return_val; diff --git a/source/core/iterators.h b/source/core/iterators.h index 7519048ce..7d9e3e57b 100644 --- a/source/core/iterators.h +++ b/source/core/iterators.h @@ -20,7 +20,7 @@ public: int NextIndex() { int n = next; - next = nextspritestat[next]; + if (n >= 0) next = nextspritestat[next]; return n; } @@ -61,7 +61,12 @@ public: int NextIndex() { int n = next; - next = nextspritesect[next]; + if (n >= 0) next = nextspritesect[next]; return n; } + + int PeekIndex() + { + return next; + } };