summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2005-07-28 15:14:22 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2005-07-28 15:14:22 +0000
commitd51efb148feef39b5ae38924371e636118f6b361 (patch)
treeb79b1523ba9b2816d71eeb2f7c099f07f0e0b4fb
parent51b75feaefd132ee0b7992a10dbe79bfa92e6d91 (diff)
downloadmana-d51efb148feef39b5ae38924371e636118f6b361.tar.gz
mana-d51efb148feef39b5ae38924371e636118f6b361.tar.bz2
mana-d51efb148feef39b5ae38924371e636118f6b361.tar.xz
mana-d51efb148feef39b5ae38924371e636118f6b361.zip
Added an action enumeration to th Being class and removed the old #define's.
-rw-r--r--ChangeLog3
-rw-r--r--src/being.cpp4
-rw-r--r--src/being.h11
-rw-r--r--src/engine.cpp20
-rw-r--r--src/game.cpp71
-rw-r--r--src/game.h11
-rw-r--r--src/gui/gui.cpp2
7 files changed, 57 insertions, 65 deletions
diff --git a/ChangeLog b/ChangeLog
index b38b5a46..2d983fb3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,9 @@
src/gui/popupmenu.h: Cleaned up the showPopup() code, moved "map"-related
code into game.cpp, made the popup show up at mouse coordinates instead of
being aligned to tiles.
+ * src/being.cpp, src/being.h, src/engine.cpp, src/game.cpp, src/game.h,
+ src/gui/gui.cpp, src/net/protocol.cpp: Added an action enumeration to the
+ Being class and removed the old #define's.
2005-07-27 Bjørn Lindeijer <bjorn@lindeijer.nl>
diff --git a/src/being.cpp b/src/being.cpp
index 315dbd7e..4d4482b6 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -103,7 +103,7 @@ Being *findNode(unsigned short x, unsigned short y)
for (i = beings.begin(); i != beings.end(); i++) {
Being *being = (*i);
// Return being if found and it is not a dead monster
- if (being->x == x && being->y == y && being->action != MONSTER_DEAD) {
+ if (being->x == x && being->y == y && being->action != Being::MONSTER_DEAD) {
return being;
}
}
@@ -117,7 +117,7 @@ Being* findNode(unsigned short x, unsigned short y, Being::Type type)
Being *being = (*i);
// Check if is a NPC (only low job ids)
if (being->x == x && being->y == y &&
- being->getType() == type && being->action != MONSTER_DEAD)
+ being->getType() == type && being->action != Being::MONSTER_DEAD)
{
return being;
}
diff --git a/src/being.h b/src/being.h
index 3a68e0ac..beeac528 100644
--- a/src/being.h
+++ b/src/being.h
@@ -53,6 +53,17 @@ class Being
MONSTER
};
+ enum Action {
+ STAND = 0,
+ WALK = 1,
+ ATTACK = 5,
+ BOW_ATTACK = 9,
+ MONSTER_DEAD = 9,
+ SIT = 13,
+ HIT = 14,
+ DEAD = 15,
+ };
+
unsigned short job; /**< Job (player job, npc, monster, ) */
unsigned short x, y; /**< Tile coordinates */
unsigned char direction; /**< Facing direction */
diff --git a/src/engine.cpp b/src/engine.cpp
index 8be62168..c6a7a6c8 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -106,7 +106,7 @@ int get_x_offset(Being *being)
int offset = 0;
char direction = being->direction;
- if (being->action == WALK)
+ if (being->action == Being::WALK)
{
if (direction != NORTH && direction != SOUTH)
{
@@ -131,7 +131,7 @@ int get_y_offset(Being *being)
int offset = 0;
char direction = being->direction;
- if (being->action == WALK)
+ if (being->action == Being::WALK)
{
if (direction != EAST && direction != WEST)
{
@@ -312,7 +312,7 @@ void Engine::logic()
being->logic();
- if (being->action == MONSTER_DEAD && being->frame >= 20)
+ if (being->action == Being::MONSTER_DEAD && being->frame >= 20)
{
if (autoTarget == being) {
autoTarget = NULL;
@@ -399,13 +399,13 @@ void Engine::draw()
being->text_x = sx * 32 + get_x_offset(being) - offset_x;
being->text_y = sy * 32 + get_y_offset(being) - offset_y;
- if (being->action == SIT || being->action == DEAD) {
+ if (being->action == Being::SIT || being->action == Being::DEAD) {
being->frame = 0;
}
frame = being->frame + being->action;
- if (being->action == ATTACK) {
+ if (being->action == Being::ATTACK) {
if (being->getWeapon() > 0)
frame += 4 * (being->getWeapon() - 1);
}
@@ -417,7 +417,7 @@ void Engine::draw()
//{
// std::cout << being->name << " " << being->getWeapon() << std::endl;
//}
- if (being->getWeapon() != 0 && being->action == ATTACK) {
+ if (being->getWeapon() != 0 && being->action == Being::ATTACK) {
Image *image = weaponset->spriteset[
16 * (being->getWeapon() - 1) + 4 * being->frame + dir];
@@ -467,9 +467,9 @@ void Engine::draw()
frame = being->frame + being->action;
- if (being->action == MONSTER_DEAD) {
+ if (being->action == Being::MONSTER_DEAD) {
guiGraphics->drawImage(
- monsterset[being->job - 1002]->spriteset[dir + 4 * MONSTER_DEAD],
+ monsterset[being->job - 1002]->spriteset[dir + 4 * Being::MONSTER_DEAD],
being->text_x + 30, being->text_y + 40);
if (autoTarget == being) {
@@ -488,11 +488,11 @@ void Engine::draw()
}
}
- if (being->action != STAND) {
+ if (being->action != Being::STAND) {
being->frame =
(get_elapsed_time(being->walk_time) * 4) / (being->speed);
- if (being->frame >= 4 && being->action != MONSTER_DEAD) {
+ if (being->frame >= 4 && being->action != Being::MONSTER_DEAD) {
being->nextStep();
}
}
diff --git a/src/game.cpp b/src/game.cpp
index f5bd366c..ff1621d6 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -332,10 +332,10 @@ void do_input()
switch (player_node->action)
{
- case STAND:
+ case Being::STAND:
action(2, 0);
break;
- case SIT:
+ case Being::SIT:
action(3, 0);
break;
}
@@ -563,8 +563,8 @@ void do_input()
* TODO: Move player to mouse click position before
* attack the monster (maybe using follow mode).
*/
- if (target->action != MONSTER_DEAD &&
- player_node->action==STAND)
+ if (target->action != Being::MONSTER_DEAD &&
+ player_node->action == Being::STAND)
{
attack(target);
// Autotarget by default with mouse
@@ -662,7 +662,7 @@ void do_input()
} // End while
// Moving player around
- if ((player_node->action != DEAD) && (current_npc == 0) &&
+ if ((player_node->action != Being::DEAD) && (current_npc == 0) &&
!chatWindow->isFocused())
{
int x = player_node->x;
@@ -675,63 +675,63 @@ void do_input()
if (keys[SDLK_UP] || keys[SDLK_KP8] || joy[JOY_UP])
{
yDirection = -1;
- if (player_node->action != WALK)
+ if (player_node->action != Being::WALK)
Direction = NORTH;
}
if (keys[SDLK_DOWN] || keys[SDLK_KP2] || joy[JOY_DOWN])
{
yDirection = 1;
- if (player_node->action != WALK)
+ if (player_node->action != Being::WALK)
Direction = SOUTH;
}
if (keys[SDLK_LEFT] || keys[SDLK_KP4] || joy[JOY_LEFT])
{
xDirection = -1;
- if (player_node->action != WALK)
+ if (player_node->action != Being::WALK)
Direction = WEST;
}
if (keys[SDLK_RIGHT] || keys[SDLK_KP6] || joy[JOY_RIGHT])
{
xDirection = 1;
- if (player_node->action != WALK)
+ if (player_node->action != Being::WALK)
Direction = EAST;
}
if (keys[SDLK_KP1]) // Bottom Left
{
xDirection = -1;
yDirection = 1;
- if (player_node->action != WALK)
+ if (player_node->action != Being::WALK)
Direction = SW;
}
if (keys[SDLK_KP3]) // Bottom Right
{
xDirection = 1;
yDirection = 1;
- if (player_node->action != WALK)
+ if (player_node->action != Being::WALK)
Direction = SE;
}
if (keys[SDLK_KP7]) // Top Left
{
xDirection = -1;
yDirection = -1;
- if (player_node->action != WALK)
+ if (player_node->action != Being::WALK)
Direction = NW;
}
if (keys[SDLK_KP9]) // Top Right
{
xDirection = 1;
yDirection = -1;
- if (player_node->action != WALK)
+ if (player_node->action != Being::WALK)
Direction = NE;
}
Map *tiledMap = engine->getCurrentMap();
// Allow keyboard control to interrupt an existing path
- if ((xDirection != 0 || yDirection != 0) && player_node->action == WALK)
+ if ((xDirection != 0 || yDirection != 0) && player_node->action == Being::WALK)
player_node->setDestination(x, y);
- if (player_node->action != WALK)
+ if (player_node->action != Being::WALK)
{
// Prevent skipping corners over colliding tiles
if ((xDirection != 0) && tiledMap->tileCollides(x + xDirection, y))
@@ -760,7 +760,7 @@ void do_input()
}
// Attacking monsters
- if (player_node->action == STAND)
+ if (player_node->action == Being::STAND)
{
if (keys[SDLK_LCTRL] || keys[SDLK_RCTRL] || joy[JOY_BTN0])
{
@@ -789,9 +789,9 @@ void do_input()
}
}
else if (joy[JOY_BTN2] && action_time) {
- if (player_node->action == STAND)
+ if (player_node->action == Being::STAND)
action(2, 0);
- else if (player_node->action == SIT)
+ else if (player_node->action == Being::SIT)
action(3, 0);
action_time = false;
}
@@ -956,7 +956,7 @@ void do_parse()
//being->setWeapon(RFIFOW(18));
being->frame = 0;
being->walk_time = tick_time;
- being->action = STAND;
+ being->action = Being::STAND;
}
break;
@@ -970,13 +970,13 @@ void do_parse()
switch (being->getType())
{
case Being::MONSTER:
- being->action = MONSTER_DEAD;
+ being->action = Being::MONSTER_DEAD;
being->frame = 0;
being->walk_time = tick_time;
break;
default:
- being->action = DEAD;
+ being->action = Being::DEAD;
break;
}
//remove_node(RFIFOL(2));
@@ -1018,7 +1018,7 @@ void do_parse()
if (RFIFOB(51) == 2)
{
- being->action = SIT;
+ being->action = Being::SIT;
}
break;
@@ -1035,7 +1035,7 @@ void do_parse()
add_node(being);
}
- being->action = STAND;
+ being->action = Being::STAND;
being->x = get_src_x(RFIFOP(50));
being->y = get_src_y(RFIFOP(50));
being->speed = RFIFOW(6);
@@ -1267,7 +1267,7 @@ void do_parse()
// Re-add the local player node
add_node(player_node);
- player_node->action = STAND;
+ player_node->action = Being::STAND;
player_node->frame = 0;
player_node->x = RFIFOW(18);
player_node->y = RFIFOW(20);
@@ -1346,7 +1346,7 @@ void do_parse()
"You're now dead, press ok to restart",
&deathNoticeListener);
deathNotice->releaseModalFocus();
- player_node->action = DEAD;
+ player_node->action = Being::DEAD;
}
break;
// Stop walking
@@ -1382,20 +1382,9 @@ void do_parse()
if (RFIFOL(2) != player_node->getId()) { // buggy
being = findNode(RFIFOL(2));
if (being) {
- switch (being->getType())
- {
- case Being::PLAYER:
- being->action = ATTACK;
- being->frame = 0;
- being->walk_time = tick_time;
- break;
-
- default:
- being->action = MONSTER_ATTACK;
- being->frame = 0;
- being->walk_time = tick_time;
- break;
- }
+ being->action = Being::ATTACK;
+ being->frame = 0;
+ being->walk_time = tick_time;
being->frame = 0;
}
}
@@ -1407,10 +1396,10 @@ void do_parse()
if (being != NULL) {
being->frame = 0;
if (RFIFOB(26) == 2) {
- being->action = SIT;
+ being->action = Being::SIT;
}
else if (RFIFOB(26) == 3) {
- being->action = STAND;
+ being->action = Being::STAND;
}
}
break;
diff --git a/src/game.h b/src/game.h
index 2ac2e386..70191296 100644
--- a/src/game.h
+++ b/src/game.h
@@ -27,17 +27,6 @@
#define SPEECH_TIME 80
#define SPEECH_MAX_TIME 100
-// Action defines
-#define STAND 0
-#define WALK 1
-#define ATTACK 5
-#define BOW_ATTACK 9
-#define SIT 13
-#define HIT 14
-#define DEAD 15
-#define MONSTER_ATTACK 5
-#define MONSTER_DEAD 9
-
#define LOCK 254
#define IDLE 255
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 737b880c..996eb5b1 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -248,7 +248,7 @@ void Gui::mousePress(int mx, int my, int button)
// Mouse pressed on window container (basically, the map)
// When conditions for walking are met, set new player destination
- if (player_node && player_node->action != DEAD && current_npc == 0 &&
+ if (player_node && player_node->action != Being::DEAD && current_npc == 0 &&
button == gcn::MouseInput::LEFT)
{
Map *tiledMap = engine->getCurrentMap();