diff --git a/code/modules/random_map/building/building.dm b/code/modules/random_map/building/building.dm index e5d3953af0..98a157c459 100644 --- a/code/modules/random_map/building/building.dm +++ b/code/modules/random_map/building/building.dm @@ -7,7 +7,7 @@ for(var/x = 1, x <= limit_x, x++) for(var/y = 1, y <= limit_y, y++) var/current_cell = get_map_cell(x,y) - if(!within_bounds(current_cell)) + if(!current_cell) continue if(x == 1 || y == 1 || x == limit_x || y == limit_y) map[current_cell] = WALL_CHAR @@ -19,7 +19,7 @@ for(var/x = 1, x <= limit_x, x++) for(var/y = 1, y <= limit_y, y++) var/current_cell = get_map_cell(x,y) - if(!within_bounds(current_cell)) + if(!current_cell) continue if(!(x == 1 || y == 1 || x == limit_x || y == limit_y)) continue diff --git a/code/modules/random_map/noise/ore.dm b/code/modules/random_map/noise/ore.dm index 5e565df18b..4caacb7099 100644 --- a/code/modules/random_map/noise/ore.dm +++ b/code/modules/random_map/noise/ore.dm @@ -38,8 +38,8 @@ /datum/random_map/noise/ore/apply_to_turf(var/x,var/y) - var/tx = (origin_x+(x-1))*chunk_size - var/ty = (origin_y+(y-1))*chunk_size + var/tx = ((origin_x-1)+x)*chunk_size + var/ty = ((origin_y-1)+y)*chunk_size for(var/i=0,i[capitalize(name)] failed to generate ([round(0.1*(world.timeofday-start_time),0.1)] seconds): could not produce sane map.", R_DEBUG) /datum/random_map/proc/get_map_cell(var/x,var/y) + if(!islist(map)) + set_map_size() var/cell = ((y-1)*limit_x)+x if((cell < 1) || (cell > map.len)) return null @@ -103,16 +103,11 @@ var/global/list/map_count = list() for(var/x = 1, x <= limit_x, x++) for(var/y = 1, y <= limit_y, y++) var/current_cell = get_map_cell(x,y) - if(within_bounds(current_cell)) + if(current_cell) dat += get_map_char(map[current_cell]) dat += "
" user << "[dat]+------+" -/datum/random_map/proc/within_bounds(var/val) - if(!islist(map)) - set_map_size() - return (val>0) && (val<=map.len) - /datum/random_map/proc/set_map_size() map = list() map.len = limit_x * limit_y @@ -148,21 +143,26 @@ var/global/list/map_count = list() /datum/random_map/proc/check_map_sanity() return 1 -/datum/random_map/proc/apply_to_map(var/tx, var/ty, var/tz) - if(!tx) tx = isnull(origin_x) ? 1 : origin_x - if(!ty) ty = isnull(origin_y) ? 1 : origin_y - if(!tz) tz = isnull(origin_z) ? 1 : origin_z +/datum/random_map/proc/set_origins(var/tx, var/ty, var/tz) + origin_x = tx ? tx : 1 + origin_y = ty ? ty : 1 + origin_z = tz ? tz : 1 + +/datum/random_map/proc/apply_to_map() + if(!origin_x) origin_x = 1 + if(!origin_y) origin_y = 1 + if(!origin_z) origin_z = 1 for(var/x = 1, x <= limit_x, x++) for(var/y = 1, y <= limit_y, y++) if(!priority_process) sleep(-1) - apply_to_turf((tx-1)+x,(ty-1)+y,tz) + apply_to_turf(x,y) -/datum/random_map/proc/apply_to_turf(var/x,var/y,var/z) +/datum/random_map/proc/apply_to_turf(var/x,var/y) var/current_cell = get_map_cell(x,y) - if(!within_bounds(current_cell)) + if(!current_cell) return 0 - var/turf/T = locate(x,y,z) + var/turf/T = locate((origin_x-1)+x,(origin_y-1)+y,origin_z) if(!T || (target_turf_type && !istype(T,target_turf_type))) return 0 var/newpath = get_appropriate_path(map[current_cell]) @@ -193,7 +193,7 @@ var/global/list/map_count = list() for(var/x = 1, x <= limit_x, x++) for(var/y = 1, y <= limit_y, y++) var/current_cell = get_map_cell(x,y) - if(!within_bounds(current_cell)) + if(!current_cell) continue if(tx+x > target_map.limit_x) continue diff --git a/code/modules/random_map/random_map_verbs.dm b/code/modules/random_map/random_map_verbs.dm index 6ab98e20b7..f94bcd4589 100644 --- a/code/modules/random_map/random_map_verbs.dm +++ b/code/modules/random_map/random_map_verbs.dm @@ -75,7 +75,8 @@ tz = !isnull(tz) ? tz : T.z message_admins("[key_name_admin(usr)] has applied [M.name] at x[tx],y[ty],z[tz].") log_admin("[key_name(usr)] has applied [M.name] at x[tx],y[ty],z[tz].") - M.apply_to_map(tx,ty,tz) + M.set_origins(tx,ty,tz) + M.apply_to_map() /client/proc/overlay_random_map() set category = "Debug"