private static void WritePlayer(Packet pPacket, DatabaseQuery pQuery)
        {
            pPacket.WriteInt((int)pQuery["identifier"]);
            pPacket.WritePaddedString((string)pQuery["name"], 13);

            pPacket.WriteByte((byte)pQuery["gender"]);
            pPacket.WriteByte((byte)pQuery["skin"]);
            pPacket.WriteInt((int)pQuery["eyes_identifier"]);
            pPacket.WriteInt((int)pQuery["hair_identifier"]);
            pPacket.WriteSkip(24);
            pPacket.WriteByte((byte)pQuery["level"]);
            pPacket.WriteUShort((ushort)pQuery["job"]);
            pPacket.WriteUShort((ushort)pQuery["strength"]);
            pPacket.WriteUShort((ushort)pQuery["dexterity"]);
            pPacket.WriteUShort((ushort)pQuery["intellect"]);
            pPacket.WriteUShort((ushort)pQuery["luck"]);
            pPacket.WriteUShort((ushort)pQuery["health"]);
            pPacket.WriteUShort((ushort)pQuery["max_health"]);
            pPacket.WriteUShort((ushort)pQuery["mana"]);
            pPacket.WriteUShort((ushort)pQuery["max_mana"]);
            pPacket.WriteUShort((ushort)pQuery["ability_points"]);
            pPacket.WriteUShort((ushort)pQuery["skill_points"]);
            pPacket.WriteInt((int)pQuery["experience"]);
            pPacket.WriteUShort((ushort)pQuery["fame"]);
            pPacket.WriteSkip(4);
            pPacket.WriteInt((int)pQuery["map_identifier"]);
            pPacket.WriteByte((byte)pQuery["map_spawn"]);
            pPacket.WriteSkip(4);

            pPacket.WriteByte((byte)pQuery["gender"]);
            pPacket.WriteByte((byte)pQuery["skin"]);
            pPacket.WriteInt((int)pQuery["eyes_identifier"]);
            pPacket.WriteBool(true);
            pPacket.WriteInt((int)pQuery["hair_identifier"]);

            SortedDictionary<byte, Doublet<int, int>> equipment = new SortedDictionary<byte, Doublet<int, int>>();
            using (DatabaseQuery queryEquipment = Database.Query("SELECT inventory_slot,item_identifier FROM player_item WHERE player_identifier=@player_identifier AND inventory_type=0 AND inventory_slot<0", new MySqlParameter("@player_identifier", (int)pQuery["identifier"])))
            {
                while (queryEquipment.NextRow())
                {
                    short slot = (short)(-((short)queryEquipment["inventory_slot"]));
                    if (slot > 100) slot -= 100;
                    Doublet<int, int> pair = equipment.GetOrDefault((byte)slot, null);
                    if (pair == null)
                    {
                        pair = new Doublet<int, int>((int)queryEquipment["item_identifier"], 0);
                        equipment.Add((byte)slot, pair);
                    }
                    else if ((short)queryEquipment["inventory_slot"] < -100)
                    {
                        pair.Second = pair.First;
                        pair.First = (int)queryEquipment["item_identifier"];
                    }
                    else pair.Second = (int)queryEquipment["item_identifier"];
                }
            }
            foreach (KeyValuePair<byte, Doublet<int, int>> pair in equipment)
            {
                pPacket.WriteByte(pair.Key);
                if (pair.Key == 11 && pair.Value.Second > 0) pPacket.WriteInt(pair.Value.Second);
                else pPacket.WriteInt(pair.Value.First);
            }
            pPacket.WriteByte(0xFF);
            foreach (KeyValuePair<byte, Doublet<int, int>> pair in equipment)
            {
                if (pair.Key != 11 && pair.Value.Second > 0)
                {
                    pPacket.WriteByte(pair.Key);
                    pPacket.WriteInt(pair.Value.Second);
                }
            }
            pPacket.WriteByte(0xFF);
            Doublet<int, int> cashWeapon = equipment.GetOrDefault((byte)11, null);
            pPacket.WriteInt(cashWeapon == null ? 0 : cashWeapon.First);
            pPacket.WriteSkip(12);

            pPacket.WriteBool(false);
        }
 private static void SendAuthentication(Client pClient, EAuthenticationResult pResult)
 {
     Packet packet = new Packet(EOpcode.SMSG_AUTHENTICATION);
     packet.WriteUInt((uint)pResult);
     packet.WriteSkip(2);
     if (pClient.Account != null)
     {
         packet.WriteInt(pClient.Account.Identifier);
         packet.WriteSkip(4);
         packet.WriteString(pClient.Account.Username);
         packet.WriteSkip(22);
     }
     pClient.SendPacket(packet);
 }
 private static void SendChannelConnect(Client pClient, int pPlayerIdentifier)
 {
     Packet packet = new Packet(EOpcode.SMSG_CHANNEL_CONNECT);
     packet.WriteByte(0x00);
     packet.WriteByte(0x00);
     packet.WriteBytes(IPAddress.Parse(Config.Instance.Channel.ExternalAddress).GetAddressBytes());
     packet.WriteUShort(Config.Instance.Channel.Listener.Port);
     packet.WriteInt(pPlayerIdentifier);
     packet.WriteSkip(5);
     pClient.SendPacket(packet);
 }
예제 #4
0
 internal void SendInitialMapChange()
 {
     Packet packet = new Packet(EOpcode.SMSG_MAP_CHANGE);
     packet.WriteUInt(0);
     packet.WriteByte(0x01);
     packet.WriteByte(0x01);
     packet.WriteUShort(0);
     packet.WriteInt(mRandom.Next());
     packet.WriteInt(mRandom.Next());
     packet.WriteInt(mRandom.Next());
     packet.WriteInt(-1);
     packet.WriteInt(-1);
     packet.WriteInt(mIdentifier);
     packet.WritePaddedString(mName, 13);
     packet.WriteByte(mGender);
     packet.WriteByte(mSkin);
     packet.WriteInt(mEyesIdentifier);
     packet.WriteInt(mHairIdentifier);
     packet.WriteSkip(24);
     packet.WriteByte(mLevel);
     packet.WriteUShort(mJob);
     packet.WriteUShort(mStrength);
     packet.WriteUShort(mDexterity);
     packet.WriteUShort(mIntellect);
     packet.WriteUShort(mLuck);
     packet.WriteUShort(mHealth);
     packet.WriteUShort(mMaxHealth);
     packet.WriteUShort(mMana);
     packet.WriteUShort(mMaxMana);
     packet.WriteUShort(mAbilityPoints);
     packet.WriteUShort(mSkillPoints);
     packet.WriteInt(mExperience);
     packet.WriteUShort(mFame);
     packet.WriteUInt(0);
     packet.WriteInt(mMap.Data.Identifier);
     packet.WriteByte(mSpawn);
     packet.WriteUInt(0);
     packet.WriteByte(mBuddies.MaxBuddies);
     mItems.WriteInitial(packet);
     mSkills.WriteInitial(packet);
     mQuests.WriteInitial(packet);
     packet.WriteUInt(0);
     packet.WriteUInt(0);
     mTeleports.WriteInitial(packet);
     mCards.WriteInitial(packet);
     packet.WriteUInt(0);
     packet.WriteUShort(0);
     packet.WriteLong(DateTime.Now.ToBinary());
     mClient.SendPacket(packet);
 }