/// An error report generated by [parsed_map/check_for_errors]. /datum/map_report var/original_path var/list/bad_paths = list() var/list/bad_keys = list() /// Whether this map can be loaded safely despite the errors. var/loadable = TRUE var/crashed = TRUE var/static/tag_number = 0 /datum/map_report/New(datum/parsed_map/map) original_path = map.original_path || "Untitled" /// Show a rendered version of this report to a client. /datum/map_report/proc/show_to(client/C) var/list/html = list() html += "

Report for map file [original_path]

" if(crashed) html += "

Validation crashed: check the runtime logs.

" if(!loadable) html += "

Not loadable: some tiles are missing their turfs or areas.

" if(bad_paths.len) html += "

Bad paths:

    " for(var/path in bad_paths) var/list/keys = bad_paths[path] html += "
  1. [path]: used in ([keys.len]): [keys.Join(", ")]" html += "

" if(bad_keys.len) html += "

Bad keys:

" C << browse(html.Join(), "window=[tag];size=600x400") /datum/map_report/Topic(href, href_list) . = ..() if(. || !check_rights(R_ADMIN, FALSE) || !usr.client.holder.CheckAdminHref(href, href_list)) return if (href_list["show"]) show_to(usr) /// Check a parsed but not yet loaded map for errors. /// /// Returns a [/datum/map_report] if there are errors or `FALSE` otherwise. /datum/parsed_map/proc/check_for_errors() var/datum/map_report/report = new(src) . = report // build_cache will check bad paths for us var/list/modelCache = build_cache(TRUE, report.bad_paths) var/static/regex/area_or_turf = regex(@"/(turf|area)/") for(var/path in report.bad_paths) if(area_or_turf.Find("[path]", 1, 1)) report.loadable = FALSE // check for tiles with the wrong number of turfs or areas for(var/key in modelCache) if(key == SPACE_KEY) continue var/model = modelCache[key] var/list/members = model[1] var/turfs = 0 var/areas = 0 for(var/i in 1 to members.len) var/atom/path = members[i] turfs += ispath(path, /turf) areas += ispath(path, /area) if(turfs == 0) report.loadable = FALSE LAZYADD(report.bad_keys[key], "no turf") else if(turfs > 1) LAZYADD(report.bad_keys[key], "[turfs] stacked turfs") if(areas != 1) report.loadable = FALSE LAZYADD(report.bad_keys[key], "[areas] areas instead of 1") // return the report if(report.bad_paths.len || report.bad_keys.len || !report.loadable) // keep the report around so it can be referenced later report.tag = "mapreport_[++report.tag_number]" report.crashed = FALSE else return FALSE