-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathintegratedDumpCmangos.patch
221 lines (219 loc) · 9.41 KB
/
integratedDumpCmangos.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
diff --git a/src/game/World/Addon.cpp b/src/game/World/Addon.cpp
new file mode 100644
index 000000000..1edb7cad9
--- /dev/null
+++ b/src/game/World/Addon.cpp
@@ -0,0 +1,173 @@
+#include "Addon.h"
+#include "Maps/GridMap.h"
+#include "Database/DatabaseEnv.h"
+#include <thread>
+
+//Ehh i compile for windows... dunno if this is correct, if you get errors just remove this part!
+#ifndef WIN64
+ #ifndef uint
+ #define uint unsigned int
+ #endif
+#endif
+
+class dumper {
+public:
+ void creature() {
+ //Creature
+ WorldDatabase.PQuery("DROP TABLE IF EXISTS creature_zone;");
+ WorldDatabase.PQuery("CREATE TABLE creature_zone (guid int unsigned NOT NULL DEFAULT 0 COMMENT 'Guid', id mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Identifier', zone mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'ZoneId', area mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'AreaId', outdoors BOOL COMMENT 'Is the point outdoors');");
+
+ int count = 0;
+
+ QueryResult* result = WorldDatabase.PQuery("SELECT guid, id, map, position_x, position_y, position_z FROM creature;");
+
+ if (result)
+ {
+ do
+ {
+ Field* fields = result->Fetch();
+ int guid = fields[0].GetInt32();
+ uint32 id = fields[1].GetUInt32();
+ uint32 map = fields[2].GetUInt32();
+ float position_x = fields[3].GetFloat();
+ float position_y = fields[4].GetFloat();
+ float position_z = fields[5].GetFloat();
+ uint zone, area;
+ TerrainInfo* terInfo = sTerrainMgr.LoadTerrain(map);
+ terInfo->GetZoneAndAreaId(zone, area, position_x, position_y, position_z);
+ bool outdoors = terInfo->IsOutdoors(position_x, position_y, position_z);
+
+ WorldDatabase.PQuery("INSERT INTO creature_zone VALUES (%d, %u, %u, %u, %d);", guid, id, zone, area, outdoors);
+ if (count % 1000 == 0){
+ std::cout<<"Creature Zone: "<<count<<"/"<<result->GetRowCount()<<std::endl;
+ }
+ count++;
+ }
+ while (result->NextRow());
+ delete result;
+ std::cout<<"Creature Done!"<<std::endl;
+ }
+ }
+
+ void creature_movement() {
+ WorldDatabase.PQuery("DROP TABLE IF EXISTS creature_movement_zone;");
+ WorldDatabase.PQuery("CREATE TABLE creature_movement_zone (id int unsigned NOT NULL DEFAULT 0 COMMENT 'GUID for creature table', point mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Point', zone mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'ZoneId', area mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'AreaId', outdoors BOOL COMMENT 'Is the point outdoors');");
+
+ int count = 0;
+ QueryResult* result = WorldDatabase.PQuery("SELECT cm.id, cm.point, c.map, cm.position_x, cm.position_y, cm.position_z FROM creature_movement AS cm, creature AS c WHERE cm.id=c.guid;");
+
+ if (result)
+ {
+ do
+ {
+ Field* fields = result->Fetch();
+ int id = fields[0].GetInt32();
+ int point = fields[1].GetInt32();
+ uint32 map = fields[2].GetUInt32();
+ float position_x = fields[3].GetFloat();
+ float position_y = fields[4].GetFloat();
+ float position_z = fields[5].GetFloat();
+ uint zone, area;
+ TerrainInfo* terInfo = sTerrainMgr.LoadTerrain(map);
+ terInfo->GetZoneAndAreaId(zone, area, position_x, position_y, position_z);
+ bool outdoors = terInfo->IsOutdoors(position_x, position_y, position_z);
+
+ WorldDatabase.PQuery("INSERT INTO creature_movement_zone VALUES (%d, %d, %u, %u, %d);", id, point, zone, area, outdoors);
+ if (count % 1000 == 0){
+ std::cout<<"Creature_movement Zone: "<<count<<"/"<<result->GetRowCount()<<std::endl;
+ }
+ count++;
+ }
+ while (result->NextRow());
+ delete result;
+ std::cout<<"Creature_movement Done!"<<std::endl;
+ }
+ }
+
+ void creature_movement_template() {
+ WorldDatabase.PQuery("DROP TABLE IF EXISTS creature_movement_template_zone;");
+ WorldDatabase.PQuery("CREATE TABLE creature_movement_template_zone (id int unsigned NOT NULL DEFAULT 0 COMMENT 'Id for creature_template table', point mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Point', zone mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'ZoneId', area mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'AreaId', guid int unsigned NOT NULL DEFAULT 0 COMMENT 'Id for creature table', outdoors BOOL COMMENT 'Is the point outdoors');");
+
+ int count = 0;
+ QueryResult* result = WorldDatabase.PQuery("SELECT cmt.entry, cmt.point, c.map, cmt.position_x, cmt.position_y, cmt.position_z, c.guid FROM creature_movement_template AS cmt, creature_template AS ct, creature AS c WHERE cmt.entry=ct.Entry AND c.id=ct.Entry;");
+
+ if (result)
+ {
+ do
+ {
+ Field* fields = result->Fetch();
+ int id = fields[0].GetInt32();
+ int point = fields[1].GetInt32();
+ uint32 map = fields[2].GetUInt32();
+ float position_x = fields[3].GetFloat();
+ float position_y = fields[4].GetFloat();
+ float position_z = fields[5].GetFloat();
+ int guid = fields[6].GetInt32();
+ uint zone, area;
+ TerrainInfo* terInfo = sTerrainMgr.LoadTerrain(map);
+ terInfo->GetZoneAndAreaId(zone, area, position_x, position_y, position_z);
+ bool outdoors = terInfo->IsOutdoors(position_x, position_y, position_z);
+
+ WorldDatabase.PQuery("INSERT INTO creature_movement_template_zone VALUES (%d, %d, %u, %u, %d, %d);", id, point, zone, area, guid, outdoors);
+ if (count % 1000 == 0){
+ std::cout<<"Creature_movement_template Zone: "<<count<<"/"<<result->GetRowCount()<<std::endl;
+ }
+ count++;
+ }
+ while (result->NextRow());
+ delete result;
+ std::cout<<"Creature_movement_template Done!"<<std::endl;
+ }
+ }
+
+ void gameobject() {
+ //GameObject
+ WorldDatabase.PQuery("DROP TABLE IF EXISTS gameobject_zone;");
+ WorldDatabase.PQuery("CREATE TABLE gameobject_zone (guid int unsigned NOT NULL DEFAULT 0 COMMENT 'Guid', id mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Identifier', zone mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'ZoneId', area mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'AreaId', outdoors BOOL COMMENT 'Is the point outdoors');");
+
+ int count = 0;
+
+ QueryResult* result = WorldDatabase.PQuery("SELECT guid, id, map, position_x, position_y, position_z FROM gameobject;");
+
+ if (result)
+ {
+ do
+ {
+ Field* fields = result->Fetch();
+ int guid = fields[0].GetInt32();
+ uint32 id = fields[1].GetUInt32();
+ uint32 map = fields[2].GetUInt32();
+ float position_x = fields[3].GetFloat();
+ float position_y = fields[4].GetFloat();
+ float position_z = fields[5].GetFloat();
+ uint zone, area;
+ TerrainInfo* terInfo = sTerrainMgr.LoadTerrain(map);
+ terInfo->GetZoneAndAreaId(zone, area, position_x, position_y, position_z);
+ bool outdoors = terInfo->IsOutdoors(position_x, position_y, position_z);
+
+ WorldDatabase.PQuery("INSERT INTO gameobject_zone VALUES (%d, %u, %u, %u, %d);", guid, id, zone, area, outdoors);
+ if (count % 1000 == 0){
+ std::cout<<"Gameobject Zone: "<<count<<"/"<<result->GetRowCount()<<std::endl;
+ }
+ count++;
+ }
+ while (result->NextRow());
+ delete result;
+ std::cout<<"Gameobject Done!"<<std::endl;
+ }
+ }
+};
+
+void getZoneAndArea()
+{
+ // This is ugly as all hell but hopefully we get some performance out of it.
+ std::cout<<"Starting 4 threads"<<std::endl;
+ std::thread creature(&dumper::creature, dumper());
+ std::thread creature_movement(&dumper::creature_movement, dumper());
+ std::thread creature_movement_template(&dumper::creature_movement_template, dumper());
+ std::thread gameobject(&dumper::gameobject, dumper());
+ creature.join();
+ creature_movement.join();
+ creature_movement_template.join();
+ gameobject.join();
+}
diff --git a/src/game/World/Addon.h b/src/game/World/Addon.h
new file mode 100644
index 000000000..da974502e
--- /dev/null
+++ b/src/game/World/Addon.h
@@ -0,0 +1,11 @@
+#ifndef __ADDON_H
+#define __ADDON_H
+
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <cstring>
+
+void getZoneAndArea();
+
+#endif
diff --git a/src/game/World/World.cpp b/src/game/World/World.cpp
index 029b82efe..f633ee210 100644
--- a/src/game/World/World.cpp
+++ b/src/game/World/World.cpp
@@ -68,6 +68,8 @@
#include "Maps/TransportMgr.h"
#include "Anticheat/Anticheat.hpp"
+#include "Addon.h"
+
#ifdef BUILD_AHBOT
#include "AuctionHouseBot/AuctionHouseBot.h"
#endif
@@ -1420,6 +1422,11 @@ void World::SetInitialWorldSettings()
uint32 uStartInterval = WorldTimer::getMSTimeDiff(startTime, WorldTimer::getMSTime());
sLog.outString("SERVER STARTUP TIME: %i minutes %i seconds", uStartInterval / 60000, (uStartInterval % 60000) / 1000);
sLog.outString();
+ //The end of the void World::SetInitialWorldSettings() function if you need to manually add it somewhere.
+ sLog.outString("---------------------------------------");
+ sLog.outString(" Addon: Dump it ");
+ sLog.outString("---------------------------------------");
+ getZoneAndArea();
}
void World::DetectDBCLang()