コード例 #1
0
ファイル: KnyttArea.cs プロジェクト: youkaicountry/yknyttlib
 // Reads the next area in the map stream
 public KnyttArea(Stream map, KnyttWorld world)
 {
     Warp       = new KnyttWarp(this);
     this.World = world;
     this.loadFromStream(map);
     this.fetchAreaExtraData();
     this.fetchFlagWarpData();
 }
コード例 #2
0
ファイル: KnyttArea.cs プロジェクト: youkaicountry/yknyttlib
 public KnyttArea(KnyttPoint position, KnyttWorld world)
 {
     Warp          = new KnyttWarp(this);
     this.World    = world;
     this.Empty    = true;
     this.Position = position;
     this.fetchAreaExtraData();
     this.fetchFlagWarpData();
 }
コード例 #3
0
 public KnyttSave(KnyttWorld world, int slot = 0)
 {
     World = world;
     Slot  = slot;
     data  = new IniData();
     setWorldDirectory(World.WorldDirectoryName);
     setArea(new KnyttPoint(1000, 1000));
     setAreaPosition(new KnyttPoint(6, 6));
 }
コード例 #4
0
        public KnyttSave(KnyttWorld world, string ini_data, int slot)
        {
            this.World = world;
            this.Slot  = slot;
            var parser = new IniDataParser();

            this.data = parser.Parse(ini_data);
            this.setWorldDirectory(World.WorldDirectoryName);
        }
コード例 #5
0
        public static KnyttSave FromBinary(KnyttWorld world, byte[] data, bool slim = false)
        {
            var save = new KnyttSave(world);

            int bposition = 0;

            if (!slim)
            {
                var y = data[bposition++];
                var k = data[bposition++];
                if (y != 'Y' || k != 'K')
                {
                    throw new SystemException("Magic number YK not present");
                }
            }

            using (SHA1Managed sha1 = new SHA1Managed())
            {
                var hash = sha1.ComputeHash(Encoding.UTF8.GetBytes(save.getWorldDirectory()));
                for (int i = 0; i < (slim ? SLIM_HASH_BYTES : HASH_BYTES); i++)
                {
                    if (!(hash[i] == data[bposition++]))
                    {
                        throw new SystemException("World name hash doesn't match.");
                    }
                }
            }

            save.setArea(new KnyttPoint((int)new VarInt(data, ref bposition).Value + 1000,
                                        (int)new VarInt(data, ref bposition).Value + 1000));

            int bitpack = (int)new VarInt(data, ref bposition).Value;

            save.setAreaPosition(new KnyttPoint(bitpack & 0x1F, (bitpack & (0xF << 5)) >> 5));

            JuniValues values = new JuniValues();

            BinaryTools.readBoolArray(bitpack, values.Powers, 9);
            BinaryTools.readBoolArray(bitpack, values.Flags, 21);
            values.writeToSave(save);

            return(save);
        }
コード例 #6
0
        public static KnyttSave FromPassword(KnyttWorld world, string password)
        {
            var bytes = Base58.DecodePlain(password);

            return(FromBinary(world, bytes, slim: true));
        }