From 1554a6749f2dbcd9b44aae1df3e320a06b049d4f Mon Sep 17 00:00:00 2001 From: Guillaume Melquiond Date: Sun, 27 Aug 2006 16:23:36 +0000 Subject: Cleaned the logic members. --- ChangeLog | 3 +++ src/being.cpp | 6 ++++++ src/localplayer.cpp | 18 +++--------------- src/monster.cpp | 14 -------------- src/monster.h | 2 -- src/player.cpp | 20 -------------------- src/player.h | 3 --- 7 files changed, 12 insertions(+), 54 deletions(-) diff --git a/ChangeLog b/ChangeLog index b5364be0..2d7cbdd9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -28,6 +28,9 @@ * src/localplayer.cpp, src/beingmanager.cpp, src/player.cpp, src/monster.cpp, src/net/playerhandler.cpp, src/being.h: Removed Being::mFrame field. + * src/localplayer.cpp, src/player.cpp, src/monster.h, src/being.cpp, + src/monster.cpp, src/player.h: Cleaned the logic members. + 2006-08-26 Bjørn Lindeijer diff --git a/src/being.cpp b/src/being.cpp index b49f790e..46fb67bb 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -285,6 +285,12 @@ Being::nextStep() void Being::logic() { + // Determine whether the being should take another step + if (mAction == WALK && get_elapsed_time(mWalkTime) >= mWalkSpeed) + { + nextStep(); + } + // Determine whether speech should still be displayed if (get_elapsed_time(mSpeechTime) > 5000) { diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 74924b1d..368bc8e3 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -52,21 +52,9 @@ LocalPlayer::~LocalPlayer() void LocalPlayer::logic() { - switch (mAction) { - case WALK: - if (get_elapsed_time(mWalkTime) >= mWalkSpeed) - { - nextStep(); - } - break; - - case ATTACK: - if (get_elapsed_time(mWalkTime) >= mAttackSpeed) - { - nextStep(); - attack(); - } - break; + if (mAction == ATTACK && get_elapsed_time(mWalkTime) >= mAttackSpeed) + { + attack(); } // Actions are allowed once per second diff --git a/src/monster.cpp b/src/monster.cpp index 26345a6c..aba242b6 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -35,20 +35,6 @@ Monster::Monster(Uint32 id, Uint16 job, Map *map): mSprites[BASE_SPRITE] = new AnimatedSprite("graphics/sprites/monster" + toString(job - 1002) + ".xml", 0); } -void -Monster::logic() -{ - if (mAction != STAND) - { - if (get_elapsed_time(mWalkTime) >= mWalkSpeed && mAction != MONSTER_DEAD) - { - nextStep(); - } - } - - Being::logic(); -} - Being::Type Monster::getType() const { diff --git a/src/monster.h b/src/monster.h index 4a82a461..6ce0d69d 100644 --- a/src/monster.h +++ b/src/monster.h @@ -31,8 +31,6 @@ class Monster : public Being public: Monster(Uint32 id, Uint16 job, Map *map); - virtual void logic(); - virtual Type getType() const; }; diff --git a/src/player.cpp b/src/player.cpp index 52f2cdb0..b635397e 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -42,26 +42,6 @@ Player::Player(Uint32 id, Uint16 job, Map *map): new AnimatedSprite("graphics/sprites/weapons.xml", 0); } -void -Player::logic() -{ - switch (mAction) { - case WALK: - if (get_elapsed_time(mWalkTime) >= mWalkSpeed) - { - nextStep(); - } - break; - case ATTACK: - if (get_elapsed_time(mWalkTime) >= mAttackSpeed) - { - nextStep(); - } - break; - } - Being::logic(); -} - Being::Type Player::getType() const { diff --git a/src/player.h b/src/player.h index 5ff0509f..d0d55cc8 100644 --- a/src/player.h +++ b/src/player.h @@ -40,9 +40,6 @@ class Player : public Being */ Player(Uint32 id, Uint16 job, Map *map); - virtual void - logic(); - virtual Type getType() const; -- cgit v1.2.3-70-g09d2