Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
PlayerDump.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#include "AccountMgr.h"
7#include "Common.h"
8#include "DatabaseEnv.h"
9#include "ObjectMgr.h"
10#include "PlayerDump.h"
11#include "UpdateFields.h"
12#include "World.h"
13
14#define DUMP_TABLE_COUNT 29
15
19
21{
22 char const* name;
24};
25
27{
28 { "characters", DTT_CHARACTER },
29 { "character_account_data", DTT_CHAR_TABLE },
30 { "character_achievement", DTT_CHAR_TABLE },
31 { "character_achievement_progress", DTT_CHAR_TABLE },
32 { "character_action", DTT_CHAR_TABLE },
33 { "character_aura", DTT_CHAR_TABLE },
34 { "character_currency", DTT_CHAR_TABLE },
35 { "character_cuf_profiles", DTT_CHAR_TABLE },
36 { "character_declinedname", DTT_CHAR_TABLE },
37 { "character_equipmentsets", DTT_EQSET_TABLE},
38 { "character_gifts", DTT_ITEM_GIFT },
39 { "character_glyphs", DTT_CHAR_TABLE },
40 { "character_homebind", DTT_CHAR_TABLE },
41 { "character_inventory", DTT_INVENTORY },
42 { "character_pet", DTT_PET },
43 { "character_pet_declinedname", DTT_PET_DECLINEDNAME },
44 { "character_queststatus", DTT_CHAR_TABLE },
45 { "character_queststatus_rewarded", DTT_CHAR_TABLE },
46 { "character_reputation", DTT_CHAR_TABLE },
47 { "character_skills", DTT_CHAR_TABLE },
48 { "character_spell", DTT_CHAR_TABLE },
49 { "character_spell_cooldown", DTT_CHAR_TABLE },
50 { "character_talent", DTT_CHAR_TABLE },
51 { "item_instance", DTT_ITEM },
52 { "mail", DTT_MAIL },
53 { "mail_items", DTT_MAIL_ITEM },
54 { "pet_aura", DTT_PET_TABLE },
55 { "pet_spell", DTT_PET_TABLE },
56 { "pet_spell_cooldown", DTT_PET_TABLE },
57};
58
59// Low level functions
60static bool findtoknth(std::string& str, int n, std::string::size_type& s, std::string::size_type& e)
61{
62 int i; s = e = 0;
63 std::string::size_type size = str.size();
64 for (i = 1; s < size && i < n; s++) if (str[s] == ' ') ++i;
65 if (i < n)
66 return false;
67
68 e = str.find(' ', s);
69
70 return e != std::string::npos;
71}
72
73std::string gettoknth(std::string& str, int n)
74{
75 std::string::size_type s = 0, e = 0;
76 if (!findtoknth(str, n, s, e))
77 return "";
78
79 return str.substr(s, e - s);
80}
81
82bool findnth(std::string& str, int n, std::string::size_type& s, std::string::size_type& e)
83{
84 s = str.find("VALUES ('") + 9;
85 if (s == std::string::npos) return false;
86
87 do
88 {
89 e = str.find('\'', s);
90 if (e == std::string::npos) return false;
91 } while (str[e - 1] == '\\');
92
93 for (int i = 1; i < n; ++i)
94 {
95 do
96 {
97 s = e + 4;
98 e = str.find('\'', s);
99 if (e == std::string::npos) return false;
100 } while (str[e - 1] == '\\');
101 }
102 return true;
103}
104
105std::string gettablename(std::string& str)
106{
107 std::string::size_type s = 13;
108 std::string::size_type e = str.find(_TABLE_SIM_, s);
109 if (e == std::string::npos)
110 return "";
111
112 return str.substr(s, e - s);
113}
114
115bool changenth(std::string& str, int n, char const* with, bool insert = false, bool nonzero = false)
116{
117 std::string::size_type s, e;
118 if (!findnth(str, n, s, e))
119 return false;
120
121 if (nonzero && str.substr(s, e - s) == "0")
122 return true; // not an error
123 if (!insert)
124 str.replace(s, e - s, with);
125 else
126 str.insert(s, with);
127
128 return true;
129}
130
131std::string getnth(std::string& str, int n)
132{
133 std::string::size_type s, e;
134 if (!findnth(str, n, s, e))
135 return "";
136
137 return str.substr(s, e - s);
138}
139
140bool changetoknth(std::string& str, int n, char const* with, bool insert = false, bool nonzero = false)
141{
142 std::string::size_type s = 0, e = 0;
143 if (!findtoknth(str, n, s, e))
144 return false;
145 if (nonzero && str.substr(s, e - s) == "0")
146 return true; // not an error
147 if (!insert)
148 str.replace(s, e - s, with);
149 else
150 str.insert(s, with);
151
152 return true;
153}
154
155uint32 registerNewGuid(uint32 oldGuid, std::map<uint32, uint32>& guidMap, uint32 hiGuid)
156{
157 std::map<uint32, uint32>::const_iterator itr = guidMap.find(oldGuid);
158 if (itr != guidMap.end())
159 return itr->second;
160
161 uint32 newguid = hiGuid + guidMap.size();
162 guidMap[oldGuid] = newguid;
163 return newguid;
164}
165
166bool changeGuid(std::string& str, int n, std::map<uint32, uint32>& guidMap, uint32 hiGuid, bool nonzero = false)
167{
168 char chritem[20];
169 uint32 oldGuid = atoi(getnth(str, n).c_str());
170 if (nonzero && oldGuid == 0)
171 return true; // not an error
172
173 uint32 newGuid = registerNewGuid(oldGuid, guidMap, hiGuid);
174 snprintf(chritem, 20, "%u", newGuid);
175
176 return changenth(str, n, chritem, false, nonzero);
177}
178
179bool changetokGuid(std::string& str, int n, std::map<uint32, uint32>& guidMap, uint32 hiGuid, bool nonzero = false)
180{
181 char chritem[20];
182 uint32 oldGuid = atoi(gettoknth(str, n).c_str());
183 if (nonzero && oldGuid == 0)
184 return true; // not an error
185
186 uint32 newGuid = registerNewGuid(oldGuid, guidMap, hiGuid);
187 snprintf(chritem, 20, "%u", newGuid);
188
189 return changetoknth(str, n, chritem, false, nonzero);
190}
191
192std::string CreateDumpString(char const* tableName, QueryResult result)
193{
194 if (!tableName || !result) return "";
195 std::ostringstream ss;
196 ss << "INSERT INTO " << _TABLE_SIM_ << tableName << _TABLE_SIM_ << " VALUES (";
197 Field* fields = result->Fetch();
198 for (uint32 i = 0; i < result->GetFieldCount(); ++i)
199 {
200 if (i == 0) ss << '\'';
201 else ss << ", '";
202
203 std::string s = fields[i].GetString();
204 CharacterDatabase.EscapeString(s);
205 ss << s;
206
207 ss << '\'';
208 }
209 ss << ");";
210 return ss.str();
211}
212
213std::string PlayerDumpWriter::GenerateWhereStr(char const* field, uint32 guid)
214{
215 std::ostringstream wherestr;
216 wherestr << field << " = '" << guid << '\'';
217 return wherestr.str();
218}
219
220std::string PlayerDumpWriter::GenerateWhereStr(char const* field, GUIDs const& guids, GUIDs::const_iterator& itr)
221{
222 std::ostringstream wherestr;
223 wherestr << field << " IN ('";
224 for (; itr != guids.end(); ++itr)
225 {
226 wherestr << *itr;
227
228 if (wherestr.str().size() > MAX_QUERY_LEN - 50) // near to max query
229 {
230 ++itr;
231 break;
232 }
233
234 GUIDs::const_iterator itr2 = itr;
235 if (++itr2 != guids.end())
236 wherestr << "', '";
237 }
238 wherestr << "')";
239 return wherestr.str();
240}
241
242void StoreGUID(QueryResult result, uint32 field, std::set<uint32>& guids)
243{
244 Field* fields = result->Fetch();
245 uint32 guid = fields[field].GetUInt32();
246 if (guid)
247 guids.insert(guid);
248}
249
250void StoreGUID(QueryResult result, uint32 data, uint32 field, std::set<uint32>& guids)
251{
252 Field* fields = result->Fetch();
253 std::string dataStr = fields[data].GetString();
254 uint32 guid = atoi(gettoknth(dataStr, field).c_str());
255 if (guid)
256 guids.insert(guid);
257}
258
259// Writing - High-level functions
260bool PlayerDumpWriter::DumpTable(std::string& dump, uint32 guid, char const* tableFrom, char const* tableTo, DumpTableType type)
261{
262 GUIDs const* guids = NULL;
263 char const* fieldname = NULL;
264
265 switch (type)
266 {
267 case DTT_ITEM: fieldname = "guid"; guids = &items; break;
268 case DTT_ITEM_GIFT: fieldname = "item_guid"; guids = &items; break;
269 case DTT_PET: fieldname = "owner"; break;
271 fieldname = "owner"; break;
272 case DTT_PET_TABLE: fieldname = "guid"; guids = &pets; break;
273 case DTT_MAIL: fieldname = "receiver"; break;
274 case DTT_MAIL_ITEM: fieldname = "mail_id"; guids = &mails; break;
275 default: fieldname = "guid"; break;
276 }
277
278 // for guid set stop if set is empty
279 if (guids && guids->empty())
280 return true; // nothing to do
281
282 // setup for guids case start position
283 GUIDs::const_iterator guids_itr;
284 if (guids)
285 guids_itr = guids->begin();
286
287 do
288 {
289 std::string wherestr;
290
291 if (guids) // set case, get next guids string
292 wherestr = GenerateWhereStr(fieldname, *guids, guids_itr);
293 else // not set case, get single guid string
294 wherestr = GenerateWhereStr(fieldname, guid);
295
296 QueryResult result = CharacterDatabase.PQuery("SELECT * FROM %s WHERE %s", tableFrom, wherestr.c_str());
297 if (!result)
298 return true;
299
300 do
301 {
302 // collect guids
303 switch (type)
304 {
305 case DTT_INVENTORY:
306 StoreGUID(result, 3, items); // item guid collection (character_inventory.item)
307 break;
308 case DTT_PET:
309 StoreGUID(result, 0, pets); // pet petnumber collection (character_pet.id)
310 break;
311 case DTT_MAIL:
312 StoreGUID(result, 0, mails); // mail id collection (mail.id)
313 break;
314 case DTT_MAIL_ITEM:
315 StoreGUID(result, 1, items); // item guid collection (mail_items.item_guid)
316 break;
317 case DTT_CHARACTER:
318 {
319 uint32 const deleteInfosAccountIndex = CharacterDumpFields::DeleteInfosAccount - 1;
320 if (result->GetFieldCount() <= deleteInfosAccountIndex) // avoid crashes on next check
321 {
322 SF_LOG_FATAL("misc", "PlayerDumpWriter::DumpTable - Trying to access non-existing or wrong positioned field (`deleteInfos_Account`) in `characters` table.");
323 return false;
324 }
325
326 if (result->Fetch()[deleteInfosAccountIndex].GetUInt32()) // characters.deleteInfos_Account - if filled error
327 return false;
328 break;
329 }
330 default:
331 break;
332 }
333
334 dump += CreateDumpString(tableTo, result);
335 dump += "\n";
336 } while (result->NextRow());
337 } while (guids && guids_itr != guids->end()); // not set case iterate single time, set case iterate for all guids
338 return true;
339}
340
341bool PlayerDumpWriter::GetDump(uint32 guid, std::string& dump)
342{
343 dump = "";
344
345 dump += "IMPORTANT NOTE: THIS DUMPFILE IS MADE FOR USE WITH THE 'PDUMP' COMMAND ONLY - EITHER THROUGH INGAME CHAT OR ON CONSOLE!\n";
346 dump += "IMPORTANT NOTE: DO NOT apply it directly - it will irreversibly DAMAGE and CORRUPT your database! You have been warned!\n\n";
347
348 for (int i = 0; i < DUMP_TABLE_COUNT; ++i)
349 if (!DumpTable(dump, guid, dumpTables[i].name, dumpTables[i].name, dumpTables[i].type))
350 return false;
351
354
355 return true;
356}
357
358DumpReturn PlayerDumpWriter::WriteDump(const std::string& file, uint32 guid)
359{
361 if (strstr(file.c_str(), "\\") || strstr(file.c_str(), "/"))
364 if (FILE* f = fopen(file.c_str(), "r"))
365 {
366 fclose(f);
368 }
369 FILE* fout = fopen(file.c_str(), "w");
370 if (!fout)
372
374 std::string dump;
375 if (!GetDump(guid, dump))
377
378 fprintf(fout, "%s\n", dump.c_str());
379 fclose(fout);
380 return ret;
381}
382
383// Reading - High-level functions
384#define ROLLBACK(DR) {fclose(fin); return (DR);}
385
386void fixNULLfields(std::string& line)
387{
388 std::string nullString("'NULL'");
389 size_t pos = line.find(nullString);
390 while (pos != std::string::npos)
391 {
392 line.replace(pos, nullString.length(), "NULL");
393 pos = line.find(nullString);
394 }
395}
396
397DumpReturn PlayerDumpReader::LoadDump(std::string const& file, uint32 account, std::string name, uint32 guid)
398{
399 uint32 charcount = AccountMgr::GetCharactersCount(account);
400 if (charcount >= 10)
401 return DUMP_TOO_MANY_CHARS;
402
403 FILE* fin = fopen(file.c_str(), "r");
404 if (!fin)
406
407 char newguid[20], chraccount[20], newpetid[20], currpetid[20], lastpetid[20];
408
409 // make sure the same guid doesn't already exist and is safe to use
410 bool incHighest = true;
411 if (guid != 0 && guid < sObjectMgr->_hiCharGuid)
412 {
413 PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHECK_GUID);
414 stmt->setUInt32(0, guid);
415 PreparedQueryResult result = CharacterDatabase.Query(stmt);
416
417 if (result)
418 guid = sObjectMgr->_hiCharGuid; // use first free if exists
419 else incHighest = false;
420 }
421 else
422 guid = sObjectMgr->_hiCharGuid;
423
424 // normalize the name if specified and check if it exists
425 if (!normalizePlayerName(name))
426 name = "";
427
429 {
430 PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHECK_NAME);
431 stmt->setString(0, name);
432 PreparedQueryResult result = CharacterDatabase.Query(stmt);
433
434 if (result)
435 name = ""; // use the one from the dump
436 }
437 else
438 name = "";
439
440 // name encoded or empty
441
442 snprintf(newguid, 20, "%u", guid);
443 snprintf(chraccount, 20, "%u", account);
444 snprintf(newpetid, 20, "%u", sObjectMgr->GeneratePetNumber());
445 snprintf(lastpetid, 20, "%s", "");
446
447 std::map<uint32, uint32> items;
448 std::map<uint32, uint32> mails;
449 char buf[32000] = "";
450
451 typedef std::map<uint32, uint32> PetIds; // old->new petid relation
452 typedef PetIds::value_type PetIdsPair;
453 PetIds petids;
454
455 uint8 gender = GENDER_NONE;
456 uint8 race = RACE_NONE;
457 uint8 playerClass = 0;
458 uint8 level = 1;
459
460 SQLTransaction trans = CharacterDatabase.BeginTransaction();
461 while (!feof(fin))
462 {
463 if (!fgets(buf, 32000, fin))
464 {
465 if (feof(fin))
466 break;
468 }
469
470 std::string line; line.assign(buf);
471
472 // skip empty strings
473 size_t nw_pos = line.find_first_not_of(" \t\n\r\7");
474 if (nw_pos == std::string::npos)
475 continue;
476
477 // skip logfile-side dump start notice, the important notes and dump end notices
478 if ((line.substr(nw_pos, 16) == "== START DUMP ==") ||
479 (line.substr(nw_pos, 15) == "IMPORTANT NOTE:") ||
480 (line.substr(nw_pos, 14) == "== END DUMP =="))
481 continue;
482
483 // add required_ check
484 /*
485 if (line.substr(nw_pos, 41) == "UPDATE character_db_version SET required_")
486 {
487 if (!CharacterDatabase.Execute(line.c_str()))
488 ROLLBACK(DUMP_FILE_BROKEN);
489
490 continue;
491 }
492 */
493
494 // determine table name and load type
495 std::string tn = gettablename(line);
496 if (tn.empty())
497 {
498 SF_LOG_ERROR("misc", "LoadPlayerDump: Can't extract table name from line: '%s'!", line.c_str());
500 }
501
503 uint8 i;
504 for (i = 0; i < DUMP_TABLE_COUNT; ++i)
505 {
506 if (tn == dumpTables[i].name)
507 {
508 type = dumpTables[i].type;
509 break;
510 }
511 }
512
513 if (i == DUMP_TABLE_COUNT)
514 {
515 SF_LOG_ERROR("misc", "LoadPlayerDump: Unknown table: '%s'!", tn.c_str());
517 }
518
519 // change the data to server values
520 switch (type)
521 {
522 case DTT_CHARACTER:
523 {
524 if (!changenth(line, CharacterDumpFields::Guid, newguid)) // characters.guid update
526
527 if (!changenth(line, CharacterDumpFields::Account, chraccount)) // characters.account update
529
530 race = uint8(atol(getnth(line, CharacterDumpFields::Race).c_str()));
531 playerClass = uint8(atol(getnth(line, CharacterDumpFields::Class).c_str()));
532 gender = uint8(atol(getnth(line, CharacterDumpFields::Gender).c_str()));
533 level = uint8(atol(getnth(line, CharacterDumpFields::Level).c_str()));
534 if (name == "")
535 {
536 // check if the original name already exists
537 name = getnth(line, CharacterDumpFields::Name);
538
539 PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHECK_NAME);
540 stmt->setString(0, name);
541 PreparedQueryResult result = CharacterDatabase.Query(stmt);
542
543 if (result)
544 if (!changenth(line, CharacterDumpFields::AtLogin, "1")) // characters.at_login set to "rename on login"
546 }
547 else if (!changenth(line, CharacterDumpFields::Name, name.c_str())) // characters.name
549
550 const char null[5] = "NULL";
551 if (!changenth(line, CharacterDumpFields::DeleteInfosAccount, null)) // characters.deleteInfos_Account
553 if (!changenth(line, CharacterDumpFields::DeleteInfosName, null)) // characters.deleteInfos_Name
555 if (!changenth(line, CharacterDumpFields::DeleteDate, null)) // characters.deleteDate
557 break;
558 }
559 case DTT_CHAR_TABLE:
560 {
561 if (!changenth(line, 1, newguid)) // character_*.guid update
563 break;
564 }
565 case DTT_EQSET_TABLE:
566 {
567 if (!changenth(line, 1, newguid))
568 ROLLBACK(DUMP_FILE_BROKEN); // character_equipmentsets.guid
569
570 char newSetGuid[24];
571 snprintf(newSetGuid, 24, UI64FMTD, sObjectMgr->GenerateEquipmentSetGuid());
572 if (!changenth(line, 2, newSetGuid))
573 ROLLBACK(DUMP_FILE_BROKEN); // character_equipmentsets.setguid
574 break;
575 }
576 case DTT_INVENTORY:
577 {
578 if (!changenth(line, 1, newguid)) // character_inventory.guid update
580
581 if (!changeGuid(line, 2, items, sObjectMgr->_hiItemGuid, true))
582 ROLLBACK(DUMP_FILE_BROKEN); // character_inventory.bag update
583 if (!changeGuid(line, 4, items, sObjectMgr->_hiItemGuid))
584 ROLLBACK(DUMP_FILE_BROKEN); // character_inventory.item update
585 break;
586 }
587 case DTT_MAIL: // mail
588 {
589 if (!changeGuid(line, 1, mails, sObjectMgr->_mailId))
590 ROLLBACK(DUMP_FILE_BROKEN); // mail.id update
591 if (!changenth(line, 6, newguid)) // mail.receiver update
593 break;
594 }
595 case DTT_MAIL_ITEM: // mail_items
596 {
597 if (!changeGuid(line, 1, mails, sObjectMgr->_mailId))
598 ROLLBACK(DUMP_FILE_BROKEN); // mail_items.id
599 if (!changeGuid(line, 2, items, sObjectMgr->_hiItemGuid))
600 ROLLBACK(DUMP_FILE_BROKEN); // mail_items.item_guid
601 if (!changenth(line, 3, newguid)) // mail_items.receiver
603 break;
604 }
605 case DTT_ITEM:
606 {
607 // item, owner, data field:item, owner guid
608 if (!changeGuid(line, 1, items, sObjectMgr->_hiItemGuid))
609 ROLLBACK(DUMP_FILE_BROKEN); // item_instance.guid update
610 if (!changenth(line, 3, newguid)) // item_instance.owner_guid update
612 break;
613 }
614 case DTT_ITEM_GIFT:
615 {
616 if (!changenth(line, 1, newguid)) // character_gifts.guid update
618 if (!changeGuid(line, 2, items, sObjectMgr->_hiItemGuid))
619 ROLLBACK(DUMP_FILE_BROKEN); // character_gifts.item_guid update
620 break;
621 }
622 case DTT_PET:
623 {
624 //store a map of old pet id to new inserted pet id for use by type 5 tables
625 snprintf(currpetid, 20, "%s", getnth(line, PetDumpFields::Id).c_str());
626 if (*lastpetid == '\0')
627 snprintf(lastpetid, 20, "%s", currpetid);
628 if (strcmp(lastpetid, currpetid) != 0)
629 {
630 snprintf(newpetid, 20, "%d", sObjectMgr->GeneratePetNumber());
631 snprintf(lastpetid, 20, "%s", currpetid);
632 }
633
634 std::map<uint32, uint32> ::const_iterator petids_iter = petids.find(atoi(currpetid));
635
636 if (petids_iter == petids.end())
637 {
638 petids.insert(PetIdsPair(atoi(currpetid), atoi(newpetid)));
639 }
640
641 if (!changenth(line, PetDumpFields::Id, newpetid)) // character_pet.id update
643 if (!changenth(line, PetDumpFields::Owner, newguid)) // character_pet.owner update
645
646 break;
647 }
649 {
650 snprintf(currpetid, 20, "%s", getnth(line, PetDeclinedNameDumpFields::Id).c_str());
651
652 std::map<uint32, uint32> ::const_iterator petids_iter = petids.find(atoi(currpetid));
653 if (petids_iter == petids.end())
655
656 snprintf(newpetid, 20, "%d", petids_iter->second);
657
658 if (!changenth(line, PetDeclinedNameDumpFields::Id, newpetid)) // character_pet_declinedname.id
660 if (!changenth(line, PetDeclinedNameDumpFields::Owner, newguid)) // character_pet_declinedname.owner
662
663 break;
664 }
665 case DTT_PET_TABLE: // pet_aura, pet_spell, pet_spell_cooldown
666 {
667 snprintf(currpetid, 20, "%s", getnth(line, 1).c_str());
668
669 // lookup currpetid and match to new inserted pet id
670 std::map<uint32, uint32> ::const_iterator petids_iter = petids.find(atoi(currpetid));
671 if (petids_iter == petids.end()) // couldn't find new inserted id
673
674 snprintf(newpetid, 20, "%d", petids_iter->second);
675
676 if (!changenth(line, 1, newpetid))
678
679 break;
680 }
681 default:
682 SF_LOG_ERROR("misc", "Unknown dump table type: %u", type);
683 break;
684 }
685
686 fixNULLfields(line);
687
688 trans->Append(line.c_str());
689 }
690
691 CharacterDatabase.CommitTransaction(trans);
692
693 uint32 realm = -1; // TODO
694 // in case of name conflict player has to rename at login anyway
695 sWorld->AddCharacterNameData(guid, name, gender, race, playerClass, level, realm);
696
697 sObjectMgr->_hiItemGuid += items.size();
698 sObjectMgr->_mailId += mails.size();
699
700 if (incHighest)
701 ++sObjectMgr->_hiCharGuid;
702
703 fclose(fin);
704
705 return DUMP_SUCCESS;
706}
@ CHAR_SEL_CHECK_NAME
@ CHAR_SEL_CHECK_GUID
#define MAX_QUERY_LEN
Definition Common.h:195
#define _TABLE_SIM_
Definition DatabaseEnv.h:20
#define UI64FMTD
Definition Define.h:64
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
#define SF_LOG_FATAL(filterType__,...)
Definition Log.h:146
#define SF_LOG_ERROR(filterType__,...)
Definition Log.h:143
bool normalizePlayerName(std::string &name)
#define sObjectMgr
Definition ObjectMgr.h:1617
static bool findtoknth(std::string &str, int n, std::string::size_type &s, std::string::size_type &e)
void fixNULLfields(std::string &line)
std::string CreateDumpString(char const *tableName, QueryResult result)
#define DUMP_TABLE_COUNT
bool findnth(std::string &str, int n, std::string::size_type &s, std::string::size_type &e)
std::string gettablename(std::string &str)
bool changetoknth(std::string &str, int n, char const *with, bool insert=false, bool nonzero=false)
void StoreGUID(QueryResult result, uint32 field, std::set< uint32 > &guids)
static DumpTable dumpTables[DUMP_TABLE_COUNT]
uint32 registerNewGuid(uint32 oldGuid, std::map< uint32, uint32 > &guidMap, uint32 hiGuid)
std::string gettoknth(std::string &str, int n)
bool changetokGuid(std::string &str, int n, std::map< uint32, uint32 > &guidMap, uint32 hiGuid, bool nonzero=false)
bool changeGuid(std::string &str, int n, std::map< uint32, uint32 > &guidMap, uint32 hiGuid, bool nonzero=false)
bool changenth(std::string &str, int n, char const *with, bool insert=false, bool nonzero=false)
std::string getnth(std::string &str, int n)
#define ROLLBACK(DR)
DumpReturn
Definition PlayerDump.h:79
@ DUMP_FILE_OPEN_ERROR
Definition PlayerDump.h:81
@ DUMP_CHARACTER_DELETED
Definition PlayerDump.h:85
@ DUMP_SUCCESS
Definition PlayerDump.h:80
@ DUMP_TOO_MANY_CHARS
Definition PlayerDump.h:82
@ DUMP_FILE_BROKEN
Definition PlayerDump.h:84
DumpTableType
Definition PlayerDump.h:16
@ DTT_EQSET_TABLE
Definition PlayerDump.h:25
@ DTT_INVENTORY
Definition PlayerDump.h:27
@ DTT_CHAR_TABLE
Definition PlayerDump.h:19
@ DTT_PET_TABLE
Definition PlayerDump.h:42
@ DTT_MAIL
Definition PlayerDump.h:29
@ DTT_MAIL_ITEM
Definition PlayerDump.h:32
@ DTT_PET_DECLINEDNAME
Definition PlayerDump.h:41
@ DTT_PET
Definition PlayerDump.h:40
@ DTT_ITEM
Definition PlayerDump.h:35
@ DTT_ITEM_GIFT
Definition PlayerDump.h:38
@ DTT_CHARACTER
Definition PlayerDump.h:17
Skyfire::AutoPtr< PreparedResultSet, Skyfire::Mutex > PreparedQueryResult
Definition QueryResult.h:94
Skyfire::AutoPtr< ResultSet, Skyfire::Mutex > QueryResult
Definition QueryResult.h:48
@ GENDER_NONE
@ RACE_NONE
Skyfire::AutoPtr< Transaction, Skyfire::Mutex > SQLTransaction
Definition Transaction.h:42
static uint32 GetCharactersCount(uint32 accountId)
Definition Field.h:16
std::string GetString() const
Definition Field.h:228
uint32 GetUInt32() const
Definition Field.h:105
static ResponseCodes CheckPlayerName(std::string const &name, bool create=false)
DumpReturn LoadDump(std::string const &file, uint32 account, std::string name, uint32 guid)
bool GetDump(uint32 guid, std::string &dump)
bool DumpTable(std::string &dump, uint32 guid, char const *tableFrom, char const *tableTo, DumpTableType type)
std::set< uint32 > GUIDs
Definition PlayerDump.h:102
DumpReturn WriteDump(std::string const &file, uint32 guid)
std::string GenerateWhereStr(char const *field, GUIDs const &guids, GUIDs::const_iterator &itr)
void setString(const uint8 index, const std::string &value)
void setUInt32(const uint8 index, const uint32 value)
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition Main.cpp:41
#define sWorld
Definition World.h:910
@ CONFIG_PDUMP_NO_OVERWRITE
Definition World.h:155
@ CONFIG_PDUMP_NO_PATHS
Definition World.h:154
DumpTableType type
char const * name