412 FILE* fin = fopen(file.c_str(),
"r");
416 char newguid[20], chraccount[20];
419 bool incHighest =
true;
420 if (guid && guid < sObjectMgr->GetGenerator<HighGuid::Player>().GetNextAfterMaxUsed())
453 snprintf(chraccount, 20,
"%u", account);
457 char buf[32000] =
"";
459 typedef std::map<
uint32 , uint32 > PetIds;
464 uint8 playerClass = 0;
472 if (!fgets(buf, 32000, fin))
479 std::string line; line.assign(buf);
482 size_t nw_pos = line.find_first_not_of(
" \t\n\r\7");
483 if (nw_pos == std::string::npos)
487 if ((line.substr(nw_pos, 16) ==
"== START DUMP ==") ||
488 (line.substr(nw_pos, 15) ==
"IMPORTANT NOTE:") ||
489 (line.substr(nw_pos, 14) ==
"== END DUMP =="))
507 TC_LOG_ERROR(
"misc",
"LoadPlayerDump: Can't extract table name from line: '%s'!", line.c_str());
522 if (i == DUMP_TABLE_COUNT)
524 TC_LOG_ERROR(
"misc",
"LoadPlayerDump: Unknown table: '%s'!", tn.c_str());
556 else if (!
ChangeNth(line, 3, name.c_str()))
559 const char null[5] =
"NULL";
585 for (
uint8 slot = 0; slot < EQUIPMENT_SLOT_END; ++slot)
586 if (!
ChangeGuid(line, 7 + slot, items, itemLowGuidOffset,
true))
595 if (!
ChangeGuid(line, 2, items, itemLowGuidOffset,
true))
597 if (!
ChangeGuid(line, 4, items, itemLowGuidOffset))
613 if (!
ChangeGuid(line, 2, items, itemLowGuidOffset))
622 if (!
ChangeGuid(line, 1, items, itemLowGuidOffset))
632 if (!
ChangeGuid(line, 2, items, itemLowGuidOffset))
639 std::string petIdStr =
GetNth(line, 1);
641 uint32 currentPetId =
atoul(petIdStr.c_str());
643 PetIds::const_iterator petIdsItr = petIds.find(currentPetId);
644 if (petIdsItr != petIds.end())
647 uint32 newPetId =
sObjectMgr->GeneratePetNumber();
648 petIds[currentPetId] = newPetId;
650 if (!
ChangeNth(line, 1, std::to_string(newPetId).c_str()))
659 std::string petIdStr =
GetNth(line, 1);
662 PetIds::const_iterator petIdsItr = petIds.find(
atoul(petIdStr.c_str()));
663 if (petIdsItr == petIds.end())
666 if (!
ChangeNth(line, 1, std::to_string(petIdsItr->second).c_str()))
672 TC_LOG_ERROR(
"misc",
"Unknown dump table type: %u", type);
678 trans->Append(line.c_str());
684 sWorld->AddCharacterInfo(ObjectGuid::Create<HighGuid::Player>(guid), account, name, gender, race, playerClass, level,
false);
#define ROLLBACK(DR)
Definition: PlayerDump.cpp:393
static ResponseCodes CheckPlayerName(std::string const &name, LocaleConstant locale, bool create=false)
Definition: ObjectMgr.cpp:7580
#define DUMP_TABLE_COUNT
Definition: PlayerDump.cpp:28
Definition: PlayerDump.h:31
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
Definition: PlayerDump.h:49
DumpTableType type
Definition: PlayerDump.cpp:32
#define snprintf
Definition: Common.h:76
Definition: SharedDefines.h:101
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
static uint32 GetCharactersCount(uint32 accountId)
Definition: AccountMgr.cpp:368
Definition: SharedDefines.h:4505
DumpTableType
Definition: PlayerDump.h:27
#define sWorld
Definition: World.h:887
std::map< ObjectGuid::LowType, ObjectGuid::LowType > DumpGuidMap
Definition: PlayerDump.h:72
Definition: PlayerDump.h:61
uint64 LowType
Definition: ObjectGuid.h:199
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: PreparedStatement.h:74
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
Definition: PlayerDump.h:60
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:133
Definition: PlayerDump.h:37
unsigned long atoul(char const *str)
Definition: Common.h:90
Definition: CharacterDatabase.h:37
bool ChangeGuid(std::string &str, uint32 n, PlayerDump::DumpGuidMap &guidMap, ObjectGuid::LowType guidOffset, bool allowZero=false)
Definition: PlayerDump.cpp:191
#define UI64FMTD
Definition: Define.h:137
Definition: PlayerDump.h:64
uint32_t uint32
Definition: Define.h:150
Definition: PlayerDump.h:46
std::string GetNth(std::string &str, uint32 n)
Definition: PlayerDump.cpp:154
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
std::string GetTableName(std::string const &str)
Definition: PlayerDump.cpp:127
Definition: PlayerDump.h:39
uint8_t uint8
Definition: g3dmath.h:164
Definition: PlayerDump.h:29
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
Definition: PlayerDump.h:55
Definition: PlayerDump.h:62
static DumpTable dumpTables[DUMP_TABLE_COUNT]
Definition: PlayerDump.cpp:35
Definition: PlayerDump.h:52
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
uint8_t uint8
Definition: Define.h:152
bool ChangeNth(std::string &str, uint32 n, char const *with, bool insert=false, bool allowZero=false)
Definition: PlayerDump.cpp:137
void fixNULLfields(std::string &line)
Definition: PlayerDump.cpp:395
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: PlayerDump.h:54
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: PlayerDump.h:41
Definition: CharacterDatabase.h:38
Definition: PlayerDump.h:43
Definition: SharedDefines.h:95
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58