Redo mobs subsystem to be more like SSai with regards to skipping

This commit is contained in:
Aronai Sieyes
2020-05-17 09:59:58 -04:00
parent 0f1d00d13b
commit 8eb77a04ec

View File

@@ -15,24 +15,23 @@ SUBSYSTEM_DEF(mobs)
var/list/currentrun = list()
var/log_extensively = FALSE
var/list/timelog = list()
var/list/busy_z_levels = list()
var/slept_mobs = 0
var/list/process_z = list()
/datum/controller/subsystem/mobs/stat_entry()
..("P: [global.mob_list.len] | S: [slept_mobs]")
/datum/controller/subsystem/mobs/fire(resumed = 0)
var/list/busy_z_levels = src.busy_z_levels
if (!resumed)
slept_mobs = 0
src.currentrun = mob_list.Copy()
busy_z_levels.Cut()
for(var/played_mob in player_list)
if(!played_mob || isobserver(played_mob))
continue
var/mob/pm = played_mob
busy_z_levels |= pm.z
process_z.Cut()
slept_mobs = 0
var/level = 1
while(process_z.len < GLOB.living_players_by_zlevel.len)
process_z.len++
process_z[level] = GLOB.living_players_by_zlevel[level].len
level++
//cache for sanic speed (lists are references anyways)
var/list/currentrun = src.currentrun
@@ -41,18 +40,13 @@ SUBSYSTEM_DEF(mobs)
var/mob/M = currentrun[currentrun.len]
currentrun.len--
if(QDELETED(M))
if(!M || QDELETED(M))
mob_list -= M
else
// Right now mob.Life() is unstable enough I think we need to use a try catch.
// Obviously we should try and get rid of this for performance reasons when we can.
try
if(M.low_priority && !(M.z in busy_z_levels))
slept_mobs++
continue
M.Life(times_fired)
catch(var/exception/e)
log_runtime(e, M, "Caught by [name] subsystem")
else if(M.low_priority && !(process_z[get_z(M)]))
slept_mobs++
continue
M.Life(times_fired)
if (MC_TICK_CHECK)
return