Пример #1
0
        /*
         * /// <summary>
         * /// Converts the log-file in the given file (within the <c>LogFolder</c>)
         * /// to a human-readable file within the <c>LogOutputFolder</c>.
         * /// </summary>
         * /// <param name="filename">The name of the file within the LogFolder to be converter</param>
         * /// <param name="converter">The Converter-method, either <c>KSnifferLogConverter.ConvertLog</c> or <c>SniffzitLogConverter.ConvertLog</c></param>
         * public static void ConvertLog(string filename, Action<string, string> converter)
         * {
         *      Directory.CreateDirectory(ToolConfig.LogFolder);
         *      Directory.CreateDirectory(ToolConfig.LogOutputFolder);
         *
         *      var inputFile = Path.Combine(ToolConfig.LogFolder, filename);
         *      Console.WriteLine("Converting log-file: " + new FileInfo(inputFile).FullName);
         *
         *      DebugUtil.Init();
         *
         *      var outFile = Path.Combine(ToolConfig.LogOutputFolder, filename);
         *      if (!outFile.EndsWith(".txt"))
         *      {
         *              outFile += ".txt";
         *      }
         *      converter(inputFile, outFile);
         * }
         *
         * [Tool]
         * public static void ConvertKSnifferLogSingleLine(string filename)
         * {
         *      Directory.CreateDirectory(ToolConfig.LogFolder);
         *      Directory.CreateDirectory(ToolConfig.LogOutputFolder);
         *
         *      var inputFile = Path.Combine(ToolConfig.LogFolder, filename);
         *      Console.Write("Converting log-file: " + new FileInfo(inputFile).FullName + " ...");
         *
         *      DebugUtil.Init();
         *
         *      var outFile = Path.Combine(ToolConfig.LogOutputFolder, filename);
         *      if (!outFile.EndsWith(".txt"))
         *      {
         *              outFile += ".txt";
         *      }
         *
         *      KSnifferLogConverter.ConvertLog(inputFile, outFile, true);
         *      Console.WriteLine("Done. - Output has been written to: " + new FileInfo(outFile).FullName);
         *      //Console.WriteLine();
         * }*/

        public static void Startup()
        {
            Utility.Measure("Load all", 1, () =>
            {
                ItemMgr.LoadAll();
                NPCMgr.LoadNPCDefs();
                GOMgr.LoadAll();
                QuestMgr.LoadAll();
            });


            Utility.Measure("Basic startup sequence", 1, () =>
            {
                RealmServ.Instance.Start();

                Utility.Measure("Load all", 1, () =>
                {
                    ItemMgr.LoadAll();
                    NPCMgr.LoadNPCDefs();
                    GOMgr.LoadAll();
                    QuestMgr.LoadAll();
                });

                Map.AutoSpawnMaps = true;
                var easternKD     = World.GetNonInstancedMap(MapId.EasternKingdoms);
                var kalimdor      = World.GetNonInstancedMap(MapId.Kalimdor);
                var outlands      = World.GetNonInstancedMap(MapId.Outland);
                Utility.Measure("Spawning Main Maps", 1, () =>
                {
                    //easternKD.Start();
                    //kalimdor.Start();
                });


                GC.Collect();
                Console.WriteLine("Total memory usage with fully spawned world: {0}", GC.GetTotalMemory(true));
            });
        }
Пример #2
0
 private static void Init()
 {
     RealmDBMgr.Initialize();
     SpellHandler.LoadSpells();
     GOMgr.LoadAll();
 }
