summaryrefslogtreecommitdiff
path: root/src/net/tmwa
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-02-05 15:00:58 +0300
committerAndrei Karas <akaras@inbox.ru>2012-02-05 15:00:58 +0300
commit9a3a196dbf633a699c26d0227802a42f025c8bfd (patch)
treedfbdb2ff1e2c54d75a2bf6411d3f70df22518c28 /src/net/tmwa
parentfc17ff22d9df50df9c5d1cf3dc0de358001271ed (diff)
parentece36a40d4e9a838cde01075d7681b8fc517b19f (diff)
downloadplus-9a3a196dbf633a699c26d0227802a42f025c8bfd.tar.gz
plus-9a3a196dbf633a699c26d0227802a42f025c8bfd.tar.bz2
plus-9a3a196dbf633a699c26d0227802a42f025c8bfd.tar.xz
plus-9a3a196dbf633a699c26d0227802a42f025c8bfd.zip
Merge branch 'master' into stripped
Conflicts: src/guichan/gui.cpp src/guichan/include/guichan/sdl/sdlpixel.hpp
Diffstat (limited to 'src/net/tmwa')
-rw-r--r--src/net/tmwa/beinghandler.cpp2
-rw-r--r--src/net/tmwa/charserverhandler.cpp7
-rw-r--r--src/net/tmwa/inventoryhandler.cpp4
-rw-r--r--src/net/tmwa/inventoryhandler.h2
-rw-r--r--src/net/tmwa/network.cpp2
-rw-r--r--src/net/tmwa/network.h2
-rw-r--r--src/net/tmwa/npchandler.cpp83
-rw-r--r--src/net/tmwa/npchandler.h7
-rw-r--r--src/net/tmwa/playerhandler.cpp50
-rw-r--r--src/net/tmwa/playerhandler.h1
-rw-r--r--src/net/tmwa/protocol.h2
-rw-r--r--src/net/tmwa/specialhandler.cpp6
-rw-r--r--src/net/tmwa/specialhandler.h6
13 files changed, 151 insertions, 23 deletions
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp
index 627db1402..8d279fc32 100644
--- a/src/net/tmwa/beinghandler.cpp
+++ b/src/net/tmwa/beinghandler.cpp
@@ -590,7 +590,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType)
if (gmstatus & 0x80)
dstBeing->setGM(true);
- if (msgType == 1)
+ if (msgType == 1 || msgType == 2)
{
int type = msg.readInt8();
switch (type)
diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp
index 717df1284..1bee91144 100644
--- a/src/net/tmwa/charserverhandler.cpp
+++ b/src/net/tmwa/charserverhandler.cpp
@@ -364,8 +364,11 @@ void CharServerHandler::processCharLogin(Net::MessageIn &msg)
Net::Character *character = new Net::Character;
readPlayerData(msg, character, version);
mCharacters.push_back(character);
- logger->log("CharServer: Player: %s (%d)",
- character->dummy->getName().c_str(), character->slot);
+ if (character && character->dummy)
+ {
+ logger->log("CharServer: Player: %s (%d)",
+ character->dummy->getName().c_str(), character->slot);
+ }
}
Client::setState(STATE_CHAR_SELECT);
diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp
index 7fa26f5ed..db670a17b 100644
--- a/src/net/tmwa/inventoryhandler.cpp
+++ b/src/net/tmwa/inventoryhandler.cpp
@@ -186,8 +186,8 @@ void InventoryHandler::closeStorage(int type A_UNUSED)
MessageOut outMsg(CMSG_CLOSE_STORAGE);
}
-void InventoryHandler::moveItem(int source, int slot, int amount,
- int destination)
+void InventoryHandler::moveItem2(int source, int slot, int amount,
+ int destination)
{
if (source == Inventory::INVENTORY && destination == Inventory::STORAGE)
{
diff --git a/src/net/tmwa/inventoryhandler.h b/src/net/tmwa/inventoryhandler.h
index d2ecc4b6d..c6e000b3a 100644
--- a/src/net/tmwa/inventoryhandler.h
+++ b/src/net/tmwa/inventoryhandler.h
@@ -53,7 +53,7 @@ class InventoryHandler : public MessageHandler, public Ea::InventoryHandler
void closeStorage(int type);
- void moveItem(int source, int slot, int amount, int destination);
+ void moveItem2(int source, int slot, int amount, int destination);
};
} // namespace TmwAthena
diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp
index addc737ee..31329eafb 100644
--- a/src/net/tmwa/network.cpp
+++ b/src/net/tmwa/network.cpp
@@ -83,7 +83,7 @@ short packet_lengths[] =
-1, -1, 20, 10, 32, 9, 34, 14, 2, 6, 48, 56, -1, 4, 5, 10,
// #0x0200
26, 0, 0, 0, 18, 0, 0, 0, 0, 0, 0, 19, 10, 0, 0, 0,
- 2, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 2, -1, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-1, 122, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
diff --git a/src/net/tmwa/network.h b/src/net/tmwa/network.h
index 17a4f7370..c0ec6ef3c 100644
--- a/src/net/tmwa/network.h
+++ b/src/net/tmwa/network.h
@@ -39,7 +39,7 @@
* Protocol version, reported to the eAthena char and mapserver who can adjust
* the protocol accordingly.
*/
-#define CLIENT_PROTOCOL_VERSION 4
+#define CLIENT_PROTOCOL_VERSION 5
#define CLIENT_TMW_PROTOCOL_VERSION 1
namespace TmwAthena
diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp
index 574f34d55..d86c64a96 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"
@@ -41,7 +42,8 @@ extern Net::NpcHandler *npcHandler;
namespace TmwAthena
{
-NpcHandler::NpcHandler()
+NpcHandler::NpcHandler() :
+ mRequestLang(false)
{
static const Uint16 _messages[] =
{
@@ -51,6 +53,7 @@ NpcHandler::NpcHandler()
SMSG_NPC_CLOSE,
SMSG_NPC_INT_INPUT,
SMSG_NPC_STR_INPUT,
+ SMSG_NPC_COMMAND,
0
};
handledMessages = _messages;
@@ -59,9 +62,12 @@ NpcHandler::NpcHandler()
void NpcHandler::handleMessage(Net::MessageIn &msg)
{
- getNpc(msg, msg.getId() == SMSG_NPC_CHOICE
+ int npcId = getNpc(msg, msg.getId() == SMSG_NPC_CHOICE
|| msg.getId() == SMSG_NPC_MESSAGE);
+ if (msg.getId() != SMSG_NPC_STR_INPUT)
+ mRequestLang = false;
+
switch (msg.getId())
{
case SMSG_NPC_CHOICE:
@@ -85,7 +91,14 @@ void NpcHandler::handleMessage(Net::MessageIn &msg)
break;
case SMSG_NPC_STR_INPUT:
- processNpcStrInput(msg);
+ if (mRequestLang)
+ processLangReuqest(msg, npcId);
+ else
+ processNpcStrInput(msg);
+ break;
+
+ case SMSG_NPC_COMMAND:
+ processNpcCommand(msg, npcId);
break;
default:
@@ -118,6 +131,8 @@ void NpcHandler::closeDialog(int npcId)
{
if ((*it).second.dialog)
(*it).second.dialog->close();
+ if ((*it).second.dialog == mDialog)
+ mDialog = nullptr;
mNpcDialogs.erase(it);
}
}
@@ -213,6 +228,7 @@ int NpcHandler::getNpc(Net::MessageIn &msg, bool haveLength)
else
{
mDialog = new NpcDialog(npcId);
+ mDialog->saveCamera();
if (player_node)
player_node->stopWalking(false);
Wrapper wrap;
@@ -222,9 +238,70 @@ int NpcHandler::getNpc(Net::MessageIn &msg, bool haveLength)
}
else
{
+ if (mDialog && mDialog != diag->second.dialog)
+ mDialog->restoreCamera();
mDialog = diag->second.dialog;
+ if (mDialog)
+ mDialog->saveCamera();
}
return npcId;
}
+void NpcHandler::processNpcCommand(Net::MessageIn &msg, int npcId)
+{
+ const int cmd = msg.readInt16();
+ 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;
+ case 5:
+ closeDialog(npcId);
+ break;
+
+ default:
+ logger->log("unknown npc command: %d", cmd);
+ break;
+ }
+}
+
+void NpcHandler::processLangReuqest(Net::MessageIn &msg A_UNUSED, int npcId)
+{
+ mRequestLang = false;
+ stringInput(npcId, getLangSimple());
+}
+
} // namespace TmwAthena
diff --git a/src/net/tmwa/npchandler.h b/src/net/tmwa/npchandler.h
index 967829ddc..1cfcacb20 100644
--- a/src/net/tmwa/npchandler.h
+++ b/src/net/tmwa/npchandler.h
@@ -65,6 +65,13 @@ class NpcHandler : public MessageHandler, public Ea::NpcHandler
void sellItem(int beingId, int itemId, int amount);
int getNpc(Net::MessageIn &msg, bool haveLength);
+
+ void processNpcCommand(Net::MessageIn &msg, int npcId);
+
+ void processLangReuqest(Net::MessageIn &msg, int npcId);
+
+ private:
+ bool mRequestLang;
};
} // namespace TmwAthena
diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp
index d5f0641eb..16e833ec9 100644
--- a/src/net/tmwa/playerhandler.cpp
+++ b/src/net/tmwa/playerhandler.cpp
@@ -22,6 +22,7 @@
#include "net/tmwa/playerhandler.h"
+#include "configuration.h"
#include "logger.h"
#include "net/messagein.h"
@@ -218,7 +219,7 @@ void PlayerHandler::processOnlineList(Net::MessageIn &msg)
return;
int size = msg.readInt16() - 4;
- std::vector<std::string> arr;
+ std::vector<OnlinePlayer*> arr;
if (!size)
{
@@ -227,14 +228,44 @@ void PlayerHandler::processOnlineList(Net::MessageIn &msg)
return;
}
- const char *start = msg.readBytes(size);
- const char *buf = start;
+ char *start = (char*)msg.readBytes(size);
+ if (!start)
+ return;
+
+ char *buf = start;
- while (buf - start + 1 < size && *(buf + 1))
+ int addVal = 1;
+ if (serverVersion >= 4)
+ addVal = 3;
+
+ while (buf - start + 1 < size && *(buf + addVal))
{
-// char status = *buf; // now unused
+ unsigned char status = 255;
+ unsigned char ver = 0;
+ unsigned char level = 0;
+ if (serverVersion >= 4)
+ {
+ status = *buf;
+ buf ++;
+ level = *buf;
+ buf ++;
+ ver = *buf;
+ }
buf ++;
- arr.push_back(buf);
+
+ int gender = GENDER_UNSPECIFIED;
+ if (serverVersion >= 4)
+ {
+ if (config.getBoolValue("showgender"))
+ {
+ if (status & Being::FLAG_GENDER)
+ gender = GENDER_MALE;
+ else
+ gender = GENDER_FEMALE;
+ }
+ }
+ arr.push_back(new OnlinePlayer((char*)buf,
+ status, level, gender, ver));
buf += strlen(buf) + 1;
}
@@ -243,4 +274,11 @@ void PlayerHandler::processOnlineList(Net::MessageIn &msg)
delete [] start;
}
+void PlayerHandler::updateStatus(Uint8 status)
+{
+ MessageOut outMsg(CMSG_SET_STATUS);
+ outMsg.writeInt8(status);
+ outMsg.writeInt8(0);
+}
+
} // namespace TmwAthena
diff --git a/src/net/tmwa/playerhandler.h b/src/net/tmwa/playerhandler.h
index 0fa524d51..14aa191f6 100644
--- a/src/net/tmwa/playerhandler.h
+++ b/src/net/tmwa/playerhandler.h
@@ -53,6 +53,7 @@ class PlayerHandler : public MessageHandler, public Ea::PlayerHandler
void changeAction(Being::Action action);
void processOnlineList(Net::MessageIn &msg);
void requestOnlineList();
+ void updateStatus(Uint8 status);
void respawn();
};
diff --git a/src/net/tmwa/protocol.h b/src/net/tmwa/protocol.h
index 0f124cc20..256f1dce4 100644
--- a/src/net/tmwa/protocol.h
+++ b/src/net/tmwa/protocol.h
@@ -335,5 +335,7 @@ enum
#define SMSG_IGNORE_ALL_RESPONSE 0x00d2
#define CMSG_ONLINE_LIST 0x0210
#define SMSG_ONLINE_LIST 0x0211
+#define SMSG_NPC_COMMAND 0x0212
+#define CMSG_SET_STATUS 0x0213
#endif
diff --git a/src/net/tmwa/specialhandler.cpp b/src/net/tmwa/specialhandler.cpp
index 9fa7b6dfa..129f0b47e 100644
--- a/src/net/tmwa/specialhandler.cpp
+++ b/src/net/tmwa/specialhandler.cpp
@@ -69,7 +69,7 @@ void SpecialHandler::handleMessage(Net::MessageIn &msg)
}
}
-void SpecialHandler::use(int id, int level, int beingId)
+void SpecialHandler::useBeing(int id, int level, int beingId)
{
MessageOut outMsg(CMSG_SKILL_USE_BEING);
outMsg.writeInt16(static_cast<Sint16>(level));
@@ -77,7 +77,7 @@ void SpecialHandler::use(int id, int level, int beingId)
outMsg.writeInt16(static_cast<Sint16>(beingId));
}
-void SpecialHandler::use(int id, int level, int x, int y)
+void SpecialHandler::usePos(int id, int level, int x, int y)
{
MessageOut outMsg(CMSG_SKILL_USE_POSITION);
outMsg.writeInt16(static_cast<Sint16>(level));
@@ -86,7 +86,7 @@ void SpecialHandler::use(int id, int level, int x, int y)
outMsg.writeInt16(static_cast<Sint16>(y));
}
-void SpecialHandler::use(int id, const std::string &map)
+void SpecialHandler::useMap(int id, const std::string &map)
{
MessageOut outMsg(CMSG_SKILL_USE_MAP);
outMsg.writeInt16(static_cast<Sint16>(id));
diff --git a/src/net/tmwa/specialhandler.h b/src/net/tmwa/specialhandler.h
index f17ef4c44..216adddc6 100644
--- a/src/net/tmwa/specialhandler.h
+++ b/src/net/tmwa/specialhandler.h
@@ -40,11 +40,11 @@ class SpecialHandler : public MessageHandler, public Ea::SpecialHandler
void handleMessage(Net::MessageIn &msg);
- void use(int id, int level, int beingId);
+ void useBeing(int id, int level, int beingId);
- void use(int id, int level, int x, int y);
+ void usePos(int id, int level, int x, int y);
- void use(int id, const std::string &map);
+ void useMap(int id, const std::string &map);
};
} // namespace TmwAthena