summaryrefslogtreecommitdiff
path: root/src/account-server/accounthandler.cpp
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-08-14 10:43:58 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-08-14 10:43:58 +0000
commit4b48bc6fefd4f580d3b8db8893f78706e64bf880 (patch)
treec6a36b566f9837bf1faf260f673f11b0ac2df783 /src/account-server/accounthandler.cpp
parent01e3326de8fc03cf9f61fd1b288cd4f16915484c (diff)
downloadmanaserv-4b48bc6fefd4f580d3b8db8893f78706e64bf880.tar.gz
manaserv-4b48bc6fefd4f580d3b8db8893f78706e64bf880.tar.bz2
manaserv-4b48bc6fefd4f580d3b8db8893f78706e64bf880.tar.xz
manaserv-4b48bc6fefd4f580d3b8db8893f78706e64bf880.zip
Handled money as part of the inventory.
Diffstat (limited to 'src/account-server/accounthandler.cpp')
-rw-r--r--src/account-server/accounthandler.cpp61
1 files changed, 22 insertions, 39 deletions
diff --git a/src/account-server/accounthandler.cpp b/src/account-server/accounthandler.cpp
index 3c1d61a6..5c553afa 100644
--- a/src/account-server/accounthandler.cpp
+++ b/src/account-server/accounthandler.cpp
@@ -149,6 +149,25 @@ AccountHandler::processMessage(NetComputer *comp, MessageIn &message)
}
}
+void AccountHandler::sendCharacterData(AccountClient &computer, int slot, CharacterData const &ch)
+{
+ MessageOut charInfo(APMSG_CHAR_INFO);
+ charInfo.writeByte(slot);
+ charInfo.writeString(ch.getName());
+ charInfo.writeByte((int)ch.getGender());
+ charInfo.writeByte(ch.getHairStyle());
+ charInfo.writeByte(ch.getHairColor());
+ charInfo.writeByte(ch.getLevel());
+ charInfo.writeLong(ch.getPossessions().money);
+
+ for (int j = 0; j < NB_BASE_ATTRIBUTES; ++j)
+ {
+ charInfo.writeShort(ch.getBaseAttribute(j));
+ }
+
+ computer.send(charInfo);
+}
+
void
AccountHandler::handleLoginMessage(AccountClient &computer, MessageIn &msg)
{
@@ -211,19 +230,7 @@ AccountHandler::handleLoginMessage(AccountClient &computer, MessageIn &msg)
// Send characters list
for (unsigned int i = 0; i < chars.size(); i++)
{
- MessageOut charInfo(APMSG_CHAR_INFO);
- charInfo.writeByte(i); // Slot
- charInfo.writeString(chars[i]->getName());
- charInfo.writeByte((unsigned char) chars[i]->getGender());
- charInfo.writeByte(chars[i]->getHairStyle());
- charInfo.writeByte(chars[i]->getHairColor());
- charInfo.writeByte(chars[i]->getLevel());
- charInfo.writeLong(chars[i]->getMoney());
-
- for (int j = 0; j < NB_BASE_ATTRIBUTES; ++j)
- charInfo.writeShort(chars[i]->getBaseAttribute(j));
-
- computer.send(charInfo);
+ sendCharacterData(computer, i, *chars[i]);
}
return;
}
@@ -582,7 +589,6 @@ AccountHandler::handleCharacterCreateMessage(AccountClient &computer,
CharacterPtr newCharacter(new CharacterData(name));
for (int i = 0; i < NB_BASE_ATTRIBUTES; ++i)
newCharacter->setBaseAttribute(i, attributes[i]);
- newCharacter->setMoney(0);
newCharacter->setLevel(1);
newCharacter->setGender(gender);
newCharacter->setHairStyle(hairStyle);
@@ -601,18 +607,8 @@ AccountHandler::handleCharacterCreateMessage(AccountClient &computer,
computer.send(reply);
// Send new characters infos back to client
- MessageOut charInfo(APMSG_CHAR_INFO);
int slot = chars.size() - 1;
- charInfo.writeByte(slot);
- charInfo.writeString(chars[slot]->getName());
- charInfo.writeByte((unsigned char) chars[slot]->getGender());
- charInfo.writeByte(chars[slot]->getHairStyle());
- charInfo.writeByte(chars[slot]->getHairColor());
- charInfo.writeByte(chars[slot]->getLevel());
- charInfo.writeShort(chars[slot]->getMoney());
- for (int j = 0; j < NB_BASE_ATTRIBUTES; ++j)
- charInfo.writeShort(chars[slot]->getBaseAttribute(j));
- computer.send(charInfo);
+ sendCharacterData(computer, slot, *chars[slot]);
return;
}
}
@@ -745,20 +741,7 @@ AccountHandler::tokenMatched(AccountClient *computer, int accountID)
// Send characters list
for (unsigned int i = 0; i < chars.size(); i++)
{
- MessageOut charInfo(APMSG_CHAR_INFO);
- charInfo.writeByte(i); // Slot
- charInfo.writeString(chars[i]->getName());
- charInfo.writeByte((unsigned char) chars[i]->getGender());
- charInfo.writeByte(chars[i]->getHairStyle());
- charInfo.writeByte(chars[i]->getHairColor());
- charInfo.writeByte(chars[i]->getLevel());
- charInfo.writeShort(chars[i]->getMoney());
-
- for (int j = 0; j < NB_BASE_ATTRIBUTES; ++j)
- {
- charInfo.writeShort(chars[i]->getBaseAttribute(j));
- }
- computer->send(charInfo);
+ sendCharacterData(*computer, i, *chars[i]);
}
}