/// <summary>
        /// Decal ServerDispatch event handler.  This is called when ac client recieves a network message.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FilterCore_ServerDispatch(object sender, NetworkMessageEventArgs e)
        {
            try {
                // see https://acemulator.github.io/protocol/ for protocol documentation
                switch (e.Message.Type)
                {
                case 0xF658:     // LoginCharacterSet S2C
                    AccountName = e.Message.Value <string>("zonename");
                    int           characterCount = e.Message.Value <int>("characterCount");
                    MessageStruct characters     = e.Message.Struct("characters");
                    Characters.Clear();

                    for (int i = 0; i < characterCount; i++)
                    {
                        int    id   = characters.Struct(i).Value <int>("character");
                        string name = characters.Struct(i).Value <string>("name");
                        Characters.Add(id, name);
                    }
                    break;

                case 0xF7E1:     // Login_WorldInfo
                    ServerName = e.Message.Value <string>("server");
                    break;
                }
            }
            catch (Exception ex) { Utils.LogException(ex); }
        }
Beispiel #2
0
    private void d(cv A_0, MessageStruct A_1)
    {
        A_0.q = true;
        A_0.t.Clear();
        byte num = A_1.Value <byte>("paletteCount");

        if (num == 0xff)
        {
            A_0.r = true;
            A_0.s = A_1.Value <int>("palette");
        }
        else
        {
            A_0.r = false;
            MessageStruct struct2 = A_1.Struct("palettes");
            for (int i = 0; i < num; i++)
            {
                bo item = new bo {
                    a = struct2.Struct(i).Value <int>("palette"),
                    b = struct2.Struct(i).Value <byte>("offset"),
                    c = struct2.Struct(i).Value <byte>("length")
                };
                A_0.t.Add(item);
            }
        }
    }
        internal void FilterCore_ServerDispatch(object sender, NetworkMessageEventArgs e)
        {
            if (e.Message.Type == 0xF658) // Zone Name
            {
                zonename = Convert.ToString(e.Message["zonename"]);
                log.WriteInfo("zonename: '{0}'", zonename);
            }

            if (e.Message.Type == 0xF7E1) // Server Name
            {
                //Server Name retrieved from the server message, not used (unreliable in EMU)
                var server = Convert.ToString(e.Message["server"]);
                log.WriteInfo("server: '{0}'", server);
            }

            if (e.Message.Type == 0xF658)             // Character List
            {
                log.WriteInfo("Inside ServerDispatch. 0xF658");
                characterSlots = Convert.ToInt32(e.Message["slotCount"]);

                characters = new List <Character>();

                MessageStruct charactersStruct = e.Message.Struct("characters");

                for (int i = 0; i < charactersStruct.Count; i++)
                {
                    int    character     = Convert.ToInt32(charactersStruct.Struct(i)["character"]);
                    string name          = Convert.ToString(charactersStruct.Struct(i)["name"]);
                    int    deleteTimeout = Convert.ToInt32(charactersStruct.Struct(i)["deleteTimeout"]);

                    characters.Add(new Character(character, name, deleteTimeout));
                    log.WriteInfo(character.ToString() + " " + name + " " + deleteTimeout.ToString());
                }

                characters.Sort((a, b) => String.Compare(a.Name, b.Name, StringComparison.Ordinal));
            }
            if (!written)
            {
                if (zonename != null && characters != null)
                {
                    CharacterBook mgr = CharacterBook.ReadCharacters();
                    mgr.WriteCharacters(zonename: zonename, characters: characters);
                    log.WriteInfo("Wrote our characters to file");
                    Heartbeat.LaunchHeartbeat();
                    written = true;
                }
            }
            if (CoreManager.Current.CharacterFilter.Name != characterName)
            {
                GameRepo.Game.SetCharacter(CoreManager.Current.CharacterFilter.Name);
                characterName = CoreManager.Current.CharacterFilter.Name;
            }
        }
Beispiel #4
0
    private void b(NetworkMessageEventArgs A_0)
    {
        this.u   = new o();
        this.u.c = A_0.get_Message().Value <int>("merchant");
        this.u.d = A_0.get_Message().Value <int>("buyCategories");
        this.u.e = A_0.get_Message().Value <int>("unknown1");
        this.u.f = A_0.get_Message().Value <int>("buyValue");
        this.u.g = A_0.get_Message().Value <int>("unknown2");
        this.u.h = A_0.get_Message().Value <float>("buyRate");
        this.u.i = A_0.get_Message().Value <float>("sellRate");
        int num = A_0.get_Message().Value <int>("itemCount");

        for (int i = 0; i < num; i++)
        {
            cv            cv      = new cv();
            MessageStruct struct2 = A_0.get_Message().Struct("items").Struct(i);
            cv.u = struct2.Value <int>("count");
            cv.k = struct2.Value <int>("object");
            this.e(cv, struct2.Struct("game"));
            cv.v = true;
            this.u.a(cv);
        }
        if (this.t != null)
        {
            this.t(this, null);
        }
    }
