Misc. Optimizations (#3993)

changes:

Overlays now creates less temporary lists.
Falling no longer queues unsimulated atoms that wouldn't fall anyways (incl. LOs).
Pixel-shifted AO is now cached too.
Changed some references to get_map_cell() to macro equivalents in random maps.
Added smoothing hinting to the icon smoother, allowing for major performance improvements in common cases.
Space initialization no longer involves appearance churn (and is much faster as a result).
This commit is contained in:
Lohikar
2017-12-23 13:27:51 -06:00
committed by Erki
parent 64d24c6979
commit bb5a34eaf8
12 changed files with 213 additions and 131 deletions
+20 -11
View File
@@ -26,6 +26,7 @@ var/global/list/map_count = list()
// Storage for the final iteration of the map.
var/list/map = list() // Actual map.
var/tmp/map_len = 0
// If set, all sleep(-1) calls will be skipped.
// Test to see if rand_seed() can be used reliably.
@@ -100,23 +101,28 @@ var/global/list/map_count = list()
if(!user)
user = world
var/dat = "<code>+------+<br>"
map_len = map.len
var/list/dat = "<code>+------+<br>"
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(current_cell)
dat += get_map_char(map[current_cell])
var/tmp_cell
TRANSLATE_AND_VERIFY_COORD_MLEN(x, y, map_len)
if(tmp_cell)
dat += get_map_char(map[tmp_cell])
dat += "<br>"
user << "[dat]+------+</code>"
dat += "+------+</code>"
user << dat.Join()
/datum/random_map/proc/set_map_size()
map = list()
map.len = limit_x * limit_y
/datum/random_map/proc/seed_map()
map_len = map.len
for(var/x = 1, x <= limit_x, x++)
for(var/y = 1, y <= limit_y, y++)
var/current_cell = get_map_cell(x,y)
var/current_cell = TRANSLATE_COORD(x, y) // Coordinate cannot be invalid here, so use the faster no-validate one.
if(prob(initial_wall_cell))
map[current_cell] = WALL_CHAR
else
@@ -125,7 +131,7 @@ var/global/list/map_count = list()
/datum/random_map/proc/clear_map()
for(var/x = 1, x <= limit_x, x++)
for(var/y = 1, y <= limit_y, y++)
map[get_map_cell(x,y)] = 0
map[TRANSLATE_COORD(x, y)] = 0
/datum/random_map/proc/generate()
seed_map()
@@ -154,6 +160,8 @@ var/global/list/map_count = list()
if(!origin_y) origin_y = 1
if(!origin_z) origin_z = 1
map_len = map.len
for(var/x = 1, x <= limit_x, x++)
for(var/y = 1, y <= limit_y, y++)
if(!priority_process)
@@ -161,16 +169,17 @@ var/global/list/map_count = list()
apply_to_turf(x,y)
/datum/random_map/proc/apply_to_turf(var/x,var/y)
var/current_cell = get_map_cell(x,y)
if(!current_cell)
var/tmp_cell
TRANSLATE_AND_VERIFY_COORD_MLEN(x, y, map_len)
if(!tmp_cell)
return 0
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])
var/newpath = get_appropriate_path(map[tmp_cell])
if(newpath)
T.ChangeTurf(newpath)
get_additional_spawns(map[current_cell],T,get_spawn_dir(x, y))
get_additional_spawns(map[tmp_cell],T,get_spawn_dir(x, y))
return T
/datum/random_map/proc/get_spawn_dir()