Beispiel #1
0
 public Letter(uint type, Character sender, Character receiver)
 {
     mId=0;
     mType=type;
     mSender=sender;
     mReceiver=receiver;
 }
Beispiel #2
0
 public void clearPost(Character player)
 {
     if(mPostBox.ContainsKey(player))
     {
         mPostBox.Remove(player);
     }
 }
Beispiel #3
0
        public Post getPost(Character player)
        {
            if(mPostBox.ContainsKey(player))
            {
                return mPostBox[player];
            }

            return null;
        }
Beispiel #4
0
        public static void sendPartyChange(Character ptr, int partyId)
        {
            GameServer s=getGameServerFromMap(ptr.getMapId());

            if(s!=null)
            {
                MessageOut msg=new MessageOut(Protocol.CGMSG_CHANGED_PARTY);
                msg.writeInt32(ptr.getDatabaseID());
                msg.writeInt32(partyId);
                s.send(msg);
            }
        }
Beispiel #5
0
 public static void registerGameClient(GameServer s, string token, Character ptr)
 {
     MessageOut msg=new MessageOut(Protocol.AGMSG_PLAYER_ENTER);
     msg.writeString(token);
     msg.writeInt32(ptr.getDatabaseID());
     msg.writeString(ptr.getName());
     ptr.serializeCharacterData(msg);
     s.send(msg);
 }
Beispiel #6
0
 public static void registerClient(string token, Character ptr)
 {
     GameServer s=getGameServerFromMap(ptr.getMapId());
     registerGameClient(s, token, ptr);
 }
Beispiel #7
0
 void addCharacter(Character character)
 {
     uint slot=character.getCharacterSlot();
     mCharacters[slot]=character;
 }
