summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xconfigure.ac38
-rw-r--r--mana.config2
-rw-r--r--src/CMakeLists.txt13
-rw-r--r--src/Makefile.am6
-rw-r--r--src/being.cpp68
-rw-r--r--src/being.h23
-rw-r--r--src/game.cpp4
-rw-r--r--src/gui/popupmenu.cpp2
-rw-r--r--src/gui/serverdialog.cpp60
-rw-r--r--src/gui/serverdialog.h24
-rw-r--r--src/gui/viewport.cpp11
-rw-r--r--src/localplayer.cpp520
-rw-r--r--src/localplayer.h2
-rw-r--r--src/main.h16
-rw-r--r--src/monster.cpp6
-rw-r--r--src/net/ea/playerhandler.cpp10
-rw-r--r--src/net/ea/playerhandler.h2
-rw-r--r--src/net/ea/tradehandler.cpp2
-rw-r--r--src/net/manaserv/playerhandler.cpp10
-rw-r--r--src/net/manaserv/playerhandler.h2
-rw-r--r--src/net/manaserv/tradehandler.cpp2
-rw-r--r--src/net/net.cpp34
-rw-r--r--src/net/net.h4
-rw-r--r--src/net/playerhandler.h2
-rw-r--r--src/player.cpp97
25 files changed, 488 insertions, 472 deletions
diff --git a/configure.ac b/configure.ac
index 9622d8aa..b102e1e8 100755
--- a/configure.ac
+++ b/configure.ac
@@ -103,39 +103,10 @@ else
AC_DEFINE(USE_OPENGL, 1, [Defines if Mana should have OpenGL support])
fi
-# Enable either Manaserv or eAthena
-AC_ARG_WITH(
- [server],
- AS_HELP_STRING(
- [--with-server=ARG],
- [which server to use [[ARG=manaserv,eathena]]
- [(default=manaserv)]]
- ),
- [if test "$withval" = "yes"; then
- # default is manaserv
- with_server="manaserv"
- elif test "$withval" = "no"; then
- AC_MSG_ERROR([$PACKAGE_NAME cannot run without a server.])
- else
- with_server="$withval"
- fi],
- [with_server="manaserv"]
-)
-
-if test "$with_server" = "manaserv"; then
- AC_CHECK_LIB([enet], [enet_initialize], ,
- AC_MSG_ERROR([ *** Unable to find enet library (http://enet.bespin.org/)]))
- AC_DEFINE(MANASERV_SUPPORT, 1, [Defines if manaserv support is enabled])
-elif test "$with_server" = "eathena"; then
- AC_CHECK_LIB(SDL_net, SDLNet_Init, ,
- AC_MSG_ERROR([ *** Unable to find SDL_net library]))
- AC_DEFINE(EATHENA_SUPPORT, 1, [Defines if eAthena support is enabled])
-else
- AC_MSG_ERROR([unknown server: $with_server])
-fi
-
-AM_CONDITIONAL(SERVER_MANASERV, test "$with_server" = "manaserv")
-AM_CONDITIONAL(SERVER_EATHENA, test "$with_server" = "eathena")
+AC_CHECK_LIB([enet], [enet_initialize], ,
+AC_MSG_ERROR([ *** Unable to find enet library (http://enet.bespin.org/)]))
+AC_CHECK_LIB(SDL_net, SDLNet_Init, ,
+AC_MSG_ERROR([ *** Unable to find SDL_net library]))
AC_CONFIG_FILES([
Makefile
@@ -155,7 +126,6 @@ AC_OUTPUT
echo
echo "Build with OpenGL: $with_opengl"
-echo "Supported server: $with_server"
echo
echo "configure complete, now type \"make\""
echo
diff --git a/mana.config b/mana.config
index 643c5d36..f97325b7 100644
--- a/mana.config
+++ b/mana.config
@@ -1,3 +1 @@
#include "../config.h"
-#define MANASERV_SUPPORT
-#define EATHENA_SUPPORT
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6b401967..68d7b064 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -589,10 +589,10 @@ IF (WIN32)
SET(SRCS_EA ${SRCS_EA} mana-ea.rc)
ENDIF ()
-SET (PROGRAMS mana mana-ea)
+SET (PROGRAMS mana)
-ADD_EXECUTABLE(mana WIN32 ${SRCS} ${SRCS_MANA})
-ADD_EXECUTABLE(mana-ea WIN32 ${SRCS} ${SRCS_EA})
+ADD_EXECUTABLE(mana WIN32 ${SRCS} ${SRCS_MANA} ${SRCS_EA})
+#ADD_EXECUTABLE(mana-ea WIN32 ${SRCS} ${SRCS_EA})
FOREACH(program ${PROGRAMS})
TARGET_LINK_LIBRARIES(${program} ${SDL_LIBRARY}
@@ -612,15 +612,12 @@ FOREACH(program ${PROGRAMS})
INSTALL(TARGETS ${program} RUNTIME DESTINATION ${PKG_BINDIR})
ENDFOREACH(program)
-SET(FLAGS_EA "${FLAGS} -DEATHENA_SUPPORT")
-SET(FLAGS_MANA "${FLAGS} -DMANASERV_SUPPORT")
-
IF (CMAKE_SYSTEM_NAME STREQUAL SunOS)
# we expect the SMCgtxt package to be present on Solaris;
# the Solaris gettext is not API-compatible to GNU gettext
SET_TARGET_PROPERTIES(mana PROPERTIES LINK_FLAGS "-L/usr/local/lib")
- SET_TARGET_PROPERTIES(mana-ea PROPERTIES LINK_FLAGS "-L/usr/local/lib")
+ #SET_TARGET_PROPERTIES(mana-ea PROPERTIES LINK_FLAGS "-L/usr/local/lib")
ENDIF()
SET_TARGET_PROPERTIES(mana PROPERTIES COMPILE_FLAGS "${FLAGS_MANA}")
-SET_TARGET_PROPERTIES(mana-ea PROPERTIES COMPILE_FLAGS "${FLAGS_EA}")
+#SET_TARGET_PROPERTIES(mana-ea PROPERTIES COMPILE_FLAGS "${FLAGS_EA}")
diff --git a/src/Makefile.am b/src/Makefile.am
index 7e7fe415..1a18402c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -394,8 +394,6 @@ mana_SOURCES = gui/widgets/avatar.cpp \
vector.cpp \
vector.h
-if SERVER_MANASERV
-mana_CXXFLAGS += -DMANASERV_SUPPORT
mana_SOURCES += \
net/manaserv/adminhandler.cpp \
net/manaserv/adminhandler.h \
@@ -444,10 +442,7 @@ mana_SOURCES += \
net/manaserv/specialhandler.h \
net/manaserv/tradehandler.cpp \
net/manaserv/tradehandler.h
-endif
-if SERVER_EATHENA
-mana_CXXFLAGS += -DEATHENA_SUPPORT
mana_SOURCES += \
net/ea/gui/partytab.cpp \
net/ea/gui/partytab.h \
@@ -492,7 +487,6 @@ mana_SOURCES += \
net/ea/specialhandler.h \
net/ea/tradehandler.cpp \
net/ea/tradehandler.h
-endif
# set the include path found by configure
INCLUDES = $(all_includes)
diff --git a/src/being.cpp b/src/being.cpp
index b30194e4..1e6da93e 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -51,6 +51,8 @@
#include "utils/dtor.h"
#include "utils/stringutils.h"
#include "utils/xml.h"
+#include "net/net.h"
+#include "net/playerhandler.h"
#include <cassert>
#include <cmath>
@@ -65,11 +67,10 @@ extern const int MILLISECONDS_IN_A_TICK;
int Being::mNumberOfHairstyles = 1;
+// TODO: mWalkTime used by eAthena only
Being::Being(int id, int job, Map *map):
mFrame(0),
-#ifdef EATHENA_SUPPORT
mWalkTime(0),
-#endif
mEmotion(0), mEmotionTime(0),
mSpeechTime(0),
mAttackSpeed(350),
@@ -88,11 +89,6 @@ Being::Being(int id, int job, Map *map):
mStatusParticleEffects(&mStunParticleEffects, false),
mChildParticleEffects(&mStatusParticleEffects, false),
mMustResetParticles(false),
-#ifdef MANASERV_SUPPORT
- mWalkSpeed(6.0f), // default speed in tile per second
-#else
- mWalkSpeed(150),
-#endif
mX(0), mY(0),
mTakedDamage(0),
mUsedTargetCursor(NULL)
@@ -103,6 +99,7 @@ Being::Being(int id, int job, Map *map):
mNameColor = &guiPalette->getColor(Palette::NPC);
mTextColor = &guiPalette->getColor(Palette::CHAT);
+ mWalkSpeed = Net::getPlayerHandler()->getDefaultWalkSpeed();
}
Being::~Being()
@@ -131,15 +128,15 @@ void Being::setPosition(const Vector &pos)
(int)pos.y - getHeight() - mText->getHeight() - 6);
}
-#ifdef EATHENA_SUPPORT
-void Being::setDestination(int destX, int destY)
-{
- if (mMap)
- setPath(mMap->findPath(mX, mY, destX, destY, getWalkMask()));
-}
-#else
void Being::setDestination(int dstX, int dstY)
{
+ if (Net::getNetworkType() == ServerInfo::EATHENA)
+ {
+ if (mMap)
+ setPath(mMap->findPath(mX, mY, dstX, dstY, getWalkMask()));
+ return;
+ }
+
mDest.x = dstX;
mDest.y = dstY;
int srcX = mPos.x;
@@ -191,7 +188,6 @@ void Being::setDestination(int dstX, int dstY)
setPath(thisPath);
}
-#endif
void Being::clearPath()
{
@@ -201,13 +197,12 @@ void Being::clearPath()
void Being::setPath(const Path &path)
{
mPath = path;
-#ifdef EATHENA_SUPPORT
- if (mAction != WALK && mAction != DEAD)
+ if ((Net::getNetworkType() == ServerInfo::EATHENA) &&
+ mAction != WALK && mAction != DEAD)
{
nextStep();
mWalkTime = tick_time;
}
-#endif
}
void Being::setSpeech(const std::string &text, int time)
@@ -349,10 +344,11 @@ void Being::handleAttack(Being *victim, int damage, AttackType type)
}
}
}
-#ifdef EATHENA_SUPPORT
- mFrame = 0;
- mWalkTime = tick_time;
-#endif
+ if (Net::getNetworkType() == ServerInfo::EATHENA)
+ {
+ mFrame = 0;
+ mWalkTime = tick_time;
+ }
}
void Being::setName(const std::string &name)
@@ -474,7 +470,7 @@ void Being::setDirection(Uint8 direction)
(*it)->setDirection(dir);
}
-#ifdef EATHENA_SUPPORT
+/** TODO: Used by eAthena only */
void Being::nextStep()
{
if (mPath.empty())
@@ -509,7 +505,6 @@ void Being::nextStep()
setAction(WALK);
mWalkTime += (int)(mWalkSpeed / 10);
}
-#endif
void Being::logic()
{
@@ -524,8 +519,7 @@ void Being::logic()
mText = 0;
}
-#ifdef MANASERV_SUPPORT
- if (mAction != DEAD)
+ if ((Net::getNetworkType() == ServerInfo::MANASERV) && (mAction != DEAD))
{
const Vector dest = (mPath.empty()) ?
mDest : Vector(mPath.front().x,
@@ -597,11 +591,12 @@ void Being::logic()
setAction(STAND);
}
}
-#else
- // Update pixel coordinates
- setPosition(mX * 32 + 16 + getXOffset(),
- mY * 32 + 32 + getYOffset());
-#endif
+ else if (Net::getNetworkType() == ServerInfo::EATHENA)
+ {
+ // Update pixel coordinates
+ setPosition(mX * 32 + 16 + getXOffset(),
+ mY * 32 + 32 + getYOffset());
+ }
if (mEmotion != 0)
{
@@ -641,11 +636,9 @@ void Being::draw(Graphics *graphics, int offsetX, int offsetY) const
// these translations aren't necessary anymore. The sprites know
// best where their base point should be.
const int px = getPixelX() + offsetX - 16;
-#ifdef MANASERV_SUPPORT
- const int py = getPixelY() + offsetY - 15; // Temporary fix to the Y offset.
-#else
- const int py = getPixelY() + offsetY - 32;
-#endif
+ // Temporary fix to the Y offset.
+ const int py = getPixelY() + offsetY -
+ ((Net::getNetworkType() == ServerInfo::MANASERV) ? 15 : 32);
if (mUsedTargetCursor)
mUsedTargetCursor->draw(graphics, px, py);
@@ -801,7 +794,7 @@ void Being::setStatusEffect(int index, bool active)
}
}
-#ifdef EATHENA_SUPPORT
+/** TODO: eAthena only */
int Being::getOffset(char pos, char neg) const
{
// Check whether we're walking in the requested direction
@@ -821,7 +814,6 @@ int Being::getOffset(char pos, char neg) const
return offset;
}
-#endif
int Being::getWidth() const
{
diff --git a/src/being.h b/src/being.h
index d7e9063f..747a5428 100644
--- a/src/being.h
+++ b/src/being.h
@@ -131,43 +131,42 @@ class Being : public Sprite, public ConfigListener
*/
void clearPath();
-#ifdef EATHENA_SUPPORT
/**
* Returns the walk time.
* Used to know which frame to display and trigger
* the next Tile step.
+ * TODO: Used by eAthena only?
*/
int getWalkTime() const { return mWalkTime; }
/**
* Set the current WalkTime value.
+ * TODO: Used by eAthena only?
* @see Ea::BeingHandler that set it to tick time.
*/
void setWalkTime(int walkTime) { mWalkTime = walkTime; }
/**
* Makes this being take the next step (tile) of its path.
+ * TODO: Used by eAthena only?
*/
virtual void nextStep();
/**
* Get the current X pixel offset.
+ * TODO: Used by eAthena only?
*/
int getXOffset() const
{ return getOffset(LEFT, RIGHT); }
/**
* Get the current Y pixel offset.
+ * TODO: Used by eAthena only?
*/
int getYOffset() const
{ return getOffset(UP, DOWN); }
/**
- * Sets a new destination for this being to walk to.
- */
- virtual void setDestination(int destX, int destY);
-#elif MANASERV_SUPPORT
- /**
* Creates a path for the being from current position to ex and ey
*/
void setDestination(int ex, int ey);
@@ -176,7 +175,6 @@ class Being : public Sprite, public ConfigListener
* Returns the destination for this being.
*/
const Vector &getDestination() const { return mDest; }
-#endif
/**
* Returns the tile x coord
@@ -580,10 +578,11 @@ class Being : public Sprite, public ConfigListener
/** The current sprite Frame number to be displayed */
int mFrame;
-#ifdef EATHENA_SUPPORT
- /** Used to trigger the nextStep (walking on next Tile) */
+ /** Used to trigger the nextStep (walking on next Tile)
+ * TODO: Used by eAthena only?
+ */
int mWalkTime;
-#endif
+
int mEmotion; /**< Currently showing emotion */
int mEmotionTime; /**< Time until emotion disappears */
/** Time until the last speech sentence disappears */
@@ -630,13 +629,13 @@ class Being : public Sprite, public ConfigListener
ParticleList mChildParticleEffects;
private:
-#ifdef EATHENA_SUPPORT
+
/**
* Calculates the offset in the given directions.
* If walking in direction 'neg' the value is negated.
+ * TODO: Used by eAthena only?
*/
int getOffset(char pos, char neg) const;
-#endif
/** Reset particle status effects on next redraw? */
bool mMustResetParticles;
diff --git a/src/game.cpp b/src/game.cpp
index 0cc59ff6..83b4708b 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -105,8 +105,8 @@ volatile int fps = 0, frame = 0;
Engine *engine = NULL;
Joystick *joystick = NULL;
-extern Window *weightNotice;
-extern Window *deathNotice;
+OkDialog *weightNotice = NULL;
+OkDialog *deathNotice = NULL;
QuitDialog *quitDialog = NULL;
OkDialog *disconnectedDialog = NULL;
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index 21bab81e..76b0500e 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -52,7 +52,7 @@
#include <cassert>
-extern std::string tradePartnerName;
+std::string tradePartnerName;
PopupMenu::PopupMenu():
Popup("PopupMenu"),
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index e92c9bec..1dfbd849 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -29,6 +29,7 @@
#include "gui/sdlinput.h"
#include "gui/widgets/button.h"
+#include "gui/widgets/dropdown.h"
#include "gui/widgets/label.h"
#include "gui/widgets/layout.h"
#include "gui/widgets/listbox.h"
@@ -40,6 +41,7 @@
#include "utils/gettext.h"
#include "utils/stringutils.h"
#include "utils/xml.h"
+#include "widgets/dropdown.h"
#include <cstdlib>
#include <iostream>
@@ -111,6 +113,16 @@ std::string ServersListModel::getElementAt(int elementIndex)
return myServer;
}
+std::string TypeListModel::getElementAt(int elementIndex)
+{
+ if (elementIndex == 0)
+ return "eAthena";
+ else if (elementIndex == 1)
+ return "Manaserv";
+ else
+ return "Unknown";
+}
+
ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir):
Window(_("Choose Your Server")),
@@ -122,6 +134,7 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir):
{
Label *serverLabel = new Label(_("Server:"));
Label *portLabel = new Label(_("Port:"));
+ Label *typeLabel = new Label(_("Server type:"));
mServerNameField = new TextField(mServerInfo->hostname);
mPortField = new TextField(toString(mServerInfo->port));
@@ -154,6 +167,9 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir):
ScrollArea *usedScroll = new ScrollArea(mServersList);
usedScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
+ mTypeListModel = new TypeListModel();
+ mTypeField = new DropDown(mTypeListModel);
+
mDescription = new Label(std::string());
mQuitButton = new Button(_("Quit"), "quit", this);
@@ -174,11 +190,13 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir):
place(1, 0, mServerNameField, 3).setPadding(3);
place(0, 1, portLabel);
place(1, 1, mPortField, 3).setPadding(3);
- place(0, 2, usedScroll, 4, 5).setPadding(3);
- place(0, 7, mDescription, 4);
- place(0, 8, mManualEntryButton);
- place(2, 8, mQuitButton);
- place(3, 8, mConnectButton);
+ place(0, 2, typeLabel);
+ place(1, 2, mTypeField, 3).setPadding(3);
+ place(0, 3, usedScroll, 4, 5).setPadding(3);
+ place(0, 8, mDescription, 4);
+ place(0, 9, mManualEntryButton);
+ place(2, 9, mQuitButton);
+ place(3, 9, mConnectButton);
// Make sure the list has enough height
getLayout().setRowHeight(3, 80);
@@ -211,6 +229,7 @@ ServerDialog::~ServerDialog()
if (mDownload)
mDownload->cancel();
delete mServersListModel;
+ delete mTypeListModel;
}
void ServerDialog::action(const gcn::ActionEvent &event)
@@ -240,7 +259,17 @@ void ServerDialog::action(const gcn::ActionEvent &event)
ServerInfo tempServer;
currentServer.hostname = mServerNameField->getText();
currentServer.port = (short) atoi(mPortField->getText().c_str());
- currentServer.type = ServerInfo::UNKNOWN;
+ switch (mTypeField->getSelected())
+ {
+ case 0:
+ currentServer.type = ServerInfo::EATHENA;
+ break;
+ case 1:
+ currentServer.type = ServerInfo::MANASERV;
+ break;
+ default:
+ currentServer.type = ServerInfo::UNKNOWN;
+ }
// now rewrite the configuration...
// id = 0 is always the last selected server
@@ -274,6 +303,7 @@ void ServerDialog::action(const gcn::ActionEvent &event)
}
mServerInfo->hostname = currentServer.hostname;
mServerInfo->port = currentServer.port;
+ mServerInfo->type = currentServer.type;
state = STATE_CONNECT_SERVER;
}
}
@@ -313,7 +343,17 @@ void ServerDialog::valueChanged(const gcn::SelectionEvent &event)
mDescription->setCaption(myServer.name);
mServerNameField->setText(myServer.hostname);
mPortField->setText(toString(myServer.port));
-
+ switch (myServer.type)
+ {
+ case ServerInfo::UNKNOWN:
+ mTypeField->setSelected(2);
+ break;
+ case ServerInfo::EATHENA:
+ mTypeField->setSelected(0);
+ break;
+ case ServerInfo::MANASERV:
+ mTypeField->setSelected(1);
+ }
setFieldsReadOnly(true);
}
@@ -407,13 +447,7 @@ void ServerDialog::loadServers()
{
if (xmlStrEqual(server->name, BAD_CAST "server"))
{
- // check wether the build matches (remove with last instances
- // if _SUPPORT ifdefs)
std::string type = XML::getProperty(server, "type", "unknown");
- if (compareStrI(type, SERVER_BUILD))
- {
- continue;
- }
currentServer.clear();
currentServer.name = XML::getProperty(server, "name", std::string());
diff --git a/src/gui/serverdialog.h b/src/gui/serverdialog.h
index d82e2613..f0d99b30 100644
--- a/src/gui/serverdialog.h
+++ b/src/gui/serverdialog.h
@@ -42,6 +42,7 @@ class Label;
class ListBox;
class ServerDialog;
class TextField;
+class DropDown;
/**
* Server and Port List Model
@@ -73,6 +74,26 @@ class ServersListModel : public gcn::ListModel
};
/**
+ * Server and Port List Model
+ */
+class TypeListModel : public gcn::ListModel
+{
+ public:
+ TypeListModel() { };
+
+ /**
+ * Used to get number of line in the list
+ */
+ int getNumberOfElements() { return 2; }
+
+ /**
+ * Used to get an element from the list
+ */
+ std::string getElementAt(int elementIndex);
+};
+
+
+/**
* The server choice dialog.
*
* \ingroup Interface
@@ -134,6 +155,9 @@ class ServerDialog : public Window,
ListBox *mServersList;
ServersListModel *mServersListModel;
+ DropDown *mTypeField;
+ TypeListModel *mTypeListModel;
+
const std::string &mDir;
enum ServerDialogDownloadStatus
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 2ed7deb9..76bf5a22 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -37,6 +37,8 @@
#include "gui/ministatus.h"
#include "gui/popupmenu.h"
+#include "net/net.h"
+
#include "resources/monsterinfo.h"
#include "resources/resourcemanager.h"
@@ -411,7 +413,8 @@ void Viewport::mouseDragged(gcn::MouseEvent &event)
if (mPlayerFollowMouse && !event.isShiftPressed())
{
-#ifdef MANASERV_SUPPORT
+ if (Net::getNetworkType() == ServerInfo::MANASERV)
+ {
if (get_elapsed_time(mLocalWalkTime) >= walkingMouseDelay)
{
mLocalWalkTime = tick_time;
@@ -419,7 +422,9 @@ void Viewport::mouseDragged(gcn::MouseEvent &event)
event.getY() + (int) mPixelViewY);
player_node->pathSetByMouse();
}
-#else
+ }
+ else
+ {
if (mLocalWalkTime != player_node->getWalkTime())
{
mLocalWalkTime = player_node->getWalkTime();
@@ -427,7 +432,7 @@ void Viewport::mouseDragged(gcn::MouseEvent &event)
int destY = event.getY() / 32 + mTileViewY;
player_node->setDestination(destX, destY);
}
-#endif
+ }
}
}
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 8846d385..eb8d8164 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -67,12 +67,10 @@
#include <cassert>
-#ifdef MANASERV_SUPPORT
// This is the minimal delay between to permitted
// setDestination() calls using the keyboard.
// TODO: This can fine tuned later on when running is added...
const short walkingKeyboardDelay = 1000;
-#endif
LocalPlayer *player_node = NULL;
@@ -103,9 +101,7 @@ LocalPlayer::LocalPlayer(int id, int job, Map *map):
mDestX(0), mDestY(0),
mInventory(new Inventory(Net::getInventoryHandler()
->getSize(Net::InventoryHandler::INVENTORY))),
-#ifdef MANASERV_SUPPORT
mLocalWalkTime(-1),
-#endif
mStorage(new Inventory(Net::getInventoryHandler()
->getSize(Net::InventoryHandler::STORAGE))),
mMessageTime(0)
@@ -210,15 +206,17 @@ void LocalPlayer::logic()
}
else
{
-#ifdef MANASERV_SUPPORT
// Find whether target is in range
- const int rangeX = abs(mTarget->getPosition().x - getPosition().x);
- const int rangeY = abs(mTarget->getPosition().y - getPosition().y);
-#else
- // Find whether target is in range
- const int rangeX = abs(mTarget->getTileX() - getTileX());
- const int rangeY = abs(mTarget->getTileY() - getTileY());
-#endif
+ // TODO: Make this nicer, probably using getPosition() only
+ const int rangeX =
+ (Net::getNetworkType() == ServerInfo::MANASERV) ?
+ abs(mTarget->getPosition().x - getPosition().x) :
+ abs(mTarget->getTileX() - getTileX());
+ const int rangeY =
+ (Net::getNetworkType() == ServerInfo::MANASERV) ?
+ abs(mTarget->getPosition().y - getPosition().y) :
+ abs(mTarget->getTileY() - getTileY());
+
const int attackRange = getAttackRange();
const int inRange = rangeX > attackRange || rangeY > attackRange
? 1 : 0;
@@ -263,92 +261,95 @@ void LocalPlayer::setGMLevel(int level)
void LocalPlayer::nextStep(unsigned char dir = 0)
{
-#ifdef EATHENA_SUPPORT
- // TODO: Fix picking up when reaching target (this method is obsolete)
- // TODO: Fix holding walking button to keep walking smoothly
- if (mPath.empty())
- {
- if (mPickUpTarget)
- pickUp(mPickUpTarget);
-
- if (mWalkingDir)
- startWalking(mWalkingDir);
- }
-
- // TODO: Fix automatically walking within range of target, when wanted
- if (mGoingToTarget && mTarget && withinAttackRange(mTarget))
- {
- mAction = Being::STAND;
- attack(mTarget, true);
- mGoingToTarget = false;
- mPath.clear();
- return;
- }
- else if (mGoingToTarget && !mTarget)
+ if (Net::getNetworkType() == ServerInfo::EATHENA)
{
- mGoingToTarget = false;
- mPath.clear();
- }
-
-
- Player::nextStep();
-#else
- if (!mMap || !dir)
- return;
+ // TODO: Fix picking up when reaching target (this method is obsolete)
+ // TODO: Fix holding walking button to keep walking smoothly
+ if (mPath.empty())
+ {
+ if (mPickUpTarget)
+ pickUp(mPickUpTarget);
- const Vector &pos = getPosition();
+ if (mWalkingDir)
+ startWalking(mWalkingDir);
+ }
- // Compute where the next step will be set.
- int dx = 0, dy = 0;
- if (dir & UP)
- dy--;
- if (dir & DOWN)
- dy++;
- if (dir & LEFT)
- dx--;
- if (dir & RIGHT)
- dx++;
+ // TODO: Fix automatically walking within range of target, when wanted
+ if (mGoingToTarget && mTarget && withinAttackRange(mTarget))
+ {
+ mAction = Being::STAND;
+ attack(mTarget, true);
+ mGoingToTarget = false;
+ mPath.clear();
+ return;
+ }
+ else if (mGoingToTarget && !mTarget)
+ {
+ mGoingToTarget = false;
+ mPath.clear();
+ }
- // Prevent skipping corners over colliding tiles
- if (dx && !mMap->getWalk(((int) pos.x + dx) / 32,
- (int) pos.y / 32, getWalkMask()))
- dx = 16 - (int) pos.x % 32;
- if (dy && !mMap->getWalk((int) pos.x / 32,
- ((int) pos.y + dy) / 32, getWalkMask()))
- dy = 16 - (int) pos.y % 32;
- // Choose a straight direction when diagonal target is blocked
- if (dx && dy && !mMap->getWalk((pos.x + dx) / 32,
- (pos.y + dy) / 32, getWalkMask()))
- dx = 16 - (int) pos.x % 32;
+ Player::nextStep();
+ }
+ else
+ {
+ if (!mMap || !dir)
+ return;
- int dScaler; // Distance to walk
+ const Vector &pos = getPosition();
- // Checks our path up to 1 tiles, if a blocking tile is found
- // We go to the last good tile, and break out of the loop
- for (dScaler = 1; dScaler <= 32; dScaler++)
- {
- if ( (dx || dy) &&
- !mMap->getWalk( ((int) pos.x + (dx * dScaler)) / 32,
- ((int) pos.y + (dy * dScaler)) / 32, getWalkMask()) )
+ // Compute where the next step will be set.
+ int dx = 0, dy = 0;
+ if (dir & UP)
+ dy--;
+ if (dir & DOWN)
+ dy++;
+ if (dir & LEFT)
+ dx--;
+ if (dir & RIGHT)
+ dx++;
+
+ // Prevent skipping corners over colliding tiles
+ if (dx && !mMap->getWalk(((int) pos.x + dx) / 32,
+ (int) pos.y / 32, getWalkMask()))
+ dx = 16 - (int) pos.x % 32;
+ if (dy && !mMap->getWalk((int) pos.x / 32,
+ ((int) pos.y + dy) / 32, getWalkMask()))
+ dy = 16 - (int) pos.y % 32;
+
+ // Choose a straight direction when diagonal target is blocked
+ if (dx && dy && !mMap->getWalk((pos.x + dx) / 32,
+ (pos.y + dy) / 32, getWalkMask()))
+ dx = 16 - (int) pos.x % 32;
+
+ int dScaler; // Distance to walk
+
+ // Checks our path up to 1 tiles, if a blocking tile is found
+ // We go to the last good tile, and break out of the loop
+ for (dScaler = 1; dScaler <= 32; dScaler++)
{
- dScaler--;
- break;
+ if ( (dx || dy) &&
+ !mMap->getWalk( ((int) pos.x + (dx * dScaler)) / 32,
+ ((int) pos.y + (dy * dScaler)) / 32, getWalkMask()) )
+ {
+ dScaler--;
+ break;
+ }
}
- }
- if (dScaler > 16)
- {
- //effectManager->trigger(15, (int) pos.x + (dx * dScaler), (int) pos.y + (dy * dScaler));
- setDestination((int) pos.x + (dx * dScaler), (int) pos.y + (dy * dScaler));
- }
- else if (dir)
- {
- // If the being can't move, just change direction
- Net::getPlayerHandler()->setDirection(dir);
- setDirection(dir);
+ if (dScaler > 16)
+ {
+ //effectManager->trigger(15, (int) pos.x + (dx * dScaler), (int) pos.y + (dy * dScaler));
+ setDestination((int) pos.x + (dx * dScaler), (int) pos.y + (dy * dScaler));
+ }
+ else if (dir)
+ {
+ // If the being can't move, just change direction
+ Net::getPlayerHandler()->setDirection(dir);
+ setDirection(dir);
+ }
}
-#endif
}
bool LocalPlayer::checkInviteRights(const std::string &guildName)
@@ -409,15 +410,17 @@ void LocalPlayer::pickUp(FloorItem *item)
}
else
{
-#ifdef MANASERV_SUPPORT
- setDestination(item->getX() * 32 + 16, item->getY() * 32 + 16);
-#else
- setDestination(item->getX(), item->getY());
-#endif
- mPickUpTarget = item;
-#ifdef EATHENA_SUPPORT
- stopAttack();
-#endif
+ if (Net::getNetworkType() == ServerInfo::MANASERV)
+ {
+ setDestination(item->getX() * 32 + 16, item->getY() * 32 + 16);
+ mPickUpTarget = item;
+ }
+ else
+ {
+ setDestination(item->getX(), item->getY());
+ mPickUpTarget = item;
+ stopAttack();
+ }
}
}
@@ -460,56 +463,57 @@ void LocalPlayer::setTarget(Being *target)
void LocalPlayer::setDestination(int x, int y)
{
-#ifdef MANASERV_SUPPORT
- // Pre-computing character's destination in tiles
- const int tx = x / 32;
- const int ty = y / 32;
-
- // Check the walkability of the destination
- // If the destination is a wall, don't go there!
- if (!mMap->getWalk(tx, ty))
- return;
-
- // Pre-computing character's position useful variables.
- Vector playerPosition = getPosition();
- const int posX = (int)(playerPosition.x / 32);
- const int posY = (int)(playerPosition.y / 32);
- const int offsetY = (int)playerPosition.y % 32;
-
- // check if we're finding a path to the seeked destination
- // If the path is empty... and isn't on the same tile,
- // then, it's an unvalid one.
- if (posX != tx || posY != ty)
+ if (Net::getNetworkType() == ServerInfo::MANASERV)
{
- Path evaluatedPath = mMap->findPath(posX, posY, tx, ty,
- getWalkMask());
- if (evaluatedPath.empty())
+ // Pre-computing character's destination in tiles
+ const int tx = x / 32;
+ const int ty = y / 32;
+
+ // Check the walkability of the destination
+ // If the destination is a wall, don't go there!
+ if (!mMap->getWalk(tx, ty))
return;
- }
- // Pre-computing character's destination offsets.
- int fx = x % 32;
- int fy = y % 32;
-
- // Fix coordinates so that the player does not seem to dig into walls.
- if (fx > 16 && !mMap->getWalk(tx + 1, ty, getWalkMask()))
- fx = 16;
- else if (fx < 16 && !mMap->getWalk(tx - 1, ty, getWalkMask()))
- fx = 16;
- else if (fy > 16 && !mMap->getWalk(tx, ty + 1, getWalkMask()))
- fy = 16;
- else if (fy < 16 && !mMap->getWalk(tx, ty - 1, getWalkMask()))
- fy = 16;
-
- // Test also the current character's position, to avoid the corner case
- // where a player can approach an obstacle by walking from slightly
- // under, diagonally. First part to the walk on water bug.
- if (offsetY < 16 && !mMap->getWalk(posX, posY - 1, getWalkMask()))
- fy = 16;
-
- x = tx * 32 + fx;
- y = ty * 32 + fy;
-#endif
+ // Pre-computing character's position useful variables.
+ Vector playerPosition = getPosition();
+ const int posX = (int)(playerPosition.x / 32);
+ const int posY = (int)(playerPosition.y / 32);
+ const int offsetY = (int)playerPosition.y % 32;
+
+ // check if we're finding a path to the seeked destination
+ // If the path is empty... and isn't on the same tile,
+ // then, it's an unvalid one.
+ if (posX != tx || posY != ty)
+ {
+ Path evaluatedPath = mMap->findPath(posX, posY, tx, ty,
+ getWalkMask());
+ if (evaluatedPath.empty())
+ return;
+ }
+
+ // Pre-computing character's destination offsets.
+ int fx = x % 32;
+ int fy = y % 32;
+
+ // Fix coordinates so that the player does not seem to dig into walls.
+ if (fx > 16 && !mMap->getWalk(tx + 1, ty, getWalkMask()))
+ fx = 16;
+ else if (fx < 16 && !mMap->getWalk(tx - 1, ty, getWalkMask()))
+ fx = 16;
+ else if (fy > 16 && !mMap->getWalk(tx, ty + 1, getWalkMask()))
+ fy = 16;
+ else if (fy < 16 && !mMap->getWalk(tx, ty - 1, getWalkMask()))
+ fy = 16;
+
+ // Test also the current character's position, to avoid the corner case
+ // where a player can approach an obstacle by walking from slightly
+ // under, diagonally. First part to the walk on water bug.
+ if (offsetY < 16 && !mMap->getWalk(posX, posY - 1, getWalkMask()))
+ fy = 16;
+
+ x = tx * 32 + fx;
+ y = ty * 32 + fy;
+ }
// Only send a new message to the server when destination changes
if (x != mDestX || y != mDestY)
@@ -529,7 +533,8 @@ void LocalPlayer::setWalkingDir(int dir)
{
// This function is called by Game::handleInput()
-#ifdef MANASERV_SUPPORT
+ if (Net::getNetworkType() == ServerInfo::MANASERV)
+ {
// First if player is pressing key for the direction he is already
// going, do nothing more...
@@ -553,7 +558,7 @@ void LocalPlayer::setWalkingDir(int dir)
// don't do anything or we could get disconnected for spamming the server
if (get_elapsed_time(mLocalWalkTime) < walkingKeyboardDelay)
return;
-#endif
+ }
mWalkingDir = dir;
@@ -562,12 +567,10 @@ void LocalPlayer::setWalkingDir(int dir)
{
startWalking(dir);
}
-#ifdef MANASERV_SUPPORT
- else if (mAction == WALK)
+ else if (mAction == WALK && (Net::getNetworkType() == ServerInfo::MANASERV))
{
nextStep(dir);
}
-#endif
}
void LocalPlayer::startWalking(unsigned char dir)
@@ -582,12 +585,13 @@ void LocalPlayer::startWalking(unsigned char dir)
if (mAction == WALK && !mPath.empty())
{
// Just finish the current action, otherwise we get out of sync
-#ifdef MANASERV_SUPPORT
- const Vector &pos = getPosition();
- Being::setDestination(pos.x, pos.y);
-#else
- Being::setDestination(getTileX(), getTileY());
-#endif
+ if (Net::getNetworkType() == ServerInfo::MANASERV)
+ {
+ const Vector &pos = getPosition();
+ Being::setDestination(pos.x, pos.y);
+ }
+ else
+ Being::setDestination(getTileX(), getTileY());
return;
}
@@ -601,31 +605,32 @@ void LocalPlayer::startWalking(unsigned char dir)
if (dir & RIGHT)
dx++;
-#ifdef EATHENA_SUPPORT
- // Prevent skipping corners over colliding tiles
- if (dx && !mMap->getWalk(getTileX() + dx, getTileY(), getWalkMask()))
- dx = 0;
- if (dy && !mMap->getWalk(getTileX(), getTileY() + dy, getWalkMask()))
- dy = 0;
-
- // Choose a straight direction when diagonal target is blocked
- if (dx && dy && !mMap->getWalk(getTileX() + dx, getTileY() + dy, getWalkMask()))
- dx = 0;
-
- // Walk to where the player can actually go
- if ((dx || dy) && mMap->getWalk(getTileX() + dx, getTileY() + dy, getWalkMask()))
- {
- setDestination(getTileX() + dx, getTileY() + dy);
- }
- else if (dir)
+ if (Net::getNetworkType() == ServerInfo::EATHENA)
{
- // If the being can't move, just change direction
- Net::getPlayerHandler()->setDirection(dir);
- setDirection(dir);
+ // Prevent skipping corners over colliding tiles
+ if (dx && !mMap->getWalk(getTileX() + dx, getTileY(), getWalkMask()))
+ dx = 0;
+ if (dy && !mMap->getWalk(getTileX(), getTileY() + dy, getWalkMask()))
+ dy = 0;
+
+ // Choose a straight direction when diagonal target is blocked
+ if (dx && dy && !mMap->getWalk(getTileX() + dx, getTileY() + dy, getWalkMask()))
+ dx = 0;
+
+ // Walk to where the player can actually go
+ if ((dx || dy) && mMap->getWalk(getTileX() + dx, getTileY() + dy, getWalkMask()))
+ {
+ setDestination(getTileX() + dx, getTileY() + dy);
+ }
+ else if (dir)
+ {
+ // If the being can't move, just change direction
+ Net::getPlayerHandler()->setDirection(dir);
+ setDirection(dir);
+ }
}
-#else
- nextStep(dir);
-#endif
+ else
+ nextStep(dir);
}
void LocalPlayer::stopWalking(bool sendToServer)
@@ -633,9 +638,8 @@ void LocalPlayer::stopWalking(bool sendToServer)
if (mAction == WALK && mWalkingDir)
{
mWalkingDir = 0;
-#ifdef MANASERV_SUPPORT
mLocalWalkTime = 0;
-#endif
+
setDestination((int) getPosition().x, (int) getPosition().y);
if (sendToServer)
Net::getPlayerHandler()->setDestination((int) getPosition().x,
@@ -690,14 +694,15 @@ void LocalPlayer::setSpecialStatus(int id, int current, int max, int recharge)
void LocalPlayer::attack(Being *target, bool keep)
{
-#ifdef MANASERV_SUPPORT
- if (mLastAction != -1)
- return;
+ if (Net::getNetworkType() == ServerInfo::MANASERV)
+ {
+ if (mLastAction != -1)
+ return;
- // Can only attack when standing still
- if (mAction != STAND && mAction != ATTACK)
- return;
-#endif
+ // Can only attack when standing still
+ if (mAction != STAND && mAction != ATTACK)
+ return;
+ }
mKeepAttacking = keep;
@@ -709,54 +714,57 @@ void LocalPlayer::attack(Being *target, bool keep)
mLastTarget = -1;
setTarget(target);
}
-#ifdef MANASERV_SUPPORT
- Vector plaPos = this->getPosition();
- Vector tarPos = mTarget->getPosition();
- int dist_x = plaPos.x - tarPos.x;
- int dist_y = plaPos.y - tarPos.y;
-
- if (abs(dist_y) >= abs(dist_x))
+ if (Net::getNetworkType() == ServerInfo::MANASERV)
{
- if (dist_y < 0)
- setDirection(DOWN);
+ Vector plaPos = this->getPosition();
+ Vector tarPos = mTarget->getPosition();
+ int dist_x = plaPos.x - tarPos.x;
+ int dist_y = plaPos.y - tarPos.y;
+
+ if (abs(dist_y) >= abs(dist_x))
+ {
+ if (dist_y < 0)
+ setDirection(DOWN);
+ else
+ setDirection(UP);
+ }
else
- setDirection(UP);
+ {
+ if (dist_x < 0)
+ setDirection(RIGHT);
+ else
+ setDirection(LEFT);
+ }
+
+ mLastAction = tick_time;
}
else
{
- if (dist_x < 0)
- setDirection(RIGHT);
- else
- setDirection(LEFT);
- }
+ int dist_x = target->getTileX() - getTileX();
+ int dist_y = target->getTileY() - getTileY();
- mLastAction = tick_time;
-#else
- int dist_x = target->getTileX() - getTileX();
- int dist_y = target->getTileY() - getTileY();
-
- // Must be standing to attack
- if (mAction != STAND)
- return;
+ // Must be standing to attack
+ if (mAction != STAND)
+ return;
- if (abs(dist_y) >= abs(dist_x))
- {
- if (dist_y > 0)
- setDirection(DOWN);
- else
- setDirection(UP);
- }
- else
- {
- if (dist_x > 0)
- setDirection(RIGHT);
+ if (abs(dist_y) >= abs(dist_x))
+ {
+ if (dist_y > 0)
+ setDirection(DOWN);
+ else
+ setDirection(UP);
+ }
else
- setDirection(LEFT);
- }
+ {
+ if (dist_x > 0)
+ setDirection(RIGHT);
+ else
+ setDirection(LEFT);
+ }
- mWalkTime = tick_time;
- mTargetTime = tick_time;
-#endif
+ mWalkTime = tick_time;
+ mTargetTime = tick_time;
+ }
setAction(ATTACK);
@@ -772,10 +780,8 @@ void LocalPlayer::attack(Being *target, bool keep)
}
Net::getPlayerHandler()->attack(target->getId());
-#ifdef EATHENA_SUPPORT
- if (!keep)
+ if ((Net::getNetworkType() == ServerInfo::EATHENA) && !keep)
stopAttack();
-#endif
}
void LocalPlayer::stopAttack()
@@ -1005,40 +1011,46 @@ int LocalPlayer::getAttackRange()
bool LocalPlayer::withinAttackRange(Being *target)
{
-#ifdef MANASERV_SUPPORT
- const Vector &targetPos = target->getPosition();
- const Vector &pos = getPosition();
- const int dx = abs(targetPos.x - pos.x);
- const int dy = abs(targetPos.y - pos.y);
- const int range = getAttackRange();
-
- return !(dx > range || dy > range);
-#else
- int dist_x = abs(target->getTileX() - getTileY());
- int dist_y = abs(target->getTileY() - getTileX());
-
- if (dist_x > getAttackRange() || dist_y > getAttackRange())
+ if (Net::getNetworkType() == ServerInfo::MANASERV)
{
- return false;
+ const Vector &targetPos = target->getPosition();
+ const Vector &pos = getPosition();
+ const int dx = abs(targetPos.x - pos.x);
+ const int dy = abs(targetPos.y - pos.y);
+ const int range = getAttackRange();
+
+ return !(dx > range || dy > range);
}
+ else
+ {
+ int dist_x = abs(target->getTileX() - getTileY());
+ int dist_y = abs(target->getTileY() - getTileX());
- return true;
-#endif
+ if (dist_x > getAttackRange() || dist_y > getAttackRange())
+ {
+ return false;
+ }
+
+ return true;
+ }
}
void LocalPlayer::setGotoTarget(Being *target)
{
mLastTarget = -1;
-#ifdef MANASERV_SUPPORT
- mTarget = target;
- mGoingToTarget = true;
- const Vector &targetPos = target->getPosition();
- setDestination(targetPos.x, targetPos.y);
-#else
- setTarget(target);
- mGoingToTarget = true;
- setDestination(target->getTileX(), target->getTileY());
-#endif
+ if (Net::getNetworkType() == ServerInfo::MANASERV)
+ {
+ mTarget = target;
+ mGoingToTarget = true;
+ const Vector &targetPos = target->getPosition();
+ setDestination(targetPos.x, targetPos.y);
+ }
+ else
+ {
+ setTarget(target);
+ mGoingToTarget = true;
+ setDestination(target->getTileX(), target->getTileY());
+ }
}
extern MiniStatusWindow *miniStatusWindow;
diff --git a/src/localplayer.h b/src/localplayer.h
index ac97b35f..36876500 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -453,10 +453,8 @@ class LocalPlayer : public Player
Inventory *mInventory;
-#ifdef MANASERV_SUPPORT
int mLocalWalkTime; /**< Timestamp used to control keyboard walk
messages flooding */
-#endif
Inventory *mStorage;
diff --git a/src/main.h b/src/main.h
index ca2612e2..6cd43866 100644
--- a/src/main.h
+++ b/src/main.h
@@ -65,16 +65,10 @@
#include <string>
-#ifdef MANASERV_SUPPORT
-#define SERVER_BUILD "manaserv"
-#else
-#define SERVER_BUILD "eAthena"
-#endif
-
#ifdef PACKAGE_VERSION
-#define FULL_VERSION "v" PACKAGE_VERSION " (" SERVER_BUILD ")"
+#define FULL_VERSION "v" PACKAGE_VERSION
#else
-#define FULL_VERSION "Unknown Version (" SERVER_BUILD ")"
+#define FULL_VERSION "Unknown Version"
#endif
#ifndef PKG_DATADIR
@@ -83,11 +77,9 @@
#define MAX_CHARACTER_COUNT 3
-#ifdef MANASERV_SUPPORT
-#define DEFAULT_PORT 9601
-#else
+//manaserv uses 9601
+//#define DEFAULT_PORT 9601
#define DEFAULT_PORT 6901
-#endif
const std::string &getHomeDirectory();
diff --git a/src/monster.cpp b/src/monster.cpp
index 57a6f229..7da7e759 100644
--- a/src/monster.cpp
+++ b/src/monster.cpp
@@ -29,6 +29,8 @@
#include "gui/palette.h"
+#include "net/net.h"
+
#include "resources/monsterdb.h"
#include "resources/monsterinfo.h"
@@ -71,15 +73,13 @@ Monster::Monster(int id, int job, Map *map):
void Monster::logic()
{
-#ifdef EATHENA_SUPPORT
- if (mAction != STAND)
+ if ((Net::getNetworkType() == ServerInfo::EATHENA) && (mAction != STAND))
{
mFrame = (int) ((get_elapsed_time(mWalkTime) * 4) / getWalkSpeed());
if (mFrame >= 4 && mAction != DEAD)
nextStep();
}
-#endif
Being::logic();
}
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp
index 0965e85a..156e8b26 100644
--- a/src/net/ea/playerhandler.cpp
+++ b/src/net/ea/playerhandler.cpp
@@ -47,9 +47,8 @@
#include "utils/stringutils.h"
#include "utils/gettext.h"
-// TODO Move somewhere else
-OkDialog *weightNotice = NULL;
-OkDialog *deathNotice = NULL;
+extern OkDialog *weightNotice;
+extern OkDialog *deathNotice;
// Max. distance we are willing to scroll after a teleport;
// everything beyond will reset the port hard.
@@ -638,4 +637,9 @@ int PlayerHandler::getJobLocation()
return JOB;
}
+float PlayerHandler::getDefaultWalkSpeed()
+{
+ return 150;
+}
+
} // namespace EAthena
diff --git a/src/net/ea/playerhandler.h b/src/net/ea/playerhandler.h
index 61f3b705..83ca91f6 100644
--- a/src/net/ea/playerhandler.h
+++ b/src/net/ea/playerhandler.h
@@ -65,6 +65,8 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler
bool canCorrectAttributes();
int getJobLocation();
+
+ float getDefaultWalkSpeed();
};
} // namespace EAthena
diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp
index 56528a85..abcfc04f 100644
--- a/src/net/ea/tradehandler.cpp
+++ b/src/net/ea/tradehandler.cpp
@@ -40,7 +40,7 @@
#include "utils/gettext.h"
#include "utils/stringutils.h"
-std::string tradePartnerName;
+extern std::string tradePartnerName;
ConfirmDialog *confirmDlg;
/**
diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp
index 60274288..0d7544fd 100644
--- a/src/net/manaserv/playerhandler.cpp
+++ b/src/net/manaserv/playerhandler.cpp
@@ -42,9 +42,8 @@
#include "net/manaserv/messageout.h"
#include "net/manaserv/protocol.h"
-// TODO Move somewhere else
-OkDialog *weightNotice = NULL;
-OkDialog *deathNotice = NULL;
+extern OkDialog *weightNotice;
+extern OkDialog *deathNotice;
extern BuyDialog *buyDialog;
extern SellDialog *sellDialog;
@@ -424,4 +423,9 @@ int PlayerHandler::getJobLocation()
return -1;
}
+float PlayerHandler::getDefaultWalkSpeed()
+{
+ return 6.0f;
+}
+
} // namespace ManaServ
diff --git a/src/net/manaserv/playerhandler.h b/src/net/manaserv/playerhandler.h
index 37d485f8..22be69f3 100644
--- a/src/net/manaserv/playerhandler.h
+++ b/src/net/manaserv/playerhandler.h
@@ -73,6 +73,8 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler
int getJobLocation();
+ float getDefaultWalkSpeed();
+
private:
void handleMapChangeMessage(Net::MessageIn &msg);
};
diff --git a/src/net/manaserv/tradehandler.cpp b/src/net/manaserv/tradehandler.cpp
index 5eedbec8..7f7be6bf 100644
--- a/src/net/manaserv/tradehandler.cpp
+++ b/src/net/manaserv/tradehandler.cpp
@@ -40,7 +40,7 @@
#include "utils/gettext.h"
#include "utils/stringutils.h"
-std::string tradePartnerName;
+extern std::string tradePartnerName;
int tradePartnerID;
extern Net::TradeHandler *tradeHandler;
diff --git a/src/net/net.cpp b/src/net/net.cpp
index 593d9cb7..75f8229c 100644
--- a/src/net/net.cpp
+++ b/src/net/net.cpp
@@ -126,41 +126,20 @@ ServerInfo::Type networkType = ServerInfo::UNKNOWN;
void connectToServer(const ServerInfo &server)
{
- // Remove with ifdefs
- if (networkType != ServerInfo::UNKNOWN)
- {
- getGeneralHandler()->reload();
- }
- else
- {
-#ifdef MANASERV_SUPPORT
- new ManaServ::GeneralHandler;
-#else
- new EAthena::GeneralHandler;
-#endif
-
- getGeneralHandler()->load();
-
- networkType = server.type;
- }
- // End remove section
-
- // Uncomment after ifdefs removed
- /*ServerInfo server = ServerInfo(inServer);
if (server.type == ServerInfo::UNKNOWN)
{
// TODO: Query the server about itself and choose the netcode based on
// that
}
- //if (networkType == server.type)
- if (networkType != ServerInfo::UNKNOWN)
+ if (networkType == server.type && getGeneralHandler() != NULL)
+ //if (networkType != ServerInfo::UNKNOWN)
{
getGeneralHandler()->reload();
}
else
{
- if (networkType != ServerInfo::UNKNOWN)
+ if (networkType != ServerInfo::UNKNOWN && getGeneralHandler() != NULL)
{
getGeneralHandler()->unload();
}
@@ -183,7 +162,7 @@ void connectToServer(const ServerInfo &server)
getGeneralHandler()->load();
networkType = server.type;
- }*/
+ }
getLoginHandler()->setServer(server);
@@ -199,5 +178,10 @@ void unload()
}
}
+ServerInfo::Type getNetworkType()
+{
+ return networkType;
+}
+
} // namespace Net
diff --git a/src/net/net.h b/src/net/net.h
index d6bb7d39..e26a4b2d 100644
--- a/src/net/net.h
+++ b/src/net/net.h
@@ -26,7 +26,7 @@
* \defgroup Network Core network layer
*/
-class ServerInfo;
+#include "net/serverinfo.h"
namespace Net {
@@ -58,6 +58,8 @@ PlayerHandler *getPlayerHandler();
SpecialHandler *getSpecialHandler();
TradeHandler *getTradeHandler();
+ServerInfo::Type getNetworkType();
+
/**
* Handles server detection and connection
*/
diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h
index d190be01..cc135c7e 100644
--- a/src/net/playerhandler.h
+++ b/src/net/playerhandler.h
@@ -61,6 +61,8 @@ class PlayerHandler
virtual int getJobLocation() = 0;
+ virtual float getDefaultWalkSpeed() = 0;
+
virtual ~PlayerHandler() {}
};
diff --git a/src/player.cpp b/src/player.cpp
index 007a398c..022b06ba 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -73,60 +73,61 @@ Player::~Player()
void Player::logic()
{
-#ifdef EATHENA_SUPPORT
- switch (mAction)
+ if (Net::getNetworkType() == ServerInfo::EATHENA)
{
- case STAND:
- case SIT:
- case DEAD:
- case HURT:
- break;
-
- case WALK:
- mFrame = (int) ((get_elapsed_time(mWalkTime) * 6) / getWalkSpeed());
- if (mFrame >= 6)
- nextStep();
- break;
-
- case ATTACK:
- int rotation = 0;
- std::string particleEffect = "";
- int frames = 4;
-
- if (mEquippedWeapon &&
- mEquippedWeapon->getAttackType() == ACTION_ATTACK_BOW)
- {
- frames = 5;
- }
-
- mFrame = (get_elapsed_time(mWalkTime) * frames) / mAttackSpeed;
-
- //attack particle effect
- if (mEquippedWeapon)
- particleEffect = mEquippedWeapon->getParticleEffect();
-
- if (!particleEffect.empty() && Particle::enabled && mFrame == 1)
- {
- switch (mDirection)
+ switch (mAction)
+ {
+ case STAND:
+ case SIT:
+ case DEAD:
+ case HURT:
+ break;
+
+ case WALK:
+ mFrame = (int) ((get_elapsed_time(mWalkTime) * 6) / getWalkSpeed());
+ if (mFrame >= 6)
+ nextStep();
+ break;
+
+ case ATTACK:
+ int rotation = 0;
+ std::string particleEffect = "";
+ int frames = 4;
+
+ if (mEquippedWeapon &&
+ mEquippedWeapon->getAttackType() == ACTION_ATTACK_BOW)
{
- case DOWN: rotation = 0; break;
- case LEFT: rotation = 90; break;
- case UP: rotation = 180; break;
- case RIGHT: rotation = 270; break;
- default: break;
+ frames = 5;
}
- Particle *p;
- p = particleEngine->addEffect("graphics/particles/" +
- particleEffect, 0, 0, rotation);
- controlParticle(p);
- }
- if (mFrame >= frames)
- nextStep();
+ mFrame = (get_elapsed_time(mWalkTime) * frames) / mAttackSpeed;
+
+ //attack particle effect
+ if (mEquippedWeapon)
+ particleEffect = mEquippedWeapon->getParticleEffect();
- break;
+ if (!particleEffect.empty() && Particle::enabled && mFrame == 1)
+ {
+ switch (mDirection)
+ {
+ case DOWN: rotation = 0; break;
+ case LEFT: rotation = 90; break;
+ case UP: rotation = 180; break;
+ case RIGHT: rotation = 270; break;
+ default: break;
+ }
+ Particle *p;
+ p = particleEngine->addEffect("graphics/particles/" +
+ particleEffect, 0, 0, rotation);
+ controlParticle(p);
+ }
+
+ if (mFrame >= frames)
+ nextStep();
+
+ break;
+ }
}
-#endif
Being::logic();
}