lib/IFMapper/Map.rb in ifmapper-0.6 vs lib/IFMapper/Map.rb in ifmapper-0.7

- old
+ new

@@ -12,15 +12,10 @@ attr_accessor :sections attr_accessor :width attr_accessor :height - def section=(x) - x = 0 if x < 0 - x = @sections.size - 1 if x >= @sections.size - @section = x - end # # Used for loading class with Marshal # def marshal_load(v) @@ -36,9 +31,32 @@ # # Used for saving class with Marshal # def marshal_dump [ @name, @creator, @date, @section, @sections, @width, @height ] + end + + def section=(x) + x = 0 if x < 0 + x = @sections.size - 1 if x >= @sections.size + @section = x + end + + # + # Auxiliary debugging function to verify the integrity of the map + # + def verify_integrity + @sections.each { |sect| + sect.rooms.each { |r| + r.exits.each_with_index { |e, idx| + next if not e + if not sect.connections.include?(e) + $stderr.puts "Exit #{e} in room, but not in section #{sect.name}." + r.exits[idx] = nil + end + } + } + } end def initialize(name) @section = 0 @name = name