Beispiel #5
0
 /// <remarks>Copied from Mag-Filter by Magnus, THANK YOU!!!</remarks>
 internal void FilterCore_ServerDispatch(object sender, NetworkMessageEventArgs e)
 {
     if (e.Message.Type == 0xF658) // Character List
     {
         WarehouseFilterGlobals.CharacterSlots = Convert.ToInt32(e.Message["slotCount"]);
         WarehouseFilterGlobals.Characters.Clear();
         MessageStruct charactersStruct = e.Message.Struct("characters");
         for (int i = 0; i < charactersStruct.Count; i++)
         {
             int    character     = Convert.ToInt32(charactersStruct.Struct(i)["character"]);
             string name          = Convert.ToString(charactersStruct.Struct(i)["name"]);
             int    deleteTimeout = Convert.ToInt32(charactersStruct.Struct(i)["deleteTimeout"]);
             WarehouseFilterGlobals.Characters.Add(new Character(character, name, deleteTimeout));
         }
         WarehouseFilterGlobals.Characters.Sort((a, b) => string.Compare(a.Name, b.Name, StringComparison.Ordinal));
         gotCharList = true;
     }
 }
Beispiel #6
0
    private void c(cv A_0, MessageStruct A_1)
    {
        int num = A_1.Value <int>("flags");

        A_0.a[0xd000027] = num;
        if ((num & 0x8000) > 0)
        {
            this.b(A_0, A_1.Struct("position"));
        }
    }
Beispiel #7
0
        /// <summary>
        /// Parses server messages.
        /// Protocols known at time of creation:
        /// http://skunkworks.sourceforge.net/protocol/Protocol.php
        /// https://acemulator.github.io/protocol/
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FilterCore_ServerDispatch(object sender, NetworkMessageEventArgs e)
        {
            // End 3D Mode and return to character screen
            if (e.Message.Type.Equals(0xF653))
            {
                Machine.LoggedIn  = false;
                CommandLineText  -= Machine.Interpreter.Command;
                Core.RenderFrame -= Machine.Clock;
                Core.WorldFilter.ChangeObject -= Machine.WorldFilter_ChangeObject;
                Machine.BotManagerView?.Dispose();
            }

            // Received the character list from the server
            if (e.Message.Type.Equals(0xF658))
            {
                AccountCharacters.Clear();
                TotalSlots = Convert.ToInt32(e.Message["slotCount"]);
                int charCount = Convert.ToInt32(e.Message["characterCount"]);

                MessageStruct characterStruct = e.Message.Struct("characters");
                for (int i = 0; i < charCount; i++)
                {
                    AccountCharacters.Add(characterStruct.Struct(i)["name"].ToString());
                }

                // Must sort the characters ordinally to be in the same order as displayed
                AccountCharacters.Sort((a, b) => String.Compare(a, b, StringComparison.Ordinal));
            }

            // Login Character
            if (e.Message.Type.Equals(0xF746))
            {
                LogonTimer.Stop();
            }

            // Game events
            if (e.Message.Type.Equals(0xF7B0))
            {
                // Action complete
                if (Convert.ToInt32(e.Message["event"]).Equals(0x01C7))
                {
                    Machine.CastCompleted = true;
                }

                // Status messages
                if (Convert.ToInt32(e.Message["event"]).Equals(0x028A))
                {
                    // Your spell fizzled.
                    if (Convert.ToInt32(e.Message[3]).Equals(0x0402))
                    {
                        Machine.Fizzled = true;
                    }
                }
            }

            // Server Name (last server message sent when logging out)
            if (e.Message.Type.Equals(0xF7E1) && Machine.CurrentState == SwitchingCharacters.GetInstance)
            {
                LogonTimer.Start();
            }
        }
