Class MapUtils

java.lang.Object
net.mtrop.doom.util.MapUtils

public final class MapUtils extends Object
Map utility methods and functions.
Author:
Matthew Tropiano
  • Field Details

  • Method Details

    • createDoomMap

      public static DoomMap createDoomMap(Wad wad, int index) throws MapException, IOException
      Creates a DoomMap from an entry index in a Wad that denotes a map header. If there is more than one header in the WAD that matches the provided header, the last one is found.
      Parameters:
      wad - the WAD to read from.
      index - the index of the map header entry.
      Returns:
      a DoomMap with all objects set.
      Throws:
      MapException - if map information is incomplete, or can't be found.
      IOException - if the WAD can't be read from.
      UnsupportedOperationException - if attempting to read from a Wad type that does not contain data.
    • createDoomMap

      public static DoomMap createDoomMap(Wad wad, String headerName) throws MapException, IOException
      Creates a DoomMap from a starting entry in a Wad. If there is more than one header in the WAD that matches the provided header, the last one is found.
      Parameters:
      wad - the WAD to read from.
      headerName - the map header name to search for.
      Returns:
      a DoomMap with all objects set.
      Throws:
      MapException - if map information is incomplete, or can't be found.
      IOException - if the WAD can't be read from.
      UnsupportedOperationException - if attempting to read from a Wad type that does not contain data.
    • createHexenMap

      public static HexenMap createHexenMap(Wad wad, int index) throws MapException, IOException
      Creates a HexenMap from an entry index in a Wad that denotes a map header. If there is more than one header in the WAD that matches the provided header, the last one is found.
      Parameters:
      wad - the WAD to read from.
      index - the index of the map header entry.
      Returns:
      a HexenMap with all objects set.
      Throws:
      MapException - if map information is incomplete, or can't be found.
      IOException - if the WAD can't be read from.
      UnsupportedOperationException - if attempting to read from a Wad type that does not contain data.
    • createHexenMap

      public static HexenMap createHexenMap(Wad wad, String headerName) throws MapException, IOException
      Creates a HexenMap from a starting entry in a Wad. If there is more than one header in the WAD that matches the provided header, the last one is found.
      Parameters:
      wad - the WAD to read from.
      headerName - the map header name to search for.
      Returns:
      a HexenMap with all objects set.
      Throws:
      MapException - if map information is incomplete, or can't be found.
      IOException - if the WAD can't be read from.
      UnsupportedOperationException - if attempting to read from a Wad type that does not contain data.
    • createUDMFMap

      public static UDMFMap createUDMFMap(Wad wad, int index) throws MapException, IOException
      Creates a UDMFMap from an entry index in a Wad that denotes a map header. If there is more than one header in the WAD that matches the provided header, the last one is found.
      Parameters:
      wad - the WAD to read from.
      index - the index of the map header entry.
      Returns:
      a UDMFMap with all objects set.
      Throws:
      MapException - if map information is incomplete, or can't be found.
      IOException - if the WAD can't be read from.
      UnsupportedOperationException - if attempting to read from a Wad type that does not contain data.
    • createUDMFMap

      public static UDMFMap createUDMFMap(Wad wad, String headerName) throws MapException, IOException
      Creates a UDMFMap from a starting entry in a Wad. If there is more than one header in the WAD that matches the provided header, the last one is found.
      Parameters:
      wad - the WAD to read from.
      headerName - the map header name to search for.
      Returns:
      a UDMFMap with all objects set.
      Throws:
      MapException - if map information is incomplete, or can't be found.
      IOException - if the WAD can't be read from.
      UnsupportedOperationException - if attempting to read from a Wad type that does not contain data.
    • createBSPTree

      public static BSPTree createBSPTree(Wad wad, String headerName) throws MapException, IOException
      Creates a BSPTree from a starting map entry in a Wad. If there is more than one header in the WAD that matches the provided header, the last one is found.
      Parameters:
      wad - the WAD to read from.
      headerName - the map header name to search for.
      Returns:
      a BSPTree with all objects set.
      Throws:
      MapException - if map information is incomplete, or can't be found.
      IOException - if the WAD can't be read from.
      UnsupportedOperationException - if attempting to read from a Wad type that does not contain data.
    • getAllMapIndices

      public static int[] getAllMapIndices(Wad wad)
      Returns all of the indices of every map in the wad. This algorithm scans for map entry names. If it finds one, the previous entry is the probably the header. This algorithm is not perfect, and may return false positives in case some outlying entries are named the same as some map entries.
      Parameters:
      wad - the Wad to search inside.
      Returns:
      an array of all of the entry indices of maps.
    • getAllMapHeaders

      public static String[] getAllMapHeaders(Wad wad)
      Returns all of the entry names of every map in the wad. This algorithm scans for map entry names. If it finds one, the previous entry is the probably the header.
      Parameters:
      wad - the Wad to search in.
      Returns:
      an array of all of the entry indices of maps.
    • getMapFormat

      public static MapFormat getMapFormat(Wad wad, int index)
      Figures out a map's format by its entry listing.
      Parameters:
      wad - the WAD to read from.
      index - the index of the map header entry.
      Returns:
      a MapFormat that details the map format type, or null if it cannot be figured out.
    • getMapFormat

      public static MapFormat getMapFormat(Wad wad, String headerName)
      Figures out a map's format by its entry listing.
      Parameters:
      wad - the WAD to read from.
      headerName - the map header name to search for.
      Returns:
      a MapFormat that details the map format type, or null if it cannot be figured out, nor if the header can be found.
    • getMapEntryCount

      public static int getMapEntryCount(Wad wad, String headerName)
      Returns the amount of entries in a map, including the header.
      Parameters:
      wad - the WAD to inspect.
      headerName - the map header name.
      Returns:
      the length, in entries, of the contiguous map data.
    • getMapEntryCount

      public static int getMapEntryCount(Wad wad, int startIndex)
      Returns the amount of entries in a map, including the header.
      Parameters:
      wad - the WAD to inspect.
      startIndex - the starting index.
      Returns:
      the length, in entries, of the contiguous map data.
    • getMapEntries

      public static WadEntry[] getMapEntries(Wad wad, int startIndex)
      Returns the entries in a map, including the header. The entry at the index is assumed to be the header.
      Parameters:
      wad - the WAD to inspect.
      startIndex - the starting index.
      Returns:
      the list of map entries for the map data.
      Since:
      2.1.0
    • getMapEntries

      public static WadEntry[] getMapEntries(Wad wad, String header)
      Returns the entries in a map, including the header, if the map is found. If there is more than one header in the WAD that matches the provided header, the last one is found.
      Parameters:
      wad - the WAD to inspect.
      header - the starting entry name to find.
      Returns:
      the list of map entries for the map data, or an empty array if the map header is not found.
      Since:
      2.1.0
    • isMapDataLump

      public static boolean isMapDataLump(String name)
      Tests if the entry name provided is a valid part of a map.
      Parameters:
      name - the lump name to test.
      Returns:
      if this is the name of a map data lump.