diff --git a/hch/CDefHandler.cpp b/hch/CDefHandler.cpp index b3d308a84..5fe36a81e 100644 --- a/hch/CDefHandler.cpp +++ b/hch/CDefHandler.cpp @@ -48,141 +48,85 @@ CDefEssential::~CDefEssential() for(size_t i=0; i < ourImages.size(); ++i) SDL_FreeSurface(ourImages[i].bitmap); } +// Note: this function is unused void CDefHandler::openDef(std::string name) { - int i,j, totalInBlock; - char Buffer[13]; - BMPPalette palette[256]; - defName=name; - int andame; std::ifstream * is = new std::ifstream(); is -> open(name.c_str(),std::ios::binary); is->seekg(0,std::ios::end); // na koniec andame = is->tellg(); // read length is->seekg(0,std::ios::beg); // wracamy na poczatek - unsigned char * FDef = new unsigned char[andame]; // allocate memory + unsigned char * FDef = new unsigned char[andame]; // allocate memory is->read((char*)FDef, andame); // read map file to buffer is->close(); delete is; - i = 0; - DEFType = readNormalNr(i,4,FDef); i+=4; - width = readNormalNr(i,4,FDef); i+=4; - height = readNormalNr(i,4,FDef); i+=4; - i=0xc; - totalBlocks = readNormalNr(i,4,FDef); i+=4; - i=0x10; - for (int it=0;it<256;it++) - { - palette[it].R = FDef[i++]; - palette[it].G = FDef[i++]; - palette[it].B = FDef[i++]; - palette[it].F = 0; - } - i=0x310; - totalEntries=0; - for (int z=0; z0) ftcp += LeftMargin; @@ -338,7 +288,7 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, unsigned char * FDef, BMPPalet { unsigned int * RWEntriesLoc = (unsigned int *)(FDef+BaseOffset); BaseOffset += sizeof(int) * SpriteHeight; - for (int i=0;i0) @@ -354,7 +304,7 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, unsigned char * FDef, BMPPalet if (SegmentType==0xFF) { - for (int k=0; kpixels))[ftcp++]=FDef[BaseOffset+k]; if ((TotalRowLength+k)>=SpriteWidth) @@ -389,7 +339,7 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, unsigned char * FDef, BMPPalet RWEntries[i] = readNormalNr(BaseOffsetor+i*2*(SpriteWidth/32), 2, FDef); }*/ BaseOffset = BaseOffsetor + *(unsigned short*)( FDef + BaseOffsetor ); //was + RWEntries[0]; - for (int i=0;i0) @@ -433,7 +383,7 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, unsigned char * FDef, BMPPalet { RWEntries[i] = readNormalNr(BaseOffsetor+i*2*(SpriteWidth/32), 2, FDef); }*/ - for (int i=0;i0) diff --git a/hch/CDefHandler.h b/hch/CDefHandler.h index 68cc73aea..a8ee67d2e 100644 --- a/hch/CDefHandler.h +++ b/hch/CDefHandler.h @@ -1,6 +1,7 @@ #ifndef __CDEFHANDLER_H__ #define __CDEFHANDLER_H__ #include "../client/CBitmapHandler.h" +#include struct SDL_Surface; class CDefEssential; class CLodHandler; @@ -22,10 +23,50 @@ struct Cimage SDL_Surface * bitmap; }; +// Def entry in file. Integer fields are all little endian and will +// need to be converted. +struct defEntryBlock { + Uint32 unknown1; + Uint32 totalInBlock; + Uint32 unknown2; + Uint32 unknown3; + unsigned char data[0]; +}; + +// Def entry in file. Integer fields are all little endian and will +// need to be converted. +struct defEntry { + Uint32 DEFType; + Uint32 width; + Uint32 height; + Uint32 totalBlocks; + + struct { + unsigned char R; + unsigned char G; + unsigned char B; + } palette[256]; + + struct defEntryBlock blocks[0]; +}; + +// Def entry in file. Integer fields are all little endian and will +// need to be converted. +struct spriteDef { + Uint32 prSize; + Uint32 defType2; + Uint32 FullWidth; + Uint32 FullHeight; + Uint32 SpriteWidth; + Uint32 SpriteHeight; + Uint32 LeftMargin; + Uint32 TopMargin; +}; + class CDefHandler { private: - int totalEntries, DEFType, totalBlocks; + unsigned int totalEntries, DEFType, totalBlocks; bool allowRepaint; int length; //unsigned int * RWEntries;