summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Athay <ko2fan@gmail.com>2008-10-15 15:44:55 +0000
committerDavid Athay <ko2fan@gmail.com>2008-10-15 15:44:55 +0000
commitce23c2eecd596c3e83cb2d813889bf2a79dae2d0 (patch)
treeb6fb19466a271e28ce41d695ea9a86293406f04e
parent5956dd7483ceda0d9e8464440d467fc7003c9182 (diff)
downloadmanaserv-ce23c2eecd596c3e83cb2d813889bf2a79dae2d0.tar.gz
manaserv-ce23c2eecd596c3e83cb2d813889bf2a79dae2d0.tar.bz2
manaserv-ce23c2eecd596c3e83cb2d813889bf2a79dae2d0.tar.xz
manaserv-ce23c2eecd596c3e83cb2d813889bf2a79dae2d0.zip
Added communicating change of direction to clients.
-rw-r--r--ChangeLog11
-rw-r--r--src/chat-server/chathandler.cpp26
-rw-r--r--src/defines.h2
-rw-r--r--src/game-server/gamehandler.cpp5
-rw-r--r--src/game-server/movingobject.hpp2
-rw-r--r--src/game-server/object.hpp3
-rw-r--r--src/game-server/state.cpp9
7 files changed, 48 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 017e04fe..144df951 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-10-15 David Athay <ko2fan@gmail.com>
+
+ * src/chat-server/chathandler.cpp, src/defines.h,
+ src/game-server/state.cpp, src/game-server/movingobject.hpp,
+ src/game-server/gamehandler.cpp, src/game-server/object.hpp: Added
+ communicating a change of direction to the clients.
+
2008-10-13 Andreas Habel <mail@exceptionfault.de>
* src/account-server/dalstorage.cpp: fixed bug 456: erroneous sql query
@@ -15,7 +22,7 @@
weapons from the item database and implemented single target attacks
useful for projectile weapons like bows.
-2008-08-19 David Athay <ko2fan@gmail.com>
+2008-09-19 David Athay <ko2fan@gmail.com>
* accountserver.cbp, src/account-server/main-account.cpp,
src/account-server/serverhandler.cpp, src/chat-server/post.cpp,
@@ -2945,4 +2952,4 @@
src/dal/sqlitedataprovider.cpp, src/dal/mysqldataprovider.cpp,
src/dal/pqdataprovider.cpp, src/main.cpp, src/client.cpp:
Grammar corrections, and a little bit of work on getting the name of
- the Db. \ No newline at end of file
+ the Db.
diff --git a/src/chat-server/chathandler.cpp b/src/chat-server/chathandler.cpp
index f6f12a12..2cffbc2a 100644
--- a/src/chat-server/chathandler.cpp
+++ b/src/chat-server/chathandler.cpp
@@ -87,17 +87,31 @@ void ChatHandler::deletePendingConnect(Pending *p)
void ChatHandler::tokenMatched(ChatClient *client, Pending *p)
{
+ MessageOut msg(CPMSG_CONNECT_RESPONSE);
+
client->characterName = p->character;
client->accountLevel = p->level;
+
Character *c = storage->getCharacter(p->character);
- client->characterId = c->getDatabaseID();
- delete p;
- MessageOut msg(CPMSG_CONNECT_RESPONSE);
- msg.writeByte(ERRMSG_OK);
+
+ if (!c)
+ {
+ // character wasnt found
+ msg.writeByte(ERRMSG_FAILURE);
+ }
+ else
+ {
+ client->characterId = c->getDatabaseID();
+ delete p;
+
+ msg.writeByte(ERRMSG_OK);
+
+ // Add chat client to player map
+ mPlayerMap.insert(std::pair<std::string, ChatClient*>(client->characterName, client));
+ }
+
client->send(msg);
- // Add chat client to player map
- mPlayerMap.insert(std::pair<std::string, ChatClient*>(client->characterName, client));
}
NetComputer *ChatHandler::computerConnected(ENetPeer *peer)
diff --git a/src/defines.h b/src/defines.h
index 0e7574a9..9d5d99dc 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -158,6 +158,8 @@ enum {
PGMSG_WALK = 0x0260, // W*2 destination
PGMSG_ACTION_CHANGE = 0x0270, // B Action
GPMSG_BEING_ACTION_CHANGE = 0x0271, // W being id, B action
+ PGMSG_DIRECTION_CHANGE = 0x0272, // B Direction
+ GPMSG_BEING_DIR_CHANGE = 0x0273, // W being id, B direction
GPMSG_BEINGS_MOVE = 0x0280, // { W being id, B flags [, C position, B speed] [, W*2 destination] }*
GPMSG_ITEMS = 0x0281, // { W item id, W*2 position }*
PGMSG_ATTACK = 0x0290, // B direction
diff --git a/src/game-server/gamehandler.cpp b/src/game-server/gamehandler.cpp
index 3540ac51..d4068664 100644
--- a/src/game-server/gamehandler.cpp
+++ b/src/game-server/gamehandler.cpp
@@ -343,6 +343,11 @@ void GameHandler::processMessage(NetComputer *comp, MessageIn &message)
} break;
+ case PGMSG_DIRECTION_CHANGE:
+ {
+ computer.character->setDirection(message.readByte());
+ } break;
+
case PGMSG_DISCONNECT:
{
bool reconnectAccount = (bool) message.readByte();
diff --git a/src/game-server/movingobject.hpp b/src/game-server/movingobject.hpp
index a81212bb..025a91d5 100644
--- a/src/game-server/movingobject.hpp
+++ b/src/game-server/movingobject.hpp
@@ -80,7 +80,7 @@ class MovingObject : public Object
* Sets object direction.
*/
void setDirection(int direction)
- { mDirection = direction; }
+ { mDirection = direction; raiseUpdateFlags(UPDATEFLAG_DIRCHANGE); }
/**
* Gets object direction.
diff --git a/src/game-server/object.hpp b/src/game-server/object.hpp
index 92980d02..d94e28c6 100644
--- a/src/game-server/object.hpp
+++ b/src/game-server/object.hpp
@@ -36,7 +36,8 @@ enum
UPDATEFLAG_NEW_DESTINATION = 2,
UPDATEFLAG_ATTACK = 4,
UPDATEFLAG_ACTIONCHANGE = 8,
- UPDATEFLAG_LOOKSCHANGE = 16
+ UPDATEFLAG_LOOKSCHANGE = 16,
+ UPDATEFLAG_DIRCHANGE = 32
};
/**
diff --git a/src/game-server/state.cpp b/src/game-server/state.cpp
index a129e889..8beb0891 100644
--- a/src/game-server/state.cpp
+++ b/src/game-server/state.cpp
@@ -216,6 +216,15 @@ static void informPlayer(MapComposite *map, Character *p)
gameHandler->sendTo(p, LooksMsg);
}
+ // Send direction change messages.
+ if (oflags & UPDATEFLAG_DIRCHANGE)
+ {
+ MessageOut DirMsg(GPMSG_BEING_DIR_CHANGE);
+ DirMsg.writeShort(oid);
+ DirMsg.writeByte(o->getDirection());
+ gameHandler->sendTo(p, DirMsg);
+ }
+
// Send damage messages.
if (o->canFight())
{