diff options
author | Bertram <bertram@cegetel.net> | 2010-01-27 01:46:58 +0100 |
---|---|---|
committer | Bertram <bertram@cegetel.net> | 2010-01-27 01:46:58 +0100 |
commit | 572ed6a1aa6c847e8764bddf2bb0d687ecf1a405 (patch) | |
tree | f0183d944a3a887b359e2dc2895e87a9c2767e66 | |
parent | 692aac3122843c59610684802e25b92cc9f0a33c (diff) | |
download | Mana-572ed6a1aa6c847e8764bddf2bb0d687ecf1a405.tar.gz Mana-572ed6a1aa6c847e8764bddf2bb0d687ecf1a405.tar.bz2 Mana-572ed6a1aa6c847e8764bddf2bb0d687ecf1a405.tar.xz Mana-572ed6a1aa6c847e8764bddf2bb0d687ecf1a405.zip |
Added mutators/accessors to being.h and smal cleanups.
-rw-r--r-- | src/being.h | 132 | ||||
-rw-r--r-- | src/beingmanager.cpp | 11 | ||||
-rw-r--r-- | src/game.cpp | 2 | ||||
-rw-r--r-- | src/gui/viewport.cpp | 8 | ||||
-rw-r--r-- | src/localplayer.cpp | 2 | ||||
-rw-r--r-- | src/map.cpp | 3 | ||||
-rw-r--r-- | src/net/ea/beinghandler.cpp | 30 | ||||
-rw-r--r-- | src/net/ea/npchandler.cpp | 2 | ||||
-rw-r--r-- | src/net/ea/playerhandler.cpp | 4 |
9 files changed, 125 insertions, 69 deletions
diff --git a/src/being.h b/src/being.h index 9f50b2cc..c564482a 100644 --- a/src/being.h +++ b/src/being.h @@ -115,18 +115,6 @@ class Being : public Sprite, public ConfigListener */ enum { DOWN = 1, LEFT = 2, UP = 4, RIGHT = 8 }; - int mFrame; -#ifdef EATHENA_SUPPORT - int mWalkTime; -#endif - int mEmotion; /**< Currently showing emotion */ - int mEmotionTime; /**< Time until emotion disappears */ - int mSpeechTime; - - int mAttackSpeed; /**< Attack speed */ - Action mAction; /**< Action the being is performing */ - Uint16 mJob; /**< Job (player job, npc, monster, creature ) */ - /** * Constructor. * @@ -143,12 +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. + */ + int getWalkTime() const { return mWalkTime; } + + /** + * Set the current WalkTime value. + * @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. + */ + virtual void nextStep(); + + /** + * Get the current X pixel offset. + */ + int getXOffset() const + { return getOffset(LEFT, RIGHT); } + + /** + * Get the current Y pixel offset. + */ + int getYOffset() const + { return getOffset(UP, DOWN); } + /** * Sets a new destination for this being to walk to. */ -#ifdef EATHENA_SUPPORT virtual void setDestination(int destX, int destY); -#else +#elif MANASERV_SUPPORT /** * Creates a path for the being from current position to ex and ey */ @@ -234,13 +252,6 @@ class Being : public Sprite, public ConfigListener */ int getNumberOfLayers() const; -#ifdef EATHENA_SUPPORT - /** - * Makes this being take the next step of his path. - */ - virtual void nextStep(); -#endif - /** * Performs being logic. */ @@ -261,6 +272,16 @@ class Being : public Sprite, public ConfigListener */ virtual Type getType() const { return UNKNOWN; } + /** + * Return Being's current Job (player job, npc, monster, creature ) + */ + Uint16 getJob() const { return mJob; } + + /** + * Set Being's current Job (player job, npc, monster, creature ) + */ + void setJob(Uint16 job) { mJob = job; } + /** * Sets the walk speed. * in pixels per second for eAthena, @@ -276,6 +297,18 @@ class Being : public Sprite, public ConfigListener float getWalkSpeed() const { return mWalkSpeed; } /** + * Sets the attack speed. + * @todo In what unit? + */ + void setAttackSpeed(int speed) { mAttackSpeed = speed; } + + /** + * Gets the attack speed. + * @todo In what unit? + */ + int getAttackSpeed() const { return mAttackSpeed; } + + /** * Sets the sprite id. */ void setId(int id) { mId = id; } @@ -293,6 +326,11 @@ class Being : public Sprite, public ConfigListener virtual void setAction(Action action, int attackType = 0); /** + * Get the being's action currently performed. + */ + Action getCurrentAction() const { return mAction; } + + /** * Returns whether this being is still alive. */ bool isAlive() const { return mAction != DEAD; } @@ -307,12 +345,15 @@ class Being : public Sprite, public ConfigListener */ void setDirection(Uint8 direction); -#ifdef EATHENA_SUPPORT /** - * Returns the walk time. + * Returns the being's current sprite frame number. */ - int getWalkTime() const { return mWalkTime; } -#endif + int getCurrentFrame() const { return mFrame; } + + /** + * Set the being's current sprite frame number. + */ + void setFrame(int frame) { mFrame = frame; } /** * Returns the direction the being is facing. @@ -361,20 +402,6 @@ class Being : public Sprite, public ConfigListener int getPixelY() const { return mPos.y; } -#ifdef EATHENA_SUPPORT - /** - * Get the current X pixel offset. - */ - int getXOffset() const - { return getOffset(LEFT, RIGHT); } - - /** - * Get the current Y pixel offset. - */ - int getYOffset() const - { return getOffset(UP, DOWN); } -#endif - /** * Sets the position of this being. */ @@ -438,6 +465,11 @@ class Being : public Sprite, public ConfigListener */ void untarget() { mUsedTargetCursor = NULL; } + + /** + * Set the Emoticon type and time displayed above + * the being. + */ void setEmote(Uint8 emotion, Uint8 emote_time) { mEmotion = emotion; @@ -445,6 +477,12 @@ class Being : public Sprite, public ConfigListener } /** + * Get the current Emoticon type displayed above + * the being. + */ + Uint8 getEmotion() const { return mEmotion; } + + /** * Sets the being's stun mode. If zero, the being is `normal', * otherwise it is `stunned' in some fashion. */ @@ -539,6 +577,22 @@ class Being : public Sprite, public ConfigListener virtual void showName(); + /** The current sprite Frame number to be displayed */ + int mFrame; + +#ifdef EATHENA_SUPPORT + /** Used to trigger the nextStep (walking on next Tile) */ + int mWalkTime; +#endif + int mEmotion; /**< Currently showing emotion */ + int mEmotionTime; /**< Time until emotion disappears */ + /** Time until the last speech sentence disappears */ + int mSpeechTime; + + int mAttackSpeed; /**< Attack speed */ + Action mAction; /**< Action the being is performing */ + Uint16 mJob; /**< Job (player job, npc, monster, creature ) */ + int mId; /**< Unique sprite id */ Uint8 mDirection; /**< Facing direction */ Uint8 mSpriteDirection; /**< Facing direction */ diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp index 1f1230d4..7c2ddc44 100644 --- a/src/beingmanager.cpp +++ b/src/beingmanager.cpp @@ -43,7 +43,7 @@ class FindBeingFunctor const Vector &pos = being->getPosition(); return ((int) pos.x / 32 == x && ((int) pos.y / 32 == y || (int) pos.y / 32 == other_y) && - being->mAction != Being::DEAD && + being->isAlive() && (type == Being::UNKNOWN || being->getType() == type)); } @@ -141,7 +141,7 @@ Being *BeingManager::findBeingByPixel(int x, int y) const int xtol = being->getWidth() / 2; int uptol = being->getHeight(); - if ((being->mAction != Being::DEAD) && + if ((being->isAlive()) && (being != player_node) && (being->getPixelX() - xtol <= x) && (being->getPixelX() + xtol >= x) && @@ -183,8 +183,9 @@ void BeingManager::logic() being->logic(); - if (being->mAction == Being::DEAD && - Net::getGameHandler()->removeDeadBeings() && being->mFrame >= 20) + if (!being->isAlive() && + Net::getGameHandler()->removeDeadBeings() && + being->getCurrentFrame() >= 20) { delete being; i = mBeings.erase(i); @@ -228,7 +229,7 @@ Being *BeingManager::findNearestLivingBeing(int x, int y, if ((being->getType() == type || type == Being::UNKNOWN) && (d < dist || !closestBeing) // it is closer - && being->mAction != Being::DEAD) // no dead beings + && being->isAlive()) // no dead beings { dist = d; closestBeing = being; diff --git a/src/game.cpp b/src/game.cpp index 427f70b6..0cc59ff6 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -905,7 +905,7 @@ void Game::handleInput() return; // Moving player around - if (player_node->mAction != Being::DEAD && current_npc == 0 && + if (player_node->isAlive() && current_npc == 0 && !chatWindow->isInputFocused() && !quitDialog) { // Get the state of the keyboard keys diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index e3d8b092..2ed7deb9 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -355,7 +355,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event) case Being::MONSTER: case Being::PLAYER: // Ignore it if its dead - if (being->mAction == Being::DEAD) + if (!being->isAlive()) break; if (player_node->withinAttackRange(being) || @@ -378,7 +378,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event) { player_node->pickUp(item); } - else if (player_node->mAction == Being::SIT) + else if (player_node->getCurrentAction() == Being::SIT) { return; } @@ -420,9 +420,9 @@ void Viewport::mouseDragged(gcn::MouseEvent &event) player_node->pathSetByMouse(); } #else - if (mLocalWalkTime != player_node->mWalkTime) + if (mLocalWalkTime != player_node->getWalkTime()) { - mLocalWalkTime = player_node->mWalkTime; + mLocalWalkTime = player_node->getWalkTime(); int destX = event.getX() / 32 + mTileViewX; int destY = event.getY() / 32 + mTileViewY; player_node->setDestination(destX, destY); diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 79ea00af..8ea6af61 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -225,7 +225,7 @@ void LocalPlayer::logic() mTarget->setTargetAnimation( mTargetCursor[inRange][mTarget->getTargetCursorSize()]); - if (mTarget->mAction == DEAD) + if (!mTarget->isAlive()) stopAttack(); if (mKeepAttacking && mTarget) diff --git a/src/map.cpp b/src/map.cpp index 0c6aee8f..26dd483f 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -542,7 +542,8 @@ bool Map::occupied(int x, int y) const const Being *being = *i; // job 45 is a portal, they don't collide - if (being->getTileX() == x && being->getTileY() == y && being->mJob != 45) + if (being->getTileX() == x && being->getTileY() == y + && being->getJob() != 45) return true; } diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp index 412b0930..797668a2 100644 --- a/src/net/ea/beinghandler.cpp +++ b/src/net/ea/beinghandler.cpp @@ -112,7 +112,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) Player *player; int hairStyle, hairColor, flag; std::string player_followed; - + switch (msg.getId()) { case SMSG_BEING_VISIBLE: @@ -153,8 +153,8 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) if (msg.getId() == 0x0078) { dstBeing->clearPath(); - dstBeing->mFrame = 0; - dstBeing->mWalkTime = tick_time; + dstBeing->setFrame(0); + dstBeing->setWalkTime(tick_time); dstBeing->setAction(Being::STAND); } @@ -163,7 +163,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) if (speed == 0) { speed = 150; } dstBeing->setWalkSpeed(speed); - dstBeing->mJob = job; + dstBeing->setJob(job); hairStyle = msg.readInt16(); weapon = msg.readInt16(); headBottom = msg.readInt16(); @@ -263,9 +263,9 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) if (!dstBeing) break; - + player_followed = player_node->getFollow(); - + if (!player_followed.empty()) { if (dstBeing->getName() == player_followed) @@ -349,7 +349,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) case 0x02: // Sit if (srcBeing) { - srcBeing->mFrame = 0; + srcBeing->setFrame(0); srcBeing->setAction(Being::SIT); } break; @@ -357,7 +357,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) case 0x03: // Stand up if (srcBeing) { - srcBeing->mFrame = 0; + srcBeing->setFrame(0); srcBeing->setAction(Being::STAND); } break; @@ -386,7 +386,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) if (player_relations.hasPermission(dstBeing, PlayerRelation::EMOTE)) { // only set emote if one doesnt already exist - if (!dstBeing->mEmotion) + if (!dstBeing->getEmotion()) dstBeing->setEmote(msg.readInt8(), EMOTION_TIME); } @@ -524,7 +524,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) } dstBeing->setWalkSpeed(speed); - dstBeing->mJob = job; + dstBeing->setJob(job); hairStyle = msg.readInt16(); weapon = msg.readInt16(); shield = msg.readInt16(); @@ -567,7 +567,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) msg.readCoordinatePair(srcX, srcY, dstX, dstY); dstBeing->setTileCoords(srcX, srcY); dstBeing->setDestination(dstX, dstY); - + player_followed = player_node->getFollow(); if (!player_followed.empty()) { @@ -612,8 +612,8 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) msg.readInt8(); // Lv msg.readInt8(); // unknown - dstBeing->mWalkTime = tick_time; - dstBeing->mFrame = 0; + dstBeing->setWalkTime(tick_time); + dstBeing->setFrame(0); dstBeing->setStunMode(stunMode); dstBeing->setStatusEffectBlock(0, (statusEffects >> 16) & 0xffff); @@ -643,9 +643,9 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) x = msg.readInt16(); y = msg.readInt16(); dstBeing->setTileCoords(x, y); - if (dstBeing->mAction == Being::WALK) + if (dstBeing->getCurrentAction() == Being::WALK) { - dstBeing->mFrame = 0; + dstBeing->setFrame(0); dstBeing->setAction(Being::STAND); } } diff --git a/src/net/ea/npchandler.cpp b/src/net/ea/npchandler.cpp index 40e9daf8..3ec3c1f8 100644 --- a/src/net/ea/npchandler.cpp +++ b/src/net/ea/npchandler.cpp @@ -126,7 +126,7 @@ void NpcHandler::handleMessage(Net::MessageIn &msg) break; } - if (resetPlayer && player_node->mAction != Being::SIT) + if (resetPlayer && player_node->getCurrentAction() != Being::SIT) player_node->setAction(Being::STAND); } diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index 3a0a2fe2..0965e85a 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -211,7 +211,7 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg) } player_node->setAction(Being::STAND); - player_node->mFrame = 0; + player_node->setFrame(0); player_node->setTileCoords(x, y); logger->log("Adjust scrolling by %d:%d", (int) scrollOffsetX, @@ -295,7 +295,7 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg) case 0x0034: player_node->setAttributeBase(CRIT, value); player_node->setAttributeEffective(CRIT, value); break; - case 0x0035: player_node->mAttackSpeed = value; break; + case 0x0035: player_node->setAttackSpeed(value); break; case 0x0037: player_node->setAttributeBase(JOB, value); player_node->setAttributeEffective(JOB, value); break; case 500: player_node->setGMLevel(value); break; |