Beispiel #8
0
        Character getCharacterBySQL(ISL.Server.Account.Account owner)
        {
            Character character=null;

            string sql=String.Format("SELECT * FROM {0} WHERE user_id = {1}", CHARACTERS_TBL_NAME, owner.getID());
            DataTable charInfo=mDb.ExecuteQuery(sql);

            // If the character is not even in the database then
            // we have no choice but to return nothing.
            if(charInfo.Rows.Count==0)
                return null;

            character=new Character(charInfo.Rows[0]["name"].ToString(), Convert.ToInt32(charInfo.Rows[0]["id"]));
            character.setGender(Convert.ToInt32(charInfo.Rows[0]["gender"]));
            character.setHairStyle(Convert.ToInt32(charInfo.Rows[0]["hair_style"]));
            character.setHairColor(Convert.ToInt32(charInfo.Rows[0]["hair_color"]));
            character.setLevel(Convert.ToInt32(charInfo.Rows[0]["level"]));
            character.setCharacterPoints(Convert.ToInt32(charInfo.Rows[0]["char_pts"]));
            character.setCorrectionPoints(Convert.ToInt32(charInfo.Rows[0]["correct_pts"]));

            Point pos=new Point(Convert.ToInt32(charInfo.Rows[0]["x"]), Convert.ToInt32(charInfo.Rows[0]["y"]));
            character.setPosition(pos);

            int mapId=Convert.ToInt32(charInfo.Rows[0]["map_id"]);
            if(mapId>0)
            {
                character.setMapId(mapId);
            }
            else
            {
                // Set character to default map and one of the default location
                // Default map is to be 1, as not found return value will be 0.
                character.setMapId(Configuration.getValue("char_defaultMap", 1));
            }

            character.setCharacterSlot(Convert.ToUInt32(charInfo.Rows[0]["slot"]));

            // Fill the account-related fields. Last step, as it may require a new
            // SQL query.
            if(owner!=null)
            {
                character.setAccount(owner);
            }
            else
            {
                int id=Convert.ToInt32(charInfo.Rows[0]["user_id"]);
                character.setAccountID(id);

                string s=String.Format("SELECT level FROM {0} WHERE id = '{1}';", ACCOUNTS_TBL_NAME, id);
                DataTable levelInfo=mDb.ExecuteQuery(s);

                character.setAccountLevel(Convert.ToInt32(levelInfo.Rows[0]["level"]), true);
            }

            // Load attributes."
            string s2=String.Format("SELECT attr_id, attr_base, attr_mod FROM {0} WHERE char_id = {1};", CHAR_ATTR_TBL_NAME, character.getDatabaseID());
            DataTable attrInfo=mDb.ExecuteQuery(s2);

            if(attrInfo.Rows.Count>0)
            {
                uint nRows=(uint)attrInfo.Rows.Count;

                for(uint row = 0;row < nRows;++row)
                {
                    uint id=Convert.ToUInt32(charInfo.Rows[0]["attr_id"]);
                    character.setAttribute(id, Convert.ToDouble(charInfo.Rows[0]["attr_base"]));
                    character.setModAttribute(id, Convert.ToDouble(charInfo.Rows[0]["attr_mod"]));
                }
            }

            // Load the skills of the char from CHAR_SKILLS_TBL_NAME
            string s3=String.Format("SELECT status_id, status_time FROM {0} WHERE char_id = {1};", CHAR_STATUS_EFFECTS_TBL_NAME, character.getDatabaseID());
            DataTable skillInfo=mDb.ExecuteQuery(s3);

            if(skillInfo.Rows.Count>0)
            {
                uint nRows=(uint)skillInfo.Rows.Count;
                for(uint row = 0;row < nRows;row++)
                {
                    character.setExperience(
                            Convert.ToInt32(skillInfo.Rows[0]["status_id"]),  // Skill Id
                            Convert.ToInt32(skillInfo.Rows[0]["status_time"])); // Experience
                }
            }

            // Load the status effect
            string s4=String.Format("SELECT status_id, status_time FROM {0} WHERE char_id = {1};", CHAR_STATUS_EFFECTS_TBL_NAME, character.getDatabaseID());
            DataTable statusInfo=mDb.ExecuteQuery(s4);

            if(statusInfo.Rows.Count>0)
            {
                uint nRows=(uint)statusInfo.Rows.Count;
                for(uint row = 0;row < nRows;row++)
                {
                    character.applyStatusEffect(
                            Convert.ToInt32(statusInfo.Rows[0]["status_id"]), // Status Id
                            Convert.ToInt32(statusInfo.Rows[0]["status_time"])); // Time
                }
            }

            // Load the kill stats
            string s5=String.Format("SELECT monster_id, kills FROM {0} WHERE char_id = {1};", CHAR_KILL_COUNT_TBL_NAME, character.getDatabaseID());
            DataTable killsInfo=mDb.ExecuteQuery(s5);

            if(killsInfo.Rows.Count>0)
            {
                uint nRows=(uint)killsInfo.Rows.Count;
                for(uint row = 0;row < nRows;row++)
                {
                    character.setKillCount(
                            Convert.ToInt32(killsInfo.Rows[0]["monster_id"]), // MonsterID
                            Convert.ToInt32(killsInfo.Rows[0]["kills"])); // Kills
                }
            }

            // Load the special status
            string s6=String.Format("SELECT special_id FROM {0} WHERE char_id = {1};", CHAR_SPECIALS_TBL_NAME, character.getDatabaseID());
            DataTable specialsInfo=mDb.ExecuteQuery(s6);

            if(specialsInfo.Rows.Count>0)
            {
                uint nRows=(uint)specialsInfo.Rows.Count;
                for(uint row = 0;row < nRows;row++)
                {
                    character.giveSpecial(Convert.ToInt32(specialsInfo.Rows[0]["special_id"]));
                }
            }

            Possessions poss=character.getPossessions();

            string s7=String.Format("SELECT slot_type, item_id, item_instance FROM {0} WHERE owner_id = '{1}' ORDER BY slot_type desc;", CHAR_EQUIPS_TBL_NAME, character.getDatabaseID());
            DataTable equipInfo=mDb.ExecuteQuery(s7);

            Dictionary< uint, EquipmentItem > equipData=new Dictionary<uint, EquipmentItem>();

            if(equipInfo.Rows.Count>0)
            {
                EquipmentItem equipItem=new EquipmentItem();

                for(int k = 0, size = equipInfo.Rows.Count;k < size;++k)
                {
                    equipItem.itemId=Convert.ToUInt32(equipInfo.Rows[0]["item_id"]);
                    equipItem.itemInstance=Convert.ToUInt32(equipInfo.Rows[0]["item_instance"]);
                    equipData.Add(Convert.ToUInt32(equipInfo.Rows[0]["slot_type"]), equipItem);
                }
            }

            poss.setEquipment(equipData);

            string s8=String.Format("SELECT * FROM {0} WHERE owner_id = '{1}' ORDER by slot ASC", INVENTORIES_TBL_NAME, character.getDatabaseID());
            DataTable itemInfo=mDb.ExecuteQuery(s8);

            Dictionary<uint, InventoryItem > inventoryData=new Dictionary<uint, InventoryItem>();

            if(itemInfo.Rows.Count>0)
            {
                for(int k = 0, size = itemInfo.Rows.Count;k < size;++k)
                {
                    InventoryItem item=new InventoryItem();
                    ushort slot=Convert.ToUInt16(itemInfo.Rows[0]["slot"]);
                    item.itemId=Convert.ToUInt32(itemInfo.Rows[0]["class_id"]);
                    item.amount=Convert.ToUInt32(itemInfo.Rows[0]["amount"]);
                    inventoryData[slot]=item;
                }
            }

            poss.setInventory(inventoryData);

            return character;
        }
