public void Union_Struct_Location()
    {
        var location = new Location
        {
            X = 1.0f,
            Y = 2.0f,
            Z = 3.0f
        };

        var table = new UnionTable
        {
            Union = new FlatBufferUnion <BasicTypes, Location, string>(location)
        };

        Span <byte> memory = new byte[10240];
        int         size   = FlatBufferSerializer.Default.Serialize(table, memory);

        var oracle = Oracle.UnionTable.GetRootAsUnionTable(
            new FlatBuffers.ByteBuffer(memory.Slice(0, size).ToArray()));

        Assert.Equal(2, (int)oracle.ValueType);
        var bt = oracle.Value <Oracle.Location>().Value;

        Assert.Equal(bt.X, location.X);
        Assert.Equal(bt.Y, location.Y);
        Assert.Equal(bt.Z, location.Z);
    }
Example #2
0
    public void Union_2Items_Table_SerializationTest()
    {
        byte[] expectedData =
        {
            4,     0,   0, 0,   // offset to table
            246, 255, 255, 255, // soffset to vtable
            16,    0,   0, 0,   // uoffset_t to table data
            1,     0,           // discriminator (1 byte), padding
            8,     0,           // vtable length
            9,     0,           // table length
            8,     0,           // discriminator offset
            4,     0,           // value offset
            0,     0,           // padding

            // table data
            248, 255, 255, 255, // soffset to vtable
            123,   0,   0, 0,   // value of index 0
            6,     0,           // vtable length
            8,     0,           // table length
            4, 0                // offset of index 0
        };

        var union = new UnionTable <SimpleTable, SimpleStruct>
        {
            Item = new FlatBufferUnion <SimpleTable, SimpleStruct>(new SimpleTable {
                Int = 123
            })
        };

        Span <byte> data  = new byte[100];
        int         count = FlatBufferSerializer.Default.Serialize(union, data);

        Assert.True(expectedData.AsSpan().SequenceEqual(data.Slice(0, count)));
    }
    public void Union_Table_BasicTypes()
    {
        var simple = new BasicTypes
        {
            Bool   = true,
            Byte   = GetRandom <byte>(),
            SByte  = GetRandom <sbyte>(),
            Double = GetRandom <double>(),
            Float  = GetRandom <float>(),
            Int    = GetRandom <int>(),
            Long   = GetRandom <long>(),
            Short  = GetRandom <short>(),
            String = "foobar",
            UInt   = GetRandom <uint>(),
            ULong  = GetRandom <ulong>(),
            UShort = GetRandom <ushort>(),
        };

        var table = new UnionTable
        {
            Union = new FlatBufferUnion <BasicTypes, Location, string>(simple)
        };

        Span <byte> memory = new byte[10240];
        int         size   = FlatBufferSerializer.Default.Serialize(table, memory);

        var oracle = Oracle.UnionTable.GetRootAsUnionTable(
            new FlatBuffers.ByteBuffer(memory.Slice(0, size).ToArray()));

        Assert.Equal(1, (int)oracle.ValueType);
        var bt = oracle.Value <Oracle.BasicTypes>().Value;

        Assert.True(bt.Bool);
        Assert.Equal(bt.Byte, simple.Byte);
        Assert.Equal(bt.SByte, simple.SByte);

        Assert.Equal(bt.UShort, simple.UShort);
        Assert.Equal(bt.Short, simple.Short);

        Assert.Equal(bt.UInt, simple.UInt);
        Assert.Equal(bt.Int, simple.Int);

        Assert.Equal(bt.ULong, simple.ULong);
        Assert.Equal(bt.Long, simple.Long);

        Assert.Equal(bt.Float, simple.Float);
        Assert.Equal(bt.Double, simple.Double);
        Assert.Equal(bt.String, simple.String);
    }
    public void Union_NotSet()
    {
        var table = new UnionTable
        {
            Union = null,
        };

        Span <byte> memory = new byte[10240];
        int         size   = FlatBufferSerializer.Default.Serialize(table, memory);

        var oracle = Oracle.UnionTable.GetRootAsUnionTable(
            new FlatBuffers.ByteBuffer(memory.Slice(0, size).ToArray()));

        Assert.Equal(0, (int)oracle.ValueType);
    }
Example #5
0
        public override object InternalExecute(Program program)
        {
            UnionTable table = new UnionTable(this, program);

            try
            {
                table.Open();
                return(table);
            }
            catch
            {
                table.Dispose();
                throw;
            }
        }
