Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Optimize replays by implementing batch marking" #3092

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions code/_onclick/item_attack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
/obj/item/proc/melee_attack_chain(mob/user, atom/target, params)
var/is_right_clicking = (user.istate & ISTATE_SECONDARY)

// monkestation start: REPLAYS
//Monkestation edit: REPLAYS
SSdemo.mark_dirty(src)
if(isturf(target))
SSdemo.mark_turf(target)
else
SSdemo.mark_dirty(target)
// monkestation end: REPLAYS
//Monkestation edit: REPLAYS

if(tool_behaviour && (target.tool_act(user, src, tool_behaviour, is_right_clicking) & TOOL_ACT_MELEE_CHAIN_BLOCKING))
return TRUE
Expand Down
4 changes: 0 additions & 4 deletions code/controllers/subsystem/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,16 @@ SUBSYSTEM_DEF(atoms)
PROFILE_INIT_ATOM_BEGIN()
InitAtom(A, TRUE, mapload_arg)
PROFILE_INIT_ATOM_END(A)
SSdemo.mark_multiple_new(atoms) // monkestation edit: replays
else
#ifdef TESTING
count = 0
#endif

var/list/atoms_to_mark = list() // monkestation edit: replays
for(var/atom/A as anything in world)
if(!(A.flags_1 & INITIALIZED_1))
PROFILE_INIT_ATOM_BEGIN()
InitAtom(A, FALSE, mapload_arg)
PROFILE_INIT_ATOM_END(A)
atoms_to_mark += A // monkestation edit: replays
#ifdef TESTING
++count
#endif
Expand All @@ -124,7 +121,6 @@ SUBSYSTEM_DEF(atoms)
stoplag()
if(mapload_source)
set_tracked_initalized(INITIALIZATION_INNEW_MAPLOAD, mapload_source)
SSdemo.mark_multiple_new(atoms_to_mark) // monkestation edit: replays

testing("Initialized [count] atoms")

Expand Down
4 changes: 2 additions & 2 deletions code/datums/components/overlay_lighting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
/datum/component/overlay_lighting/proc/clean_old_turfs()
for(var/turf/lit_turf as anything in affected_turfs)
lit_turf.dynamic_lumcount -= lum_power
SSdemo.mark_multiple_turfs(affected_turfs) // monkestation edit: REPLAYS
SSdemo.mark_turf(lit_turf) //Monkestation Edit: REPLAYS
affected_turfs = null


Expand All @@ -181,9 +181,9 @@
. = list()
for(var/turf/lit_turf in view(lumcount_range, get_turf(current_holder)))
lit_turf.dynamic_lumcount += lum_power
SSdemo.mark_turf(lit_turf) //Monkestation Edit: REPLAYS
. += lit_turf
if(length(.))
SSdemo.mark_multiple_turfs(.) // monkestation edit: REPLAYS
affected_turfs = .


Expand Down
2 changes: 1 addition & 1 deletion code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
if(SSatoms.InitAtom(src, FALSE, args))
//we were deleted
return
SSdemo.mark_new(src) //Monkestation edit: Replays
SSdemo.mark_new(src) //Monkestation edit: Replays

