ManaPlus
net.cpp
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2009 The Mana World Development Team
4  * Copyright (C) 2009-2010 The Mana Developers
5  * Copyright (C) 2011-2019 The ManaPlus Developers
6  *
7  * This file is part of The ManaPlus Client.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #include "net/net.h"
24 
25 #include "configuration.h"
26 
27 #include "net/loginhandler.h"
28 
29 #ifdef TMWA_SUPPORT
31 #endif // TMWA_SUPPORT
32 
34 
35 #include "utils/delete2.h"
36 
37 #include "debug.h"
38 
40 
41 namespace Net
42 {
43  class AuctionHandler;
44  class AchievementHandler;
45  class AttendanceHandler;
46  class BankHandler;
47  class BarterHandler;
48  class BattleGroundHandler;
49  class BuyingStoreHandler;
50  class CashShopHandler;
51  class ElementalHandler;
52  class FamilyHandler;
53  class FriendsHandler;
54  class HomunculusHandler;
55  class Mail2Handler;
56  class MailHandler;
57  class MapHandler;
58  class MarketHandler;
59  class MercenaryHandler;
60  class SearchStoreHandler;
61  class RefineHandler;
62  class RouletteHandler;
63  class VendingHandler;
64  class AdminHandler;
65  class BeingHandler;
66  class BuySellHandler;
67  class CharServerHandler;
68  class ChatHandler;
69  class ClanHandler;
70  class GameHandler;
71  class GuildHandler;
72  class InventoryHandler;
73  class NpcHandler;
74  class PartyHandler;
75  class PetHandler;
76  class PlayerHandler;
77  class QuestHandler;
78  class ServerFeatures;
79  class SkillHandler;
80  class TradeHandler;
81 } // namespace Net
82 
123 
124 namespace Net
125 {
127 std::set<int> ignorePackets;
128 
129 void connectToServer(const ServerInfo &server)
130 {
131  BLOCK_START("Net::connectToServer")
132  if (networkType == server.type &&
133  generalHandler != nullptr)
134  {
136  }
137  else
138  {
140  generalHandler != nullptr)
141  {
144  }
145 
146  switch (server.type)
147  {
148  case ServerType::EATHENA:
149  case ServerType::EVOL2:
151  break;
153  case ServerType::UNKNOWN:
154  default:
155 #ifdef TMWA_SUPPORT
157 #else // TMWA_SUPPORT
158 
160 #endif // TMWA_SUPPORT
161 
162  break;
163  }
164 
165  if (generalHandler != nullptr)
166  generalHandler->load();
167 
168  networkType = server.type;
169  }
170 
171  if (loginHandler != nullptr)
172  {
173  loginHandler->setServer(server);
175  }
176  BLOCK_END("Net::connectToServer")
177 }
178 
179 void unload()
180 {
181  const GeneralHandler *const handler = generalHandler;
182  if (handler != nullptr)
183  handler->unload();
184  ignorePackets.clear();
186 }
187 
189 {
190  return networkType;
191 }
192 
194 {
195  const std::string str = config.getStringValue("ignorelogpackets");
196  splitToIntSet(ignorePackets, str, ',');
197 }
198 
199 bool isIgnorePacket(const int id)
200 {
201  return ignorePackets.find(id) != ignorePackets.end();
202 }
203 
204 } // namespace Net
EAthena::GeneralHandler
Definition: generalhandler.h:72
charServerHandler
Net::CharServerHandler * charServerHandler
Definition: net.cpp:84
Net::BuyingStoreHandler
Definition: buyingstorehandler.h:37
loginHandler
Net::LoginHandler * loginHandler
Definition: net.cpp:89
Net::MarketHandler
Definition: markethandler.h:37
Net::PartyHandler
Definition: partyhandler.h:37
auctionHandler
Net::AuctionHandler * auctionHandler
Definition: net.cpp:101
searchStoreHandler
Net::SearchStoreHandler * searchStoreHandler
Definition: net.cpp:120
Net::GeneralHandler::load
virtual void load() const =0
homunculusHandler
Net::HomunculusHandler * homunculusHandler
Definition: net.cpp:111
Net::HomunculusHandler
Definition: homunculushandler.h:34
Net::LoginHandler::connect
virtual void connect() const =0
Net::unload
void unload()
Definition: net.cpp:179
Net::AuctionHandler
Definition: auctionhandler.h:35
Net::VendingHandler
Definition: vendinghandler.h:36
Net::isIgnorePacket
bool isIgnorePacket(const int id)
Definition: net.cpp:199
Net::Mail2Handler
Definition: mail2handler.h:37
delete2.h
buySellHandler
Net::BuySellHandler * buySellHandler
Definition: net.cpp:99
Net::loadIgnorePackets
void loadIgnorePackets()
Definition: net.cpp:193
partyHandler
Net::PartyHandler * partyHandler
Definition: net.cpp:93
playerHandler
Net::PlayerHandler * playerHandler
Definition: net.cpp:95
tradeHandler
Net::TradeHandler * tradeHandler
Definition: net.cpp:97
gameHandler
Net::GameHandler * gameHandler
Definition: net.cpp:90
Net::PlayerHandler
Definition: playerhandler.h:39
Net::LoginHandler::setServer
void setServer(const ServerInfo &server)
Definition: loginhandler.h:42
generalHandler
Net::GeneralHandler * generalHandler
Definition: net.cpp:87
Net::ElementalHandler
Definition: elementalhandler.h:29
TmwAthena::GeneralHandler
Definition: generalhandler.h:71
delete2
#define delete2(var)
Definition: delete2.h:24
Net::FriendsHandler
Definition: friendshandler.h:31
Net::ChatHandler
Definition: chathandler.h:35
evolPacketOffset
int evolPacketOffset
Definition: net.cpp:39
Net
Definition: characterdisplay.h:36
Net::ServerFeatures
Definition: serverfeatures.h:28
adminHandler
Net::AdminHandler * adminHandler
Definition: net.cpp:83
serverFeatures
Net::ServerFeatures * serverFeatures
Definition: net.cpp:100
ServerInfo::type
ServerTypeT type
Definition: serverinfo.h:41
Net::GeneralHandler::unload
virtual void unload() const =0
ServerTypeT
ServerType ::T ServerTypeT
Definition: servertype.h:35
Net::GeneralHandler::reload
virtual void reload() const =0
Net::GameHandler
Definition: gamehandler.h:31
rouletteHandler
Net::RouletteHandler * rouletteHandler
Definition: net.cpp:119
Net::AttendanceHandler
Definition: attendancehandler.h:29
mail2Handler
Net::Mail2Handler * mail2Handler
Definition: net.cpp:112
mailHandler
Net::MailHandler * mailHandler
Definition: net.cpp:113
petHandler
Net::PetHandler * petHandler
Definition: net.cpp:94
Net::RouletteHandler
Definition: roulettehandler.h:29
Net::PetHandler
Definition: pethandler.h:31
ServerType::EATHENA
@ EATHENA
Definition: servertype.h:32
Net::networkType
ServerTypeT networkType
Definition: net.cpp:126
Net::BuySellHandler
Definition: buysellhandler.h:33
generalhandler.h
bankHandler
Net::BankHandler * bankHandler
Definition: net.cpp:104
Net::CashShopHandler
Definition: cashshophandler.h:35
Net::MailHandler
Definition: mailhandler.h:31
battleGroundHandler
Net::BattleGroundHandler * battleGroundHandler
Definition: net.cpp:105
Net::NpcHandler
Definition: npchandler.h:48
vendingHandler
Net::VendingHandler * vendingHandler
Definition: net.cpp:121
ServerType::EVOL2
@ EVOL2
Definition: servertype.h:33
Net::CharServerHandler
Definition: charserverhandler.h:44
friendsHandler
Net::FriendsHandler * friendsHandler
Definition: net.cpp:110
Configuration::getStringValue
std::string getStringValue(const std::string &key) const
Definition: configuration.cpp:487
Net::AdminHandler
Definition: adminhandler.h:38
Net::ClanHandler
Definition: clanhandler.h:31
Net::BattleGroundHandler
Definition: battlegroundhandler.h:33
questHandler
Net::QuestHandler * questHandler
Definition: net.cpp:122
Net::SearchStoreHandler
Definition: searchstorehandler.h:31
mapHandler
Net::MapHandler * mapHandler
Definition: net.cpp:114
cashShopHandler
Net::CashShopHandler * cashShopHandler
Definition: net.cpp:107
ServerType::UNKNOWN
@ UNKNOWN
Definition: servertype.h:30
clanHandler
Net::ClanHandler * clanHandler
Definition: net.cpp:86
config
Configuration config
Definition: configuration.cpp:51
Net::LoginHandler
Definition: loginhandler.h:37
attendanceHandler
Net::AttendanceHandler * attendanceHandler
Definition: net.cpp:103
marketHandler
Net::MarketHandler * marketHandler
Definition: net.cpp:115
elementalHandler
Net::ElementalHandler * elementalHandler
Definition: net.cpp:108
Net::InventoryHandler
Definition: inventoryhandler.h:35
achievementHandler
Net::AchievementHandler * achievementHandler
Definition: net.cpp:102
Net::QuestHandler
Definition: questhandler.h:29
Net::BeingHandler
Definition: beinghandler.h:32
inventoryHandler
Net::InventoryHandler * inventoryHandler
Definition: net.cpp:88
Net::connectToServer
void connectToServer(const ServerInfo &server)
Definition: net.cpp:129
skillHandler
Net::SkillHandler * skillHandler
Definition: net.cpp:96
Net::getNetworkType
ServerTypeT getNetworkType()
Definition: net.cpp:188
Net::FamilyHandler
Definition: familyhandler.h:31
loginhandler.h
configuration.h
Net::BankHandler
Definition: bankhandler.h:29
ServerType::TMWATHENA
@ TMWATHENA
Definition: servertype.h:31
BLOCK_START
#define BLOCK_START(name)
Definition: perfomance.h:78
Net::BarterHandler
Definition: barterhandler.h:33
BLOCK_END
#define BLOCK_END(name)
Definition: perfomance.h:79
Net::RefineHandler
Definition: refinehandler.h:31
chatHandler
Net::ChatHandler * chatHandler
Definition: net.cpp:85
Net::GuildHandler
Definition: guildhandler.h:35
buyingStoreHandler
Net::BuyingStoreHandler * buyingStoreHandler
Definition: net.cpp:106
npcHandler
Net::NpcHandler * npcHandler
Definition: net.cpp:92
Net::SkillHandler
Definition: skillhandler.h:34
Net::TradeHandler
Definition: tradehandler.h:34
mercenaryHandler
Net::MercenaryHandler * mercenaryHandler
Definition: net.cpp:117
Net::AchievementHandler
Definition: achievementhandler.h:29
ServerInfo
Definition: serverinfo.h:36
generalhandler.h
refineHandler
Net::RefineHandler * refineHandler
Definition: net.cpp:118
Net::ignorePackets
std::set< int > ignorePackets
Definition: net.cpp:127
Net::MercenaryHandler
Definition: mercenaryhandler.h:34
guildHandler
Net::GuildHandler * guildHandler
Definition: net.cpp:91
Net::MapHandler
Definition: maphandler.h:29
splitToIntSet
void splitToIntSet(std::set< int > &tokens, const std::string &text, const char separator)
Definition: stringutils.cpp:450
debug.h
familyHandler
Net::FamilyHandler * familyHandler
Definition: net.cpp:109
barterHandler
Net::BarterHandler * barterHandler
Definition: net.cpp:116
beingHandler
Net::BeingHandler * beingHandler
Definition: net.cpp:98
Net::GeneralHandler
Definition: generalhandler.h:31