From d27c8b53bcd8c7e8e0aa74656e32aeb688629b4b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 22 Sep 2015 20:41:19 +0300 Subject: add way for reload packets db. For now it useless. --- src/net/eathena/network.cpp | 6 ++++++ src/net/eathena/protocolout.cpp | 2 -- src/net/eathena/updateprotocol.cpp | 44 ++++++++++++++++++++++++++++++++++++++ src/net/eathena/updateprotocol.h | 29 +++++++++++++++++++++++++ src/net/protocoloutupdate.h | 26 ++++++++++++++++++++++ src/net/tmwa/network.cpp | 6 ++++++ src/net/tmwa/protocolout.cpp | 3 +-- src/net/tmwa/updateprotocol.cpp | 44 ++++++++++++++++++++++++++++++++++++++ src/net/tmwa/updateprotocol.h | 29 +++++++++++++++++++++++++ 9 files changed, 185 insertions(+), 4 deletions(-) create mode 100644 src/net/eathena/updateprotocol.cpp create mode 100644 src/net/eathena/updateprotocol.h create mode 100644 src/net/protocoloutupdate.h create mode 100644 src/net/tmwa/updateprotocol.cpp create mode 100644 src/net/tmwa/updateprotocol.h (limited to 'src/net') 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 . */ - 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 . + */ + +#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 . + */ + +#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 . + */ + +#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 . */ - 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 . + */ + +#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 . + */ + +#ifndef NET_TMWA_UPDATEPROTOCOL_H +#define NET_TMWA_UPDATEPROTOCOL_H + +namespace TmwAthena +{ + void updateProtocol(); +} // namespace TmwAthena + +#endif // NET_TMWA_UPDATEPROTOCOL_H -- cgit v1.2.3-70-g09d2