characterdata.cpp

Go to the documentation of this file.
00001 /*
00002  *  The Mana World Server
00003  *  Copyright 2007 The Mana World Development Team
00004  *
00005  *  This file is part of The Mana World.
00006  *
00007  *  The Mana World  is free software; you can redistribute  it and/or modify it
00008  *  under the terms of the GNU General  Public License as published by the Free
00009  *  Software Foundation; either version 2 of the License, or any later version.
00010  *
00011  *  The Mana  World is  distributed in  the hope  that it  will be  useful, but
00012  *  WITHOUT ANY WARRANTY; without even  the implied warranty of MERCHANTABILITY
00013  *  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
00014  *  more details.
00015  *
00016  *  You should  have received a  copy of the  GNU General Public  License along
00017  *  with The Mana  World; if not, write to the  Free Software Foundation, Inc.,
00018  *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00019  *
00020  *  $Id$
00021  */
00022 
00023 #include "account-server/characterdata.hpp"
00024 
00025 #include "net/messagein.hpp"
00026 
00027 CharacterData::CharacterData(std::string const &name, int id):
00028     mDatabaseID(id), mAccountID(-1), mName(name), mGender(0), mHairStyle(0),
00029     mHairColor(0), mLevel(0), mMoney(0), mMapId(0), mPos(0,0)
00030 {
00031     for (int i = 0; i < NB_BASE_ATTRIBUTES; ++i)
00032     {
00033         mBaseAttributes[i] = 0;
00034     }
00035 }
00036 
00037 CharacterData::CharacterData(MessageIn & msg):
00038     mDatabaseID(-1), mAccountID(-1), mName(""), mGender(0), mHairStyle(0),
00039     mHairColor(0), mLevel(0), mMoney(0), mMapId(0), mPos(0,0)
00040 {
00041     for (int i = 0; i < NB_BASE_ATTRIBUTES; ++i)
00042     {
00043         mBaseAttributes[i] = 0;
00044     }
00045     deserialize(msg);
00046 }
00047 
00048 InventoryItem const &
00049 CharacterData::getInventoryItem(unsigned short slot) const
00050 {
00051     return mInventory[slot];
00052 }
00053 
00054 void
00055 CharacterData::addItemToInventory(const InventoryItem& item)
00056 {
00057     // Discard items if the inventory is full
00058     if ((int)mInventory.size() < INVENTORY_SLOTS)
00059     {
00060         mInventory.push_back(item);
00061     }
00062 }

Generated on Fri Mar 30 15:39:16 2007 for TMW Server by  doxygen 1.3.9.1