/**
* The primary method that objects are setup in SS13 with
Expand Down
25 changes: 9 additions & 16 deletions code/modules/lighting/lighting_source.dm
Original file line number Diff line number Diff line change
Expand Up @@ -193,21 +193,16 @@
/datum/light_source/proc/remove_lum()
SETUP_CORNERS_REMOVAL_CACHE(src)
applied = FALSE
var/list/turfs_to_mark = list()
for (var/datum/lighting_corner/corner as anything in effect_str)
REMOVE_CORNER(corner)
LAZYREMOVE(corner.affecting, src)

// monkestation start: REPLAYS
turfs_to_mark += list(
corner.master_NE,
corner.master_SE,
corner.master_SW,
corner.master_NW
)
// monkestation end: REPLAYS

SSdemo.mark_multiple_turfs(turfs_to_mark) // monkestation edit: REPLAYS
//Monkestation Edit: REPLAYS
SSdemo.mark_turf(corner.master_NE)
SSdemo.mark_turf(corner.master_SE)
SSdemo.mark_turf(corner.master_SW)
SSdemo.mark_turf(corner.master_NW)
//Monkestation Edit: REPLAYS

effect_str = null

Expand Down Expand Up @@ -326,7 +321,6 @@
var/uses_multiz = !!GET_LOWEST_STACK_OFFSET(source_turf.z)
var/oldlum = source_turf.luminosity
source_turf.luminosity = CEILING(light_outer_range, 1)
var/list/turfs_to_mark = list()
if(!uses_multiz) // Yes I know this could be acomplished with an if in the for loop, but it's fukin lighting code man
for(var/turf/T in view(CEILING(light_outer_range, 1), source_turf))
if(IS_OPAQUE_TURF(T))
Expand All @@ -338,7 +332,7 @@
corners[T.lighting_corner_SE] = 0
corners[T.lighting_corner_SW] = 0
corners[T.lighting_corner_NW] = 0
turfs_to_mark += T // Monkestation Edit: REPLAYS
SSdemo.mark_turf(T) //Monkestation Edit: REPLAYS
else
for(var/turf/T in view(CEILING(light_outer_range, 1), source_turf))
if(IS_OPAQUE_TURF(T))
Expand All @@ -350,7 +344,7 @@
corners[T.lighting_corner_SE] = 0
corners[T.lighting_corner_SW] = 0
corners[T.lighting_corner_NW] = 0
turfs_to_mark += T // Monkestation Edit: REPLAYS
SSdemo.mark_turf(T) //Monkestation Edit: REPLAYS

var/turf/below = GET_TURF_BELOW(T)
var/turf/previous = T
Expand Down Expand Up @@ -389,10 +383,9 @@
corners[above.lighting_corner_SW] = 0
corners[above.lighting_corner_NW] = 0
above = GET_TURF_ABOVE(above)
turfs_to_mark += T // Monkestation Edit: REPLAYS
SSdemo.mark_turf(T) //Monkestation Edit: REPLAYS

source_turf.luminosity = oldlum
SSdemo.mark_multiple_turfs(turfs_to_mark)

SETUP_CORNERS_CACHE(src)

Expand Down
3 changes: 0 additions & 3 deletions code/modules/shuttle/docking.dm
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@
old_turfs[oldT] = move_mode

/obj/docking_port/mobile/proc/takeoff(list/old_turfs, list/new_turfs, list/moved_atoms, rotation, movement_direction, old_dock, area/underlying_old_area)
var/list/atoms_to_mark = list() // monkestation edit: replays
for(var/i in 1 to old_turfs.len)
var/turf/oldT = old_turfs[i]
var/turf/newT = new_turfs[i]
Expand All @@ -153,8 +152,6 @@
continue
moving_atom.onShuttleMove(newT, oldT, movement_force, movement_direction, old_dock, src) //atoms
moved_atoms[moving_atom] = oldT
atoms_to_mark += moving_atom
SSdemo.mark_multiple_dirty(atoms_to_mark) // monkestation edit: replays


/obj/docking_port/mobile/proc/cleanup_runway(obj/docking_port/stationary/new_dock, list/old_turfs, list/new_turfs, list/areas_to_move, list/moved_atoms, rotation, movement_direction, area/underlying_old_area)
Expand Down
2 changes: 2 additions & 0 deletions code/modules/shuttle/on_move.dm
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ All ShuttleMove procs go here

abstract_move(newT)

SSdemo.mark_dirty(src) //Monkestation Edit: Replays

return TRUE

// Called on atoms after everything has been moved
Expand Down
75 changes: 19 additions & 56 deletions monkestation/code/modules/replays/subsystem/replay.dm
Original file line number Diff line number Diff line change
Expand Up @@ -163,18 +163,14 @@ SUBSYSTEM_DEF(demo)
return SS_INIT_SUCCESS

/datum/controller/subsystem/demo/fire()
var/marked_new_len = length(src.marked_new)
var/marked_dirty_len = length(src.marked_dirty)
var/marked_turfs_len = length(src.marked_turfs)
var/del_list_len = length(del_list)
if(!marked_new_len && !marked_dirty_len && !marked_turfs_len && !del_list_len)
if(!src.marked_new.len && !src.marked_dirty.len && !src.marked_turfs.len && !src.del_list.len)
return // nothing to do

last_queued = marked_new_len + marked_dirty_len + marked_turfs_len
last_queued = src.marked_new.len + src.marked_dirty.len + src.marked_turfs.len
last_completed = 0

write_time()
if(del_list_len)
if(src.del_list.len)
var/s = "del [jointext(src.del_list, ",")]\n" // if I don't do it like this I get "incorrect number of macro arguments" because byond is stupid and sucks
WRITE_LOG_NO_FORMAT(GLOB.demo_log, s)
src.del_list.Cut()
Expand All @@ -183,11 +179,11 @@ SUBSYSTEM_DEF(demo)

var/list/marked_dirty = src.marked_dirty
var/list/dirty_updates = list()
while(length(marked_dirty))
while(marked_dirty.len)
last_completed++
var/atom/movable/M = marked_dirty[length(marked_dirty)]
var/atom/movable/M = marked_dirty[marked_dirty.len]
marked_dirty.len--
if(QDELETED(M))
if(M.gc_destroyed || !M)
continue
if(M.loc == M.demo_last_loc)
continue
Expand All @@ -210,7 +206,7 @@ SUBSYSTEM_DEF(demo)
if(MC_TICK_CHECK)
canceled = TRUE
break
if(length(dirty_updates))
if(dirty_updates.len)
var/s = "update [jointext(dirty_updates, ",")]\n"
WRITE_LOG_NO_FORMAT(GLOB.demo_log, s)
if(canceled)
Expand All @@ -219,11 +215,11 @@ SUBSYSTEM_DEF(demo)

var/list/marked_new = src.marked_new
var/list/new_updates = list()
while(length(marked_new))
while(marked_new.len)
last_completed++
var/atom/movable/M = marked_new[length(marked_new)]
var/atom/movable/M = marked_new[marked_new.len]
marked_new.len--
if(QDELETED(M))
if(M.gc_destroyed || !M)
continue
var/loc_string = "null"
if(isturf(M.loc))
Expand All @@ -235,7 +231,7 @@ SUBSYSTEM_DEF(demo)
if(MC_TICK_CHECK)
canceled = TRUE
break
if(length(new_updates))
if(new_updates.len)
var/s = "new [jointext(new_updates, ",")]\n"
WRITE_LOG_NO_FORMAT(GLOB.demo_log, s)
if(canceled)
Expand All @@ -244,17 +240,17 @@ SUBSYSTEM_DEF(demo)

var/list/marked_turfs = src.marked_turfs
var/list/turf_updates = list()
while(length(marked_turfs))
while(marked_turfs.len)
last_completed++
var/turf/T = marked_turfs[length(marked_turfs)]
var/turf/T = marked_turfs[marked_turfs.len]
marked_turfs.len--
if(T && T.appearance != T.demo_last_appearance)
turf_updates += "([T.x],[T.y],[T.z])=[encode_appearance(T.appearance, T.demo_last_appearance)]"
T.demo_last_appearance = T.appearance
if(MC_TICK_CHECK)
canceled = TRUE
break
if(length(turf_updates))
if(turf_updates.len)
var/s = "turf [jointext(turf_updates, ",")]\n"
WRITE_LOG_NO_FORMAT(GLOB.demo_log, s)
if(canceled)
Expand Down Expand Up @@ -423,68 +419,35 @@ SUBSYSTEM_DEF(demo)
msg += "}"
return ..()

/datum/controller/subsystem/demo/proc/mark_turf(turf/turf)
/datum/controller/subsystem/demo/proc/mark_turf(turf/T)
if(!can_fire)
return
if(isturf(turf))
if(!isturf(T))
return
marked_turfs[turf] = TRUE

/datum/controller/subsystem/demo/proc/mark_multiple_turfs(list/turf/turf_list)
if(!can_fire)
return
if(!islist(turf_list))
return
for(var/turf in turf_list)
if(!isturf(turf))
continue
marked_turfs[turf] = TRUE
marked_turfs[T] = TRUE

/datum/controller/subsystem/demo/proc/mark_new(atom/movable/M)
if(!can_fire)
return
if(!isobj(M) && !ismob(M))
return
if(QDELING(M))
if(M.gc_destroyed)
return
marked_new[M] = TRUE
if(marked_dirty[M])
marked_dirty -= M

/datum/controller/subsystem/demo/proc/mark_multiple_new(list/atom/atom_list)
if(!can_fire)
return
for(var/atom/atom as anything in atom_list)
if(!isobj(atom) && !ismob(atom))
continue
if(QDELING(atom))
continue
marked_new[atom] = TRUE
if(marked_dirty[atom])
marked_dirty -= atom

// I can't wait for when TG ports this and they make this a #define macro.
/datum/controller/subsystem/demo/proc/mark_dirty(atom/movable/M)
if(!can_fire)
return
if(!isobj(M) && !ismob(M))
return
if(QDELING(M))
if(M.gc_destroyed)
return
if(!marked_new[M])
marked_dirty[M] = TRUE

/datum/controller/subsystem/demo/proc/mark_multiple_dirty(list/atom/movable/dirty_list)
if(!can_fire)
return
for(var/atom/movable/dirty as anything in dirty_list)
if(!isobj(dirty) && !ismob(dirty))
continue
if(QDELING(dirty))
continue
if(!marked_new[dirty])
marked_dirty[dirty] = TRUE

/datum/controller/subsystem/demo/proc/mark_destroyed(atom/movable/M)
if(!can_fire)
return
Expand Down
Loading