From 8cb0cf1daebc930bc1206bb8550546f7be4b4c88 Mon Sep 17 00:00:00 2001 From: "wrenczes@gmail.com" Date: Tue, 2 Nov 2010 05:50:07 +0000 Subject: [PATCH] Fixed a crash in the vertical text scroller. Mike, pls review. --- projects/mtg/src/TextScroller.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/projects/mtg/src/TextScroller.cpp b/projects/mtg/src/TextScroller.cpp index 289df2600..7dfedfba1 100644 --- a/projects/mtg/src/TextScroller.cpp +++ b/projects/mtg/src/TextScroller.cpp @@ -64,14 +64,14 @@ void TextScroller::Update(float dt){ ostringstream scrollerText; if ( timer == 0 ) { - for ( int idx = 0; idx < 2; idx ++ ) - { - scrollerText << strings[currentId + idx]; - } - currentId++; - if ( currentId >= (strings.size()-1) ) - currentId = 0; - mText = scrollerText.str(); + for ( int idx = 0; idx < (MIN(2, strings.size())); idx ++ ) + { + scrollerText << strings[currentId + idx]; + } + currentId++; + if ( currentId >= (strings.size()-1) ) + currentId = 0; + mText = scrollerText.str(); } timer = ++timer % ((int) mSpeed); }