Пример #3
0
        public void TestDuel()
        {
            Setup.EnsureBasicSetup();

            var chr1 = Setup.AllianceCharacterPool.Create();

            chr1.EnsureAloneInWorldAndLiving();

            var chr2 = Setup.AllianceCharacterPool.Create();

            chr2.EnsureInWorldAndLiving();
            chr2.EnsureXDistance(chr1, 2, true);

            Assert.IsNotNull(chr1.Map);
            Assert.AreEqual(chr1.Map, chr2.Map);
            Assert.AreEqual(2, chr1.Map.CharacterCount);

            chr1.Map.ForceUpdateCharacters();

            Assert.IsTrue(chr1.KnowsOf(chr2));
            Assert.IsFalse(chr1.CanHarm(chr2));
            Assert.IsFalse(chr2.CanHarm(chr1));

            GOMgr.LoadAll();

            // chr1 requests a duel with chr2
            using (var packet = new RealmPacketOut(RealmServerOpCode.CMSG_CAST_SPELL))
            {
                packet.Write((byte)1);
                packet.Write((uint)SpellId.NotDisplayedDuel);
                packet.Write((byte)0);
                packet.Write((uint)SpellTargetFlags.Unit);
                chr2.EntityId.WritePacked(packet);

                chr1.FakeClient.ReceiveCMSG(packet, false, true);
            }

            chr1.Map.WaitTicks(3);

            Assert.IsFalse(chr1.IsUsingSpell, "Character is still casting Duel Spell.");

            var spellFailure = chr1.FakeClient.DequeueSMSG(RealmServerOpCode.SMSG_SPELL_FAILURE);

            Assert.IsNull(spellFailure, "Could not start duel - {0} ({1})",
                          spellFailure != null ? spellFailure["Spell"] : null,
                          spellFailure != null ? spellFailure["FailReason"] : null);

            // server sent duel request to opposing party
            var request = chr2.FakeClient.DequeueSMSG(RealmServerOpCode.SMSG_DUEL_REQUESTED);

            Assert.IsNotNull(request);

            request = chr1.FakeClient.DequeueSMSG(RealmServerOpCode.SMSG_DUEL_REQUESTED);
            Assert.IsNotNull(request);

            var duel = chr1.Duel;

            Assert.IsNotNull(duel);
            Assert.AreEqual(duel, chr2.Duel);

            Assert.AreEqual(chr1.DuelOpponent, chr2);
            Assert.AreEqual(chr2.DuelOpponent, chr1);

            var flag = duel.Flag;

            Assert.IsNotNull(flag);
            Assert.AreEqual(chr1.Map, duel.Flag.Map);

            var map = chr1.Map;

            Assert.IsFalse(duel.IsActive);

            Assert.AreEqual(duel.Flag.EntityId, request["FlagId"].Value);
            Assert.AreEqual(chr1.EntityId, request["ChallengerId"].Value);

            // opponent accepts duel
            using (var packet = new RealmPacketOut(RealmServerOpCode.CMSG_DUEL_ACCEPTED))
            {
                chr2.FakeClient.ReceiveCMSG(packet, false, true);
            }

            Assert.IsFalse(duel.IsActive);
            if (Duel.DefaultStartDelayMillis > 0)
            {
                Asser.InBetween(0.001f, Duel.DefaultStartDelayMillis, duel.StartDelay);
                // lets speed it up
                duel.StartDelay = 1;
            }

            map.WaitTicks(2);

            // duel started
            Assert.IsTrue(duel.IsActive);
            Assert.IsTrue(chr1.CanHarm(chr2));
            Assert.IsTrue(chr2.CanHarm(chr1));

            map.AddMessage(() => {
                // finish duel by having chr1 knockout chr2
                duel.Finish(DuelWin.Knockout, chr2);

                var winMsg = chr2.FakeClient.DequeueSMSG(RealmServerOpCode.SMSG_DUEL_WINNER);
                Assert.AreEqual(DuelWin.Knockout, winMsg["Win"].Value);
                Assert.AreEqual(chr1.Name, winMsg["Winner"].Value);
                Assert.AreEqual(chr2.Name, winMsg["Looser"].Value);

                // duel ended
                Assert.IsNull(flag.Map);

                Assert.IsNull(chr1.DuelOpponent);
                Assert.IsNull(chr1.Duel);
                Assert.IsNull(chr2.DuelOpponent);
                Assert.IsNull(chr2.Duel);

                Assert.IsFalse(chr1.CanHarm(chr2));
                Assert.IsFalse(chr2.CanHarm(chr1));
            });
        }