Tools: Enabled struct packing to ensure that structures are read from files properly

This commit is contained in:
Shauren
2014-04-20 14:49:44 +02:00
parent d4e355d534
commit fc538c5088
8 changed files with 30 additions and 4 deletions

View File

@@ -40,6 +40,8 @@ enum LiquidType
#define ADT_CELL_SIZE 8
#define ADT_GRID_SIZE (ADT_CELLS_PER_GRID*ADT_CELL_SIZE)
#pragma pack(push, 1)
//
// Adt file height map chunk
//
@@ -304,4 +306,6 @@ public:
adt_MHDR *a_grid;
};
#pragma pack(pop)
#endif

View File

@@ -82,6 +82,8 @@ public:
friend class DBCFile;
friend class DBCFile::Iterator;
Record& operator=(Record const& right);
};
/** Iterator that iterates over records
*/
@@ -111,6 +113,8 @@ public:
}
private:
Record record;
Iterator& operator=(Iterator const& right);
};
// Get record by id

View File

@@ -47,6 +47,8 @@ typedef uint8_t uint8;
#define FILE_FORMAT_VERSION 18
#pragma pack(push, 1)
union u_map_fcc
{
char fcc_txt[4];
@@ -80,4 +82,7 @@ public:
bool loadFile(char *filename, bool log = true);
virtual void free();
};
#pragma pack(pop)
#endif

View File

@@ -25,6 +25,8 @@
//**************************************************************************************
#define WDT_MAP_SIZE 64
#pragma pack(push, 1)
class wdt_MWMO{
union{
uint32 fcc;
@@ -83,4 +85,6 @@ public:
wdt_MWMO *wmo;
};
#pragma pack(pop)
#endif

View File

@@ -159,7 +159,7 @@ bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY)
ADT.read(buf, size);
char* p=buf;
int q = 0;
WmoInstansName = new string[size];
WmoInstansName = new std::string[size];
while (p<buf+size)
{
char* s = GetPlainName(p);

View File

@@ -113,14 +113,14 @@ private:
//size_t mcnk_offsets[256], mcnk_sizes[256];
MPQFile ADT;
//mcell Mcell;
string Adtfilename;
std::string Adtfilename;
public:
ADTFile(char* filename);
~ADTFile();
int nWMO;
int nMDX;
string* WmoInstansName;
string* ModelInstansName;
std::string* WmoInstansName;
std::string* ModelInstansName;
bool init(uint32 map_num, uint32 tileX, uint32 tileY);
//void LoadMapChunks();

View File

@@ -47,6 +47,8 @@ typedef uint8_t uint8;
#define FILE_FORMAT_VERSION 18
#pragma pack(push, 1)
//
// File version chunk
//
@@ -74,4 +76,7 @@ public:
bool loadFile(char *filename, bool log = true);
virtual void free();
};
#pragma pack(pop)
#endif

View File

@@ -67,6 +67,8 @@ struct WMOLiquidHeader
short type;
};
#pragma pack(push, 1)
struct WMOLiquidVert
{
uint16 unk1;
@@ -74,6 +76,8 @@ struct WMOLiquidVert
float height;
};
#pragma pack(pop)
class WMOGroup
{
private: