Class ColonizationMapLoader

  • All Implemented Interfaces:
    MapLoader

    public class ColonizationMapLoader
    extends java.lang.Object
    implements MapLoader
    Just pass the name of a Colonization map file (with extension ".MP"). The map file starts with a six-byte header. Byte zero encodes the map width, byte two encodes the map height. The function of the other bytes is unknown, their values, however, are fixed. The header is followed by three "layers", each the size of the map. The first "layer" encodes the terrain type. The function of the other layers is unknown. They are filled with zero bytes. It seems that the least significant three bits encode the basic terrain type, the next two bits encode the forest overlay and the special tile types ice, ocean and sea lanes. The three most significant bits encode combinations of the hill, mountain and river overlays. bits 0-2: tile type bit 3 (8): forest bit 4 (16): forest bits 3+4 (24): special, values larger than 26 are not defined bits 5-7: overlays 0: nothing 1: hill 2: minor river 3: hill + minor river (extremely rare) 4: nothing 5: mountain 6: major river 7: mountain + major river (never seen)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static byte[] header
      A byte array of file headers
      static int HEIGHT  
      static int HIGH_SEAS  
      private byte[] layer1  
      private static java.util.logging.Logger logger  
      static int OCEAN  
      private static java.lang.String[] tiletypes
      A String array of title types.
      static int WIDTH  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Map.Layer getHighestLayer()
      Returns the highest layer this MapLoader is able to load.
      Map.Layer loadMap​(Game game, Map.Layer layer)
      Load a map into the given game, copying all layers up to the given layer.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • logger

        private static final java.util.logging.Logger logger
      • tiletypes

        private static final java.lang.String[] tiletypes
        A String array of title types. Each represents a single type of tile available in FreeCol.
      • header

        private static final byte[] header
        A byte array of file headers
      • layer1

        private byte[] layer1
    • Constructor Detail

      • ColonizationMapLoader

        public ColonizationMapLoader​(java.io.File file)
                              throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • loadMap

        public Map.Layer loadMap​(Game game,
                                 Map.Layer layer)
        Load a map into the given game, copying all layers up to the given layer. Returns the highest layer actually copied, e.g. NONE if map loading failed, or the highest level available if an even higher level was requested.
        Specified by:
        loadMap in interface MapLoader
        Parameters:
        game - a Game value
        layer - a Layer value
        Returns:
        The highest Layer value
      • getHighestLayer

        public Map.Layer getHighestLayer()
        Returns the highest layer this MapLoader is able to load.
        Specified by:
        getHighestLayer in interface MapLoader
        Returns:
        The Layer value for RIVERS