diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-01-23 20:41:50 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-01-23 20:41:50 +0300 |
commit | bac1df3b9ac0e3327e8de812793d0a18cfd64cba (patch) | |
tree | 46cf157684952f5aeccd59875917abb222024df8 /src/net/tmwa/npchandler.cpp | |
parent | 7d60bf1c04fce4ed16144aece76e594e0e217960 (diff) | |
download | manaverse-bac1df3b9ac0e3327e8de812793d0a18cfd64cba.tar.gz manaverse-bac1df3b9ac0e3327e8de812793d0a18cfd64cba.tar.bz2 manaverse-bac1df3b9ac0e3327e8de812793d0a18cfd64cba.tar.xz manaverse-bac1df3b9ac0e3327e8de812793d0a18cfd64cba.zip |
Add moving camera commands from npc.
Diffstat (limited to 'src/net/tmwa/npchandler.cpp')
-rw-r--r-- | src/net/tmwa/npchandler.cpp | 52 |
1 files changed, 46 insertions, 6 deletions
diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp index 5e305070e..c395eb1b8 100644 --- a/src/net/tmwa/npchandler.cpp +++ b/src/net/tmwa/npchandler.cpp @@ -25,6 +25,7 @@ #include "localplayer.h" #include "gui/npcdialog.h" +#include "gui/viewport.h" #include "net/messagein.h" #include "net/net.h" @@ -97,7 +98,7 @@ void NpcHandler::handleMessage(Net::MessageIn &msg) break; case SMSG_NPC_COMMAND: - processNpcCommand(msg); + processNpcCommand(msg, npcId); break; default: @@ -239,13 +240,52 @@ int NpcHandler::getNpc(Net::MessageIn &msg, bool haveLength) return npcId; } -void NpcHandler::processNpcCommand(Net::MessageIn &msg) +void NpcHandler::processNpcCommand(Net::MessageIn &msg, int npcId) { const int cmd = msg.readInt16(); - if (cmd == 0) - mRequestLang = true; - else - logger->log("unknown npc command: %d", cmd); + switch (cmd) + { + case 0: + mRequestLang = true; + break; + + case 1: + if (viewport) + viewport->moveCameraToActor(npcId); + break; + + case 2: + if (viewport) + { + const int id = msg.readInt32(); + const int x = msg.readInt16(); + const int y = msg.readInt16(); + if (!id) + viewport->moveCameraToPosition(x, y); + else + viewport->moveCameraToActor(id, x, y); + } + break; + + case 3: + if (viewport) + viewport->returnCamera(); + break; + + case 4: + if (viewport) + { + msg.readInt32(); // id + const int x = msg.readInt16(); + const int y = msg.readInt16(); + viewport->moveCameraRelative(x, y); + } + break; + + default: + logger->log("unknown npc command: %d", cmd); + break; + } } void NpcHandler::processLangReuqest(Net::MessageIn &msg A_UNUSED, int npcId) |