From 097d6d298d0f3f5a0ee73463d9c4dc8094668b67 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 11 Oct 2009 13:54:35 +0000 Subject: Print warning, when the number of colors in a palette file exceed the number of colors in the target palette on load. svn-id: r44922 --- engines/kyra/screen.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp index dc8402ecba..a3a9e8355d 100644 --- a/engines/kyra/screen.cpp +++ b/engines/kyra/screen.cpp @@ -2919,12 +2919,22 @@ bool Screen::loadPalette(const char *filename, Palette &pal) { debugC(3, kDebugLevelScreen, "Screen::loadPalette('%s', %p)", filename, (const void *)&pal); - if (_isAmiga) - pal.loadAmigaPalette(*stream, 0, stream->size() / Palette::kAmigaBytesPerColor); - else if (_vm->gameFlags().platform == Common::kPlatformPC98 && _use16ColorMode) - pal.loadPC98Palette(*stream, 0, stream->size() / Palette::kPC98BytesPerColor); - else - pal.loadVGAPalette(*stream, 0, stream->size() / Palette::kVGABytesPerColor); + const int maxCols = pal.getNumColors(); + int numCols = 0; + + if (_isAmiga) { + numCols = stream->size() / Palette::kAmigaBytesPerColor; + pal.loadAmigaPalette(*stream, 0, MIN(maxCols, numCols)); + } else if (_vm->gameFlags().platform == Common::kPlatformPC98 && _use16ColorMode) { + numCols = stream->size() / Palette::kPC98BytesPerColor; + pal.loadPC98Palette(*stream, 0, MIN(maxCols, numCols)); + } else { + numCols = stream->size() / Palette::kVGABytesPerColor; + pal.loadVGAPalette(*stream, 0, MIN(maxCols, numCols)); + } + + if (numCols > maxCols) + warning("Palette file '%s' includes %d colors, but the target palette only support %d colors", filename, numCols, maxCols); delete stream; return true; -- cgit v1.2.3