abstractcharacterdata.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: abstractcharacterdata.cpp 3188 2007-03-14 17:47:44Z rogier_polak $
00021  */
00022 
00023 #include "abstractcharacterdata.hpp"
00024 
00025 #include "defines.h"
00026 #include "net/messagein.hpp"
00027 #include "net/messageout.hpp"
00028 #include "point.h"
00029 
00030 void AbstractCharacterData::serialize(MessageOut &msg) const
00031 {
00032     msg.writeLong(getDatabaseID());
00033     msg.writeString(getName());
00034     msg.writeByte(getGender());
00035     msg.writeByte(getHairStyle());
00036     msg.writeByte(getHairColor());
00037     msg.writeByte(getLevel());
00038     msg.writeShort(getMoney());
00039 
00040     for (int i = 0; i < NB_BASE_ATTRIBUTES; ++i)
00041     {
00042         msg.writeByte(getBaseAttribute(i));
00043     }
00044 
00045     msg.writeShort(getMapId());
00046     msg.writeShort(getPosition().x);
00047     msg.writeShort(getPosition().y);
00048 
00060 }
00061 
00062 void AbstractCharacterData::deserialize(MessageIn &msg)
00063 {
00064     setDatabaseID(msg.readLong());
00065     setName(msg.readString());
00066     setGender(msg.readByte());
00067     setHairStyle(msg.readByte());
00068     setHairColor(msg.readByte());
00069     setLevel(msg.readByte());
00070     setMoney(msg.readShort());
00071 
00072     for (int i = 0; i < NB_BASE_ATTRIBUTES; ++i)
00073     {
00074         setBaseAttribute(i, msg.readByte());
00075     }
00076 
00077     setMapId(msg.readShort());
00078 
00079     Point temporaryPoint;
00080     temporaryPoint.x = msg.readShort();
00081     temporaryPoint.y = msg.readShort();
00082     setPosition(temporaryPoint);
00083 
00101 }

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