From 886522371299b45254b7dc72e6de3070703d7c10 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 19 May 2011 02:24:20 +0300 Subject: Enable server type selection again. Add evol server type. Now working same as tmweathena. --- src/being.cpp | 8 ++++---- src/client.cpp | 2 +- src/gui/serverdialog.cpp | 43 ++++++++++++++++++++++++++++++------------- src/gui/skilldialog.cpp | 2 +- src/gui/viewport.cpp | 2 +- src/localplayer.cpp | 12 ++++++++---- src/net/messagein.cpp | 2 +- src/net/net.cpp | 3 +++ src/net/serverinfo.h | 5 ++++- src/resources/monsterdb.cpp | 4 ++-- 10 files changed, 55 insertions(+), 28 deletions(-) diff --git a/src/being.cpp b/src/being.cpp index 688e838ee..6c0d3d679 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -352,7 +352,7 @@ void Being::setPosition(const Vector &pos) void Being::setDestination(int dstX, int dstY) { #ifdef MANASERV_SUPPORT - if (Net::getNetworkType() == ServerInfo::TMWATHENA) + if (Net::getNetworkType() != ServerInfo::MANASERV) #endif { if (mMap) @@ -414,7 +414,7 @@ void Being::setPath(const Path &path) return; #ifdef MANASERV_SUPPORT - if ((Net::getNetworkType() == ServerInfo::TMWATHENA) && + if ((Net::getNetworkType() != ServerInfo::MANASERV) && mAction != MOVE && mAction != DEAD) #else if (mAction != MOVE && mAction != DEAD) @@ -654,7 +654,7 @@ void Being::handleAttack(Being *victim, int damage, fireMissile(victim, mInfo->getAttack(mAttackType)->missileParticle); #ifdef MANASERV_SUPPORT - if (Net::getNetworkType() == ServerInfo::TMWATHENA) + if (Net::getNetworkType() != ServerInfo::MANASERV) #endif { reset(); @@ -1194,7 +1194,7 @@ void Being::logic() } } else - if (Net::getNetworkType() == ServerInfo::TMWATHENA) + if (Net::getNetworkType() != ServerInfo::MANASERV) #endif { switch (mAction) diff --git a/src/client.cpp b/src/client.cpp index 2e44b94b3..a5028f790 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1019,7 +1019,7 @@ int Client::exec() Net::getGameHandler()->connect(); mCurrentDialog = new ConnectionDialog( _("Connecting to the game server"), - Net::getNetworkType() == ServerInfo::TMWATHENA ? + Net::getNetworkType() != ServerInfo::MANASERV ? STATE_CHOOSE_SERVER : STATE_SWITCH_CHARACTER); break; diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index ca5711104..fca10c3c8 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -63,6 +63,8 @@ static std::string serverTypeToString(ServerInfo::Type type) { case ServerInfo::TMWATHENA: return "TmwAthena"; + case ServerInfo::EVOL: + return "Evol"; #ifdef MANASERV_SUPPORT case ServerInfo::MANASERV: return "ManaServ"; @@ -82,6 +84,7 @@ static unsigned short defaultPortForServerType(ServerInfo::Type type) default: case ServerInfo::UNKNOWN: case ServerInfo::TMWATHENA: + case ServerInfo::EVOL: #ifdef MANASERV_SUPPORT return 6901; case ServerInfo::MANASERV: @@ -134,8 +137,10 @@ std::string TypeListModel::getElementAt(int elementIndex) { if (elementIndex == 0) return "TmwAthena"; -#ifdef MANASERV_SUPPORT else if (elementIndex == 1) + return "Evol"; +#ifdef MANASERV_SUPPORT + else if (elementIndex == 2) return "ManaServ"; #endif else @@ -251,18 +256,26 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir): ScrollArea *usedScroll = new ScrollArea(mServersList); usedScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); -#ifdef MANASERV_SUPPORT Label *typeLabel = new Label(_("Server type:")); mTypeListModel = new TypeListModel(); mTypeField = new DropDown(mTypeListModel); - mTypeField->setSelected((serverInfo->type == ServerInfo::MANASERV) ? - 1 : 0); - int n = 1; -#else - mTypeListModel = 0; - mTypeField = 0; - int n = 0; + switch (serverInfo->type) + { + case ServerInfo::MANASERV: +#ifdef MANASERV_SUPPORT + mTypeField->setSelected(2); + break; #endif + default: + case ServerInfo::UNKNOWN: + case ServerInfo::TMWATHENA: + mTypeField->setSelected(0); + break; + case ServerInfo::EVOL: + mTypeField->setSelected(1); + break; + } + int n = 1; mDescription = new Label(std::string()); @@ -285,10 +298,8 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir): place(1, 0, mServerNameField, 5).setPadding(3); place(0, 1, portLabel); place(1, 1, mPortField, 5).setPadding(3); -#ifdef MANASERV_SUPPORT place(0, 2, typeLabel); place(1, 2, mTypeField, 5).setPadding(3); -#endif place(0, 2 + n, usedScroll, 6, 5).setPadding(3); place(0, 7 + n, mDescription, 6); place(0, 8 + n, mPersistentIPCheckBox, 6); @@ -399,8 +410,11 @@ void ServerDialog::action(const gcn::ActionEvent &event) case 0: mServerInfo->type = ServerInfo::TMWATHENA; break; -#ifdef MANASERV_SUPPORT case 1: + mServerInfo->type = ServerInfo::EVOL; + break; +#ifdef MANASERV_SUPPORT + case 2: mServerInfo->type = ServerInfo::MANASERV; break; #endif @@ -491,7 +505,7 @@ void ServerDialog::valueChanged(const gcn::SelectionEvent &) mTypeField->setSelected(0); break; case ServerInfo::MANASERV: - mTypeField->setSelected(1); + mTypeField->setSelected(2); break; #else case ServerInfo::MANASERV: @@ -499,6 +513,9 @@ void ServerDialog::valueChanged(const gcn::SelectionEvent &) mTypeField->setSelected(0); break; #endif + case ServerInfo::EVOL: + mTypeField->setSelected(1); + break; } } setFieldsReadOnly(true); diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp index fe2325ab8..a58a3e169 100644 --- a/src/gui/skilldialog.cpp +++ b/src/gui/skilldialog.cpp @@ -335,7 +335,7 @@ void SkillDialog::loadSkills(const std::string &file) { logger->log("Error loading skills file: %s", file.c_str()); - if (Net::getNetworkType() == ServerInfo::TMWATHENA) + if (Net::getNetworkType() != ServerInfo::MANASERV) { SkillModel *model = new SkillModel(); if (!mDefaultModel) diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 1298a9744..e399d96ce 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -337,7 +337,7 @@ void Viewport::_drawPath(Graphics *graphics, const Path &path, graphics->setColor(color); #ifdef MANASERV_SUPPORT - if (Net::getNetworkType() == ServerInfo::TMWATHENA) + if (Net::getNetworkType() != ServerInfo::MANASERV) #endif { for (Path::const_iterator i = path.begin(); i != path.end(); ++i) diff --git a/src/localplayer.cpp b/src/localplayer.cpp index ebd28e43c..2a3048a3d 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -772,7 +772,7 @@ Position LocalPlayer::getNextWalkPosition(unsigned char dir) void LocalPlayer::nextTile(unsigned char dir _UNUSED_ = 0) { #ifdef MANASERV_SUPPORT - if (Net::getNetworkType() == ServerInfo::TMWATHENA) + if (Net::getNetworkType() != ServerInfo::MANASERV) #endif { // updatePos(); @@ -1028,7 +1028,7 @@ void LocalPlayer::setDestination(int x, int y) // If the destination given to being class is accepted, // we inform the Server. if ((x == mDest.x && y == mDest.y) - || Net::getNetworkType() == ServerInfo::TMWATHENA) + || Net::getNetworkType() != ServerInfo::MANASERV) #endif { Net::getPlayerHandler()->setDestination(x, y, mDirection); @@ -1123,7 +1123,7 @@ void LocalPlayer::startWalking(unsigned char dir) dx++; #ifdef MANASERV_SUPPORT - if (Net::getNetworkType() == ServerInfo::TMWATHENA) + if (Net::getNetworkType() != ServerInfo::MANASERV) #endif { // Prevent skipping corners over colliding tiles @@ -1333,7 +1333,11 @@ void LocalPlayer::attack(Being *target, bool keep, bool dontChangeEquipment) changeEquipmentBeforeAttack(target); Net::getPlayerHandler()->attack(target->getId(), mServerAttack); - if ((Net::getNetworkType() == ServerInfo::TMWATHENA) && !keep) +#ifdef MANASERV_SUPPORT + if ((Net::getNetworkType() != ServerInfo::MANASERV) && !keep) +#else + if (!keep) +#endif stopAttack(); } diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp index 12d086207..9b76c76fa 100644 --- a/src/net/messagein.cpp +++ b/src/net/messagein.cpp @@ -116,7 +116,7 @@ void MessageIn::readCoordinates(Uint16 &x, Uint16 &y, Uint8 &direction) break; case 8: #ifdef MANASERV_SUPPORT - if (Net::getNetworkType() == ServerInfo::TMWATHENA) + if (Net::getNetworkType() != ServerInfo::MANASERV) #endif { direction = 8; diff --git a/src/net/net.cpp b/src/net/net.cpp index 052d65edc..ca26415a6 100644 --- a/src/net/net.cpp +++ b/src/net/net.cpp @@ -160,6 +160,9 @@ void connectToServer(const ServerInfo &server) switch (server.type) { + case ServerInfo::EVOL: + new TmwAthena::GeneralHandler; + break; case ServerInfo::MANASERV: #ifdef MANASERV_SUPPORT new ManaServ::GeneralHandler; diff --git a/src/net/serverinfo.h b/src/net/serverinfo.h index 2e8d63a6e..eb07f766e 100644 --- a/src/net/serverinfo.h +++ b/src/net/serverinfo.h @@ -35,7 +35,8 @@ public: { UNKNOWN = 0, MANASERV, - TMWATHENA + TMWATHENA, + EVOL }; typedef std::pair VersionString; @@ -103,6 +104,8 @@ public: { if (compareStrI(type, "tmwathena") == 0) return TMWATHENA; + if (compareStrI(type, "evol") == 0) + return EVOL; // Used for backward compatibility else if (compareStrI(type, "eathena") == 0) return TMWATHENA; diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp index 75d268c43..fbd7d10ad 100644 --- a/src/resources/monsterdb.cpp +++ b/src/resources/monsterdb.cpp @@ -60,8 +60,8 @@ void MonsterDB::load() } #ifdef MANASERV_SUPPORT - int offset = XML::getProperty(rootNode, "offset", Net::getNetworkType() == - ServerInfo::TMWATHENA ? OLD_TMWATHENA_OFFSET : 0); + int offset = XML::getProperty(rootNode, "offset", Net::getNetworkType() != + ServerInfo::MANASERV ? OLD_TMWATHENA_OFFSET : 0); #else int offset = XML::getProperty(rootNode, "offset", OLD_TMWATHENA_OFFSET); #endif -- cgit v1.2.3-60-g2f50