From cbee771bad0bed004f01c36add9f0bdafb9b753c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 16 Dec 2016 20:46:52 -0500 Subject: TITANIC: Fix remapping conversation log colors when changing class --- engines/titanic/pet_control/pet_text.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/engines/titanic/pet_control/pet_text.cpp b/engines/titanic/pet_control/pet_text.cpp index 7bb0bad16e..05038d2fd0 100644 --- a/engines/titanic/pet_control/pet_text.cpp +++ b/engines/titanic/pet_control/pet_text.cpp @@ -249,20 +249,21 @@ void CPetText::setColor(byte r, byte g, byte b) { } void CPetText::remapColors(uint count, uint *srcColors, uint *destColors) { - if (_lineCount >= 0) { - for (int lineNum = 0; lineNum <= _lineCount; ++lineNum) { - // Get the rgb values - uint r = _array[lineNum]._rgb[1]; - uint g = _array[lineNum]._rgb[2]; - uint b = _array[lineNum]._rgb[3]; - uint color = r | (g << 8) | (b << 16); - - for (uint index = 0; index < count; ++index) { - if (color == srcColors[index]) { - // Found a match, so replace the color - setLineColor(lineNum, destColors[lineNum]); - break; - } + for (int lineNum = 0; lineNum <= _lineCount; ++lineNum) { + if (_array[lineNum]._rgb.empty()) + continue; + + // Get the rgb values + uint r = _array[lineNum]._rgb[1]; + uint g = _array[lineNum]._rgb[2]; + uint b = _array[lineNum]._rgb[3]; + uint color = r | (g << 8) | (b << 16); + + for (uint index = 0; index < count; ++index) { + if (color == srcColors[index]) { + // Found a match, so replace the color + setLineColor(lineNum, destColors[lineNum]); + break; } } } -- cgit v1.2.3