1 |
|
|
/* |
2 |
|
|
* The ManaPlus Client |
3 |
|
|
* Copyright (C) 2015-2019 The ManaPlus Developers |
4 |
|
|
* Copyright (C) 2019-2021 Andrei Karas |
5 |
|
|
* |
6 |
|
|
* This file is part of The ManaPlus Client. |
7 |
|
|
* |
8 |
|
|
* This program is free software; you can redistribute it and/or modify |
9 |
|
|
* it under the terms of the GNU General Public License as published by |
10 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
11 |
|
|
* any later version. |
12 |
|
|
* |
13 |
|
|
* This program is distributed in the hope that it will be useful, |
14 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
|
|
* GNU General Public License for more details. |
17 |
|
|
* |
18 |
|
|
* You should have received a copy of the GNU General Public License |
19 |
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 |
|
|
*/ |
21 |
|
|
|
22 |
|
|
#include "net/eathena/updateprotocol.h" |
23 |
|
|
|
24 |
|
|
#include "logger.h" |
25 |
|
|
|
26 |
|
|
#include "net/eathena/network.h" |
27 |
|
|
#include "net/eathena/protocolout.h" |
28 |
|
|
#include "net/eathena/updateprotocol_main.h" |
29 |
|
|
#include "net/eathena/updateprotocol_re.h" |
30 |
|
|
#include "net/eathena/updateprotocol_zero.h" |
31 |
|
|
|
32 |
|
|
#include "debug.h" |
33 |
|
|
|
34 |
|
|
extern int packetVersion; |
35 |
|
|
extern int packetVersionMain; |
36 |
|
|
extern int packetVersionRe; |
37 |
|
|
extern int packetVersionZero; |
38 |
|
|
extern int evolPacketOffset; |
39 |
|
|
extern bool packets_main; |
40 |
|
|
extern bool packets_re; |
41 |
|
|
extern bool packets_zero; |
42 |
|
|
extern int itemIdLen; |
43 |
|
|
|
44 |
|
|
namespace EAthena |
45 |
|
|
{ |
46 |
|
|
|
47 |
|
|
void updateProtocol() |
48 |
|
|
{ |
49 |
|
|
itemIdLen = 2; |
50 |
|
|
logger->log("packet version: %d", packetVersion); |
51 |
|
|
if (packets_main == true) |
52 |
|
|
{ |
53 |
|
|
logger->log("packets version type: main"); |
54 |
|
|
packetVersionMain = packetVersion; |
55 |
|
|
packetVersionRe = 0; |
56 |
|
|
packetVersionZero = 0; |
57 |
|
|
} |
58 |
|
|
else if (packets_re == true) |
59 |
|
|
{ |
60 |
|
|
logger->log("packets version type: re"); |
61 |
|
|
packetVersionRe = packetVersion; |
62 |
|
|
packetVersionMain = 0; |
63 |
|
|
packetVersionZero = 0; |
64 |
|
|
} |
65 |
|
|
else if (packets_zero == true) |
66 |
|
|
{ |
67 |
|
|
logger->log("packets version type: zero"); |
68 |
|
|
packetVersionZero = packetVersion; |
69 |
|
|
packetVersionMain = 0; |
70 |
|
|
packetVersionRe = 0; |
71 |
|
|
} |
72 |
|
|
if (packetVersionMain >= 20181121 || |
73 |
|
|
packetVersionRe >= 20180704 || |
74 |
|
|
packetVersionZero >= 20181114) |
75 |
|
|
{ |
76 |
|
|
itemIdLen = 4; |
77 |
|
|
} |
78 |
|
|
#define PACKETS_UPDATE |
79 |
|
|
#include "net/protocoloutupdate.h" |
80 |
|
|
#include "net/eathena/packetsout.inc" |
81 |
|
|
#undef packet |
82 |
|
|
updateProtocolMain(); |
83 |
|
|
updateProtocolRe(); |
84 |
|
|
updateProtocolZero(); |
85 |
|
|
Network *const network = Network::mInstance; |
86 |
|
|
if (network != nullptr) |
87 |
|
|
{ |
88 |
|
|
network->clearHandlers(); |
89 |
|
|
network->registerHandlers(); |
90 |
|
|
network->registerFakeHandlers(); |
91 |
|
|
} |
92 |
|
|
} |
93 |
|
|
|
94 |
|
|
PACKETSOUT_VOID |
95 |
|
|
PROTOCOLOUTUPDATE_VOID |
96 |
|
|
PROTOCOLOUT_VOID |
97 |
|
|
|
98 |
|
|
} // namespace EAthena |