From aa227b1df4b099d6642b56f52c9d9c044e9f89cf Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sun, 15 Apr 2012 03:13:07 +0000 Subject: [PATCH] - Fixed: DHUDMessageTypeOnFadeOut::Tick() did not skip over color escapes. SVN r3566 (trunk) --- src/g_shared/hudmessages.cpp | 42 ++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/src/g_shared/hudmessages.cpp b/src/g_shared/hudmessages.cpp index 25c372581..b72acd9b8 100644 --- a/src/g_shared/hudmessages.cpp +++ b/src/g_shared/hudmessages.cpp @@ -658,21 +658,45 @@ bool DHUDMessageTypeOnFadeOut::Tick () { if (State == 3) { - LineVisible = (int)(Tics / TypeOnTime); - while (LineVisible > LineLen && State == 3) + int step = Tics == 0 ? 0 : int(Tics / TypeOnTime) - int((Tics - 1) / TypeOnTime); + int linevis = LineVisible; + int linedrawcount = linevis; + FString text = Lines[CurrLine].Text; + // Advance LineVisible by 'step' *visible* characters + while (step > 0 && State == 3) { - LineVisible -= LineLen; - Tics = (int)(LineVisible * TypeOnTime); - CurrLine++; - if (CurrLine >= NumLines) + if (linevis > LineLen) { - State = 1; + linevis = 0; + linedrawcount = 0; + CurrLine++; + if (CurrLine >= NumLines) + { + State = 1; + } + else + { + text = Lines[CurrLine].Text; + LineLen = (int)text.Len(); + } } - else + if (State == 3 && --step >= 0) { - LineLen = (int)Lines[CurrLine].Text.Len(); + linedrawcount++; + if (text[linevis++] == TEXTCOLOR_ESCAPE) + { + if (text[linevis] == '[') + { // named color + while (text[linevis] != ']' && text[linevis] != '\0') + { + linevis++; + } + } + linevis += 2; + } } } + LineVisible = linevis; } return false; }