diff options
author | Aaron Marks <nymacro@gmail.com> | 2005-08-08 10:12:45 +0000 |
---|---|---|
committer | Aaron Marks <nymacro@gmail.com> | 2005-08-08 10:12:45 +0000 |
commit | e4936a090b3b8f4611d10eb86e11856cbd27cf0a (patch) | |
tree | d3c8aa4d0c9ef8772cc5a5e60f970597f11f6d20 /src/gamehandler.cpp | |
parent | ca4fec29828b55ea66c5835ab20d2287bb1eb4ff (diff) | |
download | manaserv-e4936a090b3b8f4611d10eb86e11856cbd27cf0a.tar.gz manaserv-e4936a090b3b8f4611d10eb86e11856cbd27cf0a.tar.bz2 manaserv-e4936a090b3b8f4611d10eb86e11856cbd27cf0a.tar.xz manaserv-e4936a090b3b8f4611d10eb86e11856cbd27cf0a.zip |
Just some changes I forgot to commit -- I probably wont be able to work on tmwserv for a few days :(
Diffstat (limited to 'src/gamehandler.cpp')
-rw-r--r-- | src/gamehandler.cpp | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/src/gamehandler.cpp b/src/gamehandler.cpp index 568c7866..cfeda536 100644 --- a/src/gamehandler.cpp +++ b/src/gamehandler.cpp @@ -50,15 +50,31 @@ void GameHandler::receiveMessage(NetComputer &computer, MessageIn &message) case CMSG_USE_OBJECT: { unsigned int itemId = message.readLong(); + + // use item + // this should execute a script which will do the appropriate action + + // respond result.writeShort(SMSG_USE_RESPONSE); result.writeByte(USE_OK); } break; case CMSG_TARGET: - break; + { + + } break; case CMSG_WALK: - break; + { + int x = message.readLong(); + int y = message.readLong(); + + // simplistic "teleport" walk + computer.getCharacter()->setX(x); + computer.getCharacter()->setY(y); + + // no response should be required + } break; case CMSG_START_TRADE: break; @@ -73,7 +89,14 @@ void GameHandler::receiveMessage(NetComputer &computer, MessageIn &message) break; case CMSG_EQUIP: - break; + { + int itemId = message.readLong(); + char slot = message.readByte(); + + result.writeShort(SMSG_EQUIP_RESPONSE); + result.writeByte(computer.getCharacter()->equip(itemId, slot) ? + EQUIP_OK : EQUIP_FAIL); + } break; default: std::cerr << "Warning: GameHandler received message of unkown type" @@ -81,5 +104,6 @@ void GameHandler::receiveMessage(NetComputer &computer, MessageIn &message) break; } - computer.send(result.getPacket()); + if (result.getPacket()->length > 0) + computer.send(result.getPacket()); } |