[Scummvm-cvs-logs] SF.net SVN: scummvm:[44922] scummvm/trunk/engines/kyra/screen.cpp

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Sun Oct 11 15:54:36 CEST 2009


Revision: 44922
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44922&view=rev
Author:   lordhoto
Date:     2009-10-11 13:54:35 +0000 (Sun, 11 Oct 2009)

Log Message:
-----------
Print warning, when the number of colors in a palette file exceed the number of colors in the target palette on load.

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/screen.cpp

Modified: scummvm/trunk/engines/kyra/screen.cpp
===================================================================
--- scummvm/trunk/engines/kyra/screen.cpp	2009-10-11 13:46:58 UTC (rev 44921)
+++ scummvm/trunk/engines/kyra/screen.cpp	2009-10-11 13:54:35 UTC (rev 44922)
@@ -2919,13 +2919,23 @@
 
 	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;
 }


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list