summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2006-08-27 22:49:10 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2006-08-27 22:49:10 +0000
commitaf61e1e7df91b97c3f7516e9eb2b37b621f069ad (patch)
tree3123d2a6aed02c0c2938606bb99f087dd07836f1 /src
parent6f6d061b23c6c70c632fb3ec6aa3735325f701e0 (diff)
downloadmana-af61e1e7df91b97c3f7516e9eb2b37b621f069ad.tar.gz
mana-af61e1e7df91b97c3f7516e9eb2b37b621f069ad.tar.bz2
mana-af61e1e7df91b97c3f7516e9eb2b37b621f069ad.tar.xz
mana-af61e1e7df91b97c3f7516e9eb2b37b621f069ad.zip
Added support for entering monsters.
Diffstat (limited to 'src')
-rw-r--r--src/gui/gui.cpp6
-rw-r--r--src/net/beinghandler.cpp40
-rw-r--r--src/net/protocol.h14
3 files changed, 44 insertions, 16 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 5df26d63..69563dc1 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -254,7 +254,8 @@ Gui::mousePress(int mx, int my, int button)
Being *being;
FloorItem *floorItem;
- if ((being = beingManager->findBeing(tilex, tiley)) && being->getType() != Being::LOCALPLAYER)
+ if ((being = beingManager->findBeing(tilex, tiley)) &&
+ being->getType() != Being::LOCALPLAYER)
{
showPopup(mx, my, being);
return;
@@ -307,7 +308,8 @@ Gui::mousePress(int mx, int my, int button)
player_node->pickUp(item);
}
// Just walk around
- else if (engine->getCurrentMap()->getWalk(tilex, tiley))
+ else if (engine->getCurrentMap() &&
+ engine->getCurrentMap()->getWalk(tilex, tiley))
{
// XXX XXX XXX REALLY UGLY!
Uint8 *keys = SDL_GetKeyState(NULL);
diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp
index 59a4fa9a..e3eb6eba 100644
--- a/src/net/beinghandler.cpp
+++ b/src/net/beinghandler.cpp
@@ -397,24 +397,36 @@ void BeingHandler::handleMessage(MessageIn &msg)
void
BeingHandler::handleBeingEnterMessage(MessageIn &msg)
{
- msg.readByte(); // type
+ int type = msg.readByte(); // type
int id = msg.readLong();
- std::string name = msg.readString();
- Being *being;
- if (player_node->getName() == name)
+
+ switch (type) {
+ case OBJECT_PLAYER:
{
- being = player_node;
- being->setId(id);
- }
- else
+ std::string name = msg.readString();
+ Being *being;
+ if (player_node->getName() == name)
+ {
+ being = player_node;
+ being->setId(id);
+ }
+ else
+ {
+ being = beingManager->createBeing(id, 0);
+ being->setName(name);
+ }
+ being->setHairStyle(msg.readByte());
+ being->setHairColor(msg.readByte());
+ being->setSex(msg.readByte());
+ } break;
+ case OBJECT_MONSTER:
{
- // assume type is player for now, so job 0, TODO
- being = beingManager->createBeing(id, 0);
- being->setName(name);
+ int monsterId = msg.readShort();
+ Being *being;
+ being = beingManager->createBeing(id, 1002 + monsterId);
+ being->setWalkSpeed(150); // TODO
+ } break;
}
- being->setHairStyle(msg.readByte());
- being->setHairColor(msg.readByte());
- being->setSex(msg.readByte());
}
void BeingHandler::handleBeingLeaveMessage(MessageIn &msg)
diff --git a/src/net/protocol.h b/src/net/protocol.h
index d99351f2..6feee9d4 100644
--- a/src/net/protocol.h
+++ b/src/net/protocol.h
@@ -223,4 +223,18 @@ enum {
CREATE_TOO_MUCH_CHARACTERS
};
+// Object type enumeration
+enum {
+ // A simple item
+ OBJECT_ITEM = 0,
+ // An item that can be activated (doors, switchs, sign, ...)
+ OBJECT_ACTOR,
+ // Non-Playable-Character is an actor capable of movement and maybe actions
+ OBJECT_NPC,
+ // A monster (moving actor with AI. able to toggle map/quest actions, too)
+ OBJECT_MONSTER,
+ // A player
+ OBJECT_PLAYER
+};
+
#endif