765{
767 if (charcount >= 10)
769
770 std::string newguid, chraccount;
771
772
773 bool incHighest = true;
774 if (guid && guid < sObjectMgr->GetGenerator<HighGuid::Player>().GetNextAfterMaxUsed())
775 {
778
780 guid =
sObjectMgr->GetGenerator<HighGuid::Player>().GetNextAfterMaxUsed();
781 else
782 incHighest = false;
783 }
784 else
785 guid =
sObjectMgr->GetGenerator<HighGuid::Player>().GetNextAfterMaxUsed();
786
787
789 name.clear();
790
792 {
795
797 name.clear();
798 }
799 else
800 name.clear();
801
802
803 newguid = std::to_string(guid);
804 chraccount = std::to_string(account);
805
806 std::map<ObjectGuid::LowType, ObjectGuid::LowType> items;
808
809 std::map<ObjectGuid::LowType, ObjectGuid::LowType> mails;
811
812 std::map<ObjectGuid::LowType, ObjectGuid::LowType> petIds;
814
815 std::map<uint64, uint64> equipmentSetIds;
817
818 std::string line;
819
824
825
826 std::size_t lineNumber = 0;
827
829 while (std::getline(input, line))
830 {
831 ++lineNumber;
832
833
834 std::size_t nw_pos = line.find_first_not_of(" \t\n\r\7");
835 if (nw_pos == std::string::npos)
836 continue;
837
838
839 static std::string const SkippedLine = "IMPORTANT NOTE:";
840 if (line.substr(nw_pos, SkippedLine.size()) == SkippedLine)
841 continue;
842
843
845 if (tn.empty())
846 {
847 LOG_ERROR(
"misc",
"LoadPlayerDump: (line {}) Can't extract table name!", lineNumber);
849 }
850
854 {
856 {
858 break;
859 }
860 }
861
863 {
864 LOG_ERROR(
"misc",
"LoadPlayerDump: (line {}) Unknown table: `{}`!", lineNumber, tn);
866 }
867
871
872
874 {
876 continue;
877
879 {
883 break;
887 break;
891 break;
895 break;
899 break;
903 break;
905 {
906 static std::string const NullString("NULL");
909 break;
910 }
911 }
912 }
913
914
915 switch (type)
916 {
918 {
919 race = *Acore::StringTo<uint32>(
GetColumn(ts, line,
"race"));
920 playerClass = *Acore::StringTo<uint32>(
GetColumn(ts, line,
"class"));
921 gender = *Acore::StringTo<uint32>(
GetColumn(ts, line,
"gender"));
922 level = *Acore::StringTo<uint32>(
GetColumn(ts, line,
"level"));
923 if (name.empty())
924 {
925
927 std::size_t maxCharsFromOriginalName =
MAX_PLAYER_NAME - guidPart.length();
928
929 name =
GetColumn(ts, line,
"name").substr(0, maxCharsFromOriginalName) + guidPart;
930
931
936 }
939 break;
940 }
941 default:
942 break;
943 }
944
946
947 trans->Append(line.c_str());
948 }
949
950 if (input.fail() && !input.eof())
952
954
955
956 sCharacterCache->AddCharacterCacheEntry(
ObjectGuid(HighGuid::Player, guid), account, name, gender, race, playerClass, level);
957
958 sObjectMgr->GetGenerator<HighGuid::Item>().Set(
sObjectMgr->GetGenerator<HighGuid::Item>().GetNextAfterMaxUsed() + items.size());
961 sObjectMgr->_equipmentSetGuid += equipmentSetIds.size();
962
963 if (incHighest)
964 sObjectMgr->GetGenerator<HighGuid::Player>().Generate();
965
966 sWorld->UpdateRealmCharCount(account);
967
969}
#define LOG_ERROR(filterType__,...)
Definition: Log.h:157
std::uint8_t uint8
Definition: Define.h:109
std::uint32_t uint32
Definition: Define.h:107
std::uint64_t uint64
Definition: Define.h:106
@ GENDER_NONE
Definition: SharedDefines.h:63
@ CHAR_NAME_SUCCESS
Definition: SharedDefines.h:3419
@ CLASS_NONE
Definition: SharedDefines.h:140
@ RACE_NONE
Definition: SharedDefines.h:70
#define MAX_PLAYER_NAME
Definition: ObjectMgr.h:683
#define sObjectMgr
Definition: ObjectMgr.h:1635
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:208
std::string GetColumn(TableStruct const &ts, std::string &str, std::string const &column)
Definition: PlayerDump.cpp:483
bool ChangeGuid(TableStruct const &ts, std::string &str, std::string const &column, MapType< T, T, Rest... > &guidMap, T guidOffset, bool allowZero=false)
Definition: PlayerDump.cpp:505
bool ChangeColumn(TableStruct const &ts, std::string &str, std::string const &column, std::string const &with, bool allowZero=false)
Definition: PlayerDump.cpp:470
uint32 const DUMP_TABLE_COUNT
Definition: PlayerDump.cpp:123
@ GUID_TYPE_NULL
Definition: PlayerDump.cpp:45
@ GUID_TYPE_MAIL
Definition: PlayerDump.cpp:38
@ GUID_TYPE_PET
Definition: PlayerDump.cpp:37
@ GUID_TYPE_EQUIPMENT_SET
Definition: PlayerDump.cpp:42
@ GUID_TYPE_CHAR
Definition: PlayerDump.cpp:36
@ GUID_TYPE_ITEM
Definition: PlayerDump.cpp:39
@ GUID_TYPE_ACCOUNT
Definition: PlayerDump.cpp:35
DumpTable const DumpTables[]
Definition: PlayerDump.cpp:88
bool ValidateFields(TableStruct const &ts, std::string const &str, std::size_t lineNumber)
Definition: PlayerDump.cpp:429
void FixNULLfields(std::string &line)
Definition: PlayerDump.cpp:753
std::vector< TableStruct > CharacterTables
Definition: PlayerDump.cpp:166
std::string GetTableName(std::string const &str)
Definition: PlayerDump.cpp:418
@ DUMP_SUCCESS
Definition: PlayerDump.h:54
@ DUMP_TOO_MANY_CHARS
Definition: PlayerDump.h:56
@ DUMP_FILE_BROKEN
Definition: PlayerDump.h:57
DumpTableType
Definition: PlayerDump.h:25
@ DTT_CHARACTER
Definition: PlayerDump.h:26
#define sCharacterCache
Definition: CharacterCache.h:83
@ CHAR_SEL_CHECK_NAME
Definition: CharacterDatabase.h:37
@ CHAR_SEL_CHECK_GUID
Definition: CharacterDatabase.h:38
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:69
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: DatabaseEnvFwd.h:45
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define sWorld
Definition: World.h:443
std::string StringFormat(FormatString< Args... > fmt, Args &&... args)
Default AC string format function.
Definition: StringFormat.h:34
uint32 GetCharactersCount(uint32 accountId)
Definition: AccountMgr.cpp:295
Definition: PreparedStatement.h:157
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:77
Definition: ObjectGuid.h:118
uint32 LowType
Definition: ObjectGuid.h:122
static uint8 CheckPlayerName(std::string_view name, bool create=false)
Definition: ObjectMgr.cpp:8432
DumpTableType Type
Definition: PlayerDump.cpp:85
Definition: PlayerDump.cpp:149
bool IsDependentField
Definition: PlayerDump.cpp:153
std::string FieldName
Definition: PlayerDump.cpp:150
GuidType FieldGuidType
Definition: PlayerDump.cpp:152
Definition: PlayerDump.cpp:157
std::vector< TableField > TableFields
Definition: PlayerDump.cpp:160