Bleeding edgy refresh (#303)

* not code stuff

* other things

* global vars, defines, helpers

* onclick hud stuff, orphans, world.dm

* controllers and datums

* game folder

* everything not client/mobs in modules

* client folder

* stage 1 mob stuff

* simple animal things

* silicons

* carbon things

* ayylmaos and monkeys

* hyoomahn

* icons n shit

* sprite fixes

* compile fixes

* some fixes I cherrypicked.

* qdel fixes

* forgot brain refractors
This commit is contained in:
Poojawa
2017-03-21 11:44:10 -05:00
committed by GitHub
parent 099a6c8764
commit f67e9f6d87
1476 changed files with 344416 additions and 40694 deletions
+82 -96
View File
@@ -1,119 +1,105 @@
var/datum/subsystem/lighting/SSlighting
var/datum/controller/subsystem/lighting/SSlighting
#define SSLIGHTING_LIGHTS 1
#define SSLIGHTING_TURFS 2
var/list/lighting_update_lights = list() // List of lighting sources queued for update.
var/list/lighting_update_corners = list() // List of lighting corners queued for update.
var/list/lighting_update_objects = list() // List of lighting objects queued for update.
/datum/subsystem/lighting
/datum/controller/subsystem/lighting
name = "Lighting"
init_order = 1
wait = 1
wait = 2
init_order = -20
flags = SS_TICKER
priority = 25
display_order = 5
var/list/changed_lights = list() //list of all datum/light_source that need updating
var/changed_lights_workload = 0 //stats on the largest number of lights (max changed_lights.len)
var/list/changed_turfs = list() //list of all turfs which may have a different light level
var/changed_turfs_workload = 0 //stats on the largest number of turfs changed (max changed_turfs.len)
var/initialized = FALSE
/datum/subsystem/lighting/New()
/datum/controller/subsystem/lighting/New()
NEW_SS_GLOBAL(SSlighting)
return ..()
/datum/subsystem/lighting/stat_entry()
..("L:[round(changed_lights_workload,1)]|T:[round(changed_turfs_workload,1)]")
/datum/controller/subsystem/lighting/stat_entry()
..("L:[lighting_update_lights.len]|C:[lighting_update_corners.len]|O:[lighting_update_objects.len]")
//Workhorse of lighting. It cycles through each light that needs updating. It updates their
//effects and then processes every turf in the queue, updating their lighting object's appearance
//Any light that returns 1 in check() deletes itself
//By using queues we are ensuring we don't perform more updates than are necessary
/datum/subsystem/lighting/fire(resumed = 0)
var/ticklimit = CURRENT_TICKLIMIT
//split our tick allotment in half so we don't spend it all on lightshift checks
CURRENT_TICKLIMIT = world.tick_usage + ((ticklimit-world.tick_usage)/2)
var/list/changed_lights = src.changed_lights
if (!resumed)
changed_lights_workload = MC_AVERAGE(changed_lights_workload, changed_lights.len)
var/i = 1
while (i <= changed_lights.len)
var/datum/light_source/LS = changed_lights[i++]
LS.check()
if (MC_TICK_CHECK)
break
if (i > 1)
changed_lights.Cut(1,i)
CURRENT_TICKLIMIT = ticklimit
var/list/changed_turfs = src.changed_turfs
if (!resumed)
changed_turfs_workload = MC_AVERAGE(changed_turfs_workload, changed_turfs.len)
i = 1
while (i <= changed_turfs.len)
var/turf/T = changed_turfs[i++]
if(T.lighting_changed)
T.redraw_lighting()
if (MC_TICK_CHECK)
break
if (i > 1)
changed_turfs.Cut(1,i)
//same as above except it attempts to shift ALL turfs in the world regardless of lighting_changed status
/datum/subsystem/lighting/Initialize(timeofday)
var/list/turfs_to_init = block(locate(1, 1, 1), locate(world.maxx, world.maxy, world.maxz))
/datum/controller/subsystem/lighting/Initialize(timeofday)
if (config.starlight)
for(var/area/A in world)
if (A.lighting_use_dynamic == DYNAMIC_LIGHTING_IFSTARLIGHT)
if (A.dynamic_lighting == DYNAMIC_LIGHTING_IFSTARLIGHT)
A.luminosity = 0
CHECK_TICK
for(var/thing in changed_lights)
var/datum/light_source/LS = thing
LS.check()
CHECK_TICK
changed_lights.Cut()
create_all_lighting_objects()
initialized = TRUE
for(var/thing in turfs_to_init)
var/turf/T = thing
T.init_lighting()
CHECK_TICK
changed_turfs.Cut()
fire(FALSE, TRUE)
..()
//Used to strip valid information from an existing instance and transfer it to the replacement. i.e. when a crash occurs
//It works by using spawn(-1) to transfer the data, if there is a runtime the data does not get transfered but the loop
//does not crash
/datum/subsystem/lighting/Recover()
if(!istype(SSlighting.changed_turfs))
SSlighting.changed_turfs = list()
if(!istype(SSlighting.changed_lights))
SSlighting.changed_lights = list()
/datum/controller/subsystem/lighting/fire(resumed, init_tick_checks)
var/real_tick_limit
if(!init_tick_checks)
real_tick_limit = CURRENT_TICKLIMIT
CURRENT_TICKLIMIT = ((real_tick_limit - world.tick_usage) / 3) + world.tick_usage
var/i = 0
for (i in 1 to lighting_update_lights.len)
var/datum/light_source/L = lighting_update_lights[i]
for(var/thing in SSlighting.changed_lights)
var/datum/light_source/LS = thing
spawn(-1) //so we don't crash the loop (inefficient)
LS.check()
if (L.check() || L.destroyed || L.force_update)
L.remove_lum()
if (!L.destroyed)
L.apply_lum()
for(var/thing in changed_turfs)
var/turf/T = thing
if(T.lighting_changed)
spawn(-1)
T.redraw_lighting()
else if (L.vis_update) //We smartly update only tiles that became (in) visible to use.
L.smart_vis_update()
var/msg = "## DEBUG: [time2text(world.timeofday)] [name] subsystem restarted. Reports:\n"
for(var/varname in SSlighting.vars)
switch(varname)
if("tag","bestF","type","parent_type","vars")
continue
else
var/varval1 = SSlighting.vars[varname]
var/varval2 = vars[varname]
if(istype(varval1,/list))
varval1 = "/list([length(varval1)])"
varval2 = "/list([length(varval2)])"
msg += "\t [varname] = [varval1] -> [varval2]\n"
log_world(msg)
L.vis_update = FALSE
L.force_update = FALSE
L.needs_update = FALSE
if(init_tick_checks)
CHECK_TICK
else if (MC_TICK_CHECK)
break
if (i)
lighting_update_lights.Cut(1, i+1)
i = 0
if(!init_tick_checks)
CURRENT_TICKLIMIT = ((real_tick_limit - world.tick_usage)/2)+world.tick_usage
for (i in 1 to lighting_update_corners.len)
var/datum/lighting_corner/C = lighting_update_corners[i]
C.update_objects()
C.needs_update = FALSE
if(init_tick_checks)
CHECK_TICK
else if (MC_TICK_CHECK)
break
if (i)
lighting_update_corners.Cut(1, i+1)
i = 0
if(!init_tick_checks)
CURRENT_TICKLIMIT = real_tick_limit
for (i in 1 to lighting_update_objects.len)
var/atom/movable/lighting_object/O = lighting_update_objects[i]
if (QDELETED(O))
continue
O.update()
O.needs_update = FALSE
if(init_tick_checks)
CHECK_TICK
else if (MC_TICK_CHECK)
break
if (i)
lighting_update_objects.Cut(1, i+1)
/datum/controller/subsystem/lighting/Recover()
initialized = SSlighting.initialized
..()