summaryrefslogtreecommitdiff
path: root/src/game-server/being.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2008-10-29 21:31:39 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2008-10-29 21:31:39 +0000
commit8ddad761280216252953bee9467e2787aaee484e (patch)
treef13f79281964fd8f1bcdf49e52aa657995693565 /src/game-server/being.cpp
parentdf8c5ed43b5513916eff1b3f25e0bba6a50c8826 (diff)
downloadmanaserv-8ddad761280216252953bee9467e2787aaee484e.tar.gz
manaserv-8ddad761280216252953bee9467e2787aaee484e.tar.bz2
manaserv-8ddad761280216252953bee9467e2787aaee484e.tar.xz
manaserv-8ddad761280216252953bee9467e2787aaee484e.zip
Some code formatting cleanup and unduplicated conversion from direction to
angle.
Diffstat (limited to 'src/game-server/being.cpp')
-rw-r--r--src/game-server/being.cpp44
1 files changed, 14 insertions, 30 deletions
diff --git a/src/game-server/being.cpp b/src/game-server/being.cpp
index c9bec84c..2c549c9f 100644
--- a/src/game-server/being.cpp
+++ b/src/game-server/being.cpp
@@ -117,41 +117,26 @@ void Being::move()
MovingObject::move();
if (mAction == WALK || mAction == STAND)
{
- if (mActionTime)
- {
- mAction = WALK;
- }
- else
- {
- mAction = STAND;
- }
+ mAction = (mActionTime) ? WALK : STAND;
}
}
-void Being::performAttack(Damage const &damage, AttackZone const *attackZone)
+int Being::directionToAngle(int direction)
{
- Point ppos = getPosition();
- int dir = getDirection();
-
- int attackAngle = 0;
-
- switch (dir)
+ switch (direction)
{
- case DIRECTION_UP:
- attackAngle = 90;
- break;
- case DIRECTION_DOWN:
- attackAngle = 270;
- break;
+ case DIRECTION_UP: return 90;
+ case DIRECTION_DOWN: return 270;
+ case DIRECTION_RIGHT: return 180;
case DIRECTION_LEFT:
- attackAngle = 0;
- break;
- case DIRECTION_RIGHT:
- attackAngle = 180;
- break;
- default:
- break;
+ default: return 0;
}
+}
+
+void Being::performAttack(Damage const &damage, AttackZone const *attackZone)
+{
+ Point ppos = getPosition();
+ const int attackAngle = directionToAngle(getDirection());
std::list<Being *> victims;
@@ -160,7 +145,7 @@ void Being::performAttack(Damage const &damage, AttackZone const *attackZone)
{
MovingObject *o = *i;
Point opos = o->getPosition();
-
+
if (o == this) continue;
int type = o->getType();
@@ -168,7 +153,6 @@ void Being::performAttack(Damage const &damage, AttackZone const *attackZone)
if (type != OBJECT_CHARACTER && type != OBJECT_MONSTER) continue;
-
switch (attackZone->shape)
{
case ATTZONESHAPE_CONE: