Ejemplo n.º 1
0
        public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
                                   Encoding encoding)
        {
            Encoding    = encoding ?? Encoding.GetEncoding("koi8-r");
            information = "";

            var sb = new StringBuilder();

            byte[] bk0 = imagePlugin.ReadSector(0 + partition.Start);

            Block0 block0 = Marshal.ByteArrayToStructureLittleEndian <Block0>(bk0);

            sb.AppendLine("MicroDOS filesystem");
            sb.AppendFormat("Volume has {0} blocks ({1} bytes)", block0.blocks, block0.blocks * 512).AppendLine();

            sb.AppendFormat("Volume has {0} blocks used ({1} bytes)", block0.usedBlocks, block0.usedBlocks * 512).
            AppendLine();

            sb.AppendFormat("Volume contains {0} files", block0.files).AppendLine();
            sb.AppendFormat("First used block is {0}", block0.firstUsedBlock).AppendLine();

            XmlFsType = new FileSystemType
            {
                Type                  = "MicroDOS",
                ClusterSize           = 512,
                Clusters              = block0.blocks,
                Files                 = block0.files,
                FilesSpecified        = true,
                FreeClusters          = (ulong)(block0.blocks - block0.usedBlocks),
                FreeClustersSpecified = true
            };

            information = sb.ToString();
        }
