ManaPlus
generalhandler.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  * Copyright (C) 2019-2021 Andrei Karas
7  *
8  * This file is part of The ManaPlus Client.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
25 
26 #include "client.h"
27 
30 
34 
58 #include "net/eathena/maphandler.h"
63 #include "net/eathena/network.h"
64 #include "net/eathena/npchandler.h"
66 #include "net/eathena/pethandler.h"
76 
77 #include "utils/delete2.h"
78 #include "utils/gettext.h"
79 
80 #include "debug.h"
81 
82 namespace EAthena
83 {
84 
86  mAdminHandler(new AdminHandler),
87  mBeingHandler(new BeingHandler),
88  mBuySellHandler(new BuySellHandler),
89  mCharServerHandler(new CharServerHandler),
90  mChatHandler(new ChatHandler),
91  mClanHandler(new ClanHandler),
92  mGameHandler(new GameHandler),
93  mGuildHandler(new GuildHandler),
94  mInventoryHandler(new InventoryHandler),
95  mItemHandler(new ItemHandler),
96  mLoginHandler(new LoginHandler),
97  mNpcHandler(new NpcHandler),
98  mPartyHandler(new PartyHandler),
99  mPetHandler(new PetHandler),
100  mPlayerHandler(new PlayerHandler),
101  mSkillHandler(new SkillHandler),
102  mTradeHandler(new TradeHandler),
103  mQuestHandler(new QuestHandler),
104  mServerFeatures(new ServerFeatures),
105  mMail2Handler(new Mail2Handler),
106  mMailHandler(new MailHandler),
107  mAuctionHandler(new AuctionHandler),
108  mAchievementHandler(new AchievementHandler),
109  mAttendanceHandler(new AttendanceHandler),
110  mCashShopHandler(new CashShopHandler),
111  mFamilyHandler(new FamilyHandler),
112  mBankHandler(new BankHandler),
113  mBattleGroundHandler(new BattleGroundHandler),
114  mMercenaryHandler(new MercenaryHandler),
115  mBuyingStoreHandler(new BuyingStoreHandler),
116  mHomunculusHandler(new HomunculusHandler),
117  mFriendsHandler(new FriendsHandler),
118  mElementalHandler(new ElementalHandler),
119  mMapHandler(new MapHandler),
120  mMarketHandler(new MarketHandler),
121  mBarterHandler(new BarterHandler),
122  mVendingHandler(new VendingHandler),
123  mRefineHandler(new RefineHandler),
124  mRouletteHandler(new RouletteHandler),
125  mSearchStoreHandler(new SearchStoreHandler)
126 {
127  generalHandler = this;
128  logger->log("Creating eathena handler");
129 }
130 
132 {
134 
175 }
176 
178 {
179  new Network;
181 }
182 
184 {
185  if (Network::mInstance != nullptr)
187 
188  static_cast<LoginHandler*>(mLoginHandler)->clearWorlds();
189  const CharServerHandler *const charHandler =
190  static_cast<CharServerHandler*>(mCharServerHandler);
191  charHandler->setCharCreateDialog(nullptr);
192  charHandler->setCharSelectDialog(nullptr);
194 }
195 
197 {
199 }
200 
202 {
203  clearHandlers();
204 }
205 
207 {
208  if (Network::mInstance == nullptr)
209  return;
210 
212 }
213 
215 {
216  if (Network::mInstance == nullptr)
217  return;
218 
221 
222  if (Network::mInstance->getState() == Network::NET_ERROR)
223  {
225  {
227  }
228  else
229  {
230  // TRANSLATORS: error message
231  errorMessage = _("Got disconnected from server!");
232  }
233 
235  }
236 }
237 
239 {
240  if (Network::mInstance != nullptr)
242 }
243 
245 {
246  if (skillDialog != nullptr)
248 }
249 
251 {
252  if (socialWindow != nullptr)
253  {
256  }
257 
261 }
262 
263 } // namespace EAthena
ClanTab * clanTab
Definition: clantab.cpp:36
void setState(const StateT state)
Definition: client.h:66
void setCharCreateDialog(CharCreateDialog *const window) const
InventoryHandler * mInventoryHandler
AttendanceHandler * mAttendanceHandler
MailHandler * mMailHandler
ItemHandler * mItemHandler
MarketHandler * mMarketHandler
LoginHandler * mLoginHandler
RefineHandler * mRefineHandler
HomunculusHandler * mHomunculusHandler
RouletteHandler * mRouletteHandler
BeingHandler * mBeingHandler
GameHandler * mGameHandler
TradeHandler * mTradeHandler
BuySellHandler * mBuySellHandler
ElementalHandler * mElementalHandler
AdminHandler * mAdminHandler
MercenaryHandler * mMercenaryHandler
SearchStoreHandler * mSearchStoreHandler
ServerFeatures * mServerFeatures
BankHandler * mBankHandler
ClanHandler * mClanHandler
AchievementHandler * mAchievementHandler
BattleGroundHandler * mBattleGroundHandler
Mail2Handler * mMail2Handler
SkillHandler * mSkillHandler
GuildHandler * mGuildHandler
QuestHandler * mQuestHandler
FamilyHandler * mFamilyHandler
FriendsHandler * mFriendsHandler
CashShopHandler * mCashShopHandler
CharServerHandler * mCharServerHandler
ChatHandler * mChatHandler
PartyHandler * mPartyHandler
PlayerHandler * mPlayerHandler
BuyingStoreHandler * mBuyingStoreHandler
AuctionHandler * mAuctionHandler
VendingHandler * mVendingHandler
BarterHandler * mBarterHandler
void registerHandlers()
Definition: network.cpp:125
static Network * mInstance
Definition: network.h:57
void dispatchMessages()
Definition: network.cpp:194
void clearHandlers()
Definition: network.cpp:183
void setCharSelectDialog(CharSelectDialog *const window) const
void flush()
Definition: network.cpp:157
const std::string & getError() const
Definition: network.h:58
@ NET_ERROR
Definition: network.h:83
void disconnect()
Definition: network.cpp:139
static void reload()
void log(const char *const log_text,...)
Definition: logger.cpp:269
void loadSkills()
bool removeTab(Guild *const guild)
#define new
Definition: debug_new.h:147
#define delete2(var)
Definition: delete2.h:25
Client * client
Definition: client.cpp:118
std::string errorMessage
Definition: client.cpp:116
GuildTab * guildTab
Net::GeneralHandler * generalHandler
Definition: net.cpp:88
#define _(s)
Definition: gettext.h:35
Logger * logger
Definition: logger.cpp:89
Guild * taGuild
Definition: guildhandler.h:99
Party * taParty
Definition: partyrecv.cpp:48
@ ERROR
Definition: state.h:35
const char * getError()
Definition: sdltcpnet.cpp:99
PartyTab * partyTab
Definition: partytab.cpp:45
std::string empty
Definition: podict.cpp:26
SkillDialog * skillDialog
Definition: skilldialog.cpp:66
SocialWindow * socialWindow