diff --git a/baystation12.dme b/baystation12.dme index 5514ecc9fe..ec130cc9a0 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -951,7 +951,6 @@ #include "code\modules\mining\ore.dm" #include "code\modules\mining\ore_datum.dm" #include "code\modules\mining\satchel_ore_boxdm.dm" -#include "code\modules\mining\drilling\distribution.dm" #include "code\modules\mining\drilling\drill.dm" #include "code\modules\mining\drilling\scanner.dm" #include "code\modules\mob\death.dm" @@ -1264,6 +1263,8 @@ #include "code\modules\projectiles\projectile\energy.dm" #include "code\modules\projectiles\projectile\force.dm" #include "code\modules\projectiles\projectile\special.dm" +#include "code\modules\random_map\maze.dm" +#include "code\modules\random_map\mining_distribution.dm" #include "code\modules\random_map\random_map.dm" #include "code\modules\reagents\Chemistry-Colours.dm" #include "code\modules\reagents\Chemistry-Holder.dm" diff --git a/code/modules/random_map/_random_map_defines.dm b/code/modules/random_map/_random_map_defines.dm deleted file mode 100644 index 9a68f5aa3d..0000000000 --- a/code/modules/random_map/_random_map_defines.dm +++ /dev/null @@ -1,11 +0,0 @@ -#define MAP_CELL ((y-1)*real_size)+x -#define MAP_CENTRE (((y-1)+size/2)*real_size)+(x+size/2) -#define MAP_TOP_LEFT ((y-1)*real_size)+x -#define MAP_TOP_RIGHT ((y-1)*real_size)+(x+size) -#define MAP_BOTTOM_LEFT (((y+size)-1)*real_size)+x -#define MAP_BOTTOM_RIGHT ((((y+size)-1)*real_size)+(x+size)) -#define MAP_MID_TOP MAP_TOP_LEFT + (size/2) -#define MAP_MID_BOTTOM MAP_BOTTOM_LEFT + (size/2) -#define MAP_MID_LEFT (((y-1)+size/2)*real_size)+x -#define MAP_MID_RIGHT (((y-1)+size/2)*real_size)+(x+size) -#define ITERATE_BEFORE_FAIL 200 \ No newline at end of file diff --git a/code/modules/random_map/random_map.dm b/code/modules/random_map/random_map.dm index 036f80dd8e..8f100679de 100644 --- a/code/modules/random_map/random_map.dm +++ b/code/modules/random_map/random_map.dm @@ -2,6 +2,8 @@ This module is used to generate the debris fields/distribution maps/procedural stations. */ +var/global/list/random_maps = list() + /obj/item/test_randmap/New() new /datum/random_map(input("Seed?") as text|null) del(src) @@ -10,6 +12,10 @@ new /datum/random_map/ore(input("Seed?") as text|null) del(src) +/obj/item/test_randmap/maze/New() + new /datum/random_map/maze(input("Seed?") as text|null) + del(src) + /datum/random_map var/descriptor = "debris field" // Display name. var/real_size = 128 // Size of each edge (must be square :(). @@ -24,9 +30,32 @@ var/origin_z = 1 // Target Z-level. var/limit_x = 256 // Maximum x bound. var/limit_y = 256 // Maximum y bound. + var/iterate_before_fail = 120 // Infinite loop safeguard. + +/datum/random_map/proc/get_map_cell(var/x,var/y) + return ((y-1)*real_size)+x + +/datum/random_map/proc/display_map(atom/user) + + if(!user) + user = world + + for(var/x = 1, x <= real_size, x++) + var/line = "" + for(var/y = 1, y <= real_size, y++) + var/current_cell = get_map_cell(x,y) + if(within_bounds(current_cell)) + if(map[current_cell] == 2) + line += "#" + else + line += "." + user << line /datum/random_map/New(var/seed, var/tx, var/ty, var/tz, var/tlx, var/tly) + // Store this for debugging. + random_maps |= src + // Initialize map. set_map_size() @@ -46,8 +75,10 @@ if(generate()) world << "[capitalize(descriptor)] generation completed in [round(0.1*(world.timeofday-start_time),0.1)] seconds." return - world << "[capitalize(descriptor)] generation failed: could not produce sane map." - del(src) + world << "[capitalize(descriptor)] generation failed in [round(0.1*(world.timeofday-start_time),0.1)] seconds: could not produce sane map." + +/datum/random_map/proc/within_bounds(var/val) + return (val>0) && (val<=raw_map_size) /datum/random_map/proc/set_map_size(var/raw_size) if(!raw_size) @@ -58,19 +89,20 @@ /datum/random_map/proc/seed_map() for(var/x = 1, x <= real_size, x++) for(var/y = 1, y <= real_size, y++) + var/current_cell = get_map_cell(x,y) if(x == 1 || x == real_size || y == 1 || y == real_size) - map[MAP_CELL] = rand(1,2) + map[current_cell] = rand(1,2) else - map[MAP_CELL] = rand(1,cell_range) + map[current_cell] = rand(1,cell_range) /datum/random_map/proc/clear_map() for(var/x = 1, x <= real_size, x++) for(var/y = 1, y <= real_size, y++) - map[MAP_CELL] = 0 + map[get_map_cell(x,y)] = 0 /datum/random_map/proc/generate() seed_map() - for(var/i=0;i raw_map_size) + if(!within_bounds(current_cell)) continue // Copy over original value. - next_map[MAP_CELL] = map[MAP_CELL] + next_map[current_cell] = map[current_cell] // Check all neighbors. var/count = 0 - for(var/cell in list(MAP_CELL,MAP_TOP_LEFT,MAP_MID_TOP,MAP_TOP_RIGHT,MAP_MID_RIGHT,MAP_BOTTOM_RIGHT,MAP_MID_BOTTOM,MAP_BOTTOM_LEFT,MAP_MID_LEFT)) - if((cell > 0) && (cell <= raw_map_size) && (map[cell] == 2)) + for(var/cell in list(current_cell,get_map_cell(x+1,y+1),get_map_cell(x-1,y-1),get_map_cell(x+1,y-1),get_map_cell(x-1,y+1),get_map_cell(x-1,y),get_map_cell(x,y-1),get_map_cell(x+1,y),get_map_cell(x,y+1))) + if(within_bounds(cell) && map[cell] == 2) count++ if(count>=5) - next_map[MAP_CELL] = 2 // becomes a wall + next_map[current_cell] = 2 // becomes a wall else - next_map[MAP_CELL] = 1 // becomes a floor + next_map[current_cell] = 1 // becomes a floor map = next_map /datum/random_map/proc/check_map_sanity() @@ -109,12 +142,13 @@ apply_to_turf(origin_x+x,origin_y+y) /datum/random_map/proc/apply_to_turf(var/x,var/y) - if((MAP_CELL <= 0) || (MAP_CELL > raw_map_size)) + var/current_cell = get_map_cell(x,y) + if(!within_bounds(current_cell)) return var/turf/T = locate(x,y,origin_z) if(!T) return - switch(map[MAP_CELL]) + switch(map[current_cell]) if(1) T.ChangeTurf(/turf/simulated/floor/plating/airless/asteroid) if(2)