1 | /* |
---|
2 | * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> |
---|
3 | * |
---|
4 | * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> |
---|
5 | * |
---|
6 | * This program is free software; you can redistribute it and/or modify |
---|
7 | * it under the terms of the GNU General Public License as published by |
---|
8 | * the Free Software Foundation; either version 2 of the License, or |
---|
9 | * (at your option) any later version. |
---|
10 | * |
---|
11 | * This program is distributed in the hope that it will be useful, |
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | * GNU General Public License for more details. |
---|
15 | * |
---|
16 | * You should have received a copy of the GNU General Public License |
---|
17 | * along with this program; if not, write to the Free Software |
---|
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
19 | */ |
---|
20 | |
---|
21 | #ifndef _PLAYER_DUMP_H |
---|
22 | #define _PLAYER_DUMP_H |
---|
23 | /* |
---|
24 | #include "Log.h" |
---|
25 | #include "Object.h" |
---|
26 | #include "Bag.h" |
---|
27 | #include "Creature.h" |
---|
28 | #include "Player.h" |
---|
29 | #include "DynamicObject.h" |
---|
30 | #include "GameObject.h" |
---|
31 | #include "Corpse.h" |
---|
32 | #include "QuestDef.h" |
---|
33 | #include "Path.h" |
---|
34 | #include "ItemPrototype.h" |
---|
35 | #include "NPCHandler.h" |
---|
36 | #include "Database/DatabaseEnv.h" |
---|
37 | #include "AuctionHouseObject.h" |
---|
38 | #include "Mail.h" |
---|
39 | #include "Map.h" |
---|
40 | #include "ObjectAccessor.h" |
---|
41 | #include "ObjectDefines.h" |
---|
42 | #include "Policies/Singleton.h" |
---|
43 | #include "Database/SQLStorage.h" |
---|
44 | */ |
---|
45 | #include <string> |
---|
46 | #include <map> |
---|
47 | #include <set> |
---|
48 | |
---|
49 | enum DumpTableType |
---|
50 | { |
---|
51 | DTT_CHARACTER, // // characters |
---|
52 | |
---|
53 | DTT_CHAR_TABLE, // // character_action, character_aura, character_homebind, |
---|
54 | // character_queststatus, character_reputation, |
---|
55 | // character_spell, character_spell_cooldown, character_ticket, |
---|
56 | // character_tutorial |
---|
57 | |
---|
58 | DTT_INVENTORY, // -> item guids collection // character_inventory |
---|
59 | |
---|
60 | DTT_MAIL, // -> mail ids collection // mail |
---|
61 | // -> item_text |
---|
62 | |
---|
63 | DTT_MAIL_ITEM, // <- mail ids // mail_items |
---|
64 | // -> item guids collection |
---|
65 | |
---|
66 | DTT_ITEM, // <- item guids // item_instance |
---|
67 | // -> item_text |
---|
68 | |
---|
69 | DTT_ITEM_GIFT, // <- item guids // character_gifts |
---|
70 | |
---|
71 | DTT_PET, // -> pet guids collection // character_pet |
---|
72 | DTT_PET_TABLE, // <- pet guids // pet_aura, pet_spell, pet_spell_cooldown |
---|
73 | DTT_ITEM_TEXT, // <- item_text // item_text |
---|
74 | }; |
---|
75 | |
---|
76 | enum DumpReturn |
---|
77 | { |
---|
78 | DUMP_SUCCESS, |
---|
79 | DUMP_FILE_OPEN_ERROR, |
---|
80 | DUMP_TOO_MANY_CHARS, |
---|
81 | DUMP_UNEXPECTED_END, |
---|
82 | DUMP_FILE_BROKEN, |
---|
83 | }; |
---|
84 | |
---|
85 | class PlayerDump |
---|
86 | { |
---|
87 | protected: |
---|
88 | PlayerDump() {} |
---|
89 | }; |
---|
90 | |
---|
91 | class PlayerDumpWriter : public PlayerDump |
---|
92 | { |
---|
93 | public: |
---|
94 | PlayerDumpWriter() {} |
---|
95 | |
---|
96 | std::string GetDump(uint32 guid); |
---|
97 | DumpReturn WriteDump(std::string file, uint32 guid); |
---|
98 | private: |
---|
99 | typedef std::set<uint32> GUIDs; |
---|
100 | |
---|
101 | void DumpTable(std::string& dump, uint32 guid, char const*tableFrom, char const*tableTo, DumpTableType type); |
---|
102 | std::string GenerateWhereStr(char const* field, GUIDs const& guids, GUIDs::const_iterator& itr); |
---|
103 | std::string GenerateWhereStr(char const* field, uint32 guid); |
---|
104 | |
---|
105 | GUIDs pets; |
---|
106 | GUIDs mails; |
---|
107 | GUIDs items; |
---|
108 | GUIDs texts; |
---|
109 | }; |
---|
110 | |
---|
111 | class PlayerDumpReader : public PlayerDump |
---|
112 | { |
---|
113 | public: |
---|
114 | PlayerDumpReader() {} |
---|
115 | |
---|
116 | DumpReturn LoadDump(std::string file, uint32 account, std::string name, uint32 guid); |
---|
117 | }; |
---|
118 | |
---|
119 | #endif |
---|