1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-12-01 23:12:49 +02:00

Revert memory mapped support for LOD files (r881, r886 and r895) because on Windows these files get locked and other applications cannot access them anymore.

This commit is contained in:
Frank Zago
2009-05-26 04:52:34 +00:00
parent 4581c30b20
commit 5eb067e3fd
5 changed files with 142 additions and 131 deletions

View File

@@ -17,6 +17,7 @@
*
*/
boost::mutex bitmap_handler_mx;
int readNormalNr (int pos, int bytCon, unsigned char * str);
extern DLL_EXPORT CLodHandler *bitmaph;
@@ -340,21 +341,25 @@ SDL_Surface * BitmapHandler::loadBitmap(std::string fname, bool setKey)
}
}
}
const unsigned char *data = bitmaph->dataptr();
data += e->offset;
bitmap_handler_mx.lock();
fseek(bitmaph->FLOD, e->offset, 0);
if (e->size==0) //file is not compressed
{
pcx = new unsigned char[e->realSize];
memcpy(pcx, data, e->realSize);
fread((char*)pcx, 1, e->realSize, bitmaph->FLOD);
bitmap_handler_mx.unlock();
}
else
{
if (!bitmaph->infs2(data, e->size, e->realSize, pcx))
unsigned char * pcd = new unsigned char[e->size];
fread((char*)pcd, 1, e->size, bitmaph->FLOD);
bitmap_handler_mx.unlock();
int res=bitmaph->infs2(pcd,e->size,e->realSize,pcx);
if(res!=0)
{
tlog2<<"an error occurred while extracting file "<<fname<<std::endl;
return NULL;
tlog2<<"an error "<<res<<" occurred while extracting file "<<fname<<std::endl;
}
delete [] pcd;
}
CPCXConv cp;
cp.openPCX((char*)pcx,e->realSize);
@@ -362,4 +367,4 @@ SDL_Surface * BitmapHandler::loadBitmap(std::string fname, bool setKey)
if(setKey)
SDL_SetColorKey(ret,SDL_SRCCOLORKEY,SDL_MapRGB(ret->format,0,255,255));
return ret;
}
}