* Fixed lots of warnings in GCC
* Purely cosmetic ;)
This commit is contained in:
parent
17805d266d
commit
e820f0a5a4
@ -90,10 +90,10 @@ DefReturnResult DefScriptPackage::SCSendChatMessage(CmdSet& Set){
|
|||||||
if(ss.str()!=Set.arg[1]) // given lang is NOT a number
|
if(ss.str()!=Set.arg[1]) // given lang is NOT a number
|
||||||
{
|
{
|
||||||
SCPDatabase *langdb = dbmgr.GetDB("language");
|
SCPDatabase *langdb = dbmgr.GetDB("language");
|
||||||
uint32 dblang = langdb->GetFieldByStringValue("name",(char*)Set.arg[1].c_str());
|
uint32 dblang = langdb->GetFieldByStringValue("name",Set.arg[1].c_str());
|
||||||
logdev("looking up language id for lang '%s', found %i",Set.arg[1].c_str(),dblang);
|
logdev("looking up language id for lang '%s', found %i",Set.arg[1].c_str(),dblang);
|
||||||
// TODO: comment this out to enable using addon language??!
|
// TODO: comment this out to enable using addon language??!
|
||||||
if(dblang != -1)
|
if(dblang != SCP_INVALID_INT)
|
||||||
lang = dblang;
|
lang = dblang;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1237,7 +1237,7 @@ DefReturnResult DefScriptPackage::SCPreloadFile(CmdSet& Set)
|
|||||||
|
|
||||||
void DefScriptPackage::My_LoadUserPermissions(VarSet &vs)
|
void DefScriptPackage::My_LoadUserPermissions(VarSet &vs)
|
||||||
{
|
{
|
||||||
static char *prefix = "USERS::";
|
static const char *prefix = "USERS::";
|
||||||
std::string sub,usr;
|
std::string sub,usr;
|
||||||
for(uint32 i=0;i<variables.Size();i++)
|
for(uint32 i=0;i<variables.Size();i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -51,6 +51,8 @@ public:
|
|||||||
react_to_keys = true; // popup is gone, main window can react to keys again
|
react_to_keys = true; // popup is gone, main window can react to keys again
|
||||||
proc = true;
|
proc = true;
|
||||||
break;
|
break;
|
||||||
|
default:DEBUG(logdev("Unhandled event type %u ID %u",event.GUIEvent.EventType,id));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(customHandledEvents.find(event.GUIEvent.EventType) != customHandledEvents.end())
|
if(customHandledEvents.find(event.GUIEvent.EventType) != customHandledEvents.end())
|
||||||
|
|||||||
@ -8,7 +8,7 @@ SceneGuiStart::SceneGuiStart(PseuGUI *gui) : Scene(gui)
|
|||||||
{
|
{
|
||||||
|
|
||||||
irrlogo = guienv->addImage(driver->getTexture("data/misc/irrlichtlogo.png"), core::position2d<s32>(5,5));
|
irrlogo = guienv->addImage(driver->getTexture("data/misc/irrlichtlogo.png"), core::position2d<s32>(5,5));
|
||||||
char *fn;
|
const char *fn;
|
||||||
switch(gui->_driverType)
|
switch(gui->_driverType)
|
||||||
{
|
{
|
||||||
case video::EDT_DIRECT3D8:
|
case video::EDT_DIRECT3D8:
|
||||||
|
|||||||
@ -668,7 +668,7 @@ void SceneWorld::UpdateTerrain(void)
|
|||||||
{
|
{
|
||||||
for(uint32 i = 0; i < 10; i++)
|
for(uint32 i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
sprintf(fieldname_t,"file%u",i + 1); // starts with "file1"
|
sprintf(fieldname_t,"file%lu",i + 1); // starts with "file1"
|
||||||
fieldId[i] = sounddb->GetFieldId(fieldname_t);
|
fieldId[i] = sounddb->GetFieldId(fieldname_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -148,7 +148,7 @@ private:
|
|||||||
bool _error;
|
bool _error;
|
||||||
bool _createws, _creaters; // must create world/realm session?
|
bool _createws, _creaters; // must create world/realm session?
|
||||||
BigNumber _sessionkey;
|
BigNumber _sessionkey;
|
||||||
char *_ver,*_ver_short;
|
const char *_ver,*_ver_short;
|
||||||
SocketHandler _sh;
|
SocketHandler _sh;
|
||||||
CliRunnable *_cli;
|
CliRunnable *_cli;
|
||||||
ZThread::Thread _clithread;
|
ZThread::Thread _clithread;
|
||||||
|
|||||||
@ -60,7 +60,7 @@ void SCPDatabase::DropTextData(void)
|
|||||||
fields.clear();
|
fields.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void *SCPDatabase::GetPtr(uint32 index, char *entry)
|
void *SCPDatabase::GetPtr(uint32 index, const char *entry)
|
||||||
{
|
{
|
||||||
std::map<uint32,uint32>::iterator it = _indexes.find(index);
|
std::map<uint32,uint32>::iterator it = _indexes.find(index);
|
||||||
if(it == _indexes.end())
|
if(it == _indexes.end())
|
||||||
@ -84,7 +84,7 @@ void *SCPDatabase::GetPtrByField(uint32 index, uint32 entry)
|
|||||||
return (void*)&_intbuf[(_fields_per_row * target_row) + entry];
|
return (void*)&_intbuf[(_fields_per_row * target_row) + entry];
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 SCPDatabase::GetFieldByUint32Value(char *entry, uint32 val)
|
uint32 SCPDatabase::GetFieldByUint32Value(const char *entry, uint32 val)
|
||||||
{
|
{
|
||||||
std::map<std::string,SCPFieldDef>::iterator fi = _fielddefs.find(entry);
|
std::map<std::string,SCPFieldDef>::iterator fi = _fielddefs.find(entry);
|
||||||
if(fi == _fielddefs.end())
|
if(fi == _fielddefs.end())
|
||||||
@ -102,7 +102,7 @@ uint32 SCPDatabase::GetFieldByUint32Value(uint32 entry, uint32 val)
|
|||||||
return SCP_INVALID_INT;
|
return SCP_INVALID_INT;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 SCPDatabase::GetFieldByIntValue(char *entry, int32 val)
|
uint32 SCPDatabase::GetFieldByIntValue(const char *entry, int32 val)
|
||||||
{
|
{
|
||||||
std::map<std::string,SCPFieldDef>::iterator fi = _fielddefs.find(entry);
|
std::map<std::string,SCPFieldDef>::iterator fi = _fielddefs.find(entry);
|
||||||
if(fi == _fielddefs.end())
|
if(fi == _fielddefs.end())
|
||||||
@ -120,7 +120,7 @@ uint32 SCPDatabase::GetFieldByIntValue(uint32 entry, int32 val)
|
|||||||
return (int)SCP_INVALID_INT;
|
return (int)SCP_INVALID_INT;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 SCPDatabase::GetFieldByStringValue(char *entry, char *val)
|
uint32 SCPDatabase::GetFieldByStringValue(const char *entry, const char *val)
|
||||||
{
|
{
|
||||||
std::map<std::string,SCPFieldDef>::iterator fi = _fielddefs.find(entry);
|
std::map<std::string,SCPFieldDef>::iterator fi = _fielddefs.find(entry);
|
||||||
if(fi == _fielddefs.end())
|
if(fi == _fielddefs.end())
|
||||||
@ -130,7 +130,7 @@ uint32 SCPDatabase::GetFieldByStringValue(char *entry, char *val)
|
|||||||
return GetFieldByStringValue(field_id,val);
|
return GetFieldByStringValue(field_id,val);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 SCPDatabase::GetFieldByStringValue(uint32 entry, char *val)
|
uint32 SCPDatabase::GetFieldByStringValue(uint32 entry, const char *val)
|
||||||
{
|
{
|
||||||
for(uint32 row = 0; row < _rowcount; row++)
|
for(uint32 row = 0; row < _rowcount; row++)
|
||||||
if(!stricmp(GetStringByOffset(_intbuf[row * _fields_per_row + entry]), val))
|
if(!stricmp(GetStringByOffset(_intbuf[row * _fields_per_row + entry]), val))
|
||||||
@ -138,7 +138,7 @@ uint32 SCPDatabase::GetFieldByStringValue(uint32 entry, char *val)
|
|||||||
return SCP_INVALID_INT;
|
return SCP_INVALID_INT;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 SCPDatabase::GetFieldType(char *entry)
|
uint32 SCPDatabase::GetFieldType(const char *entry)
|
||||||
{
|
{
|
||||||
std::map<std::string,SCPFieldDef>::iterator it = _fielddefs.find(entry);
|
std::map<std::string,SCPFieldDef>::iterator it = _fielddefs.find(entry);
|
||||||
if(it != _fielddefs.end())
|
if(it != _fielddefs.end())
|
||||||
@ -146,7 +146,7 @@ uint32 SCPDatabase::GetFieldType(char *entry)
|
|||||||
return SCP_INVALID_INT;
|
return SCP_INVALID_INT;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 SCPDatabase::GetFieldId(char *entry)
|
uint32 SCPDatabase::GetFieldId(const char *entry)
|
||||||
{
|
{
|
||||||
std::map<std::string,SCPFieldDef>::iterator it = _fielddefs.find(entry);
|
std::map<std::string,SCPFieldDef>::iterator it = _fielddefs.find(entry);
|
||||||
if(it != _fielddefs.end())
|
if(it != _fielddefs.end())
|
||||||
@ -159,7 +159,7 @@ SCPDatabase *SCPDatabaseMgr::GetDB(std::string n, bool create)
|
|||||||
return create ? _map.Get(n) : _map.GetNoCreate(n);
|
return create ? _map.Get(n) : _map.GetNoCreate(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 SCPDatabaseMgr::AutoLoadFile(char *fn)
|
uint32 SCPDatabaseMgr::AutoLoadFile(const char *fn)
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
uint32 size;
|
uint32 size;
|
||||||
@ -241,7 +241,7 @@ uint32 SCPDatabaseMgr::AutoLoadFile(char *fn)
|
|||||||
|
|
||||||
|
|
||||||
// check the datatype that will be used for this string value
|
// check the datatype that will be used for this string value
|
||||||
uint32 SCPDatabaseMgr::GetDataTypeFromString(char *s)
|
uint32 SCPDatabaseMgr::GetDataTypeFromString(const char *s)
|
||||||
{
|
{
|
||||||
bool isint = true, first = true;
|
bool isint = true, first = true;
|
||||||
for(;*s;s++) // check every char until \0 is reached
|
for(;*s;s++) // check every char until \0 is reached
|
||||||
@ -257,7 +257,7 @@ uint32 SCPDatabaseMgr::GetDataTypeFromString(char *s)
|
|||||||
return isint ? SCP_TYPE_INT : SCP_TYPE_FLOAT;
|
return isint ? SCP_TYPE_INT : SCP_TYPE_FLOAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SCPDatabaseMgr::Compact(char *dbname, char *outfile, uint32 compression)
|
bool SCPDatabaseMgr::Compact(const char *dbname, const char *outfile, uint32 compression)
|
||||||
{
|
{
|
||||||
logdebug("Compacting database '%s' into file '%s'", dbname, outfile);
|
logdebug("Compacting database '%s' into file '%s'", dbname, outfile);
|
||||||
SCPDatabase *db = GetDB(dbname);
|
SCPDatabase *db = GetDB(dbname);
|
||||||
@ -587,7 +587,7 @@ void SCPDatabaseMgr::_FilterFiles(std::deque<std::string>& files, std::string db
|
|||||||
DEBUG(logdebug("-> %u files belong to this DB",files.size()));
|
DEBUG(logdebug("-> %u files belong to this DB",files.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 SCPDatabaseMgr::SearchAndLoad(char *dbname, bool no_compiled)
|
uint32 SCPDatabaseMgr::SearchAndLoad(const char *dbname, bool no_compiled)
|
||||||
{
|
{
|
||||||
uint32 count = 0;
|
uint32 count = 0;
|
||||||
std::deque<std::string> goodfiles;
|
std::deque<std::string> goodfiles;
|
||||||
@ -668,7 +668,7 @@ uint32 SCPDatabaseMgr::SearchAndLoad(char *dbname, bool no_compiled)
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SCPDatabaseMgr::AddSearchPath(char *path)
|
void SCPDatabaseMgr::AddSearchPath(const char *path)
|
||||||
{
|
{
|
||||||
std::string p;
|
std::string p;
|
||||||
|
|
||||||
@ -700,7 +700,7 @@ void SCPDatabaseMgr::AddSearchPath(char *path)
|
|||||||
_paths.push_back(p);
|
_paths.push_back(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SCPDatabaseMgr::LoadCompactSCP(char *fn, char *dbname, uint32 nSourcefiles)
|
bool SCPDatabaseMgr::LoadCompactSCP(const char *fn, const char *dbname, uint32 nSourcefiles)
|
||||||
{
|
{
|
||||||
uint32 filesize = GetFileSize(fn);
|
uint32 filesize = GetFileSize(fn);
|
||||||
if(filesize < HEADER_SIZE)
|
if(filesize < HEADER_SIZE)
|
||||||
@ -911,7 +911,7 @@ bool SCPDatabaseMgr::LoadCompactSCP(char *fn, char *dbname, uint32 nSourcefiles)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// used only for debugging
|
// used only for debugging
|
||||||
void SCPDatabase::DumpStructureToFile(char *fn)
|
void SCPDatabase::DumpStructureToFile(const char *fn)
|
||||||
{
|
{
|
||||||
std::ofstream f;
|
std::ofstream f;
|
||||||
f.open(fn);
|
f.open(fn);
|
||||||
|
|||||||
@ -45,32 +45,32 @@ public:
|
|||||||
void DropTextData(void);
|
void DropTextData(void);
|
||||||
|
|
||||||
// access funcs
|
// access funcs
|
||||||
void *GetPtr(uint32 index, char *entry);
|
void *GetPtr(uint32 index, const char *entry);
|
||||||
void *GetPtrByField(uint32 index, uint32 entry);
|
void *GetPtrByField(uint32 index, uint32 entry);
|
||||||
inline char *GetStringByOffset(uint32 offs) { return (char*)(offs < _stringsize ? _stringbuf + offs : ""); }
|
inline char *GetStringByOffset(uint32 offs) { return (char*)(offs < _stringsize ? _stringbuf + offs : ""); }
|
||||||
inline char *GetString(uint32 index, char *entry) { return GetStringByOffset(GetUint32(index,entry)); }
|
inline char *GetString(uint32 index, const char *entry) { return GetStringByOffset(GetUint32(index,entry)); }
|
||||||
inline char *GetString(uint32 index, uint32 entry) { return GetStringByOffset(GetUint32(index,entry)); }
|
inline char *GetString(uint32 index, uint32 entry) { return GetStringByOffset(GetUint32(index,entry)); }
|
||||||
inline uint32 GetUint32(uint32 index, char *entry) { uint32 *t = (uint32*)GetPtr(index,entry); return t ? *t : 0; }
|
inline uint32 GetUint32(uint32 index, const char *entry) { uint32 *t = (uint32*)GetPtr(index,entry); return t ? *t : 0; }
|
||||||
inline uint32 GetUint32(uint32 index, uint32 entry) { uint32 *t = (uint32*)GetPtrByField(index,entry); return t ? *t : 0; }
|
inline uint32 GetUint32(uint32 index, uint32 entry) { uint32 *t = (uint32*)GetPtrByField(index,entry); return t ? *t : 0; }
|
||||||
inline int32 GetInt(uint32 index, char *entry) { int32 *t = (int32*)GetPtr(index,entry); return t ? *t : 0; }
|
inline int32 GetInt(uint32 index, const char *entry) { int32 *t = (int32*)GetPtr(index,entry); return t ? *t : 0; }
|
||||||
inline int32 GetInt(uint32 index, uint32 entry) { int32 *t = (int32*)GetPtrByField(index,entry); return t ? *t : 0; }
|
inline int32 GetInt(uint32 index, uint32 entry) { int32 *t = (int32*)GetPtrByField(index,entry); return t ? *t : 0; }
|
||||||
inline float GetFloat(uint32 index, char *entry) { float *t = (float*)GetPtr(index,entry); return t ? *t : 0; }
|
inline float GetFloat(uint32 index, const char *entry) { float *t = (float*)GetPtr(index,entry); return t ? *t : 0; }
|
||||||
inline float GetFloat(uint32 index, uint32 entry) { float *t = (float*)GetPtrByField(index,entry); return t ? *t : 0; }
|
inline float GetFloat(uint32 index, uint32 entry) { float *t = (float*)GetPtrByField(index,entry); return t ? *t : 0; }
|
||||||
uint32 GetFieldType(char *entry);
|
uint32 GetFieldType(const char *entry);
|
||||||
uint32 GetFieldId(char *entry);
|
uint32 GetFieldId(const char *entry);
|
||||||
inline void *GetRowByIndex(uint32 index) { return GetPtrByField(index,0); }
|
inline void *GetRowByIndex(uint32 index) { return GetPtrByField(index,0); }
|
||||||
uint32 GetFieldByUint32Value(char *entry, uint32 val);
|
uint32 GetFieldByUint32Value(const char *entry, uint32 val);
|
||||||
uint32 GetFieldByUint32Value(uint32 entry, uint32 val);
|
uint32 GetFieldByUint32Value(uint32 entry, uint32 val);
|
||||||
uint32 GetFieldByIntValue(char *entry, int32 val);
|
uint32 GetFieldByIntValue(const char *entry, int32 val);
|
||||||
uint32 GetFieldByIntValue(uint32 entry, int32 val);
|
uint32 GetFieldByIntValue(uint32 entry, int32 val);
|
||||||
uint32 GetFieldByStringValue(char *entry, char *val);
|
uint32 GetFieldByStringValue(const char *entry, const char *val);
|
||||||
uint32 GetFieldByStringValue(uint32 entry, char *val);
|
uint32 GetFieldByStringValue(uint32 entry, const char *val);
|
||||||
// float value lookup not necessary
|
// float value lookup not necessary
|
||||||
inline uint32 GetFieldsCount(void) { return _fields_per_row; }
|
inline uint32 GetFieldsCount(void) { return _fields_per_row; }
|
||||||
inline uint32 GetRowsCount(void) { return _rowcount; }
|
inline uint32 GetRowsCount(void) { return _rowcount; }
|
||||||
|
|
||||||
|
|
||||||
void DumpStructureToFile(char *fn);
|
void DumpStructureToFile(const char *fn);
|
||||||
private:
|
private:
|
||||||
// text data related
|
// text data related
|
||||||
SCPSourceList sources;
|
SCPSourceList sources;
|
||||||
@ -97,13 +97,13 @@ class SCPDatabaseMgr
|
|||||||
public:
|
public:
|
||||||
SCPDatabaseMgr() : _compr(0) {}
|
SCPDatabaseMgr() : _compr(0) {}
|
||||||
SCPDatabase *GetDB(std::string n, bool create = false);
|
SCPDatabase *GetDB(std::string n, bool create = false);
|
||||||
uint32 AutoLoadFile(char *fn);
|
uint32 AutoLoadFile(const char *fn);
|
||||||
inline void DropDB(std::string s) { _map.Delete(stringToLower(s)); }
|
inline void DropDB(std::string s) { _map.Delete(stringToLower(s)); }
|
||||||
bool Compact(char *dbname, char *outfile, uint32 compression = 0);
|
bool Compact(const char *dbname, const char *outfile, uint32 compression = 0);
|
||||||
static uint32 GetDataTypeFromString(char *s);
|
static uint32 GetDataTypeFromString(const char *s);
|
||||||
uint32 SearchAndLoad(char*,bool);
|
uint32 SearchAndLoad(const char*,bool);
|
||||||
void AddSearchPath(char*);
|
void AddSearchPath(const char*);
|
||||||
bool LoadCompactSCP(char*, char*, uint32);
|
bool LoadCompactSCP(const char*, const char*, uint32);
|
||||||
void SetCompression(uint32 c) { _compr = c; } // min=0, max=9
|
void SetCompression(uint32 c) { _compr = c; } // min=0, max=9
|
||||||
uint32 GetCompression(void) { return _compr; }
|
uint32 GetCompression(void) { return _compr; }
|
||||||
|
|
||||||
|
|||||||
@ -55,7 +55,7 @@ bool PlayerNameCache::SaveToFile(void)
|
|||||||
return true; // no data to save, so we are fine
|
return true; // no data to save, so we are fine
|
||||||
|
|
||||||
logdebug("Saving PlayerNameCache...");
|
logdebug("Saving PlayerNameCache...");
|
||||||
char *fn="./cache/playernames.cache";
|
const char *fn="./cache/playernames.cache";
|
||||||
std::fstream fh;
|
std::fstream fh;
|
||||||
fh.open(fn, std::ios_base::out | std::ios_base::binary);
|
fh.open(fn, std::ios_base::out | std::ios_base::binary);
|
||||||
if(!fh)
|
if(!fh)
|
||||||
@ -85,7 +85,7 @@ bool PlayerNameCache::SaveToFile(void)
|
|||||||
|
|
||||||
bool PlayerNameCache::ReadFromFile(void)
|
bool PlayerNameCache::ReadFromFile(void)
|
||||||
{
|
{
|
||||||
char *fn="./cache/playernames.cache";
|
const char *fn="./cache/playernames.cache";
|
||||||
log("Loading PlayerNameCache...");
|
log("Loading PlayerNameCache...");
|
||||||
bool success=true;
|
bool success=true;
|
||||||
std::fstream fh;
|
std::fstream fh;
|
||||||
@ -139,7 +139,7 @@ uint32 PlayerNameCache::GetSize(void)
|
|||||||
void ItemProtoCache_InsertDataToSession(WorldSession *session)
|
void ItemProtoCache_InsertDataToSession(WorldSession *session)
|
||||||
{
|
{
|
||||||
logdetail("ItemProtoCache: Loading...");
|
logdetail("ItemProtoCache: Loading...");
|
||||||
char* fn = "./cache/ItemPrototypes.cache";
|
const char* fn = "./cache/ItemPrototypes.cache";
|
||||||
std::fstream fh;
|
std::fstream fh;
|
||||||
fh.open(fn, std::ios_base::in | std::ios_base::binary);
|
fh.open(fn, std::ios_base::in | std::ios_base::binary);
|
||||||
if(!fh)
|
if(!fh)
|
||||||
@ -288,7 +288,7 @@ void ItemProtoCache_WriteDataToCache(WorldSession *session)
|
|||||||
if (!session->objmgr.GetItemProtoCount())
|
if (!session->objmgr.GetItemProtoCount())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char* fn = "./cache/ItemPrototypes.cache";
|
const char* fn = "./cache/ItemPrototypes.cache";
|
||||||
std::fstream fh;
|
std::fstream fh;
|
||||||
fh.open(fn, std::ios_base::out | std::ios_base::binary);
|
fh.open(fn, std::ios_base::out | std::ios_base::binary);
|
||||||
if(!fh)
|
if(!fh)
|
||||||
@ -411,7 +411,7 @@ void ItemProtoCache_WriteDataToCache(WorldSession *session)
|
|||||||
void CreatureTemplateCache_InsertDataToSession(WorldSession *session)
|
void CreatureTemplateCache_InsertDataToSession(WorldSession *session)
|
||||||
{
|
{
|
||||||
logdetail("CreatureTemplateCache: Loading...");
|
logdetail("CreatureTemplateCache: Loading...");
|
||||||
char* fn = "./cache/CreatureTemplates.cache";
|
const char* fn = "./cache/CreatureTemplates.cache";
|
||||||
std::fstream fh;
|
std::fstream fh;
|
||||||
fh.open(fn, std::ios_base::in | std::ios_base::binary);
|
fh.open(fn, std::ios_base::in | std::ios_base::binary);
|
||||||
if(!fh)
|
if(!fh)
|
||||||
@ -482,7 +482,7 @@ void CreatureTemplateCache_WriteDataToCache(WorldSession *session)
|
|||||||
if (!session->objmgr.GetCreatureTemplateCount())
|
if (!session->objmgr.GetCreatureTemplateCount())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char* fn = "./cache/CreatureTemplates.cache";
|
const char* fn = "./cache/CreatureTemplates.cache";
|
||||||
std::fstream fh;
|
std::fstream fh;
|
||||||
fh.open(fn, std::ios_base::out | std::ios_base::binary);
|
fh.open(fn, std::ios_base::out | std::ios_base::binary);
|
||||||
if(!fh)
|
if(!fh)
|
||||||
@ -526,7 +526,7 @@ void CreatureTemplateCache_WriteDataToCache(WorldSession *session)
|
|||||||
void GOTemplateCache_InsertDataToSession(WorldSession *session)
|
void GOTemplateCache_InsertDataToSession(WorldSession *session)
|
||||||
{
|
{
|
||||||
logdetail("GOTemplateCache: Loading...");
|
logdetail("GOTemplateCache: Loading...");
|
||||||
char* fn = "./cache/GOTemplates.cache";
|
const char* fn = "./cache/GOTemplates.cache";
|
||||||
std::fstream fh;
|
std::fstream fh;
|
||||||
fh.open(fn, std::ios_base::in | std::ios_base::binary);
|
fh.open(fn, std::ios_base::in | std::ios_base::binary);
|
||||||
if(!fh)
|
if(!fh)
|
||||||
@ -594,7 +594,7 @@ void GOTemplateCache_WriteDataToCache(WorldSession *session)
|
|||||||
if (!session->objmgr.GetGOTemplateCount())
|
if (!session->objmgr.GetGOTemplateCount())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char* fn = "./cache/GOTemplates.cache";
|
const char* fn = "./cache/GOTemplates.cache";
|
||||||
std::fstream fh;
|
std::fstream fh;
|
||||||
fh.open(fn, std::ios_base::out | std::ios_base::binary);
|
fh.open(fn, std::ios_base::out | std::ios_base::binary);
|
||||||
if(!fh)
|
if(!fh)
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
void MakeMapFilename(char *fn, uint32 m, uint32 x, uint32 y)
|
void MakeMapFilename(char *fn, uint32 m, uint32 x, uint32 y)
|
||||||
{
|
{
|
||||||
sprintf(fn,"./data/maps/%u_%u_%u.adt",m,x,y);
|
sprintf(fn,"./data/maps/%lu_%lu_%lu.adt",m,x,y);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TileExistsInFile(uint32 m, uint32 x, uint32 y)
|
bool TileExistsInFile(uint32 m, uint32 x, uint32 y)
|
||||||
@ -38,7 +38,7 @@ void MapMgr::Update(float x, float y, uint32 m)
|
|||||||
Flush(); // we teleported to a new map, drop all loaded maps
|
Flush(); // we teleported to a new map, drop all loaded maps
|
||||||
WDTFile *wdt = new WDTFile();
|
WDTFile *wdt = new WDTFile();
|
||||||
char buf[100];
|
char buf[100];
|
||||||
sprintf(buf,"data/maps/%u.wdt",m);
|
sprintf(buf,"data/maps/%lu.wdt",m);
|
||||||
if(!wdt->Load(buf))
|
if(!wdt->Load(buf))
|
||||||
{
|
{
|
||||||
logerror("MAPMGR: Could not load WDT file '%s'",buf);
|
logerror("MAPMGR: Could not load WDT file '%s'",buf);
|
||||||
|
|||||||
@ -573,7 +573,7 @@ bool IsFloatField(uint8 ty, uint32 f)
|
|||||||
};
|
};
|
||||||
|
|
||||||
if(ty & TYPE_OBJECT)
|
if(ty & TYPE_OBJECT)
|
||||||
for(uint32 i = 0; floats_object[i] != (-1); i++)
|
for(uint32 i = 0; floats_object[i] != (uint32)(-1); i++)
|
||||||
if(floats_object[i] == f)
|
if(floats_object[i] == f)
|
||||||
return true;
|
return true;
|
||||||
/*
|
/*
|
||||||
@ -587,23 +587,23 @@ bool IsFloatField(uint8 ty, uint32 f)
|
|||||||
return true;
|
return true;
|
||||||
*/
|
*/
|
||||||
if(ty & TYPE_UNIT)
|
if(ty & TYPE_UNIT)
|
||||||
for(uint32 i = 0; floats_unit[i] != (-1); i++)
|
for(uint32 i = 0; floats_unit[i] != (uint32)(-1); i++)
|
||||||
if(floats_unit[i] == f)
|
if(floats_unit[i] == f)
|
||||||
return true;
|
return true;
|
||||||
if(ty & TYPE_PLAYER)
|
if(ty & TYPE_PLAYER)
|
||||||
for(uint32 i = 0; floats_player[i] != (-1); i++)
|
for(uint32 i = 0; floats_player[i] != (uint32)(-1); i++)
|
||||||
if(floats_player[i] == f)
|
if(floats_player[i] == f)
|
||||||
return true;
|
return true;
|
||||||
if(ty & TYPE_GAMEOBJECT)
|
if(ty & TYPE_GAMEOBJECT)
|
||||||
for(uint32 i = 0; floats_gameobject[i] != (-1); i++)
|
for(uint32 i = 0; floats_gameobject[i] != (uint32)(-1); i++)
|
||||||
if(floats_gameobject[i] == f)
|
if(floats_gameobject[i] == f)
|
||||||
return true;
|
return true;
|
||||||
if(ty & TYPE_DYNAMICOBJECT)
|
if(ty & TYPE_DYNAMICOBJECT)
|
||||||
for(uint32 i = 0; floats_dynobject[i] != (-1); i++)
|
for(uint32 i = 0; floats_dynobject[i] != (uint32)(-1); i++)
|
||||||
if(floats_dynobject[i] == f)
|
if(floats_dynobject[i] == f)
|
||||||
return true;
|
return true;
|
||||||
if(ty & TYPE_CORPSE)
|
if(ty & TYPE_CORPSE)
|
||||||
for(uint32 i = 0; floats_corpse[i] != (-1); i++)
|
for(uint32 i = 0; floats_corpse[i] != (uint32)(-1); i++)
|
||||||
if(floats_corpse[i] == f)
|
if(floats_corpse[i] == f)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|||||||
@ -245,7 +245,7 @@ void WorldSession::HandleWorldPacket(WorldPacket *packet)
|
|||||||
catch (ByteBufferException bbe)
|
catch (ByteBufferException bbe)
|
||||||
{
|
{
|
||||||
char errbuf[200];
|
char errbuf[200];
|
||||||
sprintf(errbuf,"attempt to \"%s\" %u bytes at position %u out of total %u bytes. (wpos=%u)", bbe.action, bbe.readsize, bbe.rpos, bbe.cursize, bbe.wpos);
|
sprintf(errbuf,"attempt to \"%s\" %lu bytes at position %lu out of total %lu bytes. (wpos=%lu)", bbe.action, bbe.readsize, bbe.rpos, bbe.cursize, bbe.wpos);
|
||||||
logerror("Exception while handling opcode %u [%s]!",packet->GetOpcode(),GetOpcodeName(packet->GetOpcode()));
|
logerror("Exception while handling opcode %u [%s]!",packet->GetOpcode(),GetOpcodeName(packet->GetOpcode()));
|
||||||
logerror("WorldSession: ByteBufferException");
|
logerror("WorldSession: ByteBufferException");
|
||||||
logerror("ByteBuffer reported: %s", errbuf);
|
logerror("ByteBuffer reported: %s", errbuf);
|
||||||
@ -441,7 +441,7 @@ void WorldSession::_DoTimedActions(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string WorldSession::DumpPacket(WorldPacket& pkt, int errpos, char *errstr)
|
std::string WorldSession::DumpPacket(WorldPacket& pkt, int errpos, const char *errstr)
|
||||||
{
|
{
|
||||||
static std::map<uint32,uint32> opstore;
|
static std::map<uint32,uint32> opstore;
|
||||||
std::stringstream s;
|
std::stringstream s;
|
||||||
@ -1584,7 +1584,7 @@ void WorldSession::_HandleWhoOpcode(WorldPacket& recvPacket)
|
|||||||
for(uint8 i = strlen(racename); strlen(racename) < 12; i++)
|
for(uint8 i = strlen(racename); strlen(racename) < 12; i++)
|
||||||
racename[i] = ' ';
|
racename[i] = ' ';
|
||||||
char tmp[12];
|
char tmp[12];
|
||||||
sprintf(tmp,"%u",wle.level);
|
sprintf(tmp,"%lu",wle.level);
|
||||||
std::string lvl_str = tmp;
|
std::string lvl_str = tmp;
|
||||||
while(lvl_str.length() < 3)
|
while(lvl_str.length() < 3)
|
||||||
lvl_str = " " + lvl_str;
|
lvl_str = " " + lvl_str;
|
||||||
|
|||||||
@ -85,7 +85,7 @@ public:
|
|||||||
inline World *GetWorld(void) { return _world; }
|
inline World *GetWorld(void) { return _world; }
|
||||||
|
|
||||||
std::string GetOrRequestPlayerName(uint64);
|
std::string GetOrRequestPlayerName(uint64);
|
||||||
std::string DumpPacket(WorldPacket& pkt, int errpos = -1, char *errstr = NULL);
|
std::string DumpPacket(WorldPacket& pkt, int errpos = -1, const char *errstr = NULL);
|
||||||
|
|
||||||
inline uint32 GetCharsCount(void) { return _charList.size(); }
|
inline uint32 GetCharsCount(void) { return _charList.size(); }
|
||||||
inline CharacterListExt& GetCharFromList(uint32 id) { return _charList[id]; }
|
inline CharacterListExt& GetCharFromList(uint32 id) { return _charList[id]; }
|
||||||
|
|||||||
@ -92,7 +92,7 @@ int main(int argc, char* argv[])
|
|||||||
std::set_new_handler(_new_handler);
|
std::set_new_handler(_new_handler);
|
||||||
log_prepare("logfile.txt","a");
|
log_prepare("logfile.txt","a");
|
||||||
logcustom(0,LGREEN,"+----------------------------------+");
|
logcustom(0,LGREEN,"+----------------------------------+");
|
||||||
logcustom(0,LGREEN,"| (C) 2006-2008 Snowstorm Software |");
|
logcustom(0,LGREEN,"| (C) 2006-2009 Snowstorm Software |");
|
||||||
logcustom(0,LGREEN,"| http://www.mangosclient.org |");
|
logcustom(0,LGREEN,"| http://www.mangosclient.org |");
|
||||||
logcustom(0,LGREEN,"+----------------------------------+");
|
logcustom(0,LGREEN,"+----------------------------------+");
|
||||||
logcustom(0,GREEN,"Platform: %s",PLATFORM_NAME);
|
logcustom(0,GREEN,"Platform: %s",PLATFORM_NAME);
|
||||||
|
|||||||
@ -10,7 +10,7 @@ FILE *logfile = NULL;
|
|||||||
uint8 loglevel = 0;
|
uint8 loglevel = 0;
|
||||||
bool logtime = false;
|
bool logtime = false;
|
||||||
|
|
||||||
void log_prepare(char *fn, char *mode = NULL)
|
void log_prepare(const char *fn, const char *mode = NULL)
|
||||||
{
|
{
|
||||||
if(!mode)
|
if(!mode)
|
||||||
mode = "a";
|
mode = "a";
|
||||||
@ -49,7 +49,7 @@ void log(const char *str, ...)
|
|||||||
|
|
||||||
if(logfile)
|
if(logfile)
|
||||||
{
|
{
|
||||||
fprintf(logfile, getDateString().c_str());
|
fprintf(logfile, "%s", getDateString().c_str());
|
||||||
va_start(ap, str);
|
va_start(ap, str);
|
||||||
vfprintf(logfile, str, ap);
|
vfprintf(logfile, str, ap);
|
||||||
fprintf(logfile, "\n" );
|
fprintf(logfile, "\n" );
|
||||||
@ -76,7 +76,7 @@ void logdetail(const char *str, ...)
|
|||||||
|
|
||||||
if(logfile)
|
if(logfile)
|
||||||
{
|
{
|
||||||
fprintf(logfile, getDateString().c_str());
|
fprintf(logfile, "%s", getDateString().c_str());
|
||||||
va_start(ap, str);
|
va_start(ap, str);
|
||||||
vfprintf(logfile, str, ap);
|
vfprintf(logfile, str, ap);
|
||||||
fprintf(logfile, "\n" );
|
fprintf(logfile, "\n" );
|
||||||
@ -104,7 +104,7 @@ void logdebug(const char *str, ...)
|
|||||||
|
|
||||||
if(logfile)
|
if(logfile)
|
||||||
{
|
{
|
||||||
fprintf(logfile, getDateString().c_str());
|
fprintf(logfile, "%s", getDateString().c_str());
|
||||||
va_start(ap, str);
|
va_start(ap, str);
|
||||||
vfprintf(logfile, str, ap);
|
vfprintf(logfile, str, ap);
|
||||||
fprintf(logfile, "\n" );
|
fprintf(logfile, "\n" );
|
||||||
@ -132,7 +132,7 @@ void logdev(const char *str, ...)
|
|||||||
|
|
||||||
if(logfile)
|
if(logfile)
|
||||||
{
|
{
|
||||||
fprintf(logfile, getDateString().c_str());
|
fprintf(logfile, "%s", getDateString().c_str());
|
||||||
va_start(ap, str);
|
va_start(ap, str);
|
||||||
vfprintf(logfile, str, ap);
|
vfprintf(logfile, str, ap);
|
||||||
fprintf(logfile, "\n" );
|
fprintf(logfile, "\n" );
|
||||||
@ -157,7 +157,7 @@ void logerror(const char *str, ...)
|
|||||||
|
|
||||||
if(logfile)
|
if(logfile)
|
||||||
{
|
{
|
||||||
fprintf(logfile, getDateString().c_str());
|
fprintf(logfile, "%s", getDateString().c_str());
|
||||||
va_start(ap, str);
|
va_start(ap, str);
|
||||||
vfprintf(logfile, str, ap);
|
vfprintf(logfile, str, ap);
|
||||||
fprintf(logfile, "\n" );
|
fprintf(logfile, "\n" );
|
||||||
@ -182,7 +182,7 @@ void logcritical(const char *str, ...)
|
|||||||
|
|
||||||
if(logfile)
|
if(logfile)
|
||||||
{
|
{
|
||||||
fprintf(logfile, getDateString().c_str());
|
fprintf(logfile, "%s", getDateString().c_str());
|
||||||
va_start(ap, str);
|
va_start(ap, str);
|
||||||
vfprintf(logfile, str, ap);
|
vfprintf(logfile, str, ap);
|
||||||
fprintf(logfile, "\n" );
|
fprintf(logfile, "\n" );
|
||||||
@ -209,7 +209,7 @@ void logcustom(uint8 lvl, Color color, const char *str, ...)
|
|||||||
|
|
||||||
if(logfile)
|
if(logfile)
|
||||||
{
|
{
|
||||||
fprintf(logfile, getDateString().c_str());
|
fprintf(logfile, "%s", getDateString().c_str());
|
||||||
va_start(ap, str);
|
va_start(ap, str);
|
||||||
vfprintf(logfile, str, ap);
|
vfprintf(logfile, str, ap);
|
||||||
fprintf(logfile, "\n" );
|
fprintf(logfile, "\n" );
|
||||||
|
|||||||
@ -20,7 +20,7 @@ enum Color
|
|||||||
WHITE
|
WHITE
|
||||||
};
|
};
|
||||||
|
|
||||||
void log_prepare(char *fn, char *mode);
|
void log_prepare(const char *fn, const char *mode);
|
||||||
void log_setloglevel(uint8 lvl);
|
void log_setloglevel(uint8 lvl);
|
||||||
void log_setlogtime(bool b);
|
void log_setlogtime(bool b);
|
||||||
void log(const char *str, ...);
|
void log(const char *str, ...);
|
||||||
|
|||||||
@ -6,14 +6,14 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
|
||||||
#if PLATFORM == PLATFORM_WIN32
|
#if PLATFORM == PLATFORM_WIN32
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
# include <mmsystem.h>
|
# include <mmsystem.h>
|
||||||
# include <time.h>
|
# include <time.h>
|
||||||
# include <direct.h>
|
# include <direct.h>
|
||||||
#else
|
#else
|
||||||
# include <sys/dir.h>
|
# include <sys/dir.h>
|
||||||
# include <sys/stat.h>
|
# include <sys/stat.h>
|
||||||
# if defined(__FreeBSD__) || defined(__APPLE_CC__)
|
# if defined(__FreeBSD__) || defined(__APPLE_CC__)
|
||||||
# include <time.h>
|
# include <time.h>
|
||||||
# endif
|
# endif
|
||||||
@ -69,15 +69,15 @@ std::string toString(uint64 num){
|
|||||||
|
|
||||||
std::string getDateString(void)
|
std::string getDateString(void)
|
||||||
{
|
{
|
||||||
time_t t = time(NULL);
|
time_t t = time(NULL);
|
||||||
tm* aTm = localtime(&t);
|
tm* aTm = localtime(&t);
|
||||||
char str[30];
|
char str[30];
|
||||||
// YYYY year
|
// YYYY year
|
||||||
// MM month (2 digits 01-12)
|
// MM month (2 digits 01-12)
|
||||||
// DD day (2 digits 01-31)
|
// DD day (2 digits 01-31)
|
||||||
// HH hour (2 digits 00-23)
|
// HH hour (2 digits 00-23)
|
||||||
// MM minutes (2 digits 00-59)
|
// MM minutes (2 digits 00-59)
|
||||||
// SS seconds (2 digits 00-59)
|
// SS seconds (2 digits 00-59)
|
||||||
sprintf(str,"%-4d-%02d-%02d %02d:%02d:%02d ",aTm->tm_year+1900,aTm->tm_mon+1,aTm->tm_mday,aTm->tm_hour,aTm->tm_min,aTm->tm_sec);
|
sprintf(str,"%-4d-%02d-%02d %02d:%02d:%02d ",aTm->tm_year+1900,aTm->tm_mon+1,aTm->tm_mday,aTm->tm_hour,aTm->tm_min,aTm->tm_sec);
|
||||||
return std::string(str);
|
return std::string(str);
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ std::string getDateString(void)
|
|||||||
std::string GetTimeString(void)
|
std::string GetTimeString(void)
|
||||||
{
|
{
|
||||||
time_t t = time(NULL);
|
time_t t = time(NULL);
|
||||||
tm* aTm = localtime(&t);
|
tm* aTm = localtime(&t);
|
||||||
char str[15];
|
char str[15];
|
||||||
sprintf(str,"%02d:%02d:%02d", aTm->tm_hour,aTm->tm_min,aTm->tm_sec);
|
sprintf(str,"%02d:%02d:%02d", aTm->tm_hour,aTm->tm_min,aTm->tm_sec);
|
||||||
return std::string(str);
|
return std::string(str);
|
||||||
@ -110,7 +110,7 @@ std::string toHexDump(uint8* array, uint32 size, bool spaces, uint32 per_line)
|
|||||||
{
|
{
|
||||||
if(array[i])
|
if(array[i])
|
||||||
{
|
{
|
||||||
sprintf(buf,(array[i]<=0x0F)?"0%X":"%X",(uint32)array[i]);
|
sprintf(buf,(array[i]<=0x0F)?"0%lX":"%lX",(uint32)array[i]);
|
||||||
ss << buf;
|
ss << buf;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -132,41 +132,41 @@ std::deque<std::string> GetFileList(std::string path)
|
|||||||
{
|
{
|
||||||
std::deque<std::string> files;
|
std::deque<std::string> files;
|
||||||
|
|
||||||
# ifndef _WIN32 // TODO: fix this function for linux if needed
|
# ifndef _WIN32 // TODO: fix this function for linux if needed
|
||||||
const char *p = path.c_str();
|
const char *p = path.c_str();
|
||||||
DIR * dirp;
|
DIR * dirp;
|
||||||
struct dirent * dp;
|
struct dirent * dp;
|
||||||
dirp = opendir(p);
|
dirp = opendir(p);
|
||||||
while (dirp)
|
while (dirp)
|
||||||
{
|
{
|
||||||
errno = 0;
|
errno = 0;
|
||||||
if ((dp = readdir(dirp)) != NULL)
|
if ((dp = readdir(dirp)) != NULL)
|
||||||
files.push_back(std::string(dp->d_name));
|
files.push_back(std::string(dp->d_name));
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(dirp)
|
if(dirp)
|
||||||
closedir(dirp);
|
closedir(dirp);
|
||||||
|
|
||||||
# else
|
# else
|
||||||
|
|
||||||
if(path.at(path.length()-1)!='/')
|
if(path.at(path.length()-1)!='/')
|
||||||
path += "/";
|
path += "/";
|
||||||
path += "*.*";
|
path += "*.*";
|
||||||
const char *p = path.c_str();
|
const char *p = path.c_str();
|
||||||
WIN32_FIND_DATA fil;
|
WIN32_FIND_DATA fil;
|
||||||
HANDLE hFil=FindFirstFile(p,&fil);
|
HANDLE hFil=FindFirstFile(p,&fil);
|
||||||
if(hFil!=INVALID_HANDLE_VALUE)
|
if(hFil!=INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
if( !(fil.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
|
if( !(fil.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
|
||||||
files.push_back(std::string(fil.cFileName));
|
files.push_back(std::string(fil.cFileName));
|
||||||
while(FindNextFile(hFil,&fil))
|
while(FindNextFile(hFil,&fil))
|
||||||
{
|
{
|
||||||
if( !(fil.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
|
if( !(fil.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
|
||||||
files.push_back(std::string(fil.cFileName));
|
files.push_back(std::string(fil.cFileName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
return files;
|
return files;
|
||||||
@ -251,14 +251,14 @@ std::string _PathToFileName(std::string str)
|
|||||||
std::string NormalizeFilename(std::string s)
|
std::string NormalizeFilename(std::string s)
|
||||||
{
|
{
|
||||||
uint32 p;
|
uint32 p;
|
||||||
while( (p = s.find('\\')) != std::string::npos)//Replace \ by /
|
while( (p = s.find('\\')) != std::string::npos)//Replace \ by /
|
||||||
{
|
{
|
||||||
s.replace(p,1,"/");
|
s.replace(p,1,"/");
|
||||||
}
|
}
|
||||||
while( (p = s.find(' ')) != std::string::npos)//Replace space by _
|
while( (p = s.find(' ')) != std::string::npos)//Replace space by _
|
||||||
{
|
{
|
||||||
s.replace(p,1,"_");
|
s.replace(p,1,"_");
|
||||||
}
|
}
|
||||||
std::transform(s.begin(), s.end(), s.begin(), tolower);
|
std::transform(s.begin(), s.end(), s.begin(), tolower);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@ -268,7 +268,7 @@ std::string FilesizeFormat(uint32 b)
|
|||||||
char buf[15];
|
char buf[15];
|
||||||
if (b < 1024)
|
if (b < 1024)
|
||||||
{
|
{
|
||||||
sprintf(buf,"%u B",b);
|
sprintf(buf,"%lu B",b);
|
||||||
}
|
}
|
||||||
else if(b < 1024*1024)
|
else if(b < 1024*1024)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
bool locale_set=false;
|
bool locale_set=false;
|
||||||
char my_locale[5];
|
char my_locale[5];
|
||||||
char *cconf = "WTF/config.wtf";
|
const char *cconf = "WTF/config.wtf";
|
||||||
char *cconfentry = "SET locale \"";
|
const char *cconfentry = "SET locale \"";
|
||||||
|
|
||||||
void SetLocale(char *loc)
|
void SetLocale(char *loc)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -12,13 +12,13 @@ MPQFile::~MPQFile()
|
|||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MPQFile::HasFile(char *fn)
|
bool MPQFile::HasFile(const char *fn)
|
||||||
{
|
{
|
||||||
return SFileHasFile(_mpq,fn);
|
return SFileHasFile(_mpq,fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get size of a file within an mpq archive
|
// get size of a file within an mpq archive
|
||||||
ByteBuffer MPQFile::ReadFile(char *fn)
|
ByteBuffer MPQFile::ReadFile(const char *fn)
|
||||||
{
|
{
|
||||||
ByteBuffer bb;
|
ByteBuffer bb;
|
||||||
HANDLE fh;
|
HANDLE fh;
|
||||||
@ -31,7 +31,7 @@ ByteBuffer MPQFile::ReadFile(char *fn)
|
|||||||
return bb;
|
return bb;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 MPQFile::GetFileSize(char *fn)
|
uint32 MPQFile::GetFileSize(const char *fn)
|
||||||
{
|
{
|
||||||
HANDLE fh;
|
HANDLE fh;
|
||||||
if(!SFileOpenFileEx(_mpq, fn, 0, &fh))
|
if(!SFileOpenFileEx(_mpq, fn, 0, &fh))
|
||||||
|
|||||||
@ -12,9 +12,9 @@ public:
|
|||||||
MPQFile(const char*);
|
MPQFile(const char*);
|
||||||
~MPQFile();
|
~MPQFile();
|
||||||
inline bool IsOpen(void) { return _isopen; }
|
inline bool IsOpen(void) { return _isopen; }
|
||||||
ByteBuffer ReadFile(char*);
|
ByteBuffer ReadFile(const char*);
|
||||||
uint32 GetFileSize(char*);
|
uint32 GetFileSize(const char*);
|
||||||
bool HasFile(char*);
|
bool HasFile(const char*);
|
||||||
void Close(void);
|
void Close(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
#define DATADIR "Data"
|
#define DATADIR "Data"
|
||||||
|
|
||||||
|
|
||||||
MPQHelper::MPQHelper(char *archive)
|
MPQHelper::MPQHelper(const char *archive)
|
||||||
{
|
{
|
||||||
// TODO: check which files are needed and which are not + recheck for correct ordering
|
// TODO: check which files are needed and which are not + recheck for correct ordering
|
||||||
std::string dir = "Data/";
|
std::string dir = "Data/";
|
||||||
@ -25,7 +25,7 @@ MPQHelper::MPQHelper(char *archive)
|
|||||||
for(uint32 i=1; i<=MAX_PATCH_NUMBER; i++)
|
for(uint32 i=1; i<=MAX_PATCH_NUMBER; i++)
|
||||||
{
|
{
|
||||||
char buf[200];
|
char buf[200];
|
||||||
sprintf(buf,"%spatch-%u%s",dir.c_str(),i,ext.c_str());
|
sprintf(buf,"%spatch-%lu%s",dir.c_str(),i,ext.c_str());
|
||||||
_patches.push_front(buf);
|
_patches.push_front(buf);
|
||||||
}
|
}
|
||||||
_patches.push_front(ldir+"speech-"+GetLocale()+ext);
|
_patches.push_front(ldir+"speech-"+GetLocale()+ext);
|
||||||
@ -40,7 +40,7 @@ MPQHelper::MPQHelper(char *archive)
|
|||||||
for(uint32 i=1; i<=MAX_PATCH_NUMBER; i++)
|
for(uint32 i=1; i<=MAX_PATCH_NUMBER; i++)
|
||||||
{
|
{
|
||||||
char buf[200];
|
char buf[200];
|
||||||
sprintf(buf,"%spatch-%s-%u%s",ldir.c_str(),GetLocale(),i,ext.c_str());
|
sprintf(buf,"%spatch-%s-%lu%s",ldir.c_str(),GetLocale(),i,ext.c_str());
|
||||||
//if(FileExists(buf))
|
//if(FileExists(buf))
|
||||||
_patches.push_front(buf);
|
_patches.push_front(buf);
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ MPQHelper::~MPQHelper()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteBuffer MPQHelper::ExtractFile(char* fn)
|
ByteBuffer MPQHelper::ExtractFile(const char* fn)
|
||||||
{
|
{
|
||||||
ByteBuffer bb;
|
ByteBuffer bb;
|
||||||
for(std::list<MPQFile*>::iterator i = _files.begin(); i != _files.end(); i++)
|
for(std::list<MPQFile*>::iterator i = _files.begin(); i != _files.end(); i++)
|
||||||
@ -80,7 +80,7 @@ ByteBuffer MPQHelper::ExtractFile(char* fn)
|
|||||||
return bb; // will be empty if returned here
|
return bb; // will be empty if returned here
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MPQHelper::FileExists(char *fn)
|
bool MPQHelper::FileExists(const char *fn)
|
||||||
{
|
{
|
||||||
for(std::list<MPQFile*>::iterator i = _files.begin(); i != _files.end(); i++)
|
for(std::list<MPQFile*>::iterator i = _files.begin(); i != _files.end(); i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -8,10 +8,10 @@ class MPQFile;
|
|||||||
class MPQHelper
|
class MPQHelper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MPQHelper(char*);
|
MPQHelper(const char*);
|
||||||
~MPQHelper();
|
~MPQHelper();
|
||||||
ByteBuffer ExtractFile(char*);
|
ByteBuffer ExtractFile(const char*);
|
||||||
bool FileExists(char*);
|
bool FileExists(const char*);
|
||||||
private:
|
private:
|
||||||
std::list<MPQFile*> _files;
|
std::list<MPQFile*> _files;
|
||||||
std::list<std::string> _patches;
|
std::list<std::string> _patches;
|
||||||
|
|||||||
@ -166,7 +166,7 @@ int WINAPI SFileEnumLocales(
|
|||||||
// szFileName - Name of file to look for
|
// szFileName - Name of file to look for
|
||||||
|
|
||||||
// TODO: Test for archives > 4GB
|
// TODO: Test for archives > 4GB
|
||||||
BOOL WINAPI SFileHasFile(HANDLE hMPQ, char * szFileName)
|
BOOL WINAPI SFileHasFile(HANDLE hMPQ, const char * szFileName)
|
||||||
{
|
{
|
||||||
TMPQArchive * ha = (TMPQArchive *)hMPQ;
|
TMPQArchive * ha = (TMPQArchive *)hMPQ;
|
||||||
int nError = ERROR_SUCCESS;
|
int nError = ERROR_SUCCESS;
|
||||||
|
|||||||
@ -25,7 +25,7 @@
|
|||||||
struct TID2Ext
|
struct TID2Ext
|
||||||
{
|
{
|
||||||
DWORD dwID;
|
DWORD dwID;
|
||||||
char * szExt;
|
const char * szExt;
|
||||||
};
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -630,7 +630,7 @@ static TID2Ext id2ext[] =
|
|||||||
BOOL WINAPI SFileGetFileName(HANDLE hFile, char * szFileName)
|
BOOL WINAPI SFileGetFileName(HANDLE hFile, char * szFileName)
|
||||||
{
|
{
|
||||||
TMPQFile * hf = (TMPQFile *)hFile; // MPQ File handle
|
TMPQFile * hf = (TMPQFile *)hFile; // MPQ File handle
|
||||||
char * szExt = "xxx"; // Default extension
|
const char * szExt = "xxx"; // Default extension
|
||||||
DWORD dwFirstBytes[2]; // The first 4 bytes of the file
|
DWORD dwFirstBytes[2]; // The first 4 bytes of the file
|
||||||
DWORD dwFilePos; // Saved file position
|
DWORD dwFilePos; // Saved file position
|
||||||
int nError = ERROR_SUCCESS;
|
int nError = ERROR_SUCCESS;
|
||||||
|
|||||||
@ -529,7 +529,7 @@ BOOL WINAPI SFileRenameFile(HANDLE hMPQ, const char * szOldFileName, const char
|
|||||||
BOOL WINAPI SFileSetFileLocale(HANDLE hFile, LCID lcNewLocale);
|
BOOL WINAPI SFileSetFileLocale(HANDLE hFile, LCID lcNewLocale);
|
||||||
|
|
||||||
// Retrieving info about the file
|
// Retrieving info about the file
|
||||||
BOOL WINAPI SFileHasFile(HANDLE hMPQ, char * szFileName);
|
BOOL WINAPI SFileHasFile(HANDLE hMPQ, const char * szFileName);
|
||||||
BOOL WINAPI SFileGetFileName(HANDLE hFile, char * szFileName);
|
BOOL WINAPI SFileGetFileName(HANDLE hFile, char * szFileName);
|
||||||
DWORD_PTR WINAPI SFileGetFileInfo(HANDLE hMpqOrFile, DWORD dwInfoType);
|
DWORD_PTR WINAPI SFileGetFileInfo(HANDLE hMpqOrFile, DWORD dwInfoType);
|
||||||
|
|
||||||
|
|||||||
@ -33,7 +33,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
char input[200];
|
char input[200];
|
||||||
printf("StuffExtract [version %u]\n",SE_VERSION);
|
printf("StuffExtract [version %u]\n",SE_VERSION);
|
||||||
printf("Use -help or -? to display help about command line arguments and config.\n\n",SE_VERSION);
|
printf("Use -help or -? to display help about command line arguments and config.\n\n");
|
||||||
ProcessCmdArgs(argc, argv);
|
ProcessCmdArgs(argc, argv);
|
||||||
PrintConfig();
|
PrintConfig();
|
||||||
if(!GetLocale())
|
if(!GetLocale())
|
||||||
@ -205,7 +205,7 @@ std::string AutoGetDataString(DBCFile::Iterator& it, const char* format, uint32
|
|||||||
|
|
||||||
|
|
||||||
// output a formatted scp file
|
// output a formatted scp file
|
||||||
void OutSCP(char *fn, SCPStorageMap& scp, std::string dbName="")
|
void OutSCP(const char *fn, SCPStorageMap& scp, std::string dbName="")
|
||||||
{
|
{
|
||||||
std::fstream f;
|
std::fstream f;
|
||||||
f.open(fn, std::ios_base::out);
|
f.open(fn, std::ios_base::out);
|
||||||
@ -232,7 +232,7 @@ void OutSCP(char *fn, SCPStorageMap& scp, std::string dbName="")
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutMD5(char *path, MD5FileMap& fm)
|
void OutMD5(const char *path, MD5FileMap& fm)
|
||||||
{
|
{
|
||||||
if(!doMd5)
|
if(!doMd5)
|
||||||
return;
|
return;
|
||||||
@ -331,7 +331,7 @@ bool ConvertDBC(void)
|
|||||||
for(DBCFile::Iterator ix = EmotesTextData.begin(); ix != EmotesTextData.end(); ++ix)
|
for(DBCFile::Iterator ix = EmotesTextData.begin(); ix != EmotesTextData.end(); ++ix)
|
||||||
{
|
{
|
||||||
textid = (*ix).getUInt(EMOTESTEXTDATA_TEXTID);
|
textid = (*ix).getUInt(EMOTESTEXTDATA_TEXTID);
|
||||||
if(textid == (*it).getInt(field))
|
if(textid == (*it).getUInt(field))
|
||||||
{
|
{
|
||||||
fname = EmotesTextFieldNames[field];
|
fname = EmotesTextFieldNames[field];
|
||||||
for(uint8 stringpos=EMOTESTEXTDATA_STRING1; stringpos<=EMOTESTEXTDATA_STRING8; stringpos++) // we have 8 locales, so...
|
for(uint8 stringpos=EMOTESTEXTDATA_STRING1; stringpos<=EMOTESTEXTDATA_STRING8; stringpos++) // we have 8 locales, so...
|
||||||
@ -482,7 +482,7 @@ bool ConvertDBC(void)
|
|||||||
{
|
{
|
||||||
// lookup for model path
|
// lookup for model path
|
||||||
DBCFile::Iterator itm = CreatureModelData.begin();
|
DBCFile::Iterator itm = CreatureModelData.begin();
|
||||||
for(; itm != CreatureDisplayInfo.end() && itm->getInt(CREATUREMODELDATA_ID) != modelid;) ++itm;
|
for(; itm != CreatureDisplayInfo.end() && itm->getUInt(CREATUREMODELDATA_ID) != modelid;) ++itm;
|
||||||
|
|
||||||
std::string str = itm->getString(CREATUREMODELDATA_FILE);
|
std::string str = itm->getString(CREATUREMODELDATA_FILE);
|
||||||
uint32 pathend = str.find_last_of("/\\");
|
uint32 pathend = str.find_last_of("/\\");
|
||||||
@ -625,7 +625,7 @@ void ExtractMaps(void)
|
|||||||
// extract the WDT file that stores tile information
|
// extract the WDT file that stores tile information
|
||||||
char wdt_name[300], wdt_out[300];
|
char wdt_name[300], wdt_out[300];
|
||||||
sprintf(wdt_name,"World\\Maps\\%s\\%s.wdt",it->second.c_str(),it->second.c_str());
|
sprintf(wdt_name,"World\\Maps\\%s\\%s.wdt",it->second.c_str(),it->second.c_str());
|
||||||
sprintf(wdt_out,MAPSDIR"/%u.wdt",it->first);
|
sprintf(wdt_out,MAPSDIR"/%lu.wdt",it->first);
|
||||||
const ByteBuffer& wdt_bb = mpq.ExtractFile(wdt_name);
|
const ByteBuffer& wdt_bb = mpq.ExtractFile(wdt_name);
|
||||||
std::fstream wdt_fh;
|
std::fstream wdt_fh;
|
||||||
wdt_fh.open(wdt_out, std::ios_base::out|std::ios_base::binary);
|
wdt_fh.open(wdt_out, std::ios_base::out|std::ios_base::binary);
|
||||||
@ -648,8 +648,8 @@ void ExtractMaps(void)
|
|||||||
{
|
{
|
||||||
uint32 olddeps;
|
uint32 olddeps;
|
||||||
uint32 depdiff;
|
uint32 depdiff;
|
||||||
sprintf(namebuf,"World\\Maps\\%s\\%s_%u_%u.adt",it->second.c_str(),it->second.c_str(),x,y);
|
sprintf(namebuf,"World\\Maps\\%s\\%s_%lu_%lu.adt",it->second.c_str(),it->second.c_str(),x,y);
|
||||||
sprintf(outbuf,MAPSDIR"/%u_%u_%u.adt",it->first,x,y);
|
sprintf(outbuf,MAPSDIR"/%lu_%lu_%lu.adt",it->first,x,y);
|
||||||
if(mpq.FileExists(namebuf))
|
if(mpq.FileExists(namebuf))
|
||||||
{
|
{
|
||||||
const ByteBuffer& bb = mpq.ExtractFile(namebuf);
|
const ByteBuffer& bb = mpq.ExtractFile(namebuf);
|
||||||
@ -683,7 +683,7 @@ void ExtractMaps(void)
|
|||||||
memcpy(md5ptr, h.GetDigest(), MD5_DIGEST_LENGTH);
|
memcpy(md5ptr, h.GetDigest(), MD5_DIGEST_LENGTH);
|
||||||
}
|
}
|
||||||
extr++;
|
extr++;
|
||||||
printf("[%u:%u] %s; %u new deps.\n",extr,it->first,namebuf,depdiff);
|
printf("[%lu:%lu] %s; %lu new deps.\n",extr,it->first,namebuf,depdiff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -692,7 +692,7 @@ void ExtractMaps(void)
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\nDONE - %u maps extracted, %u total dependencies.\n",extrtotal, texNames.size() + modelNames.size() + wmoNames.size());
|
printf("\nDONE - %lu maps extracted, %u total dependencies.\n",extrtotal, texNames.size() + modelNames.size() + wmoNames.size());
|
||||||
OutMD5(MAPSDIR,md5map);
|
OutMD5(MAPSDIR,md5map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -951,7 +951,7 @@ void ExtractSoundFiles(void)
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ADT_ExportStringSetByOffset(const uint8* data, uint32 off, std::set<NameAndAlt>& st, char* stop)
|
void ADT_ExportStringSetByOffset(const uint8* data, uint32 off, std::set<NameAndAlt>& st,const char* stop)
|
||||||
{
|
{
|
||||||
data += ((uint32*)data)[off]; // seek to correct absolute offset
|
data += ((uint32*)data)[off]; // seek to correct absolute offset
|
||||||
data += 28; // move ptr to real start of data
|
data += 28; // move ptr to real start of data
|
||||||
|
|||||||
@ -32,8 +32,8 @@ int main(int argc, char *argv[]);
|
|||||||
void ProcessCmdArgs(int argc, char *argv[]);
|
void ProcessCmdArgs(int argc, char *argv[]);
|
||||||
void PrintConfig(void);
|
void PrintConfig(void);
|
||||||
void PrintHelp(void);
|
void PrintHelp(void);
|
||||||
void OutSCP(char*, SCPStorageMap&, std::string);
|
void OutSCP(const char*, SCPStorageMap&, std::string);
|
||||||
void OutMD5(char*, MD5FileMap&);
|
void OutMD5(const char*, MD5FileMap&);
|
||||||
bool ConvertDBC(void);
|
bool ConvertDBC(void);
|
||||||
void ExtractMaps(void);
|
void ExtractMaps(void);
|
||||||
void ExtractMapDependencies(void);
|
void ExtractMapDependencies(void);
|
||||||
@ -41,7 +41,7 @@ void ExtractSoundFiles(void);
|
|||||||
|
|
||||||
void FetchTexturesFromModel(ByteBuffer);
|
void FetchTexturesFromModel(ByteBuffer);
|
||||||
|
|
||||||
void ADT_ExportStringSetByOffset(const uint8*, uint32, std::set<NameAndAlt>&, char*);
|
void ADT_ExportStringSetByOffset(const uint8*, uint32, std::set<NameAndAlt>&, const char*);
|
||||||
void ADT_FillTextureData(const uint8*,std::set<NameAndAlt>&);
|
void ADT_FillTextureData(const uint8*,std::set<NameAndAlt>&);
|
||||||
void ADT_FillWMOData(const uint8*,std::set<NameAndAlt>&);
|
void ADT_FillWMOData(const uint8*,std::set<NameAndAlt>&);
|
||||||
void ADT_FillModelData(const uint8*,std::set<NameAndAlt>&);
|
void ADT_FillModelData(const uint8*,std::set<NameAndAlt>&);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user