Example #1
0
        /// <summary>
        /// Executes the command and sends response.
        /// </summary>
        /// <param name="s">The session.</param>
        /// <param name="p">The package info.</param>
        public override void ExecuteCommand(Session s, Package p)
        {
            PacketBRequestRetrievePersistentData Request = new PacketBRequestRetrievePersistentData(p.Content);

            if (s.Logger.IsDebugEnabled)
            {
                s.Logger.Debug($"Execute command: {Request}");
            }

            _SendResponseCharacterInit(s, p, Request);
            _SendResponseCharacterDetails(s, p, Request);

            _SendResponseStringListProtoUnits(s, p, Request);
            _SendResponseStringListDesignsLearned(s, p, Request);
            _SendResponseStringListTechsActive(s, p, Request);
            _SendResponseStringListTechsCapital(s, p, Request);
            _SendResponseStringListTraits(s, p, Request);
            _SendResponseStringListQuestsCompleted(s, p, Request);
            _SendResponseStringListQuests(s, p, Request);
            _SendResponseStringListCapitalResources(s, p, Request);
            _SendResponseStringListRegions(s, p, Request);
            _SendResponseStringListRegionsUnlocked(s, p, Request);
            _SendResponseStringListAdvisorsAvailable(s, p, Request);
            _SendResponseStringListAdvisorsAssigned(s, p, Request);
            _SendResponseStringListCharacterConfig(s, p, Request);
            _SendResponseStringListCraftSchools(s, p, Request);
            _SendResponseStringListVendorKickbacks(s, p, Request);
            _SendResponseStringListVanities(s, p, Request);

            _SendGameCurrency(s, p, Request);

            _SendCharacterPersistenceDone(s, p, Request);


            /*
             *
             * @TODO:
             * QuestGivers = 8,
             * Inventory = 9,
             * CapitalLockedTiles = 10,
             * CraftSchool2 = 20,
             * TerritoriesModified = 21,
             * Events = 24
             *
             * // QuestGiverInstance
             * new BCharacterStringListPacket(StringListTypes.QuestGiverInstance, BRequestRetrievePersistentData.characterID, chRequestID, this).send();
             *
             * // BQuestGiverSpawnUnitPacket
             * new BQuestGiverSpawnUnitPacket(chRequestID, this).send();
             *
             * // QuestInstance
             * new BCharacterStringListPacket(StringListTypes.QuestInstance, BRequestRetrievePersistentData.characterID, chRequestID, this).send();
             *
             * // BResponseQuestListData
             * new BResponseQuestListData(chRequestID, this).send();
             *
             */
        }
        /// <summary>
        /// Executes the command and sends response.
        /// </summary>
        /// <param name="s">The session.</param>
        /// <param name="p">The package info.</param>
        public override void ExecuteCommand(Session s, Package p)
        {
            PacketBRequestRetrievePersistentData Request = new PacketBRequestRetrievePersistentData(p.Content);

            SendResponseCharacterInit(s, p, Request);
            SendResponseCharacterDetails(s, p);

            //SendResponseStringListProtoUnits(s, p);
            //SendResponseStringListDesignsLearned(s, p);
            SendResponseStringListTechsActive(s, p);
            SendResponseStringListTechsCapital(s, p);
            //SendResponseStringListTraits(s, p);
            //SendResponseStringListQuestsCompleted(s, p);
            //SendResponseStringListCapitalResources(s, p);
            SendResponseStringListRegions(s, p);
            SendResponseStringListRegionsUnlocked(s, p);
            //SendResponseStringListAdvisorsAvailable(s, p);
            SendResponseStringListAdvisorsAssigned(s, p);
            SendResponseStringListCharacterConfig(s, p);
            //SendResponseStringListCraftSchools(s, p);
            //SendResponseStringListVanities(s, p);

            SendGameCurrency(s, p);

            SendCharacterPersistenceDone(s, p);

            SendResponseStringListQuestsInstances(s, p);

            BRequestRegionMap.SendResponseQuestGivers(s, p);

            SendResponseQuestList(s, p);


            /*
             *
             * @TODO:
             * Inventory = 9,
             * CapitalLockedTiles = 10,
             * CraftSchool2 = 20,
             * TerritoriesModified = 21,
             * Events = 24
             *
             *
             *
             */
        }
Example #3
0
        /// <summary>
        /// Sends BCharacterInitPacket.
        /// </summary>
        /// <param name="s">The session.</param>
        /// <param name="p">Packet BRequestRetrievePersistentData.</param>
        /// <param name="r">Packet BRequestRetrievePersistentData content.</param>
        private static void _SendResponseCharacterInit(Session s, Package p, PacketBRequestRetrievePersistentData r)
        {
            PacketBCharacterInitPacket ResponseContent = new PacketBCharacterInitPacket(s.CharacterName, string.Empty, s.CharacterFlags, r.CharacterId, r.Xuid, s.CharacterCivilizationId);

            if (s.Logger.IsDebugEnabled)
            {
                s.Logger.Debug($"Command response: {ResponseContent}");
            }

            byte[] Response = ResponseContent.ToByteArray();

            Package Package = new Package(p.HeaderXuid, p.HeaderField20, p.HeaderServiceId, p.HeaderField22, (byte)PacketTypes.BCharacterInitPacket, p.HeaderRequestId, Response);

            byte[] ToSend = Package.ToByteArray();

            s.Send(ToSend, 0, ToSend.Length);
        }
