Exemple #1
0
        public WorldPacket(byte[] received_data)
        {
            var  decoded = Packets.decodeData(schema, received_data);
            uint height  = (uint)decoded[0];
            uint width   = (uint)decoded[1];

            int[,] worldData = (int [, ])decoded[2];
            int[,] bumpData  = (int [, ])decoded[3];
            world            = new LegendSharp.World(worldData, bumpData, (int)height, (int)width, new Dictionary <LegendSharp.Position, LegendSharp.Position>());
        }
Exemple #2
0
        public override byte[] encode(object data, BigEndianBitConverter converter)
        {
            LegendSharp.World world = (LegendSharp.World)data;
            var heightData          = converter.GetBytes(world.height);
            var widthData           = converter.GetBytes(world.width);
            var worldData           = world.GetWorldBytes();
            var worldLength         = converter.GetBytes(worldData.Length);
            var worldWordSize       = converter.GetBytes(world.GetWorldWordSize());
            //TODO: World encoding
            var output = new byte[heightData.Length + widthData.Length + worldLength.Length + worldData.Length + worldWordSize.Length];

            System.Buffer.BlockCopy(heightData, 0, output, 0, 4);
            System.Buffer.BlockCopy(widthData, 0, output, 4, 4);
            System.Buffer.BlockCopy(worldLength, 0, output, 8, 4);
            System.Buffer.BlockCopy(worldData, 0, output, 12, worldData.Length);
            System.Buffer.BlockCopy(worldWordSize, 0, output, 12 + worldData.Length, 4);

            return(output);
        }
Exemple #3
0
 public WorldPacket(LegendSharp.World world)
 {
     this.world = world;
 }