예제 #1
0
        // This finds a lump by name, returns -1 when not found
        public int FindLastLumpIndex(string name, int start, int end)
        {
            if (name.Length > 8 || lumps.Count == 0 || start > lumps.Count - 1)
            {
                return(-1);                                                                           //mxd. Can't be here. Go away!
            }
            long longname = Lump.MakeLongName(name);

            // Fix start/end when they exceed safe bounds
            start = Math.Max(start, 0);
            end   = General.Clamp(end, 0, lumps.Count - 1);

            // Loop through the lumps in backwards order
            for (int i = end; i > start - 1; i--)
            {
                // Check if the lump name matches
                if (lumps[i].LongName == longname)
                {
                    // Found the lump!
                    return(i);
                }
            }

            // Nothing found
            return(-1);
        }
예제 #2
0
        // This finds a lump by name, returns -1 when not found
        public int FindLumpIndex(string name, int start, int end)
        {
            if (name.Length > 8)
            {
                return(-1);                               //mxd. Can't be here. Go away!
            }
            long longname = Lump.MakeLongName(name);

            // Fix end when it exceeds length
            if (end > (lumps.Count - 1))
            {
                end = lumps.Count - 1;
            }

            // Loop through the lumps
            for (int i = start; i <= end; i++)
            {
                // Check if the lump name matches
                if (lumps[i].LongName == longname)
                {
                    // Found the lump!
                    return(i);
                }
            }

            // Nothing found
            return(-1);
        }
예제 #3
0
        // This finds a lump by name, returns -1 when not found
        public int FindLumpIndex(string name, int start, int end)
        {
            byte[] fixedname;
            long   longname = Lump.MakeLongName(name);

            // Fix end when it exceeds length
            if (end > (lumps.Count - 1))
            {
                end = lumps.Count - 1;
            }

            // Make sure name is in uppercase
            name = name.ToUpperInvariant();

            // Make fixed name
            fixedname = Lump.MakeFixedName(name, ENCODING);

            // Loop through the lumps
            for (int i = start; i <= end; i++)
            {
                /*
                 * // Check if first byte matches
                 * if(lumps[i].FixedName[0] == fixedname[0])
                 * {
                 *      // Check if the lump name matches
                 *      if(lumps[i].Name.StartsWith(name, false, CultureInfo.InvariantCulture))
                 *      {
                 *              // Found the lump!
                 *              return i;
                 *      }
                 * }
                 */

                // Check if the lump name matches
                if (lumps[i].LongName == longname)
                {
                    // Found the lump!
                    return(i);
                }
            }

            // Nothing found
            return(-1);
        }