aboutsummaryrefslogtreecommitdiff
path: root/src/game/PlayerDump.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/PlayerDump.cpp')
-rw-r--r--src/game/PlayerDump.cpp128
1 files changed, 64 insertions, 64 deletions
diff --git a/src/game/PlayerDump.cpp b/src/game/PlayerDump.cpp
index ffa3babc179..472f80a77ad 100644
--- a/src/game/PlayerDump.cpp
+++ b/src/game/PlayerDump.cpp
@@ -70,7 +70,7 @@ static bool findtoknth(std::string &str, int n, std::string::size_type &s, std::
{
int i; s = e = 0;
std::string::size_type size = str.size();
- for (i = 1; s < size && i < n; s++) if(str[s] == ' ') ++i;
+ for (i = 1; s < size && i < n; s++) if (str[s] == ' ') ++i;
if (i < n)
return false;
@@ -82,7 +82,7 @@ static bool findtoknth(std::string &str, int n, std::string::size_type &s, std::
std::string gettoknth(std::string &str, int n)
{
std::string::size_type s = 0, e = 0;
- if(!findtoknth(str, n, s, e))
+ if (!findtoknth(str, n, s, e))
return "";
return str.substr(s, e-s);
@@ -124,12 +124,12 @@ std::string gettablename(std::string &str)
bool changenth(std::string &str, int n, const char *with, bool insert = false, bool nonzero = false)
{
std::string::size_type s, e;
- if(!findnth(str,n,s,e))
+ if (!findnth(str,n,s,e))
return false;
- if(nonzero && str.substr(s,e-s) == "0")
+ if (nonzero && str.substr(s,e-s) == "0")
return true; // not an error
- if(!insert)
+ if (!insert)
str.replace(s,e-s, with);
else
str.insert(s, with);
@@ -140,7 +140,7 @@ bool changenth(std::string &str, int n, const char *with, bool insert = false, b
std::string getnth(std::string &str, int n)
{
std::string::size_type s, e;
- if(!findnth(str,n,s,e))
+ if (!findnth(str,n,s,e))
return "";
return str.substr(s, e-s);
@@ -149,11 +149,11 @@ std::string getnth(std::string &str, int n)
bool changetoknth(std::string &str, int n, const char *with, bool insert = false, bool nonzero = false)
{
std::string::size_type s = 0, e = 0;
- if(!findtoknth(str, n, s, e))
+ if (!findtoknth(str, n, s, e))
return false;
- if(nonzero && str.substr(s,e-s) == "0")
+ if (nonzero && str.substr(s,e-s) == "0")
return true; // not an error
- if(!insert)
+ if (!insert)
str.replace(s, e-s, with);
else
str.insert(s, with);
@@ -164,7 +164,7 @@ bool changetoknth(std::string &str, int n, const char *with, bool insert = false
uint32 registerNewGuid(uint32 oldGuid, std::map<uint32, uint32> &guidMap, uint32 hiGuid)
{
std::map<uint32, uint32>::const_iterator itr = guidMap.find(oldGuid);
- if(itr != guidMap.end())
+ if (itr != guidMap.end())
return itr->second;
uint32 newguid = hiGuid + guidMap.size();
@@ -200,7 +200,7 @@ bool changetokGuid(std::string &str, int n, std::map<uint32, uint32> &guidMap, u
std::string CreateDumpString(char const* tableName, QueryResult_AutoPtr result)
{
- if(!tableName || !result) return "";
+ if (!tableName || !result) return "";
std::ostringstream ss;
ss << "INSERT INTO "<< _TABLE_SIM_ << tableName << _TABLE_SIM_ << " VALUES (";
Field *fields = result->Fetch();
@@ -234,14 +234,14 @@ std::string PlayerDumpWriter::GenerateWhereStr(char const* field, GUIDs const& g
{
wherestr << *itr;
- if(wherestr.str().size() > MAX_QUERY_LEN - 50) // near to max query
+ if (wherestr.str().size() > MAX_QUERY_LEN - 50) // near to max query
{
++itr;
break;
}
GUIDs::const_iterator itr2 = itr;
- if(++itr2 != guids.end())
+ if (++itr2 != guids.end())
wherestr << "','";
}
wherestr << "')";
@@ -252,7 +252,7 @@ void StoreGUID(QueryResult_AutoPtr result,uint32 field,std::set<uint32>& guids)
{
Field* fields = result->Fetch();
uint32 guid = fields[field].GetUInt32();
- if(guid)
+ if (guid)
guids.insert(guid);
}
@@ -261,7 +261,7 @@ void StoreGUID(QueryResult_AutoPtr result,uint32 data,uint32 field, std::set<uin
Field* fields = result->Fetch();
std::string dataStr = fields[data].GetCppString();
uint32 guid = atoi(gettoknth(dataStr, field).c_str());
- if(guid)
+ if (guid)
guids.insert(guid);
}
@@ -284,25 +284,25 @@ void PlayerDumpWriter::DumpTable(std::string& dump, uint32 guid, char const*tabl
}
// for guid set stop if set is empty
- if(guids && guids->empty())
+ if (guids && guids->empty())
return; // nothing to do
// setup for guids case start position
GUIDs::const_iterator guids_itr;
- if(guids)
+ if (guids)
guids_itr = guids->begin();
do
{
std::string wherestr;
- if(guids) // set case, get next guids string
+ if (guids) // set case, get next guids string
wherestr = GenerateWhereStr(fieldname,*guids,guids_itr);
else // not set case, get single guid string
wherestr = GenerateWhereStr(fieldname,guid);
QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT * FROM %s WHERE %s", tableFrom, wherestr.c_str());
- if(!result)
+ if (!result)
return;
do
@@ -343,20 +343,20 @@ std::string PlayerDumpWriter::GetDump(uint32 guid)
// revision check guard
/*
QueryNamedResult* result = CharacterDatabase.QueryNamed("SELECT * FROM character_db_version LIMIT 1");
- if(result)
+ if (result)
{
QueryFieldNames const& namesMap = result->GetFieldNames();
std::string reqName;
for (QueryFieldNames::const_iterator itr = namesMap.begin(); itr != namesMap.end(); ++itr)
{
- if(itr->substr(0,9)=="required_")
+ if (itr->substr(0,9)=="required_")
{
reqName = *itr;
break;
}
}
- if(!reqName.empty())
+ if (!reqName.empty())
{
// this will fail at wrong character DB version
dump += "UPDATE character_db_version SET "+reqName+" = 1 WHERE FALSE;\n\n";
@@ -462,9 +462,9 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
CharacterDatabase.BeginTransaction();
while (!feof(fin))
{
- if(!fgets(buf, 32000, fin))
+ if (!fgets(buf, 32000, fin))
{
- if(feof(fin)) break;
+ if (feof(fin)) break;
ROLLBACK(DUMP_FILE_BROKEN);
}
@@ -472,18 +472,18 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
// skip empty strings
size_t nw_pos = line.find_first_not_of(" \t\n\r\7");
- if(nw_pos==std::string::npos)
+ if (nw_pos==std::string::npos)
continue;
// skip NOTE
- if(line.substr(nw_pos,15)=="IMPORTANT NOTE:")
+ if (line.substr(nw_pos,15)=="IMPORTANT NOTE:")
continue;
// add required_ check
/*
- if(line.substr(nw_pos,41)=="UPDATE character_db_version SET required_")
+ if (line.substr(nw_pos,41)=="UPDATE character_db_version SET required_")
{
- if(!CharacterDatabase.Execute(line.c_str()))
+ if (!CharacterDatabase.Execute(line.c_str()))
ROLLBACK(DUMP_FILE_BROKEN);
continue;
@@ -492,7 +492,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
// determine table name and load type
std::string tn = gettablename(line);
- if(tn.empty())
+ if (tn.empty())
{
sLog.outError("LoadPlayerDump: Can't extract table name from line: '%s'!", line.c_str());
ROLLBACK(DUMP_FILE_BROKEN);
@@ -519,25 +519,25 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
switch(type)
{
case DTT_CHAR_TABLE:
- if(!changenth(line, 1, newguid))
+ if (!changenth(line, 1, newguid))
ROLLBACK(DUMP_FILE_BROKEN);
break;
case DTT_CHARACTER: // character t.
{
- if(!changenth(line, 1, newguid))
+ if (!changenth(line, 1, newguid))
ROLLBACK(DUMP_FILE_BROKEN);
// guid, data field:guid, items
- if(!changenth(line, 2, chraccount))
+ if (!changenth(line, 2, chraccount))
ROLLBACK(DUMP_FILE_BROKEN);
std::string vals = getnth(line, 3);
- if(!changetoknth(vals, OBJECT_FIELD_GUID+1, newguid))
+ if (!changetoknth(vals, OBJECT_FIELD_GUID+1, newguid))
ROLLBACK(DUMP_FILE_BROKEN);
for (uint16 field = PLAYER_FIELD_INV_SLOT_HEAD; field < PLAYER_FARSIGHT; field++)
- if(!changetokGuid(vals, field+1, items, objmgr.m_hiItemGuid, true))
+ if (!changetokGuid(vals, field+1, items, objmgr.m_hiItemGuid, true))
ROLLBACK(DUMP_FILE_BROKEN);
- if(!changenth(line, 3, vals.c_str()))
+ if (!changenth(line, 3, vals.c_str()))
ROLLBACK(DUMP_FILE_BROKEN);
if (name == "")
{
@@ -548,51 +548,51 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
result = CharacterDatabase.PQuery("SELECT 1 FROM characters WHERE name = '%s'", name.c_str());
if (result)
{
- if(!changenth(line, 37, "1")) // rename on login: `at_login` field 37 in raw field list
+ if (!changenth(line, 37, "1")) // rename on login: `at_login` field 37 in raw field list
ROLLBACK(DUMP_FILE_BROKEN);
}
}
- else if(!changenth(line, 4, name.c_str()))
+ else if (!changenth(line, 4, name.c_str()))
ROLLBACK(DUMP_FILE_BROKEN);
break;
}
case DTT_INVENTORY: // character_inventory t.
{
- if(!changenth(line, 1, newguid))
+ if (!changenth(line, 1, newguid))
ROLLBACK(DUMP_FILE_BROKEN);
// bag, item
- if(!changeGuid(line, 2, items, objmgr.m_hiItemGuid, true))
+ if (!changeGuid(line, 2, items, objmgr.m_hiItemGuid, true))
ROLLBACK(DUMP_FILE_BROKEN);
- if(!changeGuid(line, 4, items, objmgr.m_hiItemGuid))
+ if (!changeGuid(line, 4, items, objmgr.m_hiItemGuid))
ROLLBACK(DUMP_FILE_BROKEN);
break;
}
case DTT_ITEM: // item_instance t.
{
// item, owner, data field:item, owner guid
- if(!changeGuid(line, 1, items, objmgr.m_hiItemGuid))
+ if (!changeGuid(line, 1, items, objmgr.m_hiItemGuid))
ROLLBACK(DUMP_FILE_BROKEN);
- if(!changenth(line, 2, newguid))
+ if (!changenth(line, 2, newguid))
ROLLBACK(DUMP_FILE_BROKEN);
std::string vals = getnth(line,3);
- if(!changetokGuid(vals, OBJECT_FIELD_GUID+1, items, objmgr.m_hiItemGuid))
+ if (!changetokGuid(vals, OBJECT_FIELD_GUID+1, items, objmgr.m_hiItemGuid))
ROLLBACK(DUMP_FILE_BROKEN);
- if(!changetoknth(vals, ITEM_FIELD_OWNER+1, newguid))
+ if (!changetoknth(vals, ITEM_FIELD_OWNER+1, newguid))
ROLLBACK(DUMP_FILE_BROKEN);
- if(!changetokGuid(vals, ITEM_FIELD_ITEM_TEXT_ID+1, itemTexts, objmgr.m_ItemTextId,true))
+ if (!changetokGuid(vals, ITEM_FIELD_ITEM_TEXT_ID+1, itemTexts, objmgr.m_ItemTextId,true))
ROLLBACK(DUMP_FILE_BROKEN);
- if(!changenth(line, 3, vals.c_str()))
+ if (!changenth(line, 3, vals.c_str()))
ROLLBACK(DUMP_FILE_BROKEN);
break;
}
case DTT_ITEM_GIFT: // character_gift
{
// guid,item_guid,
- if(!changenth(line, 1, newguid))
+ if (!changenth(line, 1, newguid))
ROLLBACK(DUMP_FILE_BROKEN);
- if(!changeGuid(line, 2, items, objmgr.m_hiItemGuid))
+ if (!changeGuid(line, 2, items, objmgr.m_hiItemGuid))
ROLLBACK(DUMP_FILE_BROKEN);
break;
}
@@ -600,8 +600,8 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
{
//store a map of old pet id to new inserted pet id for use by type 5 tables
snprintf(currpetid, 20, "%s", getnth(line, 1).c_str());
- if(strlen(lastpetid)==0) snprintf(lastpetid, 20, "%s", currpetid);
- if(strcmp(lastpetid,currpetid)!=0)
+ if (strlen(lastpetid)==0) snprintf(lastpetid, 20, "%s", currpetid);
+ if (strcmp(lastpetid,currpetid)!=0)
{
snprintf(newpetid, 20, "%d", objmgr.GeneratePetNumber());
snprintf(lastpetid, 20, "%s", currpetid);
@@ -609,15 +609,15 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
std::map<uint32, uint32> :: const_iterator petids_iter = petids.find(atoi(currpetid));
- if(petids_iter == petids.end())
+ if (petids_iter == petids.end())
{
petids.insert(PetIdsPair(atoi(currpetid), atoi(newpetid)));
}
// item, entry, owner, ...
- if(!changenth(line, 1, newpetid))
+ if (!changenth(line, 1, newpetid))
ROLLBACK(DUMP_FILE_BROKEN);
- if(!changenth(line, 3, newguid))
+ if (!changenth(line, 3, newguid))
ROLLBACK(DUMP_FILE_BROKEN);
break;
@@ -628,12 +628,12 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
// lookup currpetid and match to new inserted pet id
std::map<uint32, uint32> :: const_iterator petids_iter = petids.find(atoi(currpetid));
- if(petids_iter == petids.end()) // couldn't find new inserted id
+ if (petids_iter == petids.end()) // couldn't find new inserted id
ROLLBACK(DUMP_FILE_BROKEN);
snprintf(newpetid, 20, "%d", petids_iter->second);
- if(!changenth(line, 1, newpetid))
+ if (!changenth(line, 1, newpetid))
ROLLBACK(DUMP_FILE_BROKEN);
break;
@@ -641,29 +641,29 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
case DTT_MAIL: // mail
{
// id,messageType,stationery,mailtemplate,sender,receiver,subject,itemText
- if(!changeGuid(line, 1, mails, objmgr.m_mailid))
+ if (!changeGuid(line, 1, mails, objmgr.m_mailid))
ROLLBACK(DUMP_FILE_BROKEN);
- if(!changenth(line, 6, newguid))
+ if (!changenth(line, 6, newguid))
ROLLBACK(DUMP_FILE_BROKEN);
- if(!changeGuid(line, 8, itemTexts, objmgr.m_ItemTextId))
+ if (!changeGuid(line, 8, itemTexts, objmgr.m_ItemTextId))
ROLLBACK(DUMP_FILE_BROKEN);
break;
}
case DTT_MAIL_ITEM: // mail_items
{
// mail_id,item_guid,item_template,receiver
- if(!changeGuid(line, 1, mails, objmgr.m_mailid))
+ if (!changeGuid(line, 1, mails, objmgr.m_mailid))
ROLLBACK(DUMP_FILE_BROKEN);
- if(!changeGuid(line, 2, items, objmgr.m_hiItemGuid))
+ if (!changeGuid(line, 2, items, objmgr.m_hiItemGuid))
ROLLBACK(DUMP_FILE_BROKEN);
- if(!changenth(line, 4, newguid))
+ if (!changenth(line, 4, newguid))
ROLLBACK(DUMP_FILE_BROKEN);
break;
}
case DTT_ITEM_TEXT: // item_text
{
// id
- if(!changeGuid(line, 1, itemTexts, objmgr.m_ItemTextId))
+ if (!changeGuid(line, 1, itemTexts, objmgr.m_ItemTextId))
ROLLBACK(DUMP_FILE_BROKEN);
// add it to cache
@@ -677,7 +677,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
break;
}
- if(!CharacterDatabase.Execute(line.c_str()))
+ if (!CharacterDatabase.Execute(line.c_str()))
ROLLBACK(DUMP_FILE_BROKEN);
}
@@ -687,7 +687,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
objmgr.m_mailid += mails.size();
objmgr.m_ItemTextId += itemTexts.size();
- if(incHighest)
+ if (incHighest)
++objmgr.m_hiCharGuid;
fclose(fin);