-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcmangos.patch
144 lines (139 loc) · 4.55 KB
/
cmangos.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
diff --git a/src/game/Chat/Chat.cpp b/src/game/Chat/Chat.cpp
index 21f555727..68dd0a77c 100644
--- a/src/game/Chat/Chat.cpp
+++ b/src/game/Chat/Chat.cpp
@@ -678,6 +678,7 @@ ChatCommand* ChatHandler::getCommandTable()
static ChatCommand serverCommandTable[] =
{
+ { "zone", SEC_CONSOLE, true, &ChatHandler::HandleZoneAndAreaRequest, "", nullptr },
{ "corpses", SEC_GAMEMASTER, true, &ChatHandler::HandleServerCorpsesCommand, "", nullptr },
{ "exit", SEC_CONSOLE, true, &ChatHandler::HandleServerExitCommand, "", nullptr },
{ "idlerestart", SEC_ADMINISTRATOR, true, nullptr, "", serverIdleRestartCommandTable },
diff --git a/src/game/Chat/Chat.h b/src/game/Chat/Chat.h
index 2ff556e20..4a0f9b6f1 100644
--- a/src/game/Chat/Chat.h
+++ b/src/game/Chat/Chat.h
@@ -507,6 +507,7 @@ class ChatHandler
bool HandleSendMassMailCommand(char* args);
bool HandleSendMassMoneyCommand(char* args);
+ bool HandleZoneAndAreaRequest(char* args);
bool HandleServerCorpsesCommand(char* args);
bool HandleServerExitCommand(char* args);
bool HandleServerIdleRestartCommand(char* args);
diff --git a/src/mangosd/CMakeLists.txt b/src/mangosd/CMakeLists.txt
index 86ad8bb93..3b2ed2ec2 100644
--- a/src/mangosd/CMakeLists.txt
+++ b/src/mangosd/CMakeLists.txt
@@ -19,6 +19,8 @@
set(EXECUTABLE_NAME ${CMANGOS_BINARY_SERVER_NAME})
set(EXECUTABLE_SRCS
+ CliAddon.cpp
+ CliAddon.h
CliRunnable.cpp
CliRunnable.h
MaNGOSsoap.cpp
@@ -47,6 +49,7 @@ add_executable(${EXECUTABLE_NAME}
target_include_directories(${EXECUTABLE_NAME}
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
+ INTERFACE ${CMAKE_SOURCE_DIR}/game
PRIVATE ${OPENSSL_INCLUDE_DIR}
PRIVATE ${Boost_INCLUDE_DIRS}
)
diff --git a/src/mangosd/CliAddon.cpp b/src/mangosd/CliAddon.cpp
new file mode 100644
index 000000000..973e43e5b
--- /dev/null
+++ b/src/mangosd/CliAddon.cpp
@@ -0,0 +1,41 @@
+#include "CliAddon.h"
+#include "Maps/GridMap.h"
+
+std::istream& read_line(std::istream& in, CoordinateSet& cs)
+{
+ getline(in, cs.id, ',');
+ getline(in, cs.map, ',');
+ getline(in, cs.x, ',');
+ getline(in, cs.y, ',');
+ getline(in, cs.z, ',');
+ return in;
+}
+
+void getZoneAndArea(char* fileName)
+{
+ using namespace std;
+ ifstream csvread(fileName);
+ if (!csvread.is_open())
+ {
+ cerr<<"Error opening the file"<<endl;
+ return;
+ }
+ char zoneAndArea[] = "zone_and_area.csv";
+ char * newFileName = new char[strlen(fileName)+strlen(zoneAndArea)+1];
+ strcpy(newFileName, fileName);
+ strcat(newFileName, zoneAndArea);
+ ofstream csvwrite(newFileName);
+ csvwrite<<"--uniqueID,zoneID,areaID,\n";
+ for (CoordinateSet cs; read_line(csvread, cs); )
+ {
+ uint mapid = stoul(cs.map);
+ float ax = stof(cs.x);
+ float ay = stof(cs.y);
+ float az = stof(cs.z);
+ uint zone, area;
+ sTerrainMgr.LoadTerrain(mapid)->GetZoneAndAreaId(zone, area, ax, ay, az);
+ csvwrite<<cs.id<<","<<zone<<","<<area<<",";
+ }
+ csvread.close();
+ csvwrite.close();
+}
diff --git a/src/mangosd/CliAddon.h b/src/mangosd/CliAddon.h
new file mode 100644
index 000000000..479cef1c0
--- /dev/null
+++ b/src/mangosd/CliAddon.h
@@ -0,0 +1,21 @@
+#ifndef __CLIADDON_H
+#define __CLIADDON_H
+
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <cstring>
+
+struct CoordinateSet
+{
+ std::string id;
+ std::string map;
+ std::string x;
+ std::string y;
+ std::string z;
+};
+
+std::istream& read_line(std::istream& in, CoordinateSet& cs);
+void getZoneAndArea(char* fileName);
+
+#endif
diff --git a/src/mangosd/CliRunnable.cpp b/src/mangosd/CliRunnable.cpp
index 08e7f6e9d..322d6abb6 100644
--- a/src/mangosd/CliRunnable.cpp
+++ b/src/mangosd/CliRunnable.cpp
@@ -29,6 +29,7 @@
#include "Config/Config.h"
#include "Util.h"
#include "Accounts/AccountMgr.h"
+#include "CliAddon.h"
#include "CliRunnable.h"
#include "Maps/MapManager.h"
#include "Entities/Player.h"
@@ -63,6 +64,12 @@ void commandFinished(bool /*sucess*/)
fflush(stdout);
}
+bool ChatHandler::HandleZoneAndAreaRequest(char* args)
+{
+ getZoneAndArea(args);
+ return true;
+}
+
/// Delete a user account and all associated characters in this realm
/// \todo This function has to be enhanced to respect the login/realm split (delete char, delete account chars in realm, delete account chars in realm then delete account
bool ChatHandler::HandleAccountDeleteCommand(char* args)