Browse Source

More endianess checking / minor

Michał W. Urbańczyk 17 years ago
parent
commit
d371f14ad2
1 changed files with 13 additions and 1 deletions
  1. 13 1
      hch/CLodHandler.cpp

+ 13 - 1
hch/CLodHandler.cpp

@@ -200,9 +200,15 @@ SDL_Surface * CPCXConv::getSurface()
 	}
 	else
 	{
+#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
+		int bmask = 0xff0000;
+		int gmask = 0x00ff00;
+		int rmask = 0x0000ff;
+#else
 		int bmask = 0x0000ff;
 		int gmask = 0x00ff00;
 		int rmask = 0xff0000;
+#endif
 		ret = SDL_CreateRGBSurface(SDL_SWSURFACE, bh.x+add, bh.y, 24, rmask, gmask, bmask, 0);
 	}
 	if (format==PCX8B)
@@ -211,9 +217,15 @@ SDL_Surface * CPCXConv::getSurface()
 		for (int i=0;i<256;i++)
 		{
 			SDL_Color tp;
+#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
+			tp.b = pcx[it++];
+			tp.g = pcx[it++];
+			tp.r = pcx[it++];
+#else
 			tp.r = pcx[it++];
 			tp.g = pcx[it++];
 			tp.b = pcx[it++];
+#endif
 			tp.unused = 0;
 			*(ret->format->palette->colors+i) = tp;
 		}
@@ -680,7 +692,7 @@ void CLodHandler::extract(std::string FName)
 	for (int i=0;i<totalFiles;i++)
 	{
 		fseek(FLOD, entries[i].offset, 0);
-		std::string bufff = (/*DATADIR  + */FName.substr(0, FName.size()-4) + PATHSEPARATOR + (char*)entries[i].name);
+		std::string bufff = (DATADIR + FName.substr(0, FName.size()-4) + PATHSEPARATOR + (char*)entries[i].name);
 		unsigned char * outp;
 		if (entries[i].size==0) //file is not compressed
 		{