diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-01-05 17:54:12 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-01-05 17:54:12 +0000 |
commit | f96ca90ba90da3175be96ff7ed34efb78ea5dfed (patch) | |
tree | adad6b54eb2654750934213d5c456fb3179dcbff /src | |
parent | 9a55df8602e624051e4f3a527c053d655f78c501 (diff) | |
download | manaserv-f96ca90ba90da3175be96ff7ed34efb78ea5dfed.tar.gz manaserv-f96ca90ba90da3175be96ff7ed34efb78ea5dfed.tar.bz2 manaserv-f96ca90ba90da3175be96ff7ed34efb78ea5dfed.tar.xz manaserv-f96ca90ba90da3175be96ff7ed34efb78ea5dfed.zip |
Generalized player state.
Diffstat (limited to 'src')
-rw-r--r-- | src/game-server/gamehandler.cpp | 2 | ||||
-rw-r--r-- | src/game-server/player.cpp | 4 | ||||
-rw-r--r-- | src/game-server/player.hpp | 29 |
3 files changed, 27 insertions, 8 deletions
diff --git a/src/game-server/gamehandler.cpp b/src/game-server/gamehandler.cpp index b171a9b9..ae18e893 100644 --- a/src/game-server/gamehandler.cpp +++ b/src/game-server/gamehandler.cpp @@ -300,7 +300,7 @@ void GameHandler::processMessage(NetComputer *comp, MessageIn &message) LOG_DEBUG("Player " << computer.character->getPublicID() << " attacks", 0); computer.character->setDirection(message.readByte()); - computer.character->setAttacking(true); + computer.character->setAction(PLAYER_ATTACK); } break; default: diff --git a/src/game-server/player.cpp b/src/game-server/player.cpp index 2160cbb6..f687cba6 100644 --- a/src/game-server/player.cpp +++ b/src/game-server/player.cpp @@ -39,14 +39,14 @@ void Player::update() setStat(STAT_SPEED, getRawStat(STAT_DEXTERITY)); // attacking - if (mIsAttacking) + if (mAction == PLAYER_ATTACK) { // plausibility check of attack command if (mActionTime <= 0) { // request perform attack mActionTime = 1000; - mIsAttacking = false; + mAction = PLAYER_STAND; raiseUpdateFlags(ATTACK); } } diff --git a/src/game-server/player.hpp b/src/game-server/player.hpp index 5a0336a8..426738d7 100644 --- a/src/game-server/player.hpp +++ b/src/game-server/player.hpp @@ -31,6 +31,19 @@ class GameClient; +/** + * Actions for a player being. + */ +enum +{ + PLAYER_STAND = 0, + PLAYER_SIT, + PLAYER_ATTACK +}; + +/** + * Stores the data of a remote client. + */ class Player : public Being, public PlayerData { public: @@ -39,7 +52,7 @@ class Player : public Being, public PlayerData : Being(OBJECT_PLAYER, 65535), PlayerData(name, id), mClient(NULL), - mIsAttacking(false) + mAction(PLAYER_STAND) {} /** @@ -48,10 +61,16 @@ class Player : public Being, public PlayerData void update(); /** - * Set attacking state + * Sets next action. + **/ + void setAction(int s) + { mAction = s; } + + /** + * Gets next action. **/ - void setAttacking(bool isAttacking) - { mIsAttacking = isAttacking; } + int getAction() const + { return mAction; } /** * Gets client computer. @@ -70,7 +89,7 @@ class Player : public Being, public PlayerData Player &operator=(Player const &); GameClient *mClient; /**< Client computer. */ - bool mIsAttacking; /**< Attacking state. */ + unsigned char mAction; /**< Player state. */ }; #endif // _TMWSERV_PLAYER_H_ |