summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--src/defines.h1
-rw-r--r--src/game-server/accountconnection.cpp166
-rw-r--r--src/game-server/accountconnection.hpp28
-rw-r--r--src/game-server/character.cpp3
-rw-r--r--src/game-server/character.hpp9
-rw-r--r--src/game-server/gamehandler.cpp13
-rw-r--r--src/game-server/gamehandler.hpp7
8 files changed, 46 insertions, 189 deletions
diff --git a/ChangeLog b/ChangeLog
index a4d4b17d..73e02255 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-07-03 David Athay <ko2fan@gmail.com>
+
+ * src/defines.h, src/game-server/character.cpp,
+ src/game-server/character.hpp, src/game-server/gamehandler.cpp,
+ src/game-server/accountconnection.cpp, src/game-server/gamehandler.hpp,
+ src/game-server/accountconnection.hpp: Removed guild stuff from game
+ server. Added some party stuff to game server.
+
2008-07-03 Roderic Morris <roderic@ccs.neu.edu>
* src/game-server/mapreader.cpp, src/game-server/mapreader.hpp:
diff --git a/src/defines.h b/src/defines.h
index 7ddcf0c4..e425f554 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -244,6 +244,7 @@ enum {
AGMSG_GET_QUEST_RESPONSE = 0x0542, // L id, S name, S value
GAMSG_BAN_PLAYER = 0x550, // L id, W duration
GAMSG_STATISTICS = 0x560, // { W map id, W thing nb, W monster nb, W player nb, { L character id }* }*
+ CGMSG_CHANGED_PARTY = 0x0590, // L character id, L party id
XXMSG_INVALID = 0x7FFF
};
diff --git a/src/game-server/accountconnection.cpp b/src/game-server/accountconnection.cpp
index 60da1ee1..67ea9571 100644
--- a/src/game-server/accountconnection.cpp
+++ b/src/game-server/accountconnection.cpp
@@ -103,121 +103,14 @@ void AccountConnection::processMessage(MessageIn &msg)
recoveredQuestVar(id, name, value);
} break;
-// The client should directly talk with the chat server and not go through the game server.
-#if 0
- case AGMSG_GUILD_CREATE_RESPONSE:
+ case CGMSG_CHANGED_PARTY:
{
- if(msg.readByte() == ERRMSG_OK)
- {
- int playerId = msg.readLong();
-
- MessageOut result(GPMSG_GUILD_CREATE_RESPONSE);
- result.writeByte(ERRMSG_OK);
-
- /* Create a message that the player has joined the guild
- * Output the guild ID and guild name
- * Send a 1 if the player has rights
- * to invite users, otherwise 0.
- */
- MessageOut out(GPMSG_GUILD_JOINED);
- out.writeShort(msg.readShort());
- out.writeString(msg.readString());
- out.writeShort(msg.readShort());
-
- Character *player = gameHandler->messageMap[playerId];
- if(player)
- {
- gameHandler->sendTo(player, result);
- gameHandler->sendTo(player, out);
- }
- }
- } break;
-
- case AGMSG_GUILD_INVITE_RESPONSE:
- {
- if(msg.readByte() == ERRMSG_OK)
- {
- int playerId = msg.readLong();
-
- MessageOut result(GPMSG_GUILD_INVITE_RESPONSE);
- result.writeByte(ERRMSG_OK);
-
- Character *player = gameHandler->messageMap[playerId];
- if(player)
- {
- gameHandler->sendTo(player, result);
- }
- }
- } break;
-
- case AGMSG_GUILD_ACCEPT_RESPONSE:
- {
- if(msg.readByte() == ERRMSG_OK)
- {
- int playerId = msg.readLong();
-
- MessageOut result(GPMSG_GUILD_ACCEPT_RESPONSE);
- result.writeByte(ERRMSG_OK);
-
- /* Create a message that the player has joined the guild
- * Output the guild ID and guild name
- * Send a 0 for invite rights, since player has been invited
- * they wont have any rights to invite other users yet.
- */
- MessageOut out(GPMSG_GUILD_JOINED);
- out.writeShort(msg.readShort());
- out.writeString(msg.readString());
- out.writeShort(0);
-
- Character *player = gameHandler->messageMap[playerId];
- if(player)
- {
- gameHandler->sendTo(player, result);
- gameHandler->sendTo(player, out);
- }
- }
- } break;
-
- case AGMSG_GUILD_GET_MEMBERS_RESPONSE:
- {
- if(msg.readByte() != ERRMSG_OK)
- break;
- int playerId = msg.readLong();
- short guildId = msg.readShort();
-
- MessageOut result(GPMSG_GUILD_GET_MEMBERS_RESPONSE);
- result.writeByte(ERRMSG_OK);
- result.writeShort(guildId);
- while(msg.getUnreadLength())
- {
- result.writeString(msg.readString());
- }
-
- Character *player = gameHandler->messageMap[playerId];
- if(player)
- {
- gameHandler->sendTo(player, result);
- }
- } break;
-
- case AGMSG_GUILD_QUIT_RESPONSE:
- {
- if(msg.readByte() != ERRMSG_OK)
- break;
- int playerId = msg.readLong();
- short guildId = msg.readShort();
-
- MessageOut result(GPMSG_GUILD_QUIT_RESPONSE);
- result.writeByte(ERRMSG_OK);
- result.writeShort(guildId);
-
- Character *player = gameHandler->messageMap[playerId];
- if(player)
- {
- gameHandler->sendTo(player, result);
- }
+ // Party id, 0 for none
+ int partyid = msg.readLong();
+ // Character DB id
+ int charid = msg.readLong();
+ gameHandler->updateCharacter(charid, partyid);
} break;
-#endif
default:
LOG_WARN("Invalid message type");
@@ -303,50 +196,3 @@ void AccountConnection::sendStatistics()
send(msg);
}
-#if 0
-void AccountConnection::playerCreateGuild(int id, const std::string &guildName)
-{
- LOG_INFO("Send GAMSG_GUILD_CREATE");
- MessageOut msg(GAMSG_GUILD_CREATE);
- msg.writeLong(id);
- msg.writeString(guildName);
- send(msg);
-}
-
-void AccountConnection::playerInviteToGuild(int id, short guildId, const std::string &member)
-{
- LOG_INFO("Send GAMSG_GUILD_INVITE");
- MessageOut msg(GAMSG_GUILD_INVITE);
- msg.writeLong(id);
- msg.writeShort(guildId);
- msg.writeString(member);
- send(msg);
-}
-
-void AccountConnection::playerAcceptInvite(int id, const std::string &guildName)
-{
- LOG_INFO("Send GAMSG_GUILD_ACCEPT");
- MessageOut msg(GAMSG_GUILD_ACCEPT);
- msg.writeLong(id);
- msg.writeString(guildName);
- send(msg);
-}
-
-void AccountConnection::getGuildMembers(int id, short guildId)
-{
- LOG_INFO("Send GAMSG_GUILD_GET_MEMBERS");
- MessageOut msg(GAMSG_GUILD_GET_MEMBERS);
- msg.writeLong(id);
- msg.writeShort(guildId);
- send(msg);
-}
-
-void AccountConnection::quitGuild(int id, short guildId)
-{
- LOG_INFO("Send GAMSG_GUILD_QUIT");
- MessageOut msg(GAMSG_GUILD_QUIT);
- msg.writeLong(id);
- msg.writeShort(guildId);
- send(msg);
-}
-#endif
diff --git a/src/game-server/accountconnection.hpp b/src/game-server/accountconnection.hpp
index 59652dd5..6bad4651 100644
--- a/src/game-server/accountconnection.hpp
+++ b/src/game-server/accountconnection.hpp
@@ -71,38 +71,12 @@ class AccountConnection : public Connection
*/
void sendStatistics();
-#if 0
- /**
- * Sends create guild message
- */
- void playerCreateGuild(int id, const std::string &guildName);
-
- /**
- * Sends invite message
- */
- void playerInviteToGuild(int id, short guildId, const std::string &name);
-
- /**
- * Sends accept message
- */
- void playerAcceptInvite(int id, const std::string &name);
-
- /**
- * Sends get guild members message.
- */
- void getGuildMembers(int id, short guildId);
-
- /**
- * Sends quit guild message.
- */
- void quitGuild(int id, short guildId);
-#endif
-
protected:
/**
* Processes server messages.
*/
virtual void processMessage(MessageIn &);
+
};
extern AccountConnection *accountHandler;
diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp
index 0c15ad6c..3fb938c8 100644
--- a/src/game-server/character.cpp
+++ b/src/game-server/character.cpp
@@ -53,7 +53,8 @@ Character::Character(MessageIn &msg):
Being(OBJECT_CHARACTER, 65535),
mClient(NULL), mTransactionHandler(NULL), mDatabaseID(-1),
mGender(0), mHairStyle(0), mHairColor(0), mLevel(1), mLevelProgress(0),
- mUpdateLevelProgress(false), mRecalculateLevel(true), mTransaction(TRANS_NONE)
+ mUpdateLevelProgress(false), mRecalculateLevel(true), mParty(0),
+ mTransaction(TRANS_NONE)
{
Attribute attr = { 0, 0 };
mAttributes.resize(NB_CHARACTER_ATTRIBUTES, attr);
diff --git a/src/game-server/character.hpp b/src/game-server/character.hpp
index 5e26b96c..220f5c38 100644
--- a/src/game-server/character.hpp
+++ b/src/game-server/character.hpp
@@ -187,6 +187,14 @@ class Character : public Being
void setAccountLevel(int l)
{ mAccountLevel = l; }
+ /** Gets the party id of the character */
+ int getParty() const
+ { return mPartyId; }
+
+ /** Sets the party id of the character */
+ void setParty(int party)
+ { mParty = party; }
+
/**
* Sends a message that informs the client about attribute
* modified since last call.
@@ -336,6 +344,7 @@ class Character : public Being
bool mUpdateLevelProgress; /**< flag raised when percent to next level changed */
bool mRecalculateLevel; /**< flag raised when the character level might have increased */
unsigned char mAccountLevel; /**< Account level of the user. */
+ int mParty; /**< Party id of the character */
TransactionType mTransaction; /**< Trade/buy/sell action the character is involved in. */
protected:
diff --git a/src/game-server/gamehandler.cpp b/src/game-server/gamehandler.cpp
index 07bf9ad1..3afc4bed 100644
--- a/src/game-server/gamehandler.cpp
+++ b/src/game-server/gamehandler.cpp
@@ -116,6 +116,19 @@ void GameHandler::completeServerChange(int id, std::string const &token,
}
}
+void GameHandler::updateCharacter(int charid, int partyid)
+{
+ for (NetComputers::const_iterator i = clients.begin(),
+ i_end = clients.end(); i != i_end; ++i)
+ {
+ GameClient *c = static_cast< GameClient * >(*i);
+ if (c->character->getDatabaseID() == id)
+ {
+ c->character->setParty(partyid);
+ }
+ }
+}
+
static MovingObject *findBeingNear(Object *p, int id)
{
MapComposite *map = p->getMap();
diff --git a/src/game-server/gamehandler.hpp b/src/game-server/gamehandler.hpp
index f564c60d..0604ba20 100644
--- a/src/game-server/gamehandler.hpp
+++ b/src/game-server/gamehandler.hpp
@@ -81,7 +81,12 @@ class GameHandler: public ConnectionHandler
*/
void completeServerChange(int id, std::string const &token,
std::string const &address, int port);
-
+
+ /**
+ * Updates the party id of the character
+ */
+ void updateCharacter(int charid, int partyid);
+
/**
* Registers a character that should soon be claimed by a client.
* @param token token used by the client when connecting.