# File ../lib/roller/CWRP.rb, line 371
  def read_wrp(stream)
    reader = BinaryReader.new(stream)

    # These vars are used in initiation, but can be derived from the
    # arrays after that.

    if is_arma?
      x_texture_range = reader.read_uint32
      z_texture_range = reader.read_uint32
      
      x_terrain_range = reader.read_uint32
      z_terrain_range = reader.read_uint32

      @texture_cell_size = reader.read_float

      @terrain_height = Array.new(z_terrain_range) do
        reader.read_float x_terrain_range
      end
    else
      x_texture_range = reader.read_uint32
      z_texture_range = reader.read_uint32

      # All OFP maps have the same texture gridsize.
      @texture_cell_size = OFP_CELL_SIZE

      # Terrain ranges are the same as texture ranges.
      @terrain_height = Array.new(z_texture_range) do
        reader.read_int16 x_texture_range
      end
      
      # Add crazy fudge factor to make OFP data same as ArmA data (within 1cm).
      @terrain_height.each do |row|
        row.map! { |height| height * OFP_TO_ARMA_HEIGHT_FACTOR }
      end
    end

    @texture_index = Array.new(z_texture_range) do
      reader.read_uint16 x_texture_range
    end

    # Load textures.
    if is_arma?
      n_textures = reader.read_uint32
      @textures = Array.new(n_textures) do
        Texture.new(reader, stream)
      end
    else
      @textures = Array.new
      
      OFP_NUM_TEXTURES.times do
        texture = Texture.new(stream)
        @textures.push texture unless texture.name.empty?
      end

      # TODO: Add a dummy texture?
    end

    # Load objects. Number unknown - goes to EOF.
    reset_progress 'Importing WRP', 1_000_000 / OBJECTS_PER_PROGRESS
    @objects = []
    until stream.eof?
            @objects.push WrpObject.new(reader, stream, @is_arma)
      increment_progress if @objects.size.modulo(OBJECTS_PER_PROGRESS) == 0
    end

    unless is_arma?
      # In ArmA maps, it is the convention that the first texture is a "dummy"
      # and is never used.
      #@textures.unshift Texture.new

      # Fudge-factor to correct the heights of objects.
      #@objects.each do |object|
#         object.position.z *= OFP_TO_ARMA_HEIGHT_FACTOR
      #end

      # In ArmA maps, it is the convention that the last object is a "centre"
      # marker.
      unless @objects.empty?
        centre = @objects.last.deep_copy
        centre.name = ''
        centre.id += 1
        centre.position.x = map_size / 2
        centre.position.y = map_size / 2
        @objects.push centre
      end
    end

    nil
  end