From be8e5ba6c65b4cdad46e7753e31295692011b8c9 Mon Sep 17 00:00:00 2001 From: Andrew Wong Date: Sun, 10 Aug 2003 05:54:20 +0000 Subject: [PATCH] ehhh, decrementing an unsigned when it equals zero bug ^^ --- stepmania/src/ScreenUnlock.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/stepmania/src/ScreenUnlock.cpp b/stepmania/src/ScreenUnlock.cpp index 3b33f13db4..7a92d4f816 100644 --- a/stepmania/src/ScreenUnlock.cpp +++ b/stepmania/src/ScreenUnlock.cpp @@ -296,10 +296,16 @@ ScreenUnlock::ScreenUnlock() : ScreenAttract("ScreenUnlock") } } - for(i = item.size() - 1; i >= 0; i--) + // NOTE: the following two loops require the iterator to + // be ints because if you decrement an unsigned when it + // equals zero, you get the maximum value of an unsigned, + // which is still greater than 0. By typecasting it as + // an integer, you can achieve -1, which exits the loop. + + for(i = item.size() - 1; (int)i >= 0; i--) this->AddChild(item[i]); - for(i = ItemIcons.size() - 1; i >= 0; i--) + for(i = ItemIcons.size() - 1; (int)i >= 0; i--) this->AddChild(ItemIcons[i]); PointsUntilNextUnlock.SetName( "PointsDisplay" );