ManaPlus
updateprotocol.cpp
Go to the documentation of this file.
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 
23 
24 #include "logger.h"
25 
26 #include "net/eathena/network.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 
48 {
49  itemIdLen = 2;
50  logger->log("packet version: %d", packetVersion);
51  if (packets_main == true)
52  {
53  logger->log("packets version type: main");
55  packetVersionRe = 0;
57  }
58  else if (packets_re == true)
59  {
60  logger->log("packets version type: re");
64  }
65  else if (packets_zero == true)
66  {
67  logger->log("packets version type: zero");
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
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
97 
98 } // namespace EAthena
void registerFakeHandlers()
Definition: network.cpp:131
void registerHandlers()
Definition: network.cpp:125
static Network * mInstance
Definition: network.h:57
void clearHandlers()
Definition: network.cpp:183
void log(const char *const log_text,...)
Definition: logger.cpp:269
#define PROTOCOLOUT_VOID
Definition: protocolout.h:27
bool packets_zero
Definition: client.cpp:133
bool packets_re
Definition: client.cpp:132
int itemIdLen
Definition: client.cpp:130
int packetVersionRe
Definition: client.cpp:127
bool packets_main
Definition: client.cpp:131
int packetVersionMain
Definition: client.cpp:126
int evolPacketOffset
Definition: net.cpp:40
int packetVersionZero
Definition: client.cpp:128
int packetVersion
Definition: client.cpp:125
Logger * logger
Definition: logger.cpp:89
void updateProtocolRe()
void updateProtocolMain()
void updateProtocol()
void updateProtocolZero()
#define PROTOCOLOUTUPDATE_VOID