overmapper.rb
def parse_seen_data(data)
  boxes = Array.new
  position = 0

  data.scan(/\d+ \d+/).map do |e|
    visited, len = e.split.map(&:to_i)

    if visited == 1
      x0 = position % @conf[:mapx]
      y0 = position / @conf[:mapx]
      x1 = (position + len - 1) % @conf[:mapx]
      y1 = (position + len - 1) / @conf[:mapx]

      # split into 'scan lines' if needed
      if y0 != y1
        boxes.push([x0, y0, @conf[:mapx]-1, y0])
        (y0+1).upto(y1).each do |sy|
          if sy == y1
            boxes.push([0, sy, x1, sy])
          else
            boxes.push([0, sy, @conf[:mapx]-1, sy])
          end
        end
      else
        boxes.push([x0, y0, x1, y1])
      end
    end

    position += len
  end

  boxes
end
# Transform the raw seen data into an array of arrays of box coordinates for
# drawing
#
# Box coordinates are overmap-local and unscaled. Does translate the RLE
# into a set of 'scan lines', so to say...
Transform the raw seen data into an array of arrays of box coordinates for
drawing

Box coordinates are overmap-local and unscaled. Does translate the RLE
into a set of 'scan lines', so to say
Transform the raw seen data into an array of arrays of box coordinates for drawing Box coordinates are overmap - local and unscaled . Does translate the RLE into a set of ' scan lines ' so to say
def parse_seen_data(data)
  boxes = Array.new
  position = 0
  data.scan(/\d+ \d+/).map do |e|
    visited, len = e.split.map(&:to_i)
    if visited == 1
      x0 = position % @conf[:mapx]
      y0 = position / @conf[:mapx]
      x1 = (position + len - 1) % @conf[:mapx]
      y1 = (position + len - 1) / @conf[:mapx]
      if y0 != y1
        boxes.push([x0, y0, @conf[:mapx]-1, y0])
        (y0+1).upto(y1).each do |sy|
          if sy == y1
            boxes.push([0, sy, x1, sy])
          else
            boxes.push([0, sy, @conf[:mapx]-1, sy])
          end
        end
      else
        boxes.push([x0, y0, x1, y1])
      end
    end
    position += len
  end
  boxes
end
def parse_seen_data ( data ) boxes = Array . new position = 0 data . scan ( / \d +  \d + / ) . map do | e | visited , len = e . split . map ( & :to_i ) if visited == 1 x0 = position % @conf [ :mapx ] y0 = position / @conf [ :mapx ] x1 = ( position + len - 1 ) % @conf [ :mapx ] y1 = ( position + len - 1 ) / @conf [ :mapx ] if y0 != y1 boxes . push ( [ x0 , y0 , @conf [ :mapx ] - 1 , y0 ] ) ( y0 + 1 ) . upto ( y1 ) . each do | sy | if sy == y1 boxes . push ( [ 0 , sy , x1 , sy ] ) else boxes . push ( [ 0 , sy , @conf [ :mapx ] - 1 , sy ] ) end end else boxes . push ( [ x0 , y0 , x1 , y1 ] ) end end position += len end boxes end
Transform the raw seen data into an array of arrays of box coordinates for
drawing
Transform the raw seen data into an array of arrays of box coordinates for drawing
# split into 'scan lines' if needed
data