def read_wrp(stream)
reader = BinaryReader.new(stream)
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
@texture_cell_size = OFP_CELL_SIZE
@terrain_height = Array.new(z_texture_range) do
reader.read_int16 x_texture_range
end
@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
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
end
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?
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