Ejemplo n.º 2
0
        public bool Identify(IMediaImage imagePlugin, Partition partition)
        {
            if (1 + partition.Start >= partition.End)
            {
                return(false);
            }

            if (imagePlugin.Info.SectorSize < 512)
            {
                return(false);
            }

            byte[] bk0 = imagePlugin.ReadSector(0 + partition.Start);

            Block0 block0 = Marshal.ByteArrayToStructureLittleEndian <Block0>(bk0);

            return(block0.label == MAGIC && block0.mklabel == MAGIC2);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Loads the specified file.
        /// </summary>
        /// <param name="filePath">The file path.</param>
        public void Load(string filePath)
        {
            FileHandler fh = new FileHandler(FilePath = filePath, FileHandler.FileOpenMode.Reading, Encoding.UTF8);

            int blockCount = fh.Read <int>();

            Blocks = new List <Block>(blockCount);

            for (int i = 0; i < blockCount; i++)
            {
                Blocks.Add(new Block()
                {
                    Type   = (BlockType)fh.Read <int>(),
                    Offset = fh.Read <int>()
                });
            }

            for (int i = 0; i < blockCount; i++)
            {
                fh.Seek(Blocks[i].Offset, SeekOrigin.Begin);

                switch (Blocks[i].Type)
                {
                case BlockType.Block0:
                {
                    ZoneInfo = new Block0()
                    {
                        ZoneType   = fh.Read <int>(),
                        ZoneWidth  = fh.Read <int>(),
                        ZoneHeight = fh.Read <int>(),
                        GridCount  = fh.Read <int>(),
                        GridSize   = fh.Read <float>(),

                        XCount = fh.Read <int>(),
                        YCount = fh.Read <int>()
                    };

                    ZoneInfo.ZoneParts = new Block0.ZonePart[ZoneInfo.ZoneWidth, ZoneInfo.ZoneHeight];

                    for (int j = 0; j < ZoneInfo.ZoneWidth; j++)
                    {
                        for (int k = 0; k < ZoneInfo.ZoneHeight; k++)
                        {
                            ZoneInfo.ZoneParts[j, k] = new Block0.ZonePart()
                            {
                                UseMap   = fh.Read <byte>(),
                                Position = fh.Read <Vector2>()
                            };
                        }
                    }
                }
                break;

                case BlockType.SpawnPoints:
                {
                    int spawnPointCount = fh.Read <int>();
                    SpawnPoints = new List <SpawnPoint>(spawnPointCount);

                    for (int j = 0; j < spawnPointCount; j++)
                    {
                        SpawnPoints.Add(new SpawnPoint()
                            {
                                Position = new Vector3()
                                {
                                    x = (fh.Read <float>() + 520000.00f) / 100.0f,
                                    z = fh.Read <float>() / 100.0f,
                                    y = (fh.Read <float>() + 520000.00f) / 100.0f
                                },

                                Name = fh.Read <BString>()
                            });
                    }
                }
                break;

                case BlockType.Textures:
                {
                    int textureCount = fh.Read <int>();
                    Textures = new List <Texture>(textureCount);

                    for (int j = 0; j < textureCount; j++)
                    {
                        Texture tex  = new Texture();
                        string  path = RootPath + fh.Read <BString>();
                        tex.Tex = Utils.loadTex(ref path);                                         //.ToLower().Replace("\\", "/").Replace(".dds",".png");
                        // = Resources.LoadAssetAtPath<Texture2D>(tex.TexPath);
                        tex.TexPath = path;

                        Textures.Add(tex);
                    }
                }
                break;

                case BlockType.Tiles:
                {
                    int tileCount = fh.Read <int>();
                    Tiles = new List <Tile>(tileCount);

                    for (int j = 0; j < tileCount; j++)
                    {
                        Tiles.Add(new Tile()
                            {
                                BaseID1    = fh.Read <int>(),
                                BaseID2    = fh.Read <int>(),
                                Offset1    = fh.Read <int>(),
                                Offset2    = fh.Read <int>(),
                                IsBlending = fh.Read <int>() > 0,
                                Rotation   = (RotationType)fh.Read <int>(),
                                TileType   = fh.Read <int>()
                            });
                    }
                }
                break;

                case BlockType.Economy:
                {
                    try
                    {
                        EconomyInfo = new Economy()
                        {
                            AreaName              = fh.Read <BString>(),
                            IsUnderground         = fh.Read <int>(),
                            ButtonBGM             = fh.Read <BString>(),
                            ButtonBack            = fh.Read <BString>(),
                            CheckCount            = fh.Read <int>(),
                            StandardPopulation    = fh.Read <int>(),
                            StandardGrowthRate    = fh.Read <int>(),
                            MetalConsumption      = fh.Read <int>(),
                            StoneConsumption      = fh.Read <int>(),
                            WoodConsumption       = fh.Read <int>(),
                            LeatherConsumption    = fh.Read <int>(),
                            ClothConsumption      = fh.Read <int>(),
                            AlchemyConsumption    = fh.Read <int>(),
                            ChemicalConsumption   = fh.Read <int>(),
                            IndustrialConsumption = fh.Read <int>(),
                            MedicineConsumption   = fh.Read <int>(),
                            FoodConsumption       = fh.Read <int>()
                        };
                    }
                    catch
                    {
                        Debug.LogError("-- Error reading the Economy Info block");


                        EconomyInfo = new Economy()
                        {
                            AreaName              = string.Empty,
                            IsUnderground         = 0,
                            ButtonBGM             = string.Empty,
                            ButtonBack            = string.Empty,
                            CheckCount            = 0,
                            StandardPopulation    = 0,
                            StandardGrowthRate    = 0,
                            MetalConsumption      = 0,
                            StoneConsumption      = 0,
                            WoodConsumption       = 0,
                            LeatherConsumption    = 0,
                            ClothConsumption      = 0,
                            AlchemyConsumption    = 0,
                            ChemicalConsumption   = 0,
                            IndustrialConsumption = 0,
                            MedicineConsumption   = 0,
                            FoodConsumption       = 0
                        };
                    }
                }
                break;
                }
            }

            fh.Close();
        }
Ejemplo n.º 4
0
	public void AddData(Block0 NewData) {
		Data.Add (NewData);
	}
Ejemplo n.º 5
0
        /// <summary>
        /// Loads the specified file.
        /// </summary>
        /// <param name="filePath">The file path.</param>
        public void Load(string filePath)
        {
            FileHandler fh = new FileHandler(FilePath = filePath, FileHandler.FileOpenMode.Reading, Encoding.UTF8);

            int blockCount = fh.Read<int>();

            Blocks = new List<Block>(blockCount);

            for (int i = 0; i < blockCount; i++)
            {
                Blocks.Add(new Block()
                {
                    Type = (BlockType)fh.Read<int>(),
                    Offset = fh.Read<int>()
                });
            }

            for (int i = 0; i < blockCount; i++)
            {
                fh.Seek(Blocks[i].Offset, SeekOrigin.Begin);

                switch (Blocks[i].Type)
                {
                    case BlockType.Block0:
                        {
                            ZoneInfo = new Block0()
                            {
                                ZoneType = fh.Read<int>(),
                                ZoneWidth = fh.Read<int>(),
                                ZoneHeight = fh.Read<int>(),
                                GridCount = fh.Read<int>(),
                                GridSize = fh.Read<float>(),

                                XCount = fh.Read<int>(),
                                YCount = fh.Read<int>()
                            };

                            ZoneInfo.ZoneParts = new Block0.ZonePart[ZoneInfo.ZoneWidth, ZoneInfo.ZoneHeight];

                            for (int j = 0; j < ZoneInfo.ZoneWidth; j++)
                            {
                                for (int k = 0; k < ZoneInfo.ZoneHeight; k++)
                                {
                                    ZoneInfo.ZoneParts[j, k] = new Block0.ZonePart()
                                    {
                                        UseMap = fh.Read<byte>(),
                                        Position = fh.Read<Vector2>()
                                    };
                                }
                            }
                        }
                        break;
                    case BlockType.SpawnPoints:
                        {
                            int spawnPointCount = fh.Read<int>();
                            SpawnPoints = new List<SpawnPoint>(spawnPointCount);

                            for (int j = 0; j < spawnPointCount; j++)
                            {
                                SpawnPoints.Add(new SpawnPoint()
                                {
                                    Position = new Vector3()
                                    {
                                        x = (fh.Read<float>() + 520000.00f) / 100.0f,
                                        z = fh.Read<float>() / 100.0f,
                                        y = (fh.Read<float>() + 520000.00f) / 100.0f
                                    },

                                    Name = fh.Read<BString>()
                                });
                            }
                        }
                        break;
                    case BlockType.Textures:
                        {
                            int textureCount = fh.Read<int>();
                            Textures = new List<Texture>(textureCount);

                            for (int j = 0; j < textureCount; j++)
                            {
                                Texture tex = new Texture();
                                string path = RootPath + fh.Read<BString>();
                                tex.Tex = Utils.loadTex(ref path); //.ToLower().Replace("\\", "/").Replace(".dds",".png");
                                // = Resources.LoadAssetAtPath<Texture2D>(tex.TexPath);
                                tex.TexPath = path;

                                Textures.Add(tex);

                            }
                        }
                        break;
                    case BlockType.Tiles:
                        {
                            int tileCount = fh.Read<int>();
                            Tiles = new List<Tile>(tileCount);

                            for (int j = 0; j < tileCount; j++)
                            {
                                Tiles.Add(new Tile()
                                {
                                    BaseID1 = fh.Read<int>(),
                                    BaseID2 = fh.Read<int>(),
                                    Offset1 = fh.Read<int>(),
                                    Offset2 = fh.Read<int>(),
                                    IsBlending = fh.Read<int>() > 0,
                                    Rotation = (RotationType)fh.Read<int>(),
                                    TileType = fh.Read<int>()
                                });
                            }
                        }
                        break;
                    case BlockType.Economy:
                        {
                            try
                            {
                                EconomyInfo = new Economy()
                                {
                                    AreaName = fh.Read<BString>(),
                                    IsUnderground = fh.Read<int>(),
                                    ButtonBGM = fh.Read<BString>(),
                                    ButtonBack = fh.Read<BString>(),
                                    CheckCount = fh.Read<int>(),
                                    StandardPopulation = fh.Read<int>(),
                                    StandardGrowthRate = fh.Read<int>(),
                                    MetalConsumption = fh.Read<int>(),
                                    StoneConsumption = fh.Read<int>(),
                                    WoodConsumption = fh.Read<int>(),
                                    LeatherConsumption = fh.Read<int>(),
                                    ClothConsumption = fh.Read<int>(),
                                    AlchemyConsumption = fh.Read<int>(),
                                    ChemicalConsumption = fh.Read<int>(),
                                    IndustrialConsumption = fh.Read<int>(),
                                    MedicineConsumption = fh.Read<int>(),
                                    FoodConsumption = fh.Read<int>()
                                };
                            }
                            catch
                            {
                                Debug.LogError("-- Error reading the Economy Info block");

                                EconomyInfo = new Economy()
                                {
                                    AreaName = string.Empty,
                                    IsUnderground = 0,
                                    ButtonBGM = string.Empty,
                                    ButtonBack = string.Empty,
                                    CheckCount = 0,
                                    StandardPopulation = 0,
                                    StandardGrowthRate = 0,
                                    MetalConsumption = 0,
                                    StoneConsumption = 0,
                                    WoodConsumption = 0,
                                    LeatherConsumption = 0,
                                    ClothConsumption = 0,
                                    AlchemyConsumption = 0,
                                    ChemicalConsumption = 0,
                                    IndustrialConsumption = 0,
                                    MedicineConsumption = 0,
                                    FoodConsumption = 0
                                };
                            }
                        }
                        break;
                }
            }

            fh.Close();
        }
Ejemplo n.º 6
0
	public void ExtendStructureY(bool IsBefore) {
		for (int i = 0; i < Data.Count; i++) {
			Block1 NewBlock1 = new Block1();
			for (int j = 0; j < Data[i].GetSize(); j++) {
				Block0 NewBlock0 = new Block0();
				NewBlock1.AddData(NewBlock0);
			}
			if (!IsBefore)
				Data[i].AddData(NewBlock1);
			else 
				Data[i].Insert(0,NewBlock1);
		}
	}
Ejemplo n.º 7
0
	public void ExtendStructureZ(bool IsBefore) {
		for (int i = 0; i < Data.Count; i++) {
			for (int j = 0; j < Data[i].GetSize(); j++) {
				Block0 NewBlock0 = new Block0();
				if (!IsBefore)
					Data[i].GetData(j).AddData(NewBlock0);
				else 
					Data[i].GetData(j).Insert(0,NewBlock0);
			}
		}
	}
Ejemplo n.º 8
0
	public void ExtendStructureX(bool IsBefore) {
		float i = Size.x;
		{
			Block2 NewBlock2 = new Block2(); 
			for (int j = 0; j < Size.y; j++) 
			{
				Block1 NewBlock1 = new Block1();
				for (int k = 0; k < Size.z; k++) 
				{
					Block0 NewBlock0 = new Block0();
					NewBlock1.AddData(NewBlock0);
				}
				NewBlock2.AddData(NewBlock1);
			}
			if (!IsBefore)
				Data.Add(NewBlock2);
			else 
				Data.Insert (0,NewBlock2);
		}
	}
Ejemplo n.º 9
0
	public void SetBlockData0(Block1 NewBlock1) {
		for (int k = 0; k < Size.z; k++) 
		{
			Block0 NewBlock0 = new Block0();
			NewBlock1.AddData(NewBlock0);
		}
	}
Ejemplo n.º 10
0
	public void InitilizeData() {
		ClearData ();
		for (int i = 0; i < Size.x; i++) 
		{
			Block2 NewBlock2 = new Block2(); 
			for (int j = 0; j < Size.y; j++) 
			{
				Block1 NewBlock1 = new Block1();
				for (int k = 0; k < Size.z; k++) 
				{
					Block0 NewBlock0 = new Block0();
					NewBlock1.AddData(NewBlock0);
				}
				NewBlock2.AddData(NewBlock1);
			}
			Data.Add(NewBlock2);
		}
		for (int i = 0; i < 32; i++) {
			BlockAmounts.Add (0);
		}
	}
Ejemplo n.º 11
0
	public List<Block2> GetData() {
		List<Block2> NewData = new List<Block2>();
		
		for (int i = 0; i < SizeX; i++) 
		{
			Block2 NewBlock2 = new Block2(); 
			for (int j = 0; j < SizeY; j++) 
			{
				Block1 NewBlock1 = new Block1();
				for (int k = 0; k < SizeZ; k++) 
				{
					Block0 NewBlock0 = new Block0();
					NewBlock0.SetType(Data[i].Data[j].Data[k].Type);
					NewBlock0.SetIsActivated(Data[i].Data[j].Data[k].IsActivated);
					NewBlock1.AddData(NewBlock0);
				}
				NewBlock2.AddData(NewBlock1);
			}
			NewData.Add(NewBlock2);
		}
		return NewData;
	}
Ejemplo n.º 12
0
	public void Insert(int Position, Block0 NewData) {
		Data.Insert (Position, NewData);
	}