Beispiel #9
0
        public bool updateCharacter(Character character)
        {
            //dal::PerformTransaction transaction(mDb);

            //try
            //{
            //    // Update the database Character data (see CharacterData for details)
            //    std::ostringstream sqlUpdateCharacterInfo;
            //    sqlUpdateCharacterInfo
            //        << "update "        << CHARACTERS_TBL_NAME << " "
            //        << "set "
            //        << "gender = '"     << character.getGender() << "', "
            //        << "hair_style = '" << character.getHairStyle() << "', "
            //        << "hair_color = '" << character.getHairColor() << "', "
            //        << "level = '"      << character.getLevel() << "', "
            //        << "char_pts = '"   << character.getCharacterPoints() << "', "
            //        << "correct_pts = '"<< character.getCorrectionPoints() << "', "
            //        << "x = '"          << character.getPosition().x << "', "
            //        << "y = '"          << character.getPosition().y << "', "
            //        << "map_id = '"     << character.getMapId() << "', "
            //        << "slot = '"     << character.getCharacterSlot() << "' "
            //        << "where id = '"   << character.getDatabaseID() << "';";

            //    mDb.execSql(sqlUpdateCharacterInfo.str());
            //}
            //catch (const dal::DbSqlQueryExecFailure& e)
            //{
            //    utils::throwError("(DALStorage::updateCharacter #1) "
            //                      "SQL query failure: ", e);
            //}

            //// Character attributes.
            //try
            //{
            //    for (AttributeMap::const_iterator it = character.mAttributes.begin(),
            //         it_end = character.mAttributes.end(); it != it_end; ++it)
            //        updateAttribute(character.getDatabaseID(), it.first,
            //                        it.second.base, it.second.modified);
            //}
            //catch (const dal::DbSqlQueryExecFailure &e)
            //{
            //    utils::throwError("(DALStorage::updateCharacter #2) "
            //                      "SQL query failure: ", e);
            //}

            //// Character's skills
            //try
            //{
            //    std::map<int, int>::const_iterator skill_it;
            //    for (skill_it = character.mExperience.begin();
            //         skill_it != character.mExperience.end(); skill_it++)
            //    {
            //        updateExperience(character.getDatabaseID(),
            //                         skill_it.first, skill_it.second);
            //    }
            //}
            //catch (const dal::DbSqlQueryExecFailure& e)
            //{
            //    utils::throwError("(DALStorage::updateCharacter #3) "
            //                      "SQL query failure: ", e);
            //}

            //// Character's kill count
            //try
            //{
            //    std::map<int, int>::const_iterator kill_it;
            //    for (kill_it = character.getKillCountBegin();
            //         kill_it != character.getKillCountEnd(); kill_it++)
            //    {
            //        updateKillCount(character.getDatabaseID(),
            //                        kill_it.first, kill_it.second);
            //    }
            //}
            //catch (const dal::DbSqlQueryExecFailure& e)
            //{
            //    utils::throwError("(DALStorage::updateCharacter #4) "
            //                      "SQL query failure: ", e);
            //}

            ////  Character's special actions
            //try
            //{
            //    // Out with the old
            //    std::ostringstream deleteSql("");
            //    std::ostringstream insertSql;
            //    deleteSql   << "DELETE FROM " << CHAR_SPECIALS_TBL_NAME
            //                << " WHERE char_id='"
            //                << character.getDatabaseID() << "';";
            //    mDb.execSql(deleteSql.str());
            //    // In with the new
            //    std::map<int, Special*>::const_iterator special_it;
            //    for (special_it = character.getSpecialBegin();
            //         special_it != character.getSpecialEnd(); special_it++)
            //    {
            //        insertSql.str("");
            //        insertSql   << "INSERT INTO " << CHAR_SPECIALS_TBL_NAME
            //                    << " (char_id, special_id) VALUES ("
            //                    << " '" << character.getDatabaseID() << "',"
            //                    << " '" << special_it.first << "');";
            //        mDb.execSql(insertSql.str());
            //    }
            //}
            //catch (const dal::DbSqlQueryExecFailure& e)
            //{
            //    utils::throwError("(DALStorage::updateCharacter #5) "
            //                      "SQL query failure: ", e);;
            //}

            //// Character's inventory
            //// Delete the old inventory and equipment table first
            //try
            //{
            //    std::ostringstream sqlDeleteCharacterEquipment;
            //    sqlDeleteCharacterEquipment
            //        << "delete from " << CHAR_EQUIPS_TBL_NAME
            //        << " where owner_id = '" << character.getDatabaseID() << "';";
            //    mDb.execSql(sqlDeleteCharacterEquipment.str());

            //    std::ostringstream sqlDeleteCharacterInventory;
            //    sqlDeleteCharacterInventory
            //        << "delete from " << INVENTORIES_TBL_NAME
            //        << " where owner_id = '" << character.getDatabaseID() << "';";
            //    mDb.execSql(sqlDeleteCharacterInventory.str());
            //}
            //catch (const dal::DbSqlQueryExecFailure& e)
            //{
            //    utils::throwError("(DALStorage::updateCharacter #6) "
            //                      "SQL query failure: ", e);
            //}

            //// Insert the new inventory data
            //try
            //{
            //    std::ostringstream sql;

            //    sql << "insert into " << CHAR_EQUIPS_TBL_NAME
            //        << " (owner_id, slot_type, item_id, item_instance) values ("
            //        << character.getDatabaseID() << ", ";
            //    std::string base = sql.str();

            //    const Possessions &poss = character.getPossessions();
            //    const EquipData &equipData = poss.getEquipment();
            //    for (EquipData::const_iterator it = equipData.begin(),
            //         it_end = equipData.end(); it != it_end; ++it)
            //    {
            //            sql.str("");
            //            sql << base << it.first << ", " << it.second.itemId
            //                << ", " << it.second.itemInstance << ");";
            //            mDb.execSql(sql.str());
            //    }

            //    sql.str("");

            //    sql << "insert into " << INVENTORIES_TBL_NAME
            //        << " (owner_id, slot, class_id, amount) values ("
            //        << character.getDatabaseID() << ", ";
            //    base = sql.str();

            //    const InventoryData &inventoryData = poss.getInventory();
            //    for (InventoryData::const_iterator j = inventoryData.begin(),
            //         j_end = inventoryData.end(); j != j_end; ++j)
            //    {
            //        sql.str("");
            //        unsigned short slot = j.first;
            //        unsigned int itemId = j.second.itemId;
            //        unsigned int amount = j.second.amount;
            //        assert(itemId);
            //        sql << base << slot << ", " << itemId << ", " << amount << ");";
            //        mDb.execSql(sql.str());
            //    }

            //}
            //catch (const dal::DbSqlQueryExecFailure& e)
            //{
            //    utils::throwError("(DALStorage::updateCharacter #7) "
            //                      "SQL query failure: ", e);
            //}

            //// Update char status effects
            //try
            //{
            //    // Delete the old status effects first
            //    std::ostringstream sql;

            //    sql << "delete from " << CHAR_STATUS_EFFECTS_TBL_NAME
            //        << " where char_id = '" << character.getDatabaseID() << "';";

            //     mDb.execSql(sql.str());
            //}
            //catch (const dal::DbSqlQueryExecFailure& e)
            //{
            //    utils::throwError("(DALStorage::updateCharacter #8) "
            //                      "SQL query failure: ", e);
            //}
            //try
            //{
            //    std::map<int, int>::const_iterator status_it;
            //    for (status_it = character.getStatusEffectBegin();
            //         status_it != character.getStatusEffectEnd(); status_it++)
            //    {
            //        insertStatusEffect(character.getDatabaseID(),
            //                           status_it.first, status_it.second);
            //    }
            //}
            //catch (const dal::DbSqlQueryExecFailure& e)
            //{
            //    utils::throwError("(DALStorage::updateCharacter #9) "
            //                      "SQL query failure: ", e);
            //}

            //transaction.commit();
            return true;
        }
