summaryrefslogtreecommitdiff
path: root/src/being.cpp
diff options
context:
space:
mode:
authorDaniel Bradshaw <daniel+commits@the-cell.co.uk>2010-01-31 13:14:07 +0000
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2010-01-31 17:50:29 +0100
commit2ff6ad2e8a67bd8ef34b56b866ef277c30135f19 (patch)
tree536497f63044441a6e8032209446d1c3213b9d55 /src/being.cpp
parent22c75a346e029fad746b6aa0b123c886ddeb5c75 (diff)
downloadmana-client-2ff6ad2e8a67bd8ef34b56b866ef277c30135f19.tar.gz
mana-client-2ff6ad2e8a67bd8ef34b56b866ef277c30135f19.tar.bz2
mana-client-2ff6ad2e8a67bd8ef34b56b866ef277c30135f19.tar.xz
mana-client-2ff6ad2e8a67bd8ef34b56b866ef277c30135f19.zip
Unify eAthena and manaserv support in to one build.
Finish support for server types in the server dialog. Using the new server type function, strip out ifdefs, replacing them with if blocks for later merging in smaller atomic commits. Remove any remaining references to the support defs, including in build system.
Diffstat (limited to 'src/being.cpp')
-rw-r--r--src/being.cpp68
1 files changed, 30 insertions, 38 deletions
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
{