/// <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;
        }
示例#2
0
        private ZoneCorners TransposeCorner(MiscSection ms, ZoneCorners corner)
        {
            if (ms.Rotation == 1)
            {
                switch (corner)
                {
                    case ZoneCorners.BottomLeft:
                        return ZoneCorners.BottomRight;
                    case ZoneCorners.BottomRight:
                        return ZoneCorners.TopRight;
                    case ZoneCorners.TopLeft:
                        return ZoneCorners.BottomLeft;
                    case ZoneCorners.TopRight:
                        return ZoneCorners.TopLeft;
                }
            }
            else if (ms.Rotation == 2)
            {
                switch (corner)
                {
                    case ZoneCorners.BottomLeft:
                        return ZoneCorners.TopRight;
                    case ZoneCorners.BottomRight:
                        return ZoneCorners.TopLeft;
                    case ZoneCorners.TopLeft:
                        return ZoneCorners.BottomRight;
                    case ZoneCorners.TopRight:
                        return ZoneCorners.BottomLeft;
                }
            }
            else if (ms.Rotation == 3)
            {
                switch (corner)
                {
                    case ZoneCorners.BottomLeft:
                        return ZoneCorners.TopLeft;
                    case ZoneCorners.BottomRight:
                        return ZoneCorners.BottomLeft;
                    case ZoneCorners.TopLeft:
                        return ZoneCorners.TopRight;
                    case ZoneCorners.TopRight:
                        return ZoneCorners.BottomRight;
                }
            }

            return corner;
        }