Beispiel #10
0
        void handleCharacterCreateMessage(AccountClient client, MessageIn msg)
        {
            string name=msg.readString();
            int hairStyle=msg.readInt8();
            int hairColor=msg.readInt8();
            int gender=msg.readInt8();

            // Avoid creation of character from old clients.
            //            int slot=-1;
            //            if(msg.getUnreadLength()>7)
            //            {
            int slot=msg.readInt8();
            //            }

            MessageOut reply=new MessageOut(Protocol.APMSG_CHAR_CREATE_RESPONSE);

            ISL.Server.Account.Account acc=client.getAccount();

            if(acc==null)
            {
                reply.writeInt8((byte)ErrorMessage.ERRMSG_NO_LOGIN);
            }
            else if(!Program.stringFilter.filterContent(name))
            {
                reply.writeInt8((byte)ErrorMessage.ERRMSG_INVALID_ARGUMENT);
            }
            else if(Program.stringFilter.findDoubleQuotes(name))
            {
                reply.writeInt8((byte)ErrorMessage.ERRMSG_INVALID_ARGUMENT);
            }
            else if(hairStyle>mNumHairStyles)
            {
                reply.writeInt8((byte)Create.CREATE_INVALID_HAIRSTYLE);
            }
            else if(hairColor>mNumHairColors)
            {
                reply.writeInt8((byte)Create.CREATE_INVALID_HAIRCOLOR);
            }
            else if(gender>mNumGenders)
            {
                reply.writeInt8((byte)Create.CREATE_INVALID_GENDER);
            }
            else if((name.Length<mMinNameLength)||
                (name.Length>mMaxNameLength))
            {
                reply.writeInt8((byte)ErrorMessage.ERRMSG_INVALID_ARGUMENT);
            }
            else
            {
                if(Program.storage.doesCharacterNameExist(name))
                {
                    reply.writeInt8((byte)Create.CREATE_EXISTS_NAME);
                    client.send(reply);
                    return;
                }

                // An account shouldn't have more
                // than <account_maxCharacters> characters.
                Dictionary<uint, ISL.Server.Account.Character> chars=acc.getCharacters();

                if(slot<1||slot>mMaxCharacters||!acc.isSlotEmpty((uint)slot))
                {
                    reply.writeInt8((byte)Create.CREATE_INVALID_SLOT);
                    client.send(reply);
                    return;
                }

                if((int)chars.Count>=mMaxCharacters)
                {
                    reply.writeInt8((byte)Create.CREATE_TOO_MUCH_CHARACTERS);
                    client.send(reply);
                    return;
                }

                // TODO: Add race, face and maybe special attributes.

                // Customization of character's attributes...
                List<int> attributes=new List<int>();
                //std::vector<int>(mModifiableAttributes.size(), 0);
                for(uint i = 0;i < mModifiableAttributes.Count;++i)
                {
                    attributes.Add(msg.readInt16());
                }

                int totalAttributes=0;
                for(uint i = 0;i < mModifiableAttributes.Count;++i)
                {
                    // For good total attributes check.
                    totalAttributes+=attributes[(int)i];

                    // For checking if all stats are >= min and <= max.
                    if(attributes[(int)i]<mAttributeMinimum
                        ||attributes[(int)i]>mAttributeMaximum)
                    {
                        reply.writeInt8((byte)Create.CREATE_ATTRIBUTES_OUT_OF_RANGE);
                        client.send(reply);
                        return;
                    }
                }

                if(totalAttributes>mStartingPoints)
                {
                    reply.writeInt8((byte)Create.CREATE_ATTRIBUTES_TOO_HIGH);
                }
                else if(totalAttributes<mStartingPoints)
                {
                    reply.writeInt8((byte)Create.CREATE_ATTRIBUTES_TOO_LOW);
                }
                else
                {
                    Character newCharacter=new Character(name);

                    // Set the initial attributes provided by the client
                    for(uint i = 0;i < mModifiableAttributes.Count;++i)
                    {
                        //TODO schauen was hier genau passieren muss
                        //newCharacter.mAttributes.Add((uint)(mModifiableAttributes[(int)i]), mModifiableAttributes[i]);
                        //newCharacter.mAttributes.Add((uint)mModifiableAttributes[(int)i], attributes[(int)i]);
                    }

                    foreach(KeyValuePair<uint, Attribute> defaultAttributePair in mDefaultAttributes)
                    {
                        //TODO schauen was hier genau passieren muss
                        // newCharacter.mAttributes.Add(defaultAttributePair.Key, defaultAttributePair.Value);
                    }

                    newCharacter.setAccount(acc);
                    newCharacter.setCharacterSlot((uint)slot);
                    newCharacter.setGender(gender);
                    newCharacter.setHairStyle(hairStyle);
                    newCharacter.setHairColor(hairColor);
                    newCharacter.setMapId(Configuration.getValue("char_startMap", 1));
                    Point startingPos=new Point(Configuration.getValue("char_startX", 1024),
                                      Configuration.getValue("char_startY", 1024));
                    newCharacter.setPosition(startingPos);
                    acc.addCharacter(newCharacter);

                    Logger.Write(LogLevel.Information, "Character {0} was created for {1}'s account.", name, acc.getName());

                    Program.storage.flush(acc); // flush changes

                    // log transaction
                    Transaction trans=new Transaction();
                    trans.mCharacterId=(uint)newCharacter.getDatabaseID();
                    trans.mAction=(uint)TransactionMembers.TRANS_CHAR_CREATE;
                    trans.mMessage=acc.getName()+" created character ";
                    trans.mMessage+="called "+name;
                    Program.storage.addTransaction(trans);

                    reply.writeInt8((byte)ErrorMessage.ERRMSG_OK);
                    client.send(reply);

                    // Send new characters infos back to client
                    sendCharacterData(client, chars[(uint)slot]);
                    return;
                }
            }

            client.send(reply);
        }
