* fixed ZCompressor for VS2008 release builds

* drop SCP db if occurs compacting problem
This commit is contained in:
bluma4862 2008-07-07 15:36:54 +00:00
parent 678aff60af
commit 3086c09146
3 changed files with 18 additions and 11 deletions

View File

@ -117,6 +117,8 @@ bool PseuInstance::Init(void)
_scp->SetPath(_scpdir); _scp->SetPath(_scpdir);
CreateDir("cache");
dbmgr.AddSearchPath("./cache"); dbmgr.AddSearchPath("./cache");
dbmgr.AddSearchPath("./data/scp"); dbmgr.AddSearchPath("./data/scp");
dbmgr.SetCompression(6); dbmgr.SetCompression(6);

View File

@ -626,7 +626,7 @@ uint32 SCPDatabaseMgr::SearchAndLoad(char *dbname, bool no_compiled)
if(!goodfiles.size()) if(!goodfiles.size())
{ {
logerror("SCP: No files found that contain database [%u]", dbname); logerror("SCP: No files found that contain database [%s]", dbname);
return 0; return 0;
} }
@ -657,7 +657,12 @@ uint32 SCPDatabaseMgr::SearchAndLoad(char *dbname, bool no_compiled)
char fn[100]; char fn[100];
sprintf(fn,"./cache/%s.ccp",dbname); sprintf(fn,"./cache/%s.ccp",dbname);
Compact(dbname, fn, _compr); if (!Compact(dbname, fn, _compr))
{
logerror("Can't compact database %s, dropping it.", dbname);
DropDB(dbname);
return 0;
}
logdetail("Database '%s' loaded from source and compacted with compression %u", dbname, _compr); logdetail("Database '%s' loaded from source and compacted with compression %u", dbname, _compr);

View File

@ -16,14 +16,14 @@ void ZCompressor::_compress(void* dst, uint32 *dst_size, void* src, uint32 src_s
{ {
z_stream c_stream; z_stream c_stream;
c_stream.zalloc = (alloc_func)0; c_stream.zalloc = (alloc_func)Z_NULL;
c_stream.zfree = (free_func)0; c_stream.zfree = (free_func)Z_NULL;
c_stream.opaque = (voidpf)0; c_stream.opaque = (voidpf)Z_NULL;
// default Z_BEST_SPEED (1) // default Z_BEST_SPEED (1)
if (Z_OK != deflateInit(&c_stream, level)) if (Z_OK != deflateInit(&c_stream, level))
{ {
//printf("ZLIB: Can't compress (zlib: deflateInit).\n"); logerror("ZLIB: Can't compress (zlib: deflateInit).\n");
*dst_size = 0; *dst_size = 0;
return; return;
} }
@ -35,28 +35,28 @@ void ZCompressor::_compress(void* dst, uint32 *dst_size, void* src, uint32 src_s
if (Z_OK != deflate(&c_stream, Z_NO_FLUSH)) if (Z_OK != deflate(&c_stream, Z_NO_FLUSH))
{ {
//printf("ZLIB: Can't compress (zlib: deflate)\n"); logerror("ZLIB: Can't compress (zlib: deflate)\n");
*dst_size = 0; *dst_size = 0;
return; return;
} }
if (c_stream.avail_in != 0) if (c_stream.avail_in != 0)
{ {
//printf("Can't compress (zlib: deflate not greedy)\n"); logerror("Can't compress (zlib: deflate not greedy)\n");
*dst_size = 0; *dst_size = 0;
return; return;
} }
if (Z_STREAM_END != deflate(&c_stream, Z_FINISH)) if (Z_STREAM_END != deflate(&c_stream, Z_FINISH))
{ {
//printf("Can't compress (zlib: deflate should report Z_STREAM_END)\n"); logerror("Can't compress (zlib: deflate should report Z_STREAM_END)\n");
*dst_size = 0; *dst_size = 0;
return; return;
} }
if (Z_OK != deflateEnd(&c_stream)) if (Z_OK != deflateEnd(&c_stream))
{ {
//printf("Can't compress (zlib: deflateEnd)\n"); logerror("Can't compress (zlib: deflateEnd)\n");
*dst_size = 0; *dst_size = 0;
return; return;
} }
@ -73,7 +73,7 @@ void ZCompressor::Deflate(uint8 level)
char *buf; char *buf;
buf=new char[size()+8]; buf=new char[size()+8];
uint32 newsize,oldsize=size(); uint32 newsize=size(),oldsize=size();
reserve(size()+8); reserve(size()+8);
_compress((void*)buf, &newsize, (void*)contents(),size(),level); _compress((void*)buf, &newsize, (void*)contents(),size(),level);