summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-11-07 11:47:24 -0700
committerJared Adams <jaxad0127@gmail.com>2009-11-07 11:47:24 -0700
commit99be9859a30e84e758ee3bfe7dcc3de33dfa2391 (patch)
tree49354012582a4c9e9218ebafad429b07b19b2539 /src
parent9c1cc1e46fd21ec48809fbb8f64853fcecef2439 (diff)
downloadmana-99be9859a30e84e758ee3bfe7dcc3de33dfa2391.tar.gz
mana-99be9859a30e84e758ee3bfe7dcc3de33dfa2391.tar.bz2
mana-99be9859a30e84e758ee3bfe7dcc3de33dfa2391.tar.xz
mana-99be9859a30e84e758ee3bfe7dcc3de33dfa2391.zip
More eAthena guild stuff
Also some related chenges elsewhere
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/Makefile.am6
-rw-r--r--src/gui/inventorywindow.h2
-rw-r--r--src/gui/storagewindow.cpp2
-rw-r--r--src/gui/storagewindow.h2
-rw-r--r--src/gui/trade.cpp4
-rw-r--r--src/guild.cpp176
-rw-r--r--src/guild.h90
-rw-r--r--src/localplayer.cpp10
-rw-r--r--src/localplayer.h2
-rw-r--r--src/net/ea/guildhandler.cpp29
-rw-r--r--src/net/ea/guildhandler.h8
-rw-r--r--src/net/ea/inventoryhandler.cpp22
-rw-r--r--src/net/ea/inventoryhandler.h8
-rw-r--r--src/net/ea/protocol.h39
-rw-r--r--src/net/guildhandler.h6
-rw-r--r--src/net/inventoryhandler.h17
-rw-r--r--src/net/manaserv/guildhandler.cpp44
-rw-r--r--src/net/manaserv/guildhandler.h4
-rw-r--r--src/net/manaserv/inventoryhandler.cpp25
-rw-r--r--src/net/manaserv/inventoryhandler.h8
-rw-r--r--src/player.cpp8
-rw-r--r--src/player.h7
23 files changed, 398 insertions, 125 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ec0430cf..b2bc22a8 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -373,6 +373,8 @@ SET(SRCS
graphics.cpp
graphics.h
guichanfwd.h
+ guild.cpp
+ guild.h
imageparticle.cpp
imageparticle.h
inventory.cpp
@@ -540,8 +542,6 @@ SET(SRCS_MANA
net/manaserv/specialhandler.h
net/manaserv/tradehandler.cpp
net/manaserv/tradehandler.h
- guild.cpp
- guild.h
)
diff --git a/src/Makefile.am b/src/Makefile.am
index b91930a4..9bbcbc29 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -322,6 +322,8 @@ mana_SOURCES = gui/widgets/avatar.cpp \
graphics.cpp \
graphics.h \
guichanfwd.h \
+ guild.cpp \
+ guild.h \
imageparticle.cpp \
imageparticle.h \
inventory.cpp \
@@ -441,9 +443,7 @@ mana_SOURCES += \
net/manaserv/specialhandler.cpp \
net/manaserv/specialhandler.h \
net/manaserv/tradehandler.cpp \
- net/manaserv/tradehandler.h \
- guild.cpp \
- guild.h
+ net/manaserv/tradehandler.h
endif
if SERVER_EATHENA
diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h
index d7e82bd1..e40ac325 100644
--- a/src/gui/inventorywindow.h
+++ b/src/gui/inventorywindow.h
@@ -53,7 +53,7 @@ class InventoryWindow : public Window,
* Constructor.
*/
InventoryWindow(int invSize = Net::getInventoryHandler()
- ->getInventorySize());
+ ->getSize(Net::InventoryHandler::INVENTORY));
/**
* Destructor.
diff --git a/src/gui/storagewindow.cpp b/src/gui/storagewindow.cpp
index b0ffa3ff..e6583bad 100644
--- a/src/gui/storagewindow.cpp
+++ b/src/gui/storagewindow.cpp
@@ -197,5 +197,5 @@ void StorageWindow::removeStore(Item *item, int amount)
void StorageWindow::close()
{
- Net::getInventoryHandler()->closeStorage();
+ Net::getInventoryHandler()->closeStorage(Net::InventoryHandler::STORAGE);
}
diff --git a/src/gui/storagewindow.h b/src/gui/storagewindow.h
index 8c890c27..a67e0617 100644
--- a/src/gui/storagewindow.h
+++ b/src/gui/storagewindow.h
@@ -50,7 +50,7 @@ class StorageWindow : public Window, gcn::ActionListener,
* Constructor.
*/
StorageWindow(int invSize = Net::getInventoryHandler()
- ->getStorageSize());
+ ->getSize(Net::InventoryHandler::STORAGE));
/**
* Destructor.
diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp
index 15a4d7e8..5a659da9 100644
--- a/src/gui/trade.cpp
+++ b/src/gui/trade.cpp
@@ -58,9 +58,9 @@
TradeWindow::TradeWindow():
Window(_("Trade: You")),
mMyInventory(new Inventory(Net::getInventoryHandler()
- ->getInventorySize())),
+ ->getSize(Net::InventoryHandler::INVENTORY))),
mPartnerInventory(new Inventory(Net::getInventoryHandler()
- ->getInventorySize())),
+ ->getSize(Net::InventoryHandler::INVENTORY))),
mStatus(PROPOSING)
{
setWindowName("Trade");
diff --git a/src/guild.cpp b/src/guild.cpp
index be4a5204..3b30ec23 100644
--- a/src/guild.cpp
+++ b/src/guild.cpp
@@ -21,30 +21,114 @@
#include "guild.h"
-Guild::Guild(short id, short rights):
+GuildMember::GuildMember(int guildId, int id, const std::string &name):
+ mName(name), mId(id), mOnline(false)
+{
+ mGuild = Guild::getGuild(guildId);
+};
+
+GuildMember::GuildMember(int guildId, int id):
+ mId(id), mOnline(false)
+{
+ mGuild = Guild::getGuild(guildId);
+};
+
+GuildMember::GuildMember(int guildId, const std::string &name):
+ mName(name), mId(0), mOnline(false)
+{
+ mGuild = Guild::getGuild(guildId);
+};
+
+Guild::GuildMap Guild::guilds;
+
+Guild::Guild(short id):
mId(id),
mCanInviteUsers(false)
{
- // to invite, rights must be greater than 0
- if (rights > 0)
- mCanInviteUsers = true;
+ guilds[id] = this;
}
-void Guild::addMember(const std::string &name)
+void Guild::addMember(GuildMember *member)
{
- if (!isMember(name))
+ if (member->mGuild > 0 && member->mGuild != this)
+ {
+ throw "Member in another guild!";
+ }
+
+ if (!isMember(member))
{
- mMembers.push_back(name);
+ mMembers.push_back(member);
+ member->mGuild = this;
+ }
+}
+
+GuildMember *Guild::getMember(int id)
+{
+ MemberList::iterator itr = mMembers.begin(),
+ itr_end = mMembers.end();
+ while(itr != itr_end)
+ {
+ if((*itr)->mId == id)
+ {
+ return (*itr);
+ }
+ ++itr;
+ }
+
+ return NULL;
+}
+
+GuildMember *Guild::getMember(std::string name)
+{
+ MemberList::iterator itr = mMembers.begin(),
+ itr_end = mMembers.end();
+ while(itr != itr_end)
+ {
+ if((*itr)->mName == name)
+ {
+ return (*itr);
+ }
+ ++itr;
+ }
+
+ return NULL;
+}
+
+void Guild::removeMember(GuildMember *member)
+{
+ MemberList::iterator itr = mMembers.begin(),
+ itr_end = mMembers.end();
+ while(itr != itr_end)
+ {
+ if((*itr)->mId == member->mId && (*itr)->mName == member->mName)
+ {
+ mMembers.erase(itr);
+ }
+ ++itr;
+ }
+}
+
+void Guild::removeMember(int id)
+{
+ MemberList::iterator itr = mMembers.begin(),
+ itr_end = mMembers.end();
+ while(itr != itr_end)
+ {
+ if((*itr)->mId == id)
+ {
+ mMembers.erase(itr);
+ }
+ ++itr;
}
}
void Guild::removeMember(const std::string &name)
{
- std::vector<std::string>::iterator itr = mMembers.begin(),
- itr_end = mMembers.end();
+ MemberList::iterator itr = mMembers.begin(),
+ itr_end = mMembers.end();
while(itr != itr_end)
{
- if((*itr) == name)
+ if((*itr)->mName == name)
{
mMembers.erase(itr);
}
@@ -52,13 +136,70 @@ void Guild::removeMember(const std::string &name)
}
}
+std::string Guild::getElementAt(int index)
+{
+ GuildMember *m = mMembers[index];
+ if (m->mOnline)
+ {
+ return "* " + m->mName;
+ }
+ else
+ {
+ return m->mName;
+ }
+}
+
+void Guild::setRights(short rights)
+{
+ // to invite, rights must be greater than 0
+ if (rights > 0)
+ {
+ mCanInviteUsers = true;
+ }
+}
+
+bool Guild::isMember(GuildMember *member) const
+{
+ if (member->mGuild > 0 && member->mGuild != this)
+ return false;
+
+ MemberList::const_iterator itr = mMembers.begin(),
+ itr_end = mMembers.end();
+ while (itr != itr_end)
+ {
+ if ((*itr)->mId == member->mId && (*itr)->mName == member->mName)
+ {
+ return true;
+ }
+ ++itr;
+ }
+
+ return false;
+}
+
+bool Guild::isMember(int id) const
+{
+ MemberList::const_iterator itr = mMembers.begin(),
+ itr_end = mMembers.end();
+ while (itr != itr_end)
+ {
+ if ((*itr)->mId == id)
+ {
+ return true;
+ }
+ ++itr;
+ }
+
+ return false;
+}
+
bool Guild::isMember(const std::string &name) const
{
- std::vector<std::string>::const_iterator itr = mMembers.begin(),
- itr_end = mMembers.end();
+ MemberList::const_iterator itr = mMembers.begin(),
+ itr_end = mMembers.end();
while (itr != itr_end)
{
- if ((*itr) == name)
+ if ((*itr)->mName == name)
{
return true;
}
@@ -67,3 +208,12 @@ bool Guild::isMember(const std::string &name) const
return false;
}
+
+Guild *Guild::getGuild(int id)
+{
+ GuildMap::iterator it = guilds.find(id);
+ if (it != guilds.end())
+ return it->second;
+
+ return new Guild(id);
+}
diff --git a/src/guild.h b/src/guild.h
index b9e9e4b6..d59f6020 100644
--- a/src/guild.h
+++ b/src/guild.h
@@ -24,16 +24,47 @@
#include <guichan/listmodel.hpp>
+#include <map>
#include <string>
#include <vector>
+class Guild;
+
+class GuildMember
+{
+public:
+ GuildMember(int guildId, int id, const std::string &name);
+
+ GuildMember(int guildId, int id);
+
+ GuildMember(int guildId, const std::string &name);
+
+ int getID() const { return mId; }
+
+ void setID(int id) { mId = id; }
+
+ std::string getName() const { return mName; }
+
+ void setName(std::string name) { mName = name; }
+
+ Guild *getGuild() const { return mGuild; }
+
+ bool getOnline() const { return mOnline; }
+
+ void setOnline(bool online) { mOnline = online; }
+
+protected:
+ friend class Guild;
+
+ std::string mName;
+ int mId;
+ Guild *mGuild;
+ bool mOnline;
+};
+
class Guild : public gcn::ListModel
{
public:
- /**
- * Constructor with guild id passed to it.
- */
- Guild(short id, short rights);
/**
* Set the guild's name.
@@ -46,7 +77,21 @@ public:
/**
* Adds member to the list.
*/
- void addMember(const std::string &name);
+ void addMember(GuildMember *member);
+
+ /**
+ * Find a member by ID.
+ *
+ * @return the member with the given ID, or NULL if they don't exist.
+ */
+ GuildMember *getMember(int id);
+
+ /**
+ * Find a member by name.
+ *
+ * @return the member with the given name, or NULL if they don't exist.
+ */
+ GuildMember *getMember(std::string name);
/**
* Get the name of the guild.
@@ -69,8 +114,20 @@ public:
/**
* Removes a member from the guild.
*/
+ void removeMember(GuildMember *member);
+
+ /**
+ * Removes a member from the guild.
+ */
+ void removeMember(int id);
+
+ /**
+ * Removes a member from the guild.
+ */
void removeMember(const std::string &name);
+ void clearMembers() { mMembers.clear(); }
+
/**
* Get size of members list.
* @return Returns the number of members in the guild.
@@ -83,9 +140,7 @@ public:
* Get member at \a index.
* @return Returns the name of member.
*/
- std::string getElementAt(int index) {
- return mMembers[index];
- }
+ std::string getElementAt(int index);
/**
* Get whether user can invite users to this guild.
@@ -96,12 +151,29 @@ public:
return mCanInviteUsers;
}
+ void setRights(short rights);
+
+ bool isMember(GuildMember *member) const;
+
+ bool isMember(int id) const;
+
bool isMember(const std::string &name) const;
+ static Guild *getGuild(int id);
+
private:
+ typedef std::map<int, Guild*> GuildMap;
+ static GuildMap guilds;
+
+ /**
+ * Constructor with guild id passed to it.
+ */
+ Guild(short id);
+
+ typedef std::vector<GuildMember*> MemberList;
+ MemberList mMembers;
std::string mName;
short mId;
- std::vector<std::string> mMembers;
bool mCanInviteUsers;
};
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index e736a01c..d670b3b6 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -102,11 +102,13 @@ LocalPlayer::LocalPlayer(int id, int job, Map *map):
mWalkingDir(0),
mPathSetByMouse(false),
mDestX(0), mDestY(0),
- mInventory(new Inventory(Net::getInventoryHandler()->getInventorySize())),
+ mInventory(new Inventory(Net::getInventoryHandler()
+ ->getSize(Net::InventoryHandler::INVENTORY))),
#ifdef MANASERV_SUPPORT
mLocalWalkTime(-1),
#endif
- mStorage(new Inventory(Net::getInventoryHandler()->getStorageSize())),
+ mStorage(new Inventory(Net::getInventoryHandler()
+ ->getSize(Net::InventoryHandler::STORAGE))),
mMessageTime(0)
{
// Variable to keep the local player from doing certain actions before a map
@@ -350,8 +352,6 @@ void LocalPlayer::nextStep(unsigned char dir = 0)
#endif
}
-
-#ifdef MANASERV_SUPPORT
bool LocalPlayer::checkInviteRights(const std::string &guildName)
{
Guild *guild = getGuild(guildName);
@@ -389,6 +389,7 @@ void LocalPlayer::clearInventory()
mInventory->clear();
}
+#ifdef MANASERV_SUPPORT
void LocalPlayer::setInvItem(int index, int id, int amount)
{
bool equipment = false;
@@ -397,7 +398,6 @@ void LocalPlayer::setInvItem(int index, int id, int amount)
equipment = true;
mInventory->setItem(index, id, amount, equipment);
}
-
#endif
void LocalPlayer::pickUp(FloorItem *item)
diff --git a/src/localplayer.h b/src/localplayer.h
index 2c784ac4..819b086d 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -141,7 +141,6 @@ class LocalPlayer : public Player
*/
Inventory *getStorage() const { return mStorage; }
-#ifdef MANASERV_SUPPORT
/**
* Check the player has permission to invite users to specific guild
*/
@@ -153,6 +152,7 @@ class LocalPlayer : public Player
void inviteToGuild(Being *being);
void clearInventory();
+#ifdef MANASERV_SUPPORT
void setInvItem(int index, int id, int amount);
#endif
diff --git a/src/net/ea/guildhandler.cpp b/src/net/ea/guildhandler.cpp
index f4cfc038..0cccd8f4 100644
--- a/src/net/ea/guildhandler.cpp
+++ b/src/net/ea/guildhandler.cpp
@@ -25,6 +25,7 @@
#include "net/ea/protocol.h"
#include "localplayer.h"
+#include "log.h"
Net::GuildHandler *guildHandler;
@@ -102,6 +103,20 @@ void GuildHandler::handleMessage(Net::MessageIn &msg)
// TODO
}
break;
+
+ case SMSG_GUILD_POSITION_INFO:
+ {
+ int guildId = msg.readInt32();
+ int emblem = msg.readInt32();
+ int posMode = msg.readInt32();
+ msg.readInt32(); // Unused
+ msg.readInt8(); // Unused
+ std::string guildName = msg.readString(24);
+
+ logger->log("Guild position info: %d %d %d %s\n", guildId,
+ emblem, posMode, guildName.c_str());
+ }
+ break;
}
}
@@ -143,14 +158,20 @@ void GuildHandler::leave(int guildId)
msg.writeString("", 30); // Message
}
-void GuildHandler::kick(int guildId, int playerId)
+void GuildHandler::kick(GuildMember member)
{
- // TODO
+ MessageOut msg(CMSG_GUILD_EXPULSION);
+ msg.writeInt32(member.getGuild()->getId());
+ msg.writeInt32(member.getID()); // Account ID
+ msg.writeInt32(0); // Char ID
+ msg.writeString("", 40); // Message
}
void GuildHandler::chat(int guildId, const std::string &text)
{
- // TODO
+ MessageOut msg(CMSG_GUILD_MESSAGE);
+ msg.writeInt16(text.size() + 4);
+ msg.writeString(text);
}
void GuildHandler::memberList(int guildId)
@@ -158,7 +179,7 @@ void GuildHandler::memberList(int guildId)
// TODO
}
-void GuildHandler::changeMemberPostion(int guildId, int playerId, int level)
+void GuildHandler::changeMemberPostion(GuildMember member, int level)
{
// TODO
}
diff --git a/src/net/ea/guildhandler.h b/src/net/ea/guildhandler.h
index e80e4818..f04a56bb 100644
--- a/src/net/ea/guildhandler.h
+++ b/src/net/ea/guildhandler.h
@@ -45,13 +45,13 @@ class GuildHandler : public Net::GuildHandler, public MessageHandler
void leave(int guildId);
- void kick(int guildId, int playerId);
+ void kick(GuildMember member);
void chat(int guildId, const std::string &text);
void memberList(int guildId);
- void changeMemberPostion(int guildId, int playerId, int level);
+ void changeMemberPostion(GuildMember member, int level);
void requestAlliance(int guildId, int otherGuildId);
@@ -59,6 +59,10 @@ class GuildHandler : public Net::GuildHandler, public MessageHandler
bool response);
void endAlliance(int guildId, int otherGuildId);
+
+ private:
+ // eAthena only supports one guild per player
+ Guild *mGuild;
};
}
diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp
index 8f2b4453..94118ae2 100644
--- a/src/net/ea/inventoryhandler.cpp
+++ b/src/net/ea/inventoryhandler.cpp
@@ -347,12 +347,12 @@ void InventoryHandler::moveItem(int oldIndex, int newIndex)
// Not implemented for eAthena (possible?)
}
-void InventoryHandler::openStorage()
+void InventoryHandler::openStorage(StorageType type)
{
// Doesn't apply to eAthena, since opening happens through NPCs?
}
-void InventoryHandler::closeStorage()
+void InventoryHandler::closeStorage(StorageType type)
{
MessageOut outMsg(CMSG_CLOSE_STORAGE);
}
@@ -374,14 +374,20 @@ void InventoryHandler::moveItem(StorageType source, int slot, int amount,
}
}
-size_t InventoryHandler::getInventorySize() const
+size_t InventoryHandler::getSize(StorageType type) const
{
- return 100;
-}
+ switch (type)
+ {
+ case INVENTORY:
+ return 100;
+ case STORAGE:
+ return 300;
+ case GUILD_STORAGE:
+ return 1000;
+ case CART:
+ return 0;
+ }
-size_t InventoryHandler::getStorageSize() const
-{
- return 300;
}
} // namespace EAthena
diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h
index e61ee14b..83a2b440 100644
--- a/src/net/ea/inventoryhandler.h
+++ b/src/net/ea/inventoryhandler.h
@@ -50,16 +50,14 @@ class InventoryHandler : public MessageHandler, public Net::InventoryHandler
void moveItem(int oldIndex, int newIndex);
- void openStorage();
+ void openStorage(StorageType type);
- void closeStorage();
+ void closeStorage(StorageType type);
void moveItem(StorageType source, int slot, int amount,
StorageType destination);
- size_t getInventorySize() const;
-
- size_t getStorageSize() const;
+ size_t getSize(StorageType type) const;
};
} // namespace EAthena
diff --git a/src/net/ea/protocol.h b/src/net/ea/protocol.h
index e6a417aa..75d0d30e 100644
--- a/src/net/ea/protocol.h
+++ b/src/net/ea/protocol.h
@@ -163,8 +163,31 @@ static const int STORAGE_OFFSET = 1;
#define SMSG_ADMIN_KICK_ACK 0x00cd
#define SMSG_GUILD_CREATE_RESPONSE 0x0167
+#define SMSG_GUILD_POSITION_INFO 0x016c
+#define SMSG_GUILD_MEMBER_LOGIN 0x016d
+#define SMSG_GUILD_MASTER_OR_MEMBER 0x014e
+#define SMSG_GUILD_BASIC_INFO 0x01b6
+#define SMSG_GUILD_ALIANCE_INFO 0x014c
+#define SMSG_GUILD_MEMBER_LIST 0x0154
+#define SMSG_GUILD_POS_NAME_LIST 0x0166
+#define SMSG_GUILD_POS_INFO_LIST 0x0160
+#define SMSG_GUILD_POSITION_CHANGED 0x0174
+#define SMSG_GUILD_MEMBER_POS_CHANGE 0x0156
+#define SMSG_GUILD_EMBLEM 0x0152
+#define SMSG_GUILD_SKILL_INFO 0x0162
+#define SMSG_GUILD_NOTICE 0x016f
+#define SMSG_GUILD_INVITE 0x016a
#define SMSG_GUILD_INVITE_ACK 0x0169
-#define SMSG_GUILD_INVITE 0x016A
+#define SMSG_GUILD_LEAVE 0x015a
+#define SMSG_GUILD_EXPULSION 0x015c
+#define SMSG_GUILD_EXPULSION_LIST 0x0163
+#define SMSG_GUILD_MESSAGE 0x017f
+#define SMSG_GUILD_SKILL_UP 0x010e
+#define SMSG_GUILD_REQ_ALLIANCE 0x0171
+#define SMSG_GUILD_REQ_ALLIANCE_ACK 0x0173
+#define SMSG_GUILD_DEL_ALLIANCE 0x0184
+#define SMSG_GUILD_OPPOSITION_ACK 0x0181
+#define SMSG_GUILD_BROKEN 0x015e
#define SMSG_MVP 0x010c
@@ -246,22 +269,22 @@ static const int STORAGE_OFFSET = 1;
#define CMSG_ADMIN_KICK 0x00CC
#define CMSG_ADMIN_MUTE 0x0149
-#define CMSG_GUILD_CHECK_MASTER 0x014D
-#define CMSG_GUILD_REQUEST_INFO 0x014F
+#define CMSG_GUILD_CHECK_MASTER 0x014d
+#define CMSG_GUILD_REQUEST_INFO 0x014f
#define CMSG_GUILD_REQUEST_EMBLEM 0x0151
#define CMSG_GUILD_CHANGE_EMBLEM 0x0153
#define CMSG_GUILD_CHANGE_MEMBER_POS 0x0155
#define CMSG_GUILD_LEAVE 0x0159
-#define CMSG_GUILD_EXPULSION 0x015B
-#define CMSG_GUILD_BREAK 0x015D
+#define CMSG_GUILD_EXPULSION 0x015b
+#define CMSG_GUILD_BREAK 0x015d
#define CMSG_GUILD_CHANGE_POS_INFO 0x0161
#define CMSG_GUILD_CREATE 0x0165
#define CMSG_GUILD_INVITE 0x0168
-#define CMSG_GUILD_INVITE_REPLY 0x016B
-#define CMSG_GUILD_CHANGE_NOTICE 0x016E
+#define CMSG_GUILD_INVITE_REPLY 0x016b
+#define CMSG_GUILD_CHANGE_NOTICE 0x016e
#define CMSG_GUILD_ALLIANCE_REQUEST 0x0170
#define CMSG_GUILD_ALLIANCE_REPLY 0x0172
-#define CMSG_GUILD_MESSAGE 0x017E
+#define CMSG_GUILD_MESSAGE 0x017e
#define CMSG_GUILD_OPPOSITION 0x0180
#define CMSG_GUILD_ALLIANCE_DELETE 0x0183
diff --git a/src/net/guildhandler.h b/src/net/guildhandler.h
index bba261bc..da44e6cd 100644
--- a/src/net/guildhandler.h
+++ b/src/net/guildhandler.h
@@ -22,6 +22,7 @@
#ifndef GUILDHANDLER_H
#define GUILDHANDLER_H
+#include "guild.h"
#include "player.h"
#include <iosfwd>
@@ -41,14 +42,13 @@ class GuildHandler
virtual void leave(int guildId) = 0;
- virtual void kick(int guildId, int playerId) = 0;
+ virtual void kick(GuildMember member) = 0;
virtual void chat(int guildId, const std::string &text) = 0;
virtual void memberList(int guildId) = 0;
- virtual void changeMemberPostion(int guildId, int playerId,
- int level) = 0;
+ virtual void changeMemberPostion(GuildMember member, int level) = 0;
virtual void requestAlliance(int guildId, int otherGuildId) = 0;
diff --git a/src/net/inventoryhandler.h b/src/net/inventoryhandler.h
index 08caf926..520e390e 100644
--- a/src/net/inventoryhandler.h
+++ b/src/net/inventoryhandler.h
@@ -45,24 +45,23 @@ class InventoryHandler
virtual void moveItem(int oldIndex, int newIndex) = 0;
- virtual void openStorage() = 0;
-
- virtual void closeStorage() = 0;
-
- //void changeCart() = 0;
-
enum StorageType {
INVENTORY,
STORAGE,
+ GUILD_STORAGE,
CART
};
+ virtual void openStorage(StorageType type) = 0;
+
+ virtual void closeStorage(StorageType type) = 0;
+
+ //void changeCart() = 0;
+
virtual void moveItem(StorageType source, int slot, int amount,
StorageType destination) = 0;
- virtual size_t getInventorySize() const = 0;
-
- virtual size_t getStorageSize() const = 0;
+ virtual size_t getSize(StorageType type) const = 0;
};
} // namespace Net
diff --git a/src/net/manaserv/guildhandler.cpp b/src/net/manaserv/guildhandler.cpp
index e71f4d20..dfc0e8c5 100644
--- a/src/net/manaserv/guildhandler.cpp
+++ b/src/net/manaserv/guildhandler.cpp
@@ -111,10 +111,10 @@ void GuildHandler::handleMessage(Net::MessageIn &msg)
logger->log("Received CPMSG_GUILD_GET_MEMBERS_RESPONSE");
if(msg.readInt8() == ERRMSG_OK)
{
- std::string guildMember;
+ std::string name;
bool online;
- std::string guildName;
Guild *guild;
+ GuildMember *member;
short guildId = msg.readInt16();
guild = player_node->getGuild(guildId);
@@ -122,16 +122,17 @@ void GuildHandler::handleMessage(Net::MessageIn &msg)
if (!guild)
return;
- guildName = guild->getName();
+ guild->clearMembers();
while(msg.getUnreadLength())
{
- guildMember = msg.readString();
+ name = msg.readString();
online = msg.readInt8();
- if(guildMember != "")
+ if(name != "")
{
- guild->addMember(guildMember);
- guildWindow->setOnline(guildName, guildMember, online);
+ member = new GuildMember(guildId, name);
+ member->setOnline(online);
+ guild->addMember(member);
}
}
@@ -143,8 +144,9 @@ void GuildHandler::handleMessage(Net::MessageIn &msg)
{
logger->log("Received CPMSG_GUILD_UPDATE_LIST");
short guildId = msg.readInt16();
- std::string guildMember = msg.readString();
+ std::string name = msg.readString();
char eventId = msg.readInt8();
+ GuildMember *member;
Guild *guild = player_node->getGuild(guildId);
if (guild)
@@ -152,23 +154,29 @@ void GuildHandler::handleMessage(Net::MessageIn &msg)
switch(eventId)
{
case GUILD_EVENT_NEW_PLAYER:
- guild->addMember(guildMember);
- guildWindow->setOnline(guild->getName(), guildMember,
- true);
+ member = new GuildMember(guildId, name);
+ member->setOnline(true);
+ guild->addMember(member);
break;
case GUILD_EVENT_LEAVING_PLAYER:
- guild->removeMember(guildMember);
+ guild->removeMember(name);
break;
case GUILD_EVENT_ONLINE_PLAYER:
- guildWindow->setOnline(guild->getName(), guildMember,
- true);
+ member = guild->getMember(name);
+ if (member)
+ {
+ member->setOnline(true);
+ }
break;
case GUILD_EVENT_OFFLINE_PLAYER:
- guildWindow->setOnline(guild->getName(), guildMember,
- false);
+ member = guild->getMember(name);
+ if (member)
+ {
+ member->setOnline(false);
+ }
break;
default:
@@ -292,7 +300,7 @@ void GuildHandler::leave(int guildId)
chatServerConnection->send(msg);
}
-void GuildHandler::kick(int guildId, int playerId)
+void GuildHandler::kick(GuildMember member)
{
// TODO
}
@@ -309,7 +317,7 @@ void GuildHandler::memberList(int guildId)
chatServerConnection->send(msg);
}
-void GuildHandler::changeMemberPostion(int guildId, int playerId, int level)
+void GuildHandler::changeMemberPostion(GuildMember member, int level)
{
/*MessageOut msg(PCMSG_GUILD_PROMOTE_MEMBER);
msg.writeInt16(guildId);
diff --git a/src/net/manaserv/guildhandler.h b/src/net/manaserv/guildhandler.h
index d80f0b33..3beaf16f 100644
--- a/src/net/manaserv/guildhandler.h
+++ b/src/net/manaserv/guildhandler.h
@@ -45,13 +45,13 @@ public:
void leave(int guildId);
- void kick(int guildId, int playerId);
+ void kick(GuildMember member);
void chat(int guildId, const std::string &text);
void memberList(int guildId);
- void changeMemberPostion(int guildId, int playerId, int level);
+ void changeMemberPostion(GuildMember member, int level);
void requestAlliance(int guildId, int otherGuildId);
diff --git a/src/net/manaserv/inventoryhandler.cpp b/src/net/manaserv/inventoryhandler.cpp
index 0d0c1b34..e2a579fd 100644
--- a/src/net/manaserv/inventoryhandler.cpp
+++ b/src/net/manaserv/inventoryhandler.cpp
@@ -66,7 +66,7 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg)
case GPMSG_INVENTORY:
while (msg.getUnreadLength())
{
- int slot = msg.readInt8();
+ unsigned int slot = msg.readInt8();
if (slot == 255)
{
player_node->setMoney(msg.readInt32());
@@ -78,7 +78,7 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg)
{
player_node->mEquipment->setEquipment(slot, id);
}
- else if (slot >= 32 && slot < 32 + getInventorySize())
+ else if (slot >= 32 && slot < 32 + getSize(INVENTORY))
{
int amount = id ? msg.readInt8() : 0;
player_node->setInvItem(slot - 32, id, amount);
@@ -153,12 +153,12 @@ void InventoryHandler::moveItem(int oldIndex, int newIndex)
gameServerConnection->send(msg);
}
-void InventoryHandler::openStorage()
+void InventoryHandler::openStorage(StorageType type)
{
// TODO
}
-void InventoryHandler::closeStorage()
+void InventoryHandler::closeStorage(StorageType type)
{
// TODO
}
@@ -169,14 +169,19 @@ void InventoryHandler::moveItem(StorageType source, int slot, int amount,
// TODO
}
-size_t InventoryHandler::getInventorySize() const
+size_t InventoryHandler::getSize(StorageType type) const
{
- return 50;
-}
+ switch (type)
+ {
+ case INVENTORY:
+ return 50;
+ case STORAGE:
+ case GUILD_STORAGE:
+ return 300;
+ case CART:
+ return 0;
+ }
-size_t InventoryHandler::getStorageSize() const
-{
- return 300;
}
} // namespace ManaServ
diff --git a/src/net/manaserv/inventoryhandler.h b/src/net/manaserv/inventoryhandler.h
index 1f937df9..d3feca0a 100644
--- a/src/net/manaserv/inventoryhandler.h
+++ b/src/net/manaserv/inventoryhandler.h
@@ -49,16 +49,14 @@ class InventoryHandler : public MessageHandler, Net::InventoryHandler
void moveItem(int oldIndex, int newIndex);
- void openStorage();
+ void openStorage(StorageType type);
- void closeStorage();
+ void closeStorage(StorageType type);
void moveItem(StorageType source, int slot, int amount,
StorageType destination);
- size_t getInventorySize() const;
-
- size_t getStorageSize() const;
+ size_t getSize(StorageType type) const;
};
} // namespace ManaServ
diff --git a/src/player.cpp b/src/player.cpp
index abcfffe9..7e390b84 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -22,9 +22,7 @@
#include "animatedsprite.h"
#include "configuration.h"
#include "game.h"
-#ifdef MANASERV_SUPPORT
#include "guild.h"
-#endif
#include "localplayer.h"
#include "particle.h"
#include "player.h"
@@ -209,10 +207,10 @@ void Player::setSpriteColor(unsigned int slot, const std::string &color)
setSprite(slot, mSpriteIDs[slot], color);
}
-#ifdef MANASERV_SUPPORT
Guild* Player::addGuild(short guildId, short rights)
{
- Guild *guild = new Guild(guildId, rights);
+ Guild *guild = Guild::getGuild(guildId);
+ guild->setRights(rights);
mGuilds.insert(std::pair<int, Guild*>(guildId, guild));
return guild;
}
@@ -254,8 +252,6 @@ short Player::getNumberOfGuilds()
return mGuilds.size();
}
-#endif
-
void Player::setInParty(bool inParty)
{
mInParty = inParty;
diff --git a/src/player.h b/src/player.h
index a1ba1b5c..5cdc35a7 100644
--- a/src/player.h
+++ b/src/player.h
@@ -26,9 +26,7 @@
class Graphics;
class Map;
-#ifdef MANASERV_SUPPORT
class Guild;
-#endif
enum Gender
{
@@ -109,7 +107,6 @@ class Player : public Being
virtual void setSpriteColor(unsigned int slot,
const std::string &color = "");
-#ifdef MANASERV_SUPPORT
/**
* Adds a guild to the player.
*/
@@ -135,8 +132,6 @@ class Player : public Being
*/
short getNumberOfGuilds();
-#endif
-
/**
* Set whether the player in the LocalPlayer's party. Players that are
* in the same party as the local player get their name displayed in
@@ -170,10 +165,8 @@ class Player : public Being
std::vector<int> mSpriteIDs;
std::vector<std::string> mSpriteColors;
-#ifdef MANASERV_SUPPORT
// Character guild information
std::map<int, Guild*> mGuilds;
-#endif
bool mIsGM;