summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/Makefile.am6
-rw-r--r--src/net/eathena/network.cpp6
-rw-r--r--src/net/eathena/protocolout.cpp2
-rw-r--r--src/net/eathena/updateprotocol.cpp44
-rw-r--r--src/net/eathena/updateprotocol.h29
-rw-r--r--src/net/protocoloutupdate.h26
-rw-r--r--src/net/tmwa/network.cpp6
-rw-r--r--src/net/tmwa/protocolout.cpp3
-rw-r--r--src/net/tmwa/updateprotocol.cpp44
-rw-r--r--src/net/tmwa/updateprotocol.h29
11 files changed, 194 insertions, 5 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 99a2bd0e5..2272a3125 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1502,6 +1502,8 @@ SET(SRCS_TMWA
net/tmwa/tradehandler.h
net/tmwa/traderecv.cpp
net/tmwa/traderecv.h
+ net/tmwa/updateprotocol.cpp
+ net/tmwa/updateprotocol.h
)
SET(SRCS_TMWAEATHENA
@@ -1735,6 +1737,8 @@ SET(SRCS_EATHENA
net/eathena/tradehandler.h
net/eathena/traderecv.cpp
net/eathena/traderecv.h
+ net/eathena/updateprotocol.cpp
+ net/eathena/updateprotocol.h
net/eathena/vendinghandler.cpp
net/eathena/vendinghandler.h
net/eathena/vendingrecv.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index bb73c2050..6587795ff 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1348,7 +1348,9 @@ manaplus_SOURCES += \
net/tmwa/tradehandler.cpp \
net/tmwa/tradehandler.h \
net/tmwa/traderecv.cpp \
- net/tmwa/traderecv.h
+ net/tmwa/traderecv.h \
+ net/tmwa/updateprotocol.cpp \
+ net/tmwa/updateprotocol.h
endif
if ENABLE_EATHENA
@@ -1585,6 +1587,8 @@ manaplus_SOURCES += gui/windows/bankwindow.cpp \
net/eathena/tradehandler.h \
net/eathena/traderecv.cpp \
net/eathena/traderecv.h \
+ net/eathena/updateprotocol.cpp \
+ net/eathena/updateprotocol.h \
net/eathena/vendinghandler.cpp \
net/eathena/vendinghandler.h \
net/eathena/vendingrecv.cpp \
diff --git a/src/net/eathena/network.cpp b/src/net/eathena/network.cpp
index 2842760a7..1271f029c 100644
--- a/src/net/eathena/network.cpp
+++ b/src/net/eathena/network.cpp
@@ -108,6 +108,12 @@ void Network::registerHandlers()
void Network::clearHandlers()
{
+ for (size_t f = 0; f < packet_lengths_size; f ++)
+ {
+ mPackets[f].name = "";
+ mPackets[f].len = 0;
+ mPackets[f].func = nullptr;
+ }
}
void Network::dispatchMessages()
diff --git a/src/net/eathena/protocolout.cpp b/src/net/eathena/protocolout.cpp
index f37d5e37b..3bc15194f 100644
--- a/src/net/eathena/protocolout.cpp
+++ b/src/net/eathena/protocolout.cpp
@@ -18,7 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
namespace EAthena
{
#include "net/protocoloutdefine.h"
@@ -26,5 +25,4 @@ namespace EAthena
#undef packet
} // namespace EAthena
-
#include "debug.h"
diff --git a/src/net/eathena/updateprotocol.cpp b/src/net/eathena/updateprotocol.cpp
new file mode 100644
index 000000000..ebe17c575
--- /dev/null
+++ b/src/net/eathena/updateprotocol.cpp
@@ -0,0 +1,44 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2015 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "net/eathena/updateprotocol.h"
+
+#include "net/eathena/network.h"
+#include "net/eathena/protocolout.h"
+
+#include "debug.h"
+
+namespace EAthena
+{
+
+void updateProtocol()
+{
+#include "net/protocoloutupdate.h"
+#include "net/eathena/packetsout.inc"
+#undef packet
+ Network *const network = Network::mInstance;
+ if (network)
+ {
+ network->clearHandlers();
+ network->registerHandlers();
+ }
+}
+
+} // namespace EAthena
diff --git a/src/net/eathena/updateprotocol.h b/src/net/eathena/updateprotocol.h
new file mode 100644
index 000000000..e2d4e585f
--- /dev/null
+++ b/src/net/eathena/updateprotocol.h
@@ -0,0 +1,29 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2015 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NET_EATHENA_UPDATEPROTOCOL_H
+#define NET_EATHENA_UPDATEPROTOCOL_H
+
+namespace EAthena
+{
+ void updateProtocol();
+} // namespace Eathena
+
+#endif // NET_EATHENA_UPDATEPROTOCOL_H
diff --git a/src/net/protocoloutupdate.h b/src/net/protocoloutupdate.h
new file mode 100644
index 000000000..b60ec5a5f
--- /dev/null
+++ b/src/net/protocoloutupdate.h
@@ -0,0 +1,26 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2015 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NET_PROTOCOLOUTUPDATE_H
+#define NET_PROTOCOLOUTUPDATE_H
+
+#define packet(name, id) name = id
+
+#endif // NET_PROTOCOLOUTUPDATE_H
diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp
index 28cfce499..b2c2f5bbd 100644
--- a/src/net/tmwa/network.cpp
+++ b/src/net/tmwa/network.cpp
@@ -89,6 +89,12 @@ void Network::registerHandlers()
void Network::clearHandlers()
{
+ for (size_t f = 0; f < packet_lengths_size; f ++)
+ {
+ mPackets[f].name = "";
+ mPackets[f].len = 0;
+ mPackets[f].func = nullptr;
+ }
}
void Network::dispatchMessages()
diff --git a/src/net/tmwa/protocolout.cpp b/src/net/tmwa/protocolout.cpp
index f5e3f20d6..b0941e01d 100644
--- a/src/net/tmwa/protocolout.cpp
+++ b/src/net/tmwa/protocolout.cpp
@@ -18,13 +18,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
namespace TmwAthena
{
#include "net/protocoloutdefine.h"
#include "net/tmwa/packetsout.inc"
#undef packet
-} // namesspace TmwAthena
+} // namesspace TmwAthena
#include "debug.h"
diff --git a/src/net/tmwa/updateprotocol.cpp b/src/net/tmwa/updateprotocol.cpp
new file mode 100644
index 000000000..59d0d836a
--- /dev/null
+++ b/src/net/tmwa/updateprotocol.cpp
@@ -0,0 +1,44 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2015 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "net/tmwa/updateprotocol.h"
+
+#include "net/tmwa/network.h"
+#include "net/tmwa/protocolout.h"
+
+#include "debug.h"
+
+namespace TmwAthena
+{
+
+void updateProtocol()
+{
+#include "net/protocoloutupdate.h"
+#include "net/tmwa/packetsout.inc"
+#undef packet
+ Network *const network = Network::mInstance;
+ if (network)
+ {
+ network->clearHandlers();
+ network->registerHandlers();
+ }
+}
+
+} // namesspace TmwAthena
diff --git a/src/net/tmwa/updateprotocol.h b/src/net/tmwa/updateprotocol.h
new file mode 100644
index 000000000..038d419ca
--- /dev/null
+++ b/src/net/tmwa/updateprotocol.h
@@ -0,0 +1,29 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2015 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NET_TMWA_UPDATEPROTOCOL_H
+#define NET_TMWA_UPDATEPROTOCOL_H
+
+namespace TmwAthena
+{
+ void updateProtocol();
+} // namespace TmwAthena
+
+#endif // NET_TMWA_UPDATEPROTOCOL_H