summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2009-12-06 17:40:37 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2009-12-06 17:40:37 +0100
commitfe116c52a7fafc3ad61d14263dd60bc8e7acecdd (patch)
treea09f8b5f96af3840e49f784ccaefa3ca10872867 /src
parent50916cc0b70adc14e3ae8fedb04c0ed0f9d8d85e (diff)
downloadmanaserv-fe116c52a7fafc3ad61d14263dd60bc8e7acecdd.tar.gz
manaserv-fe116c52a7fafc3ad61d14263dd60bc8e7acecdd.tar.bz2
manaserv-fe116c52a7fafc3ad61d14263dd60bc8e7acecdd.tar.xz
manaserv-fe116c52a7fafc3ad61d14263dd60bc8e7acecdd.zip
Made the Being timer accessors const
Diffstat (limited to 'src')
-rw-r--r--src/game-server/being.cpp16
-rw-r--r--src/game-server/being.hpp29
2 files changed, 25 insertions, 20 deletions
diff --git a/src/game-server/being.cpp b/src/game-server/being.cpp
index fe0190de..a85cc974 100644
--- a/src/game-server/being.cpp
+++ b/src/game-server/being.cpp
@@ -440,20 +440,18 @@ void Being::setTimerHard(TimerID id, int value)
mTimers[id] = value;
}
-int Being::getTimer(TimerID id)
+int Being::getTimer(TimerID id) const
{
- Timers::iterator i = mTimers.find(id);
- if (i == mTimers.end()) return -1;
- return i->second;
+ Timers::const_iterator i = mTimers.find(id);
+ return (i == mTimers.end()) ? -1 : i->second;
}
-bool Being::isTimerRunning(TimerID id)
+bool Being::isTimerRunning(TimerID id) const
{
- return (getTimer(id) > 0);
+ return getTimer(id) > 0;
}
-bool Being::isTimerJustFinished(TimerID id)
+bool Being::isTimerJustFinished(TimerID id) const
{
- return (getTimer(id) == 0);
+ return getTimer(id) == 0;
}
-
diff --git a/src/game-server/being.hpp b/src/game-server/being.hpp
index 5335d37a..d0ca4be3 100644
--- a/src/game-server/being.hpp
+++ b/src/game-server/being.hpp
@@ -54,8 +54,6 @@ enum TimerID
T_B_HP_REGEN // time until hp is regenerated again
};
-typedef std::map <TimerID, int> Timers;
-
/**
* Methods of damage calculation
*/
@@ -127,7 +125,6 @@ typedef std::vector<unsigned int> Hits;
class Being : public Actor
{
public:
-
/**
* Moves enum for beings and actors for others players vision.
* WARNING: Has to be in sync with the same enum in the Being class
@@ -339,7 +336,7 @@ class Being : public Actor
/**
* Get Target
*/
- Being* getTarget() const
+ Being *getTarget() const
{ return mTarget; }
/**
@@ -357,15 +354,24 @@ class Being : public Actor
Being *mTarget;
Point mOld; /**< Old coordinates. */
Point mDst; /**< Target coordinates. */
+
+ /** Sets timer unless already higher. */
+ void setTimerSoft(TimerID id, int value);
+
/**
- * Timer stuff
- */
- void setTimerSoft(TimerID id, int value); /**< sets timer unless already higher */
- void setTimerHard(TimerID id, int value); /**< sets timer even when already higher (when in doubt this one is faster)*/
- int getTimer(TimerID id); /**< returns number of ticks left on the timer */
- bool isTimerRunning(TimerID id); /**< true when timer exists and is > 0 */
- bool isTimerJustFinished(TimerID id); /**< true during the tick where the timer reaches 0 */
+ * Sets timer even when already higher (when in doubt this one is
+ * faster)
+ */
+ void setTimerHard(TimerID id, int value);
+
+ /** Returns number of ticks left on the timer */
+ int getTimer(TimerID id) const;
+
+ /** Returns whether timer exists and is > 0 */
+ bool isTimerRunning(TimerID id) const;
+ /** Returns whether the timer reached 0 in this tick */
+ bool isTimerJustFinished(TimerID id) const;
private:
Being(const Being &rhs);
@@ -379,6 +385,7 @@ class Being : public Actor
Hits mHitsTaken; /**< List of punches taken since last update. */
AttributeModifiers mModifiers; /**< Currently modified attributes. */
+ typedef std::map<TimerID, int> Timers;
Timers mTimers;
};