/// <summary>
        /// Pre-condition: stream's file position must be at the beginning of a new section, marked with 4/8 byte ascii strings
        /// </summary>
        /// <param name="stream"></param>
        /// <returns></returns>
        public static SaveSection ParseSaveSection(FileStream stream, SimCity2000Save save)
        {
            byte[] name = new byte[4];

            stream.Read(name, 0, 4);
            string sectionName = BytesToString(name);

            SaveSection newSection = null;

            switch (sectionName)
            {
                case "MISC":
                    newSection = new MiscSection();
                    break;
                case "ALTM":
                    newSection = new AltitudeSection();
                    break;
                case "XTER":
                    newSection = new TerrainSection();
                    break;
                case "XBLD":
                    newSection = new BuildingSection();
                    break;
                case "XZON":
                    newSection = new ZoneSection();
                    ((ZoneSection)newSection).MiscSection = save.MiscSection;
                    break;
                default:
                    newSection = new SaveSection(sectionName);
                    break;
            }

            newSection.ParseSection(stream);
            return newSection;
        }
Esempio n. 2
0
        public ZoneDescriptor(Stream s, ZoneSection zs)
        {
            byte data = (byte)s.ReadByte();

            if ((data & 0x80) != 0)
            {
                CornerInfo |= TransposeCorner(zs.MiscSection, ZoneCorners.TopLeft);
            }

            if ((data & 0x40) != 0)
            {
                CornerInfo |= TransposeCorner(zs.MiscSection, ZoneCorners.BottomLeft);
            }

            if ((data & 0x20) != 0)
            {
                CornerInfo |= TransposeCorner(zs.MiscSection, ZoneCorners.BottomRight);
            }

            if ((data & 0x10) != 0)
            {
                CornerInfo |= TransposeCorner(zs.MiscSection, ZoneCorners.TopRight);
            }

            ZoneType = (ZoneType)(data & 0xF);
            IsMultiTile = false;
        }
 public TerrainGenerator(SimCity2000Save simCity, AnvilWorld world, BuildingSource buildingSource)
 {
     terrain = simCity.TerrainSection;
     altitude = simCity.AltitudeSection;
     buildings = simCity.BuildingSection;
     zones = simCity.ZoneSection;
     this.world = world;
     this.buildingSource = buildingSource;
     seaLevel = simCity.MiscSection.SeaLevel;
 }
 internal void SetZoneSection(ZoneSection section)
 {
     zoneSection = section;
 }