Example #4
0
        /// <summary>
        /// Sends BCharacterPersistenceDone.
        /// </summary>
        /// <param name="s">The session.</param>
        /// <param name="p">Packet BRequestRetrievePersistentData.</param>
        /// <param name="r">Packet BRequestRetrievePersistentData content.</param>
        private static void _SendCharacterPersistenceDone(Session s, Package p, PacketBRequestRetrievePersistentData r)
        {
            PacketBCharacterPersistenceDone ResponseContent = new PacketBCharacterPersistenceDone(r.CharacterId);

            if (s.Logger.IsDebugEnabled)
            {
                s.Logger.Debug($"Command response: {ResponseContent}");
            }

            byte[] Response = ResponseContent.ToByteArray();

            Package Package = new Package(p.HeaderXuid, p.HeaderField20, p.HeaderServiceId, p.HeaderField22, (byte)PacketTypes.BCharacterPersistenceDone, p.HeaderRequestId, Response);

            byte[] ToSend = Package.ToByteArray();

            s.Send(ToSend, 0, ToSend.Length);
        }
Example #5
0
        /// <summary>
        /// Sends BCharacterDetailsPacket.
        /// </summary>
        /// <param name="s">The session.</param>
        /// <param name="p">Packet BRequestRetrievePersistentData.</param>
        /// <param name="r">Packet BRequestRetrievePersistentData content.</param>
        private static void _SendResponseCharacterDetails(Session s, Package p, PacketBRequestRetrievePersistentData r)
        {
            PacketBCharacterDetailsPacket ResponseContent = new PacketBCharacterDetailsPacket(s.CharacterName, r.CharacterId, s.CharacterLevel, s.CharacterXp, s.CharacterMaxAge, s.CharacterMaxLevelXp, s.Region, s.SkillPoints, s.SkillResetPoints);

            if (s.Logger.IsDebugEnabled)
            {
                s.Logger.Debug($"Command response: {ResponseContent}");
            }

            byte[] Response = ResponseContent.ToByteArray();

            Package Package = new Package(p.HeaderXuid, p.HeaderField20, p.HeaderServiceId, p.HeaderField22, (byte)PacketTypes.BCharacterDetailsPacket, p.HeaderRequestId, Response);

            byte[] ToSend = Package.ToByteArray();

            s.Send(ToSend, 0, ToSend.Length);
        }
        /// <summary>
        /// Sends BCharacterInitPacket.
        /// </summary>
        /// <param name="s">The session.</param>
        /// <param name="p">Packet BRequestRetrievePersistentData.</param>
        /// <param name="r">Packet BRequestRetrievePersistentData content.</param>
        public static void SendResponseCharacterInit(Session s, Package p, PacketBRequestRetrievePersistentData r)
        {
            //@TODO
            // Use the real Xuid instead of r.Xuid
            // See issue https://github.com/firesinging/xlive/issues/2

            Player ObjPlayer = s.Player;

            ObjPlayer.Empire.SetLastLaunchedCharacter(r.CharacterId);

            PacketBCharacterInitPacket ResponseContent = new PacketBCharacterInitPacket(ObjPlayer.Empire.CurrentCharacter.Name, string.Empty, ObjPlayer.Empire.CurrentCharacter.Flag, ObjPlayer.Empire.CurrentCharacter.Id, r.Xuid, ObjPlayer.Empire.CurrentCharacter.CivId);

            Logger.Debug($"{p.Key}::SendResponseCharacterInit - Execute command: {ResponseContent}");

            byte[] Response = ResponseContent.ToByteArray();

            Package Package = new Package(p.HeaderXuid, p.HeaderField20, p.HeaderServiceId, p.HeaderField22, PacketTypes.BCharacterInitPacket, p.HeaderRequestId, Response);

            byte[] ToSend = Package.ToByteArray();

            s.Send(ToSend, 0, ToSend.Length);
        }
Example #7
0
        /// <summary>
        /// Sends BGameCurrencyPacket for game currencies.
        /// </summary>
        /// <param name="s">The session.</param>
        /// <param name="p">Packet BRequestRetrievePersistentData.</param>
        /// <param name="r">Packet BRequestRetrievePersistentData content.</param>
        private static void _SendGameCurrency(Session s, Package p, PacketBRequestRetrievePersistentData r)
        {
            string Content = File.ReadAllText($"{PathingHelper.tmpDir}BGameCurrencyPacketGameCurrencyResponse.xml");

            if (string.IsNullOrEmpty(Content))
            {
                return;
            }

            PacketBGameCurrencyPacket ResponseContent = new PacketBGameCurrencyPacket(Content);

            if (s.Logger.IsDebugEnabled)
            {
                s.Logger.Debug($"Command response: {ResponseContent}");
            }

            byte[] Response = ResponseContent.ToByteArray();

            Package Package = new Package(p.HeaderXuid, p.HeaderField20, p.HeaderServiceId, p.HeaderField22, (byte)PacketTypes.BGameCurrencyPacket, p.HeaderRequestId, Response);

            byte[] ToSend = Package.ToByteArray();

            s.Send(ToSend, 0, ToSend.Length);
        }