summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorReid <reidyaro@gmail.com>2012-01-30 15:27:30 +0100
committerReid <reidyaro@gmail.com>2012-01-30 15:27:30 +0100
commit502a0a0163e702af7334979a2eabfc4826a94091 (patch)
tree5e80ef76585b1718d7e74a411117c725fe3cb0e9 /src/net
parent8dea62750ab3a44e0f35f2543bbb6ccf2a9470ce (diff)
parent193ea898e5f549c14c0e4cd0d060785de4fb4bcf (diff)
downloadmanaverse-502a0a0163e702af7334979a2eabfc4826a94091.tar.gz
manaverse-502a0a0163e702af7334979a2eabfc4826a94091.tar.bz2
manaverse-502a0a0163e702af7334979a2eabfc4826a94091.tar.xz
manaverse-502a0a0163e702af7334979a2eabfc4826a94091.zip
Merge branch 'master' of gitorious.org:manaplus/manaplus
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/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/specialhandler.h6
-rw-r--r--src/net/tmwa/beinghandler.cpp2
-rw-r--r--src/net/tmwa/inventoryhandler.cpp4
-rw-r--r--src/net/tmwa/inventoryhandler.h2
-rw-r--r--src/net/tmwa/playerhandler.cpp47
-rw-r--r--src/net/tmwa/playerhandler.h1
-rw-r--r--src/net/tmwa/protocol.h1
-rw-r--r--src/net/tmwa/specialhandler.cpp6
-rw-r--r--src/net/tmwa/specialhandler.h6
24 files changed, 110 insertions, 48 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/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/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/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/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp
index d5f0641eb..8747cf9c4 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,41 @@ void PlayerHandler::processOnlineList(Net::MessageIn &msg)
return;
}
- const char *start = msg.readBytes(size);
- const char *buf = start;
+ char *start = (char*)msg.readBytes(size);
+ 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 +271,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 ddc642101..256f1dce4 100644
--- a/src/net/tmwa/protocol.h
+++ b/src/net/tmwa/protocol.h
@@ -336,5 +336,6 @@ enum
#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