Beispiel #11
0
 void delCharacter(Character character)
 {
     //delCharacter(character.getDatabaseID());
 }
Beispiel #12
0
        void sendCharacterData(AccountClient client, Character ch)
        {
            MessageOut charInfo=new MessageOut(Protocol.APMSG_CHAR_INFO);

            charInfo.writeInt8((int)ch.getCharacterSlot());
            charInfo.writeString(ch.getName());
            charInfo.writeInt8(ch.getGender());
            charInfo.writeInt8(ch.getHairStyle());
            charInfo.writeInt8(ch.getHairColor());
            charInfo.writeInt16(ch.getLevel());
            charInfo.writeInt16(ch.getCharacterPoints());
            charInfo.writeInt16(ch.getCorrectionPoints());

            foreach(KeyValuePair<uint, AttributeValue> at in ch.mAttributes)
            {
                charInfo.writeInt32((int)at.Key);
                charInfo.writeInt32((int)(at.Value.@base*256));
                charInfo.writeInt32((int)(at.Value.modified*256));
            }

            client.send(charInfo);
        }
Beispiel #13
0
 void flushSkill(Character character, int skillId)
 {
     // Note: Deprecated, use DALStorage::updateExperience instead!!!
     // TODO: Remove calls of flushSkill for updateExperience instead.
     //updateExperience(character.getDatabaseID(), skillId,
     //    character.getExperience(skillId));
 }
