Exemple #1
0
        public void RemoveKeySection(byte xiWaypoint)
        {
            KeyWaypointsChunk.KeySection lSection =
                GetKeySectionByWaypoint(xiWaypoint);

            if (lSection == null || xiWaypoint == 0)
            {
                return;
            }

            KeyWaypointsChunk.KeySection lPreviousSection =
                GetKeySectionByWaypoint((byte)(xiWaypoint - 1));
            KeyWaypointsChunk.KeySection lFollowingSection =
                GetKeySectionByWaypoint((byte)(xiWaypoint + 1));

            int lPreviousByteSize = KeyWaypoints.ByteSize;

            if (lPreviousSection == null && lFollowingSection == null)
            {
                ArrayList lSections = new ArrayList(KeyWaypoints.KeySections);
                lSections.Remove(lSection);
                KeyWaypoints.KeySections = (KeyWaypointsChunk.KeySection[])
                                           lSections.ToArray(typeof(KeyWaypointsChunk.KeySection));
            }
            else if (lPreviousSection == null)
            {
                lFollowingSection.From = (byte)(xiWaypoint + 1);
            }
            else if (lFollowingSection == null)
            {
                lPreviousSection.To = (byte)(xiWaypoint - 1);
            }
            else
            {
                KeyWaypointsChunk.KeySection lNewSection =
                    new KeyWaypointsChunk.KeySection((byte)(xiWaypoint + 1), lFollowingSection.To);
                KeyWaypointsChunk.KeySection[] lNewSectionArray =
                    new KeyWaypointsChunk.KeySection[KeyWaypoints.KeySections.Length + 1];
                Array.Copy(
                    KeyWaypoints.KeySections,
                    lNewSectionArray,
                    KeyWaypoints.KeySections.Length);
                lNewSectionArray[KeyWaypoints.KeySections.Length] = lNewSection;
                KeyWaypoints.KeySections = lNewSectionArray;
                lPreviousSection.To      = (byte)(xiWaypoint - 1);
            }

            TrailingZeroByteCount += lPreviousByteSize - KeyWaypoints.ByteSize;

            if (TrailingZeroByteCount < 0)
            {
                MessageBox.Show("You have run out of space in your level file! Please reduce the size of the file before saving.", "MMEd", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }

            mKeySectionsByWaypoint = null;
        }
Exemple #2
0
        public void RemoveKeySection(byte xiWaypoint)
        {
            KeyWaypointsChunk.KeySection lSection =
            GetKeySectionByWaypoint(xiWaypoint);

              if (lSection == null || xiWaypoint == 0)
              {
            return;
              }

              KeyWaypointsChunk.KeySection lPreviousSection =
            GetKeySectionByWaypoint((byte)(xiWaypoint - 1));
              KeyWaypointsChunk.KeySection lFollowingSection =
            GetKeySectionByWaypoint((byte)(xiWaypoint + 1));

              int lPreviousByteSize = KeyWaypoints.ByteSize;

              if (lPreviousSection == null && lFollowingSection == null)
              {
            ArrayList lSections = new ArrayList(KeyWaypoints.KeySections);
            lSections.Remove(lSection);
            KeyWaypoints.KeySections = (KeyWaypointsChunk.KeySection[])
              lSections.ToArray(typeof(KeyWaypointsChunk.KeySection));
              }
              else if (lPreviousSection == null)
              {
            lFollowingSection.From = (byte)(xiWaypoint + 1);
              }
              else if (lFollowingSection == null)
              {
            lPreviousSection.To = (byte)(xiWaypoint - 1);
              }
              else
              {
            KeyWaypointsChunk.KeySection lNewSection =
            new KeyWaypointsChunk.KeySection((byte)(xiWaypoint + 1), lFollowingSection.To);
            KeyWaypointsChunk.KeySection[] lNewSectionArray =
              new KeyWaypointsChunk.KeySection[KeyWaypoints.KeySections.Length + 1];
            Array.Copy(
              KeyWaypoints.KeySections,
              lNewSectionArray,
              KeyWaypoints.KeySections.Length);
            lNewSectionArray[KeyWaypoints.KeySections.Length] = lNewSection;
            KeyWaypoints.KeySections = lNewSectionArray;
            lPreviousSection.To = (byte)(xiWaypoint - 1);
              }

              TrailingZeroByteCount += lPreviousByteSize - KeyWaypoints.ByteSize;

              if (TrailingZeroByteCount < 0)
              {
            MessageBox.Show("You have run out of space in your level file! Please reduce the size of the file before saving.", "MMEd", MessageBoxButtons.OK, MessageBoxIcon.Stop);
              }

              mKeySectionsByWaypoint = null;
        }