1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Added endian aware macros read_le_u16 and read_le_u32 to replace readNormalNR(). Fixes a couple of issues on big endian machines.

This commit is contained in:
Frank Zago
2011-10-08 01:23:46 +00:00
parent 8963293c07
commit 8403d177aa
11 changed files with 200 additions and 201 deletions

View File

@@ -4,6 +4,7 @@
#include "CBitmapHandler.h"
#include "CDefHandler.h"
#include "../lib/CLodHandler.h"
#include "../lib/vcmi_endian.h"
#include <sstream>
#include <boost/thread.hpp>
@@ -57,9 +58,9 @@ SDL_Surface * CPCXConv::getSurface() const
unsigned char add;
int it=0;
fSize = readNormalNr(pcx, it); it+=4;
width = readNormalNr(pcx, it); it+=4;
height = readNormalNr(pcx, it); it+=4;
fSize = read_le_u32(pcx + it); it+=4;
width = read_le_u32(pcx + it); it+=4;
height = read_le_u32(pcx + it); it+=4;
if (fSize==width*height*3)
check1=true;
else
@@ -142,9 +143,9 @@ SDL_Surface * CPCXConv::getSurface() const
bool isPCX(const unsigned char *header)//check whether file can be PCX according to 1st 12 bytes
{
int fSize = readNormalNr(header, 0);
int width = readNormalNr(header, 4);
int height = readNormalNr(header, 8);
int fSize = read_le_u32(header + 0);
int width = read_le_u32(header + 4);
int height = read_le_u32(header + 8);
return fSize == width*height || fSize == width*height*3;
}