Beispiel #14
0
        public static void deserializeCharacterData(Character data, MessageIn msg)
        {
            //// general character properties
            //data.setAccountLevel(msg.readInt8());
            //data.setGender(ManaServ.getGender(msg.readInt8()));
            //data.setHairStyle(msg.readInt8());
            //data.setHairColor(msg.readInt8());
            //data.setLevel(msg.readInt16());
            //data.setCharacterPoints(msg.readInt16());
            //data.setCorrectionPoints(msg.readInt16());

            //// character attributes
            //uint attrSize = (uint)msg.readInt16();
            //for (uint i = 0; i < attrSize; ++i)
            //{
            //    uint id = msg.readInt16();
            //    double @base = msg.readDouble(),
            //           mod  = msg.readDouble();
            //    data.setAttribute(id, @base);
            //    data.setModAttribute(id, mod);
            //}

            //// character skills
            //int skillSize = msg.readInt16();

            //for (int i = 0; i < skillSize; ++i)
            //{
            //    int skill = msg.readInt16();
            //    int level = msg.readInt32();
            //    data.setExperience(skill,level);
            //}

            //// status effects currently affecting the character
            //int statusSize = msg.readInt16();

            //for (int i = 0; i < statusSize; i++)
            //{
            //    int status = msg.readInt16();
            //    int time = msg.readInt16();
            //    data.applyStatusEffect(status, time);
            //}

            //// location
            //data.setMapId(msg.readInt16());

            //Point temporaryPoint;
            //temporaryPoint.x = msg.readInt16();
            //temporaryPoint.y = msg.readInt16();
            //data.setPosition(temporaryPoint);

            //// kill count
            //int killSize = msg.readInt16();
            //for (int i = 0; i < killSize; i++)
            //{
            //    int monsterId = msg.readInt16();
            //    int kills = msg.readInt32();
            //    data.setKillCount(monsterId, kills);
            //}

            //// character specials
            //int specialSize = msg.readInt16();
            //data.clearSpecials();
            //for (int i = 0; i < specialSize; i++)
            //{
            //    data.giveSpecial(msg.readInt32());
            //}

            //Possessions &poss = data.getPossessions();
            //EquipData equipData;
            //int equipSlotsSize = msg.readInt16();
            //uint eqSlot;
            //EquipmentItem equipItem;
            //for (int j = 0; j < equipSlotsSize; ++j)
            //{
            //    eqSlot  = msg.readInt16();
            //    equipItem.itemId = msg.readInt16();
            //    equipItem.itemInstance = msg.readInt16();
            //    equipData.insert(equipData.end(),
            //                           std::make_pair(eqSlot, equipItem));
            //}
            //poss.setEquipment(equipData);

            //// Loads inventory - must be last because size isn't transmitted
            //Dictionary<uint, InventoryItem > inventoryData;
            //while (msg.getUnreadLength())
            //{
            //    InventoryItem i;
            //    int slotId = msg.readInt16();
            //    i.itemId   = msg.readInt16();
            //    i.amount   = msg.readInt16();
            //    inventoryData.insert(inventoryData.end(), std::make_pair(slotId, i));
            //}
            //poss.setInventory(inventoryData);
        }