Beispiel #8
0
    private void d(NetworkMessageEventArgs A_0)
    {
        cv n;

        this.o = A_0.get_Message().Value <int>("character");
        foreach (KeyValuePair <int, cv> pair in this.i)
        {
            this.c(pair.Value);
        }
        if (this.i.ContainsKey(this.o))
        {
            n = this.i[this.o];
        }
        else
        {
            this.n = new cv();
            n      = this.n;
            n.k    = this.o;
        }
        MessageStruct struct2 = A_0.get_Message().Struct("properties");
        int           num     = struct2.Value <int>("flags");

        if ((num & 1) > 0)
        {
            short num2 = struct2.Value <short>("dwordCount");
            for (int i = 0; i < num2; i++)
            {
                int num4 = struct2.Struct("dwords").Struct(i).Value <int>("key");
                int num5 = struct2.Struct("dwords").Struct(i).Value <int>("value");
                n.a[num4] = num5;
            }
        }
        if ((num & 0x80) > 0)
        {
            short num6 = struct2.Value <short>("qwordCount");
            for (int j = 0; j < num6; j++)
            {
                int  num8 = struct2.Struct("qwords").Struct(j).Value <int>("key");
                long num9 = struct2.Struct("qwords").Struct(j).Value <long>("value");
                n.e[num8] = num9;
            }
        }
        if ((num & 2) > 0)
        {
            short num10 = struct2.Value <short>("booleanCount");
            for (int k = 0; k < num10; k++)
            {
                int  num12 = struct2.Struct("booleans").Struct(k).Value <int>("key");
                bool flag  = struct2.Struct("booleans").Struct(k).Value <int>("value") != 0;
                n.c[num12] = flag;
            }
        }
        if ((num & 4) > 0)
        {
            short num13 = struct2.Value <short>("doubleCount");
            for (int m = 0; m < num13; m++)
            {
                int    num15 = struct2.Struct("doubles").Struct(m).Value <int>("key");
                double num16 = struct2.Struct("doubles").Struct(m).Value <double>("value");
                n.d[num15] = num16;
            }
        }
        if ((num & 0x10) > 0)
        {
            short num17 = struct2.Value <short>("stringCount");
            for (int num18 = 0; num18 < num17; num18++)
            {
                int    num19 = struct2.Struct("strings").Struct(num18).Value <int>("key");
                string str   = struct2.Struct("strings").Struct(num18).Value <string>("value");
                n.b[num19] = str;
            }
        }
        if ((num & 0x40) > 0)
        {
            short num20 = struct2.Value <short>("resourceCount");
            for (int num21 = 0; num21 < num20; num21++)
            {
                int num22 = struct2.Struct("resources").Struct(num21).Value <int>("key");
                int num23 = struct2.Struct("resources").Struct(num21).Value <int>("value");
                switch (num22)
                {
                case 8:
                {
                    n.a[0xd000001] = num23;
                }
                }
                n.g[num22] = num23;
            }
        }
        if (this.e != null)
        {
            this.e(n);
        }
    }
Beispiel #9
0
        internal void FilterCore_ServerDispatch(object sender, NetworkMessageEventArgs e)
        {
            log.WriteDebug("Account123:" + GameRepo.Game.Account);
            if (e.Message.Type == 0xF658) // Zone Name
            {
                zonename = Convert.ToString(e.Message["zonename"]);
                log.WriteInfo("zonename123: '{0}'", zonename);
                GameRepo.Game.SetAccount(zonename);
            }

            if (e.Message.Type == 0xF7E1) // Server Name
            {
                //Server Name retrieved from the server message, not used (unreliable in EMU)
                var server = Convert.ToString(e.Message["server"]);
                log.WriteInfo("server: '{0}'", server);
                GameRepo.Game.SetServer(server);
            }

            if (e.Message.Type == 0xF658) // Character List
            {
                characterSlots = Convert.ToInt32(e.Message["slotCount"]);

                characters = new List <Character>();

                MessageStruct charactersStruct = e.Message.Struct("characters");

                bool all_chars = true;
                for (int i = 0; i < charactersStruct.Count; i++)
                {
                    int    character     = Convert.ToInt32(charactersStruct.Struct(i)["character"]);
                    string name          = Convert.ToString(charactersStruct.Struct(i)["name"]);
                    int    deleteTimeout = Convert.ToInt32(charactersStruct.Struct(i)["deleteTimeout"]);

                    characters.Add(new Character(character, name, deleteTimeout));
                    log.WriteInfo(character.ToString() + " " + name + " " + deleteTimeout.ToString());
                    if (!name.StartsWith(base_name))
                    {
                        all_chars = false;
                    }
                }

                if (characters.Count < 10 && all_chars && !creating_character)
                {
                    log.WriteDebug("Found less than 10 Ztiel characters, creating!");
                    CreateCharacter();
                }

                characters.Sort((a, b) => String.Compare(a.Name, b.Name, StringComparison.Ordinal));
            }
            if (!written)
            {
                if (GameRepo.Game.Server != "" && zonename != null && characters != null)
                {
                    CharacterBook.WriteCharacters(ServerName: GameRepo.Game.Server, zonename: zonename, characters: characters);
                    Heartbeat.LaunchHeartbeat();
                    written = true;
                }
            }
            if (CoreManager.Current.CharacterFilter.Name != characterName)
            {
                GameRepo.Game.SetCharacter(CoreManager.Current.CharacterFilter.Name);
                characterName = CoreManager.Current.CharacterFilter.Name;
            }
        }
Beispiel #10
0
    private void a(object A_0, NetworkMessageEventArgs A_1)
    {
        if (A_1.get_Message().get_Type() == 0xf7b0)
        {
            int num23 = A_1.get_Message().Value <int>("event");
            if (num23 != 0x13)
            {
                switch (num23)
                {
                case 0x2c2:
                    this.a(A_1.get_Message().Struct("enchantment"));
                    return;

                case 0x2c3:
                {
                    int num9  = A_1.get_Message().Value <int>("spell");
                    int num10 = A_1.get_Message().Value <short>("layer");
                    this.a(num9, num10);
                    return;
                }

                case 0x2c4:
                    return;

                case 0x2c5:
                {
                    int num11 = A_1.get_Message().Value <int>("count");
                    for (int i = 0; i < num11; i++)
                    {
                        int num13 = A_1.get_Message().Struct("enchantments").Struct(i).Value <int>("spell");
                        int num14 = A_1.get_Message().Struct("enchantments").Struct(i).Value <short>("layer");
                        this.a(num13, num14);
                    }
                    return;
                }

                case 710:
                {
                    Dictionary <int, ActiveSpellInfo> a = this.a;
                    this.a = new Dictionary <int, ActiveSpellInfo>();
                    foreach (KeyValuePair <int, ActiveSpellInfo> pair in a)
                    {
                        if (pair.Value.IsCoolDown)
                        {
                            this.a[pair.Key] = pair.Value;
                        }
                        else if (this.e != null)
                        {
                            this.e(pair.Value);
                        }
                    }
                    return;
                }

                case 0x2c7:
                {
                    int num15 = A_1.get_Message().Value <int>("spell");
                    int num16 = A_1.get_Message().Value <short>("layer");
                    this.a(num15, num16);
                    return;
                }

                case 0x2c8:
                {
                    int num17 = A_1.get_Message().Value <int>("count");
                    for (int j = 0; j < num17; j++)
                    {
                        int num19 = A_1.get_Message().Struct("enchantments").Struct(j).Value <int>("spell");
                        int num20 = A_1.get_Message().Struct("enchantments").Struct(j).Value <short>("layer");
                        this.a(num19, num20);
                    }
                    return;
                }

                case 0x1ac:
                {
                    List <int> list = new List <int>();
                    foreach (KeyValuePair <int, ActiveSpellInfo> pair2 in this.a)
                    {
                        MySpell spell = PluginCore.cq.e.b(pair2.Key);
                        if ((spell != null) && spell.isOffensive)
                        {
                            list.Add(pair2.Key);
                        }
                    }
                    foreach (int num21 in list)
                    {
                        ActiveSpellInfo info = this.a[num21];
                        this.a.Remove(num21);
                        if (this.e != null)
                        {
                            this.e(info);
                        }
                    }
                    return;
                }
                }
            }
            else
            {
                MessageStruct struct2 = A_1.get_Message().Struct("vectors");
                if ((struct2.Value <int>("flags") & 0x200) > 0)
                {
                    int num2 = struct2.Value <int>("enchantmentMask");
                    if ((num2 & 1) > 0)
                    {
                        int num3 = struct2.Value <int>("lifeSpellCount");
                        for (int k = 0; k < num3; k++)
                        {
                            this.a(struct2.Struct("lifeSpells").Struct(k).Struct(0));
                        }
                    }
                    if ((num2 & 2) > 0)
                    {
                        int num5 = struct2.Value <int>("creatureSpellCount");
                        for (int m = 0; m < num5; m++)
                        {
                            this.a(struct2.Struct("creatureSpells").Struct(m).Struct(0));
                        }
                    }
                    if ((num2 & 8) > 0)
                    {
                        int num7 = struct2.Value <int>("cooldownCount");
                        for (int n = 0; n < num7; n++)
                        {
                            this.a(struct2.Struct("cooldowns").Struct(n).Struct(0));
                        }
                    }
                }
            }
        }
    }