Example #6
0
    private static T2 CreateAndDeserialize2 <T1, T2>(T1 one, T2 two)
    {
        var table = new UnionTable <T1, T2>
        {
            Item = new FlatBufferUnion <T1, T2>(two)
        };

        byte[] buffer = new byte[1024];

        FlatBufferSerializer.Default.Serialize(table, buffer);

        var parseResult = FlatBufferSerializer.Default.Parse <UnionTable <T1, T2> >(buffer);

        Assert.Equal(2, parseResult.Item.Value.Discriminator);

        return(parseResult.Item.Value.Item2);
    }
    public void Union_String()
    {
        var table = new UnionTable
        {
            Union = new FlatBufferUnion <BasicTypes, Location, string>("foobar")
        };

        Span <byte> memory = new byte[10240];
        int         size   = FlatBufferSerializer.Default.Serialize(table, memory);

        var oracle = Oracle.UnionTable.GetRootAsUnionTable(
            new FlatBuffers.ByteBuffer(memory.Slice(0, size).ToArray()));

        // There is nothing to assert here, since the google C# SDK does not support reading strings
        // out of a union. All indications are that we are doing it right, but there's no way to test
        // this particular scenario.
        Assert.Equal(3, (int)oracle.ValueType);
    }
Example #8
0
File: Mains.cs Project: iodz37/Iodz
        public static void LoadServer(bool KnowConfig)
        {
            Time32 Start = Time32.Now;

            RandomSeed    = Convert.ToInt32(DateTime.Now.Ticks.ToString().Remove(DateTime.Now.Ticks.ToString().Length / 2));
            Console.Title = "Conquord Is Loading...";
            Kernel.Random = new FastRandom(RandomSeed);
            if (!KnowConfig)
            {
                ConquordDBName = "test";
                ConquordDBPass = "******";
                ConquordIP     = "149.202.128.35";
            }
            System.Console.ForegroundColor = ConsoleColor.DarkGray;
            IntPtr hWnd = FindWindow(null, Console.Title);

            System.Console.WriteLine(@"      `       ______                                       __   `     `      ");
            System.Console.WriteLine(@"             / ____/___  ____  ____ ___  ______  _________/ /                ");
            System.Console.WriteLine(@"        `   / /   / __ \/ __ \/ __ `/ / / / __ \/ ___/ __  /  `      `    _  ");
            System.Console.WriteLine(@"          _/ /___/ /_/ / / / / /_/ / /_/ / /_/ / /  / /_/ /              | | ");
            System.Console.WriteLine(@"   `       \____/\____/_/ /_/\__, /\__,_/\____/_/   \__,_/        `   ___| | ");
            System.Console.WriteLine(@"         `                     /_/            `               `      (    .' ");
            System.Console.WriteLine(@" __        ...       _____ Michael Nashaat _____        ...       __  )  (   ");
            System.Console.WriteLine();
            System.Console.WriteLine(@"                  Copyright (c) Conquord Project 2015-2016.                  ");
            Console.BackgroundColor        = ConsoleColor.Black;
            System.Console.ForegroundColor = ConsoleColor.DarkGray;
            Database.DataHolder.CreateConnection(ConquordDBName, ConquordDBPass);
            Database.EntityTable.EntityUID = new Counter(0);
            new MySqlCommand(MySqlCommandType.UPDATE).Update("entities").Set("Online", 0).Execute();
            using (MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT))
            {
                cmd.Select("configuration");
                using (MySqlReader r = new MySqlReader(cmd))
                {
                    if (r.Read())
                    {
                        if (!KnowConfig)
                        {
                            ConquordIP = r.ReadString("ConquordIP");
                            GamePort   = 5816;
                            AuthPort   = r.ReadUInt16("ConquordPort");
                        }
                        Database.EntityTable.EntityUID = new Counter(r.ReadUInt32("EntityID"));
                        if (Database.EntityTable.EntityUID.Now == 0)
                        {
                            Database.EntityTable.EntityUID.Now = 1;
                        }
                        Union.UnionCounter   = new Counter(r.ReadUInt32("UnionID"));
                        Kernel.ServerKingdom = (r.ReadUInt32("ServerKingdom"));
                        if (r.ReadByte("LastDailySignReset") != DateTime.Now.Month)
                        {
                            MsgSignIn.Reset();
                        }
                        Game.ConquerStructures.Society.Guild.GuildCounter = new Conquord.Counter(r.ReadUInt32("GuildID"));
                        Network.GamePackets.ConquerItem.ItemUID           = new Conquord.Counter(r.ReadUInt32("ItemUID"));
                        Constants.ExtraExperienceRate   = r.ReadUInt32("ExperienceRate");
                        Constants.ExtraSpellRate        = r.ReadUInt32("SpellExperienceRate");
                        Constants.ExtraProficiencyRate  = r.ReadUInt32("ProficiencyExperienceRate");
                        Constants.MoneyDropRate         = r.ReadUInt32("MoneyDropRate");
                        Constants.ConquerPointsDropRate = r.ReadUInt32("ConquerPointsDropRate");
                        Constants.ItemDropRate          = r.ReadUInt32("ItemDropRate");
                        Constants.ItemDropQualityRates  = r.ReadString("ItemDropQualityString").Split('~');
                        Database.EntityVariableTable.Load(0, out Vars);
                    }
                }
            }
            using (var cmd = new MySqlCommand(MySqlCommandType.UPDATE).Update("configuration"))
                cmd.Set("LastDailySignReset", DateTime.Now.Month).Execute();
            Database.JiangHu.LoadStatus();
            Database.JiangHu.LoadJiangHu();
            Console.WriteLine("JiangHu Loaded.");
            Way2Heroes.Load();
            QuestInfo.Load();
            AuctionBase.Load();
            Database.DataHolder.ReadStats();
            Conquord.Soul.SoulProtection.Load();
            Database.PerfectionTable.Load();
            Console.WriteLine("Perfection Loaded.");
            Database.LotteryTable.Load();
            Database.ConquerItemTable.ClearNulledItems();
            Database.ConquerItemInformation.Load();
            Console.WriteLine("Items Loaded.");
            Database.GameUpdetess.LoadRates();
            Database.MonsterInformation.Load();
            Database.IPBan.Load();
            Database.SpellTable.Load();
            Database.ShopFile.Load();
            Database.HonorShop.Load();
            Database.RacePointShop.Load();
            Database.ChampionShop.Load();
            Database.EShopFile.Load();
            Database.EShopV2File.Load();
            Console.WriteLine("Shops Loaded.");
            Database.MapsTable.Load();
            Database.Flowers.LoadFlowers();
            Database.Flowers.SaveFlowers();
            Console.WriteLine("Flowers Systems Loaded.");
            Database.NobilityTable.Load();
            Database.ArenaTable.Load();
            Database.TeamArenaTable.Load();
            Database.GuildTable.Load();
            Database.ChiTable.LoadAllChi();
            Console.WriteLine("Social Systems Loaded.");
            Refinery.LoadItems();
            StorageManager.Load();
            UnionTable.Load();
            Console.WriteLine("Union Loaded.");
            World = new World();
            World.Init();
            Database.Statue.Load();
            Console.WriteLine("Tops And Quests Loaded.");
            Database.PoketTables.LoadTables();
            Database.InnerPowerTable.LoadDBInformation();
            Database.InnerPowerTable.Load();
            Console.WriteLine("InnerPower Loaded.");
            Map.CreateTimerFactories();
            Database.SignInTable.Load();
            Database.DMaps.Load();
            Console.WriteLine("Maps Loaded.");
            Game.Screen.CreateTimerFactories();
            World.CreateTournaments();
            Game.GuildWar.Initiate();
            Game.ClanWar.Initiate();
            Game.Tournaments.SkillTournament.LoadSkillTop8();
            Game.Tournaments.TeamTournament.LoadTeamTop8();
            Clan.LoadClans();
            Game.EliteGuildWar.EliteGwint();
            Console.WriteLine("Guilds and Clans loaded.");
            Booths.Load();
            Console.WriteLine("Booths Loaded.");

            Database.FloorItemTable.Load();
            Database.ReincarnationTable.Load();
            new MsgUserAbilityScore().GetRankingList();
            new MsgEquipRefineRank().UpdateRanking();
            PrestigeRank.LoadRanking();
            Console.WriteLine("Ranks Loaded.");
            BruteForceProtection.CreatePoll();
            Console.WriteLine("Protection System On.");
            {
                Client.GameClient gc = new Client.GameClient(new ClientWrapper());
                gc.Account      = new AccountTable("NONE");
                gc.Socket.Alive = false;
                gc.Entity       = new Entity(EntityFlag.Player, false)
                {
                    Name = "NONE"
                };
                Npcs.GetDialog(new NpcRequest(), gc, true);
            }
            #region OpenSocket
            Network.Cryptography.AuthCryptography.PrepareAuthCryptography();
            AuthServer = new ServerSocket();
            AuthServer.OnClientConnect    += AuthServer_OnClientConnect;
            AuthServer.OnClientReceive    += AuthServer_OnClientReceive;
            AuthServer.OnClientDisconnect += AuthServer_OnClientDisconnect;
            AuthServer.Enable(AuthPort, "0.0.0.0");
            GameServer = new ServerSocket();
            GameServer.OnClientConnect    += GameServer_OnClientConnect;
            GameServer.OnClientReceive    += GameServer_OnClientReceive;
            GameServer.OnClientDisconnect += GameServer_OnClientDisconnect;
            GameServer.Enable(GamePort, "0.0.0.0");
            #endregion
            Console.WriteLine("Server loaded iN : " + (Time32.Now - Start) + " MilliSeconds.");
            ConquordHandler += ConquordConsole_CloseEvent;
            Native.SetConsoleCtrlHandler(ConquordHandler, true);
            GC.Collect();
            WorkConsole();
        }