Beispiel #15
0
        public static void serializeCharacterData(Character data, MessageOut msg)
        {
            //// general character properties
            //msg.writeInt8(data.getAccountLevel());
            //msg.writeInt8(data.getGender());
            //msg.writeInt8(data.getHairStyle());
            //msg.writeInt8(data.getHairColor());
            //msg.writeInt16(data.getLevel());
            //msg.writeInt16(data.getCharacterPoints());
            //msg.writeInt16(data.getCorrectionPoints());

            //msg.writeInt16(data.mAttributes.Count);

            //        foreach(KeyValuePair<uint, AttributeValue> pair in data.mAttributes)
            //        {
            //              msg.writeInt16((Int16)pair.Key);
            //    msg.writeDouble(data.getAttrBase(pair));
            //    msg.writeDouble(data.getAttrMod(pair));
            //        }

            //// character skills
            //msg.writeInt16(data.getSkillSize());

            //Dictionary<int, int>::const_iterator skill_it;
            //for (skill_it = data.getSkillBegin(); skill_it != data.getSkillEnd() ; skill_it++)
            //{
            //    msg.writeInt16(skill_it.first);
            //    msg.writeInt32(skill_it.second);
            //}

            //// status effects currently affecting the character
            //msg.writeInt16(data.getStatusEffectSize());
            //std::map<int, int>::const_iterator status_it;
            //for (status_it = data.getStatusEffectBegin(); status_it != data.getStatusEffectEnd(); status_it++)
            //{
            //    msg.writeInt16(status_it.first);
            //    msg.writeInt16(status_it.second);
            //}

            //// location
            //msg.writeInt16(data.getMapId());
            //Point pos = data.getPosition();
            //msg.writeInt16(pos.x);
            //msg.writeInt16(pos.y);

            //// kill count
            //msg.writeInt16(data.getKillCountSize());
            //Dictionary<int, int>::const_iterator kills_it;
            //for (kills_it = data.getKillCountBegin(); kills_it != data.getKillCountEnd(); kills_it++)
            //{
            //    msg.writeInt16(kills_it.first);
            //    msg.writeInt32(kills_it.second);
            //}

            //// character specials
            //Dictionary<int, Special>::const_iterator special_it;
            //msg.writeInt16(data.getSpecialSize());
            //for (special_it = data.getSpecialBegin(); special_it != data.getSpecialEnd() ; special_it++)
            //{
            //    msg.writeInt32(special_it.first);
            //}

            //// inventory - must be last because size isn't transmitted
            //const Possessions &poss = data.getPossessions();
            //const EquipData &equipData = poss.getEquipment();
            //msg.writeInt16(equipData.size()); // number of equipment
            //for (EquipData::const_iterator k = equipData.begin(),
            //         k_end = equipData.end(); k != k_end; ++k)
            //{
            //    msg.writeInt16(k.first);                 // Equip slot id
            //    msg.writeInt16(k.second.itemId);         // ItemId
            //    msg.writeInt16(k.second.itemInstance);   // Item Instance id
            //}

            //const InventoryData &inventoryData = poss.getInventory();
            //for (InventoryData::const_iterator j = inventoryData.begin(),
            //     j_end = inventoryData.end(); j != j_end; ++j)
            //{
            //    msg.writeInt16(j.first);           // slot id
            //    msg.writeInt16(j.second.itemId);   // item id
            //    msg.writeInt16(j.second.amount);   // amount
            //}
        }
Beispiel #16
0
        void sendCharacterData(AccountClient client, Character ch)
        {
            MessageOut charInfo=new MessageOut(Protocol.APMSG_CHAR_INFO);

            //charInfo.writeInt8(ch.getCharacterSlot());
            //charInfo.writeString(ch.getName());
            //charInfo.writeInt8(ch.getGender());
            //charInfo.writeInt8(ch.getHairStyle());
            //charInfo.writeInt8(ch.getHairColor());
            //charInfo.writeInt16(ch.getLevel());
            //charInfo.writeInt16(ch.getCharacterPoints());
            //charInfo.writeInt16(ch.getCorrectionPoints());

            //for (AttributeMap::const_iterator it = ch.mAttributes.begin(),
            //                                  it_end = ch.mAttributes.end();
            //    it != it_end;
            //    ++it)
            //{
            //    // {id, base value in 256ths, modified value in 256ths }*
            //    charInfo.writeInt32(it.first);
            //    charInfo.writeInt32((int) (it.second.base * 256));
            //    charInfo.writeInt32((int) (it.second.modified * 256));
            //}

            //client.send(charInfo);
        }