summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFreeyorp <Freeyorp101@hotmail.com>2010-09-19 13:27:44 +1200
committerFreeyorp <Freeyorp101@hotmail.com>2010-10-17 17:24:16 +1300
commit0e054272d44735aa7e15e749c95c0a5471033f73 (patch)
tree5a5ae521ffc15e0efea784a606f7c0021f0d78a4
parent181bd14f09baa1bf94a9ceae578e1fd3990a7439 (diff)
downloadmanaserv-0e054272d44735aa7e15e749c95c0a5471033f73.tar.gz
manaserv-0e054272d44735aa7e15e749c95c0a5471033f73.tar.bz2
manaserv-0e054272d44735aa7e15e749c95c0a5471033f73.tar.xz
manaserv-0e054272d44735aa7e15e749c95c0a5471033f73.zip
Get rid of some unneeded direct calls to setBase for attributes.
setAttribute should be used for this, which also calls updateDerivedAttributes as needed. Reviewed-by: Bertram
-rw-r--r--src/game-server/being.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/game-server/being.cpp b/src/game-server/being.cpp
index 4f552cab..39eaeb27 100644
--- a/src/game-server/being.cpp
+++ b/src/game-server/being.cpp
@@ -122,8 +122,7 @@ int Being::damage(Actor *source, const Damage &damage)
<< " damage. HP: "
<< HP.getModifiedAttribute() << "/"
<< mAttributes.at(ATTR_MAX_HP).getModifiedAttribute());
- HP.setBase(HP.getBase() - HPloss);
- updateDerivedAttributes(ATTR_HP);
+ setAttribute(ATTR_HP, HP.getBase() - HPloss);
// No HP regen after being hit if this is set.
setTimerSoft(T_B_HP_REGEN,
Configuration::getValue("game_hpRegenBreakAfterHit", 0));
@@ -145,8 +144,7 @@ void Being::heal()
// Reset all modifications present in hp.
hp.clearMods();
- hp.setBase(maxHp.getModifiedAttribute());
- updateDerivedAttributes(ATTR_HP);
+ setAttribute(ATTR_HP, maxHp.getModifiedAttribute());
}
void Being::heal(int gain)
@@ -157,10 +155,9 @@ void Being::heal(int gain)
return; // Full hp, do nothing.
// Cannot go over maximum hitpoints.
- hp.setBase(hp.getBase() + gain);
+ setAttribute(ATTR_HP, hp.getBase() + gain);
if (hp.getModifiedAttribute() > maxHp.getModifiedAttribute())
- hp.setBase(maxHp.getModifiedAttribute());
- updateDerivedAttributes(ATTR_HP);
+ setAttribute(ATTR_HP, maxHp.getModifiedAttribute());
}
void Being::died()
@@ -470,7 +467,7 @@ void Being::update()
// Only update HP when it actually changed to avoid network noise
if (newHP != oldHP)
{
- mAttributes.at(ATTR_HP).setBase(newHP);
+ setAttribute(ATTR_HP, newHP);
raiseUpdateFlags(UPDATEFLAG_HEALTHCHANGE);
}