summaryrefslogtreecommitdiffstats
path: root/src/game-server
diff options
context:
space:
mode:
authorDavid Athay <ko2fan@gmail.com>2008-07-03 16:52:52 +0000
committerDavid Athay <ko2fan@gmail.com>2008-07-03 16:52:52 +0000
commit1c1c3ad9029ab4796b0c27013ac317e566716039 (patch)
tree25193ad310ae7b70f140d22b8f285b191d78af7f /src/game-server
parentb4277aadb5c24b3459f7085bcdb8911fdb70799d (diff)
downloadmanaserv-1c1c3ad9029ab4796b0c27013ac317e566716039.tar.gz
manaserv-1c1c3ad9029ab4796b0c27013ac317e566716039.tar.xz
manaserv-1c1c3ad9029ab4796b0c27013ac317e566716039.zip
Removed guild stuff from game server and added some party stuff to it.
Diffstat (limited to 'src/game-server')
-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
6 files changed, 37 insertions, 189 deletions
diff --git a/src/game-server/accountconnection.cpp b/src/game-server/accountconnection.cpp
index 60da1ee..67ea957 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 59652dd..6bad465 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 0c15ad6..3fb938c 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 5e26b96..220f5c3 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 07bf9ad..3afc4be 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 f564c60..0604ba2 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.