1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

* compilation fixes for MSVC / minor changes

* CDefHandler::openFromMemory DOES NOT WORK! It seems to be design error, not windows specific.

Note: please write more C++-like code (declarations don't have to be in the beginning of block of code, use C++-style casts, follow our naming convention for structs / classes, don't write struct before structure's name etc.)
This commit is contained in:
mateuszb
2009-10-14 12:44:44 +00:00
parent 6c008d5fea
commit 0078037df8
3 changed files with 13 additions and 13 deletions

View File

@@ -70,7 +70,7 @@ void CDefHandler::openDef(std::string name)
void CDefHandler::openFromMemory(unsigned char *table, std::string name) void CDefHandler::openFromMemory(unsigned char *table, std::string name)
{ {
BMPPalette palette[256]; BMPPalette palette[256];
struct defEntry &de = *(struct defEntry *)table; SDefEntry &de = * reinterpret_cast<SDefEntry *>(table);
unsigned char *p; unsigned char *p;
defName = name; defName = name;
@@ -87,11 +87,11 @@ void CDefHandler::openFromMemory(unsigned char *table, std::string name)
palette[it].F = 0; palette[it].F = 0;
} }
p = (unsigned char *)de.blocks; p = reinterpret_cast<unsigned char *>(de.blocks);
totalEntries=0; totalEntries=0;
for (unsigned int z=0; z<totalBlocks; z++) for (unsigned int z=0; z<totalBlocks; z++)
{ {
struct defEntryBlock &block = *(struct defEntryBlock *)p; SDefEntryBlock &block = * reinterpret_cast<SDefEntryBlock *>(p);
unsigned int totalInBlock; unsigned int totalInBlock;
totalInBlock = SDL_SwapLE32(block.totalInBlock); totalInBlock = SDL_SwapLE32(block.totalInBlock);
@@ -110,7 +110,7 @@ void CDefHandler::openFromMemory(unsigned char *table, std::string name)
} }
for (unsigned int j=0; j<totalInBlock; j++) for (unsigned int j=0; j<totalInBlock; j++)
{ {
SEntries[totalEntries+j].offset = SDL_SwapLE32(*(Uint32 *)p); SEntries[totalEntries+j].offset = SDL_SwapLE32(* reinterpret_cast<Uint32 *>(p));
p += 4; p += 4;
} }
//totalEntries+=totalInBlock; //totalEntries+=totalInBlock;
@@ -212,8 +212,8 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, unsigned char * FDef, BMPPalet
unsigned char SegmentType;//, BL, BR; //TODO use me unsigned char SegmentType;//, BL, BR; //TODO use me
BaseOffset=SEntries[SIndex].offset; BaseOffset = SEntries[SIndex].offset;
struct spriteDef sd = *(struct spriteDef *)(FDef + BaseOffset); SSpriteDef sd = * reinterpret_cast<SSpriteDef *>(FDef + BaseOffset);
prSize = SDL_SwapLE32(sd.prSize); //TODO use me prSize = SDL_SwapLE32(sd.prSize); //TODO use me
defType2 = SDL_SwapLE32(sd.defType2); defType2 = SDL_SwapLE32(sd.defType2);
@@ -241,7 +241,7 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, unsigned char * FDef, BMPPalet
ret = SDL_CreateRGBSurface(SDL_SWSURFACE, FullWidth, FullHeight, 8, 0, 0, 0, 0); ret = SDL_CreateRGBSurface(SDL_SWSURFACE, FullWidth, FullHeight, 8, 0, 0, 0, 0);
//int tempee2 = readNormalNr(0,4,((unsigned char *)tempee.c_str())); //int tempee2 = readNormalNr(0,4,((unsigned char *)tempee.c_str()));
BaseOffset += sizeof(struct spriteDef); BaseOffset += sizeof(SSpriteDef);
int BaseOffsetor = BaseOffset; int BaseOffsetor = BaseOffset;
for(int i=0; i<256; ++i) for(int i=0; i<256; ++i)
@@ -286,7 +286,7 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, unsigned char * FDef, BMPPalet
case 1: case 1:
{ {
unsigned int * RWEntriesLoc = (unsigned int *)(FDef+BaseOffset); unsigned int * RWEntriesLoc = reinterpret_cast<unsigned int *>(FDef+BaseOffset);
BaseOffset += sizeof(int) * SpriteHeight; BaseOffset += sizeof(int) * SpriteHeight;
for (unsigned int i=0;i<SpriteHeight;i++) for (unsigned int i=0;i<SpriteHeight;i++)
{ {

View File

@@ -25,7 +25,7 @@ struct Cimage
// Def entry in file. Integer fields are all little endian and will // Def entry in file. Integer fields are all little endian and will
// need to be converted. // need to be converted.
struct defEntryBlock { struct SDefEntryBlock {
Uint32 unknown1; Uint32 unknown1;
Uint32 totalInBlock; Uint32 totalInBlock;
Uint32 unknown2; Uint32 unknown2;
@@ -35,7 +35,7 @@ struct defEntryBlock {
// Def entry in file. Integer fields are all little endian and will // Def entry in file. Integer fields are all little endian and will
// need to be converted. // need to be converted.
struct defEntry { struct SDefEntry {
Uint32 DEFType; Uint32 DEFType;
Uint32 width; Uint32 width;
Uint32 height; Uint32 height;
@@ -47,12 +47,12 @@ struct defEntry {
unsigned char B; unsigned char B;
} palette[256]; } palette[256];
struct defEntryBlock blocks[0]; struct SDefEntryBlock * blocks;
}; };
// Def entry in file. Integer fields are all little endian and will // Def entry in file. Integer fields are all little endian and will
// need to be converted. // need to be converted.
struct spriteDef { struct SSpriteDef {
Uint32 prSize; Uint32 prSize;
Uint32 defType2; Uint32 defType2;
Uint32 FullWidth; Uint32 FullWidth;

View File

@@ -153,7 +153,7 @@ void CVCMIServer::start()
tlog0<<"Got connection!" << std::endl; tlog0<<"Got connection!" << std::endl;
while(!end2) while(!end2)
{ {
uint8_t mode; ui8 mode;
*connection >> mode; *connection >> mode;
switch (mode) switch (mode)
{ {