mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2025-12-25 17:41:56 +00:00
Speed up asteroid generation a bunch (#2872)
Shaves 10-20 seconds off of asteroid generation time, bringing it down to 20 seconds, as well as renames some macros so their function is more clear.
This commit is contained in:
@@ -12,75 +12,60 @@
|
||||
|
||||
// Automata-specific procs and processing.
|
||||
/datum/random_map/automata/generate_map()
|
||||
for(var/i=1;i<=iterations;i++)
|
||||
iterate(i)
|
||||
for(var/iter = 1 to iterations)
|
||||
var/list/next_map[limit_x*limit_y]
|
||||
var/count
|
||||
var/is_not_border_left
|
||||
var/is_not_border_right
|
||||
var/ilim_u
|
||||
var/ilim_d
|
||||
var/bottom_lim = ((limit_y - 1) * limit_x)
|
||||
|
||||
/datum/random_map/automata/get_additional_spawns(var/value, var/turf/T)
|
||||
return
|
||||
if (!islist(map))
|
||||
set_map_size()
|
||||
|
||||
/datum/random_map/automata/proc/iterate(var/iteration)
|
||||
var/list/next_map[limit_x*limit_y]
|
||||
var/tmp_cell
|
||||
var/current_cell
|
||||
var/count
|
||||
if (!islist(map))
|
||||
set_map_size()
|
||||
for(var/x = 1, x <= limit_x, x++)
|
||||
for(var/y = 1, y <= limit_y, y++)
|
||||
PREPARE_CELL(x,y)
|
||||
current_cell = tmp_cell
|
||||
next_map[current_cell] = map[current_cell]
|
||||
for (var/i in 1 to (limit_x * limit_y))
|
||||
count = 0
|
||||
|
||||
// Every attempt to place this in a proc or a list has resulted in
|
||||
// the generator being totally bricked and useless. Fuck it. We're
|
||||
// hardcoding this shit. Feel free to rewrite and PR a fix. ~ Z
|
||||
PREPARE_CELL(x,y)
|
||||
if (tmp_cell && CELL_ALIVE(map[tmp_cell]))
|
||||
count++
|
||||
PREPARE_CELL(x+1,y+1)
|
||||
if (tmp_cell && CELL_ALIVE(map[tmp_cell]))
|
||||
count++
|
||||
PREPARE_CELL(x-1,y-1)
|
||||
if (tmp_cell && CELL_ALIVE(map[tmp_cell]))
|
||||
count++
|
||||
PREPARE_CELL(x+1,y-1)
|
||||
if (tmp_cell && CELL_ALIVE(map[tmp_cell]))
|
||||
count++
|
||||
PREPARE_CELL(x-1,y+1)
|
||||
if (tmp_cell && CELL_ALIVE(map[tmp_cell]))
|
||||
count++
|
||||
PREPARE_CELL(x-1,y)
|
||||
if (tmp_cell && CELL_ALIVE(map[tmp_cell]))
|
||||
count++
|
||||
PREPARE_CELL(x,y-1)
|
||||
if (tmp_cell && CELL_ALIVE(map[tmp_cell]))
|
||||
count++
|
||||
PREPARE_CELL(x+1,y)
|
||||
if (tmp_cell && CELL_ALIVE(map[tmp_cell]))
|
||||
count++
|
||||
PREPARE_CELL(x,y+1)
|
||||
if (tmp_cell && CELL_ALIVE(map[tmp_cell]))
|
||||
count++
|
||||
is_not_border_left = i != 1 && ((i - 1) % limit_x)
|
||||
is_not_border_right = i % limit_x
|
||||
|
||||
if (CELL_ALIVE(map[i])) // Center row.
|
||||
++count
|
||||
if (is_not_border_left && CELL_ALIVE(map[i - 1]))
|
||||
++count
|
||||
if (is_not_border_right && CELL_ALIVE(map[i + 1]))
|
||||
++count
|
||||
|
||||
if (i > limit_x) // top row
|
||||
ilim_u = i - limit_x
|
||||
if (CELL_ALIVE(map[ilim_u]))
|
||||
++count
|
||||
if (is_not_border_left && CELL_ALIVE(map[ilim_u - 1]))
|
||||
++count
|
||||
if (is_not_border_right && CELL_ALIVE(map[ilim_u + 1]))
|
||||
++count
|
||||
|
||||
if (i <= bottom_lim) // bottom row
|
||||
ilim_d = i + limit_x
|
||||
if (CELL_ALIVE(map[ilim_d]))
|
||||
++count
|
||||
if (is_not_border_left && CELL_ALIVE(map[ilim_d - 1]))
|
||||
++count
|
||||
if (is_not_border_right && CELL_ALIVE(map[ilim_d + 1]))
|
||||
++count
|
||||
|
||||
if(count >= cell_threshold)
|
||||
REVIVE_CELL(current_cell, next_map)
|
||||
else
|
||||
KILL_CELL(current_cell, next_map)
|
||||
|
||||
CHECK_TICK
|
||||
REVIVE_CELL(i, next_map)
|
||||
else // Nope. Can't be alive. Kill it.
|
||||
KILL_CELL(i, next_map)
|
||||
|
||||
map = next_map
|
||||
CHECK_TICK
|
||||
|
||||
/datum/random_map/automata/proc/revive_cell(var/target_cell, var/list/use_next_map, var/final_iter)
|
||||
if(!use_next_map)
|
||||
use_next_map = map
|
||||
use_next_map[target_cell] = cell_live_value
|
||||
map = next_map
|
||||
|
||||
/datum/random_map/automata/proc/kill_cell(var/target_cell, var/list/use_next_map, var/final_iter)
|
||||
if(!use_next_map)
|
||||
use_next_map = map
|
||||
use_next_map[target_cell] = cell_dead_value
|
||||
/datum/random_map/automata/get_additional_spawns(value, turf/T)
|
||||
return
|
||||
|
||||
#undef KILL_CELL
|
||||
#undef REVIVE_CELL
|
||||
|
||||
@@ -32,12 +32,9 @@
|
||||
|
||||
// Create ore turfs.
|
||||
/datum/random_map/automata/cave_system/cleanup()
|
||||
var/tmp_cell
|
||||
for (var/x = 1; x < limit_x; x++)
|
||||
for (var/y = 1; y < limit_y; y++)
|
||||
PREPARE_CELL(x, y)
|
||||
if (tmp_cell && CELL_ALIVE(map[tmp_cell]))
|
||||
ore_turfs += tmp_cell
|
||||
for (var/i = 1 to (limit_x * limit_y))
|
||||
if (CELL_ALIVE(map[i]))
|
||||
ore_turfs += i
|
||||
|
||||
game_log("ASGEN", "Found [ore_turfs.len] ore turfs.")
|
||||
var/ore_count = round(map.len/20)
|
||||
@@ -68,8 +65,6 @@
|
||||
if(!origin_z) origin_z = 1
|
||||
|
||||
var/tmp_cell
|
||||
var/x
|
||||
var/y
|
||||
var/new_path
|
||||
var/num_applied = 0
|
||||
for (var/thing in block(locate(origin_x, origin_y, origin_z), locate(limit_x, limit_y, origin_z)))
|
||||
@@ -78,13 +73,7 @@
|
||||
if (!T || (target_turf_type && !istype(T, target_turf_type)))
|
||||
continue
|
||||
|
||||
x = T.x
|
||||
y = T.y
|
||||
|
||||
PREPARE_CELL(x,y)
|
||||
|
||||
if (!tmp_cell)
|
||||
continue
|
||||
tmp_cell = TRANSLATE_COORD(T.x, T.y)
|
||||
|
||||
switch (map[tmp_cell])
|
||||
if(DOOR_CHAR)
|
||||
@@ -119,7 +108,6 @@
|
||||
target_turf_type = /turf/unsimulated/chasm_mask
|
||||
mineral_sparse = /turf/unsimulated/mask
|
||||
mineral_rich = /turf/unsimulated/mask
|
||||
cell_threshold = 5
|
||||
|
||||
/datum/random_map/automata/cave_system/chasms/apply_to_map()
|
||||
if(!origin_x) origin_x = 1
|
||||
@@ -127,9 +115,6 @@
|
||||
if(!origin_z) origin_z = 1
|
||||
|
||||
var/tmp_cell
|
||||
var/x
|
||||
var/y
|
||||
var/z
|
||||
var/new_path
|
||||
var/num_applied = 0
|
||||
for (var/thing in block(locate(origin_x, origin_y, origin_z), locate(limit_x, limit_y, origin_z)))
|
||||
@@ -138,14 +123,7 @@
|
||||
if (!T || (target_turf_type && !istype(T, target_turf_type)))
|
||||
continue
|
||||
|
||||
x = T.x
|
||||
y = T.y
|
||||
z = T.z
|
||||
|
||||
PREPARE_CELL(x,y)
|
||||
|
||||
if (!tmp_cell)
|
||||
continue
|
||||
tmp_cell = TRANSLATE_COORD(T.x, T.y)
|
||||
|
||||
switch (map[tmp_cell])
|
||||
if(DOOR_CHAR)
|
||||
@@ -153,7 +131,7 @@
|
||||
if(EMPTY_CHAR)
|
||||
new_path = mineral_rich
|
||||
if(FLOOR_CHAR)
|
||||
var/turf/below = GET_BELOW_OR_NULL(T, z)
|
||||
var/turf/below = GET_BELOW_OR_NULL(T, T.z)
|
||||
if(below)
|
||||
var/area/below_area = below.loc // Let's just assume that the turf is not in nullspace.
|
||||
if(below_area.station_area)
|
||||
|
||||
Reference in New Issue
Block a user