summaryrefslogtreecommitdiff
path: root/src/net
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
parentfc17ff22d9df50df9c5d1cf3dc0de358001271ed (diff)
parentece36a40d4e9a838cde01075d7681b8fc517b19f (diff)
downloadmanaverse-9a3a196dbf633a699c26d0227802a42f025c8bfd.tar.gz
manaverse-9a3a196dbf633a699c26d0227802a42f025c8bfd.tar.bz2
manaverse-9a3a196dbf633a699c26d0227802a42f025c8bfd.tar.xz
manaverse-9a3a196dbf633a699c26d0227802a42f025c8bfd.zip
Merge branch 'master' into stripped
Conflicts: src/guichan/gui.cpp src/guichan/include/guichan/sdl/sdlpixel.hpp
Diffstat (limited to 'src/net')
-rw-r--r--src/net/adminhandler.h6
-rw-r--r--src/net/download.cpp2
-rw-r--r--src/net/ea/adminhandler.cpp6
-rw-r--r--src/net/ea/adminhandler.h6
-rw-r--r--src/net/ea/playerhandler.cpp1
-rw-r--r--src/net/inventoryhandler.h4
-rw-r--r--src/net/manaserv/adminhandler.cpp6
-rw-r--r--src/net/manaserv/adminhandler.h6
-rw-r--r--src/net/manaserv/attributes.cpp8
-rw-r--r--src/net/manaserv/connection.h2
-rw-r--r--src/net/manaserv/gamehandler.h6
-rw-r--r--src/net/manaserv/guildhandler.h2
-rw-r--r--src/net/manaserv/loginhandler.cpp2
-rw-r--r--src/net/manaserv/playerhandler.cpp5
-rw-r--r--src/net/manaserv/playerhandler.h2
-rw-r--r--src/net/manaserv/specialhandler.cpp10
-rw-r--r--src/net/manaserv/specialhandler.h6
-rw-r--r--src/net/messagein.cpp19
-rw-r--r--src/net/messagein.h2
-rw-r--r--src/net/playerhandler.h2
-rw-r--r--src/net/serverinfo.h2
-rw-r--r--src/net/specialhandler.h6
-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
35 files changed, 220 insertions, 65 deletions
diff --git a/src/net/adminhandler.h b/src/net/adminhandler.h
index f6d8606ce..2ac462834 100644
--- a/src/net/adminhandler.h
+++ b/src/net/adminhandler.h
@@ -42,15 +42,15 @@ class AdminHandler
virtual void kick(int playerId) = 0;
- virtual void kick(const std::string &name) = 0;
+ virtual void kickName(const std::string &name) = 0;
virtual void ban(int playerId) = 0;
- virtual void ban(const std::string &name) = 0;
+ virtual void banName(const std::string &name) = 0;
virtual void unban(int playerId) = 0;
- virtual void unban(const std::string &name) = 0;
+ virtual void unbanName(const std::string &name) = 0;
virtual void mute(int playerId, int type, int limit) = 0;
diff --git a/src/net/download.cpp b/src/net/download.cpp
index 22af389f3..d20713dfa 100644
--- a/src/net/download.cpp
+++ b/src/net/download.cpp
@@ -239,7 +239,7 @@ int Download::downloadThread(void *ptr)
curl_easy_setopt(d->mCurl, CURLOPT_USERAGENT,
strprintf(PACKAGE_EXTENDED_VERSION,
- branding.getStringValue("appShort").c_str()).c_str());
+ branding.getStringValue("appName").c_str()).c_str());
curl_easy_setopt(d->mCurl, CURLOPT_ERRORBUFFER, d->mError);
curl_easy_setopt(d->mCurl, CURLOPT_URL, d->mUrl.c_str());
curl_easy_setopt(d->mCurl, CURLOPT_NOPROGRESS, 0);
diff --git a/src/net/ea/adminhandler.cpp b/src/net/ea/adminhandler.cpp
index 556629458..f70be3cc8 100644
--- a/src/net/ea/adminhandler.cpp
+++ b/src/net/ea/adminhandler.cpp
@@ -32,7 +32,7 @@
namespace Ea
{
-void AdminHandler::kick(const std::string &name)
+void AdminHandler::kickName(const std::string &name)
{
Net::getChatHandler()->talk("@kick " + name);
}
@@ -42,7 +42,7 @@ void AdminHandler::ban(int playerId A_UNUSED)
// Not supported
}
-void AdminHandler::ban(const std::string &name)
+void AdminHandler::banName(const std::string &name)
{
Net::getChatHandler()->talk("@ban " + name);
}
@@ -52,7 +52,7 @@ void AdminHandler::unban(int playerId A_UNUSED)
// Not supported
}
-void AdminHandler::unban(const std::string &name)
+void AdminHandler::unbanName(const std::string &name)
{
Net::getChatHandler()->talk("@unban " + name);
}
diff --git a/src/net/ea/adminhandler.h b/src/net/ea/adminhandler.h
index 70c458514..5b5224174 100644
--- a/src/net/ea/adminhandler.h
+++ b/src/net/ea/adminhandler.h
@@ -35,15 +35,15 @@ class AdminHandler : public Net::AdminHandler
virtual ~AdminHandler()
{ }
- virtual void kick(const std::string &name);
+ virtual void kickName(const std::string &name);
virtual void ban(int playerId);
- virtual void ban(const std::string &name);
+ virtual void banName(const std::string &name);
virtual void unban(int playerId);
- virtual void unban(const std::string &name);
+ virtual void unbanName(const std::string &name);
virtual void mute(int playerId, int type, int limit);
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp
index 6a841415f..76a7b0dbc 100644
--- a/src/net/ea/playerhandler.cpp
+++ b/src/net/ea/playerhandler.cpp
@@ -645,4 +645,5 @@ int PlayerHandler::getAttackLocation() const
{
return EA_ATK;
}
+
} // namespace Ea
diff --git a/src/net/inventoryhandler.h b/src/net/inventoryhandler.h
index ec2f3db47..642d6f1c1 100644
--- a/src/net/inventoryhandler.h
+++ b/src/net/inventoryhandler.h
@@ -57,8 +57,8 @@ class InventoryHandler
//void changeCart() = 0;
- virtual void moveItem(int source, int slot, int amount,
- int destination) = 0;
+ virtual void moveItem2(int source, int slot, int amount,
+ int destination) = 0;
// TODO: fix/remove me
virtual size_t getSize(int type) const = 0;
diff --git a/src/net/manaserv/adminhandler.cpp b/src/net/manaserv/adminhandler.cpp
index 609c9e4f1..f44da97ff 100644
--- a/src/net/manaserv/adminhandler.cpp
+++ b/src/net/manaserv/adminhandler.cpp
@@ -62,7 +62,7 @@ void AdminHandler::kick(int playerId A_UNUSED)
// TODO
}
-void AdminHandler::kick(const std::string &name A_UNUSED)
+void AdminHandler::kickName(const std::string &name A_UNUSED)
{
// TODO
}
@@ -72,7 +72,7 @@ void AdminHandler::ban(int playerId A_UNUSED)
// TODO
}
-void AdminHandler::ban(const std::string &name A_UNUSED)
+void AdminHandler::banName(const std::string &name A_UNUSED)
{
// TODO
}
@@ -82,7 +82,7 @@ void AdminHandler::unban(int playerId A_UNUSED)
// TODO
}
-void AdminHandler::unban(const std::string &name A_UNUSED)
+void AdminHandler::unbanName(const std::string &name A_UNUSED)
{
// TODO
}
diff --git a/src/net/manaserv/adminhandler.h b/src/net/manaserv/adminhandler.h
index a4157b3b0..87c536c31 100644
--- a/src/net/manaserv/adminhandler.h
+++ b/src/net/manaserv/adminhandler.h
@@ -42,15 +42,15 @@ class AdminHandler : public Net::AdminHandler
void kick(int playerId);
- void kick(const std::string &name);
+ void kickName(const std::string &name);
void ban(int playerId);
- void ban(const std::string &name);
+ void banName(const std::string &name);
void unban(int playerId);
- void unban(const std::string &name);
+ void unbanName(const std::string &name);
void mute(int playerId, int type, int limit);
diff --git a/src/net/manaserv/attributes.cpp b/src/net/manaserv/attributes.cpp
index 662032e29..c032b6bb8 100644
--- a/src/net/manaserv/attributes.cpp
+++ b/src/net/manaserv/attributes.cpp
@@ -73,16 +73,16 @@ namespace Attributes
static unsigned int attributeMinimum = 0;
static unsigned int attributeMaximum = 0;
- unsigned int getCreationPoints()
+ unsigned int getCreationPoints() const
{ return creationPoints; }
- unsigned int getAttributeMinimum()
+ unsigned int getAttributeMinimum() const
{ return attributeMinimum; }
- unsigned int getAttributeMaximum()
+ unsigned int getAttributeMaximum() const
{ return attributeMaximum; }
- std::vector<std::string>& getLabels()
+ std::vector<std::string>& getLabels() const
{ return attributeLabels; }
/**
diff --git a/src/net/manaserv/connection.h b/src/net/manaserv/connection.h
index 4263ae21f..1d3454c75 100644
--- a/src/net/manaserv/connection.h
+++ b/src/net/manaserv/connection.h
@@ -63,7 +63,7 @@ namespace ManaServ
*/
void disconnect();
- State getState()
+ State getState() const
{ return mState; }
/**
diff --git a/src/net/manaserv/gamehandler.h b/src/net/manaserv/gamehandler.h
index 443533bba..83e636e0e 100644
--- a/src/net/manaserv/gamehandler.h
+++ b/src/net/manaserv/gamehandler.h
@@ -52,14 +52,16 @@ class GameHandler : public MessageHandler, public Net::GameHandler
void ping(int tick);
- bool removeDeadBeings() const { return false; }
+ bool removeDeadBeings() const
+ { return false; }
void clear();
void gameLoading();
/** The ManaServ protocol doesn't use the MP status bar. */
- bool canUseMagicBar() const { return false; }
+ bool canUseMagicBar() const
+ { return false; }
void disconnect2();
};
diff --git a/src/net/manaserv/guildhandler.h b/src/net/manaserv/guildhandler.h
index 893a7157b..47d595bfa 100644
--- a/src/net/manaserv/guildhandler.h
+++ b/src/net/manaserv/guildhandler.h
@@ -35,7 +35,7 @@ class GuildHandler : public Net::GuildHandler, public MessageHandler
public:
GuildHandler();
- bool isSupported()
+ bool isSupported() const
{ return true; }
void handleMessage(Net::MessageIn &msg);
diff --git a/src/net/manaserv/loginhandler.cpp b/src/net/manaserv/loginhandler.cpp
index 8b8ac831f..f1c597c00 100644
--- a/src/net/manaserv/loginhandler.cpp
+++ b/src/net/manaserv/loginhandler.cpp
@@ -339,7 +339,7 @@ void LoginHandler::readServerInfo(Net::MessageIn &msg)
return;
// Set the update host when included in the message
- const std::string updateHost = msg.readString();
+ std::string updateHost = msg.readString();
if (!updateHost.empty())
{
if (!checkPath(updateHost))
diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp
index 5ebf840bc..aa79d4d41 100644
--- a/src/net/manaserv/playerhandler.cpp
+++ b/src/net/manaserv/playerhandler.cpp
@@ -448,4 +448,9 @@ void PlayerHandler::requestOnlineList()
}
+void PlayerHandler::updateStatus(Uint8 status)
+{
+
+}
+
} // namespace ManaServ
diff --git a/src/net/manaserv/playerhandler.h b/src/net/manaserv/playerhandler.h
index 0255406a8..23d2f5e32 100644
--- a/src/net/manaserv/playerhandler.h
+++ b/src/net/manaserv/playerhandler.h
@@ -74,6 +74,8 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler
Vector getDefaultWalkSpeed() const;
+ void updateStatus(Uint8 status);
+
private:
void handleMapChangeMessage(Net::MessageIn &msg);
};
diff --git a/src/net/manaserv/specialhandler.cpp b/src/net/manaserv/specialhandler.cpp
index 13c6f7613..c168afd7c 100644
--- a/src/net/manaserv/specialhandler.cpp
+++ b/src/net/manaserv/specialhandler.cpp
@@ -53,19 +53,19 @@ void SpecialHandler::use(int id)
gameServerConnection->send(msg);
}
-void SpecialHandler::use(int id A_UNUSED, int level A_UNUSED,
- int beingId A_UNUSED)
+void SpecialHandler::useBeing(int id A_UNUSED, int level A_UNUSED,
+ int beingId A_UNUSED)
{
// TODO
}
-void SpecialHandler::use(int id A_UNUSED, int level A_UNUSED, int x A_UNUSED,
- int y A_UNUSED)
+void SpecialHandler::usePos(int id A_UNUSED, int level A_UNUSED,
+ int x A_UNUSED, int y A_UNUSED)
{
// TODO
}
-void SpecialHandler::use(int id A_UNUSED, const std::string &map A_UNUSED)
+void SpecialHandler::useMap(int id A_UNUSED, const std::string &map A_UNUSED)
{
// TODO
}
diff --git a/src/net/manaserv/specialhandler.h b/src/net/manaserv/specialhandler.h
index f6a20e4ac..2f1ce4d07 100644
--- a/src/net/manaserv/specialhandler.h
+++ b/src/net/manaserv/specialhandler.h
@@ -39,11 +39,11 @@ class SpecialHandler : public MessageHandler, public Net::SpecialHandler
void use(int id);
- 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 ManaServ
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp
index 4fb61dc6a..0547ed337 100644
--- a/src/net/messagein.cpp
+++ b/src/net/messagein.cpp
@@ -241,7 +241,7 @@ std::string MessageIn::readRawString(int length)
return str;
}
-char *MessageIn::readBytes(int length)
+unsigned char *MessageIn::readBytes(int length)
{
// Get string length
if (length < 0)
@@ -255,13 +255,28 @@ char *MessageIn::readBytes(int length)
return nullptr;
}
- char *buf = new char[length + 2];
+ unsigned char *buf = new unsigned char[length + 2];
memcpy (buf, mData + mPos, length);
buf[length] = 0;
buf[length + 1] = 0;
mPos += length;
+#ifdef ENABLEDEBUGLOG
+ std::string str;
+ for (int f = 0; f < length; f ++)
+ str += strprintf ("%02x", (unsigned)buf[f]);
+ str += " ";
+ for (int f = 0; f < length; f ++)
+ {
+ if (buf[f])
+ str += strprintf ("%c", buf[f]);
+ else
+ str += "_";
+ }
+ logger->log("ReadBytes: " + str);
+#endif
+
PacketCounters::incInBytes(length);
return buf;
}
diff --git a/src/net/messagein.h b/src/net/messagein.h
index 8dd43a1a0..1eb5bf232 100644
--- a/src/net/messagein.h
+++ b/src/net/messagein.h
@@ -95,7 +95,7 @@ class MessageIn
virtual std::string readRawString(int length);
- char *readBytes(int length);
+ unsigned char *readBytes(int length);
virtual ~MessageIn()
{ }
diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h
index f62acc0c9..6ae912102 100644
--- a/src/net/playerhandler.h
+++ b/src/net/playerhandler.h
@@ -73,6 +73,8 @@ class PlayerHandler
virtual Vector getDefaultWalkSpeed() const = 0;
virtual void requestOnlineList() = 0;
+
+ virtual void updateStatus(Uint8 status) = 0;
};
} // namespace Net
diff --git a/src/net/serverinfo.h b/src/net/serverinfo.h
index fb6a99a33..b4bb1a2d8 100644
--- a/src/net/serverinfo.h
+++ b/src/net/serverinfo.h
@@ -54,7 +54,7 @@ public:
ServerInfo()
{
type = TMWATHENA;
- port = 0;
+ port = 6901;
save = false;
version.first = 0;
}
diff --git a/src/net/specialhandler.h b/src/net/specialhandler.h
index 7ed3673cf..f385f47f9 100644
--- a/src/net/specialhandler.h
+++ b/src/net/specialhandler.h
@@ -35,11 +35,11 @@ class SpecialHandler
virtual void use(int id) = 0;
- virtual void use(int id, int level, int beingId) = 0;
+ virtual void useBeing(int id, int level, int beingId) = 0;
- virtual void use(int id, int level, int x, int y) = 0;
+ virtual void usePos(int id, int level, int x, int y) = 0;
- virtual void use(int id, const std::string &map) = 0;
+ virtual void useMap(int id, const std::string &map) = 0;
};
}
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