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:
@@ -70,7 +70,7 @@ void CDefHandler::openDef(std::string name)
|
||||
void CDefHandler::openFromMemory(unsigned char *table, std::string name)
|
||||
{
|
||||
BMPPalette palette[256];
|
||||
struct defEntry &de = *(struct defEntry *)table;
|
||||
SDefEntry &de = * reinterpret_cast<SDefEntry *>(table);
|
||||
unsigned char *p;
|
||||
|
||||
defName = name;
|
||||
@@ -87,11 +87,11 @@ void CDefHandler::openFromMemory(unsigned char *table, std::string name)
|
||||
palette[it].F = 0;
|
||||
}
|
||||
|
||||
p = (unsigned char *)de.blocks;
|
||||
p = reinterpret_cast<unsigned char *>(de.blocks);
|
||||
totalEntries=0;
|
||||
for (unsigned int z=0; z<totalBlocks; z++)
|
||||
{
|
||||
struct defEntryBlock &block = *(struct defEntryBlock *)p;
|
||||
SDefEntryBlock &block = * reinterpret_cast<SDefEntryBlock *>(p);
|
||||
unsigned int 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++)
|
||||
{
|
||||
SEntries[totalEntries+j].offset = SDL_SwapLE32(*(Uint32 *)p);
|
||||
SEntries[totalEntries+j].offset = SDL_SwapLE32(* reinterpret_cast<Uint32 *>(p));
|
||||
p += 4;
|
||||
}
|
||||
//totalEntries+=totalInBlock;
|
||||
@@ -212,8 +212,8 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, unsigned char * FDef, BMPPalet
|
||||
|
||||
unsigned char SegmentType;//, BL, BR; //TODO use me
|
||||
|
||||
BaseOffset=SEntries[SIndex].offset;
|
||||
struct spriteDef sd = *(struct spriteDef *)(FDef + BaseOffset);
|
||||
BaseOffset = SEntries[SIndex].offset;
|
||||
SSpriteDef sd = * reinterpret_cast<SSpriteDef *>(FDef + BaseOffset);
|
||||
|
||||
prSize = SDL_SwapLE32(sd.prSize); //TODO use me
|
||||
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);
|
||||
//int tempee2 = readNormalNr(0,4,((unsigned char *)tempee.c_str()));
|
||||
|
||||
BaseOffset += sizeof(struct spriteDef);
|
||||
BaseOffset += sizeof(SSpriteDef);
|
||||
int BaseOffsetor = BaseOffset;
|
||||
|
||||
for(int i=0; i<256; ++i)
|
||||
@@ -286,7 +286,7 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, unsigned char * FDef, BMPPalet
|
||||
|
||||
case 1:
|
||||
{
|
||||
unsigned int * RWEntriesLoc = (unsigned int *)(FDef+BaseOffset);
|
||||
unsigned int * RWEntriesLoc = reinterpret_cast<unsigned int *>(FDef+BaseOffset);
|
||||
BaseOffset += sizeof(int) * SpriteHeight;
|
||||
for (unsigned int i=0;i<SpriteHeight;i++)
|
||||
{
|
||||
|
@@ -25,7 +25,7 @@ struct Cimage
|
||||
|
||||
// Def entry in file. Integer fields are all little endian and will
|
||||
// need to be converted.
|
||||
struct defEntryBlock {
|
||||
struct SDefEntryBlock {
|
||||
Uint32 unknown1;
|
||||
Uint32 totalInBlock;
|
||||
Uint32 unknown2;
|
||||
@@ -35,7 +35,7 @@ struct defEntryBlock {
|
||||
|
||||
// Def entry in file. Integer fields are all little endian and will
|
||||
// need to be converted.
|
||||
struct defEntry {
|
||||
struct SDefEntry {
|
||||
Uint32 DEFType;
|
||||
Uint32 width;
|
||||
Uint32 height;
|
||||
@@ -47,12 +47,12 @@ struct defEntry {
|
||||
unsigned char B;
|
||||
} palette[256];
|
||||
|
||||
struct defEntryBlock blocks[0];
|
||||
struct SDefEntryBlock * blocks;
|
||||
};
|
||||
|
||||
// Def entry in file. Integer fields are all little endian and will
|
||||
// need to be converted.
|
||||
struct spriteDef {
|
||||
struct SSpriteDef {
|
||||
Uint32 prSize;
|
||||
Uint32 defType2;
|
||||
Uint32 FullWidth;
|
||||
|
@@ -153,7 +153,7 @@ void CVCMIServer::start()
|
||||
tlog0<<"Got connection!" << std::endl;
|
||||
while(!end2)
|
||||
{
|
||||
uint8_t mode;
|
||||
ui8 mode;
|
||||
*connection >> mode;
|
||||
switch (mode)
|
||||
{
|
||||
|
Reference in New Issue
Block a user