Skip to content

Commit

Permalink
Removes remnants of my enthusiasm 2: Electric Boogalo (#2717)
Browse files Browse the repository at this point in the history
  • Loading branch information
ImJustKisik authored Nov 2, 2024
1 parent 904ee58 commit bea01aa
Show file tree
Hide file tree
Showing 36 changed files with 223 additions and 137 deletions.
2 changes: 2 additions & 0 deletions code/__defines/ZAS.dm
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,5 @@ GLOBAL_LIST_INIT(gzn_check, list(
}

#endif

#define GAS_STANDARD_AIRMIX "STANDARD_AIRMIX"
4 changes: 4 additions & 0 deletions code/__defines/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -523,3 +523,7 @@
///from /datum/bank_account/pay_debt(), after a portion or all the debt has been paid.
#define COMSIG_BANK_ACCOUNT_DEBT_PAID "bank_account_debt_paid"
//[/SIERRA-ADD]

/// A null statement to guard against EmptyBlock lint without necessitating the use of pass()
/// Used to avoid proc-call overhead. But use sparingly. Probably pointless in most places.
#define EMPTY_BLOCK_GUARD ;
2 changes: 1 addition & 1 deletion code/controllers/master.dm
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ var/global/datum/controller/master/Master = new
SS.state = SS_IDLE
if (SS.flags & SS_TICKER)
tickersubsystems += SS
timer += world.tick_lag * rand(1, 5)
timer += world.tick_lag * rand(0,1)
SS.next_fire = timer
continue

Expand Down
17 changes: 12 additions & 5 deletions code/controllers/subsystems/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,26 @@ SUBSYSTEM_DEF(atoms)
if (QDELING(atom))
bad_inits[atom_type] |= BAD_INIT_QDEL_BEFORE
return TRUE
// This is handled and battle tested by dreamchecker. Limit to UNIT_TESTS just in case that ever fails.
#ifdef UNIT_TESTS
var/start_tick = world.time
#endif
var/hint = atom.Initialize(arglist(arguments))
#ifdef UNIT_TESTS
if (start_tick != world.time)
bad_inits[atom_type] |= BAD_INIT_SLEPT
#endif
var/deleted = FALSE
switch (hint)
if (INITIALIZE_HINT_NORMAL) //noop
if (INITIALIZE_HINT_LATELOAD)
if (arguments[1]) //mapload
switch(hint)
if(INITIALIZE_HINT_NORMAL)
EMPTY_BLOCK_GUARD
if(INITIALIZE_HINT_LATELOAD)
if(arguments[1]) //mapload
late_init_queue[atom] = arguments
else
atom.LateInitialize(arglist(arguments))
if (INITIALIZE_HINT_QDEL)
if(INITIALIZE_HINT_QDEL)
atom.atom_flags |= ATOM_FLAG_INITIALIZED // never call EarlyDestroy if we return this hint
qdel(atom)
deleted = TRUE
else
Expand Down
4 changes: 4 additions & 0 deletions code/controllers/subsystems/processing/nano.dm
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ PROCESSING_SUBSYSTEM_DEF(nano)
*/
/datum/controller/subsystem/processing/nano/proc/close_uis(src_object)
. = 0

if (!length(open_uis))
return

var/src_object_key = "\ref[src_object]"
if (!open_uis[src_object_key])
return
Expand Down
15 changes: 10 additions & 5 deletions code/datums/datum.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
var/list/_listen_lookup
/// Lazy associated list in the structure of `target -> list(signal -> proctype)` that are run when the datum receives that signal
var/list/list/_signal_procs

/// Used to avoid unnecessary refstring creation in Destroy().
var/has_state_machine = FALSE

//[/SIERRA-ADD]
// Default implementation of clean-up code.
// This should be overridden to remove all references pointing to the object being destroyed.
Expand Down Expand Up @@ -63,11 +67,12 @@
//[/SIERRA-ADD]
GLOB.destroyed_event && GLOB.destroyed_event.raise_event(src)
cleanup_events(src)
var/list/machines = global.state_machines["\ref[src]"]
if (length(machines))
for (var/base_type in machines)
qdel(machines[base_type])
global.state_machines -= "\ref[src]"
if(has_state_machine)
var/list/machines = global.state_machines["\ref[src]"]
if(length(machines))
for(var/base_type in machines)
qdel(machines[base_type])
global.state_machines -= "\ref[src]"
if (instance_pool?.ReturnInstance(src))
return QDEL_HINT_IWILLGC
instance_configurator = null
Expand Down
10 changes: 6 additions & 4 deletions code/datums/extensions/state_machine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
var/global/list/state_machines = list()

/proc/get_state_machine(datum/holder, base_type)
if(istype(holder) && base_type)
if(istype(holder) && base_type && holder.has_state_machine)
var/list/machines = global.state_machines["\ref[holder]"]
return islist(machines) && machines[base_type]

Expand All @@ -19,16 +19,18 @@ var/global/list/state_machines = list()
fsm_type = base_type
var/datum/state_machine/machine = new fsm_type(holder)
machines[base_type] = machine
holder.has_state_machine = TRUE
return machine

/proc/remove_state_machine(datum/holder, base_type)
if(istype(holder) && base_type)
if(istype(holder) && base_type && holder.has_state_machine)
var/holder_ref = "\ref[holder]"
var/list/machines = global.state_machines[holder_ref]
if(length(machines))
machines -= base_type
if(!length(machines))
global.state_machines -= holder_ref
holder.has_state_machine = FALSE
return TRUE
return FALSE

Expand All @@ -43,8 +45,8 @@ var/global/list/state_machines = list()

/datum/state_machine/New(datum/_holder)
..()
if(!istype(_holder))
stack_trace("Non-datum holder supplied to [type] New().")
if(!istype(_holder, expected_type))
stack_trace("Non-[expected_type] holder supplied to [type] New().")
else
holder_ref = weakref(_holder)
set_state(current_state)
Expand Down
8 changes: 8 additions & 0 deletions code/datums/observation/moved.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ GLOBAL_DATUM_INIT(moved_event, /singleton/observ/moved, new)
if(. && istype(mover.loc, expected_type))
register(mover.loc, mover, TYPE_PROC_REF(/atom/movable, recursive_move))

/singleton/observ/moved/unregister(atom/movable/mover, datum/listener, proc_call)
. = ..()

// Unregister from the parent if possible.
if(. && istype(mover.loc, expected_type))
unregister(mover.loc, mover, TYPE_PROC_REF(/atom/movable, recursive_move))


/********************
* Movement Handling *
********************/
Expand Down
4 changes: 2 additions & 2 deletions code/game/area/areas.dm
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@
A.contents.Add(T)
if(old_area)
old_area.Exited(T, A)
for(var/atom/movable/AM in T)
for(var/atom/movable/AM as anything in T)
old_area.Exited(AM, A) // Note: this _will_ raise exited events.
A.Entered(T, old_area)
for(var/atom/movable/AM in T)
for(var/atom/movable/AM as anything in T)
A.Entered(AM, old_area) // Note: this will _not_ raise moved or entered events. If you change this, you must also change everything which uses them.

for(var/obj/machinery/M in T)
Expand Down
4 changes: 2 additions & 2 deletions code/game/atoms_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
GLOB.moved_event.raise_event(src, old_loc, null)

// freelook
if(opacity)
if(simulated && opacity)
updateVisibility(src)

// lighting
Expand All @@ -244,7 +244,7 @@
GLOB.moved_event.raise_event(src, old_loc, null)

// freelook
if(opacity)
if(simulated && opacity)
updateVisibility(src)

// lighting
Expand Down
4 changes: 4 additions & 0 deletions code/game/machinery/_machines_base/machinery_components.dm
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ GLOBAL_LIST_INIT(machine_path_to_circuit_type, cache_circuits_by_build_path())
for(var/component_path in uncreated_component_parts)
var/number = uncreated_component_parts[component_path] || 1
LAZYREMOVE(uncreated_component_parts, component_path)
// Stacks are created differently to avoid qdel churn.
if(ispath(component_path, /obj/item/stack))
install_component(new component_path(src, number), refresh_parts = FALSE)
continue
for(var/i in 1 to number)
install_component(component_path, refresh_parts = FALSE)

Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/structures.dm
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
return istype(S, src)

/obj/structure/proc/refresh_neighbors()
for(var/thing in RANGE_TURFS(src, 1))
for(var/thing as anything in RANGE_TURFS(src, 1))
var/turf/T = thing
T.update_icon()

Expand Down
12 changes: 10 additions & 2 deletions code/game/turfs/flooring/flooring.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@
//How we smooth with other flooring
var/decal_layer = DECAL_LAYER
var/floor_smooth = SMOOTH_ALL
var/list/flooring_whitelist = list() //Smooth with nothing except the contents of this list
var/list/flooring_blacklist = list() //Smooth with everything except the contents of this list
/// Smooth with nothing except the types in this list. Turned into a typecache for performance reasons.
var/list/flooring_whitelist = list()
/// Smooth with everything except the types in this list. Turned into a typecache for performance reasons.
var/list/flooring_blacklist = list()

//How we smooth with walls
var/wall_smooth = SMOOTH_ALL
Expand All @@ -49,6 +51,12 @@

var/height = 0

/singleton/flooring/Initialize()
. = ..()
flooring_whitelist = typecacheof(flooring_whitelist)
flooring_blacklist = typecacheof(flooring_blacklist)


/singleton/flooring/proc/on_remove()
return

Expand Down
2 changes: 1 addition & 1 deletion code/game/turfs/simulated.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
var/list/resources

var/thermite = 0
initial_gas = list(GAS_OXYGEN = MOLES_O2STANDARD, GAS_NITROGEN = MOLES_N2STANDARD)
initial_gas = GAS_STANDARD_AIRMIX
var/to_be_destroyed = 0 //Used for fire, if a melting temperature was reached, it will be destroyed
var/max_fire_temperature_sustained = 0 //The max temperature of the fire which it was subjected to
var/dirt = 0
Expand Down
4 changes: 2 additions & 2 deletions code/game/turfs/simulated/floor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
/turf/simulated/floor/proc/set_flooring(singleton/flooring/newflooring)
make_plating(defer_icon_update = 1)
flooring = newflooring
update_icon(1)
queue_icon_update(SSatoms.initialized) // only update neighbors if we're setting flooring after SSatoms has finished
levelupdate()

//This proc will set floor_type to null and the update_icon() proc will then change the icon_state of the turf
Expand Down Expand Up @@ -106,7 +106,7 @@
initial_gas = null

/turf/simulated/floor/shuttle_ceiling/air
initial_gas = list(GAS_OXYGEN = MOLES_O2STANDARD, GAS_NITROGEN = MOLES_N2STANDARD)
initial_gas = GAS_STANDARD_AIRMIX

/turf/simulated/floor/is_floor()
return TRUE
Expand Down
70 changes: 31 additions & 39 deletions code/game/turfs/simulated/floor_icon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ var/global/list/flooring_cache = list()
if(update_neighbors)
for(var/turf/simulated/floor/F in orange(src, 1))
F.queue_ao(FALSE)
F.update_icon()
F.queue_icon_update()

/turf/simulated/floor/proc/get_flooring_overlay(cache_key, icon_base, icon_dir = 0, external = FALSE)
if(!flooring_cache[cache_key])
Expand Down Expand Up @@ -125,50 +125,42 @@ var/global/list/flooring_cache = list()
flooring_cache[cache_key] = I
return flooring_cache[cache_key]

/singleton/flooring/proc/test_link(turf/origin, turf/T)
/singleton/flooring/proc/test_link(turf/origin, turf/opponent)
var/is_linked = FALSE
//is_wall is true for wall turfs and for floors containing a low wall
if(T.is_wall())
if(wall_smooth == SMOOTH_ALL)
is_linked = TRUE

//If is_hole is true, then it's space or openspace
else if(T.is_open())
if(space_smooth == SMOOTH_ALL)
is_linked = TRUE


//If we get here then its a normal floor
else if (T.is_floor())
var/turf/simulated/floor/t = T

//Check for window frames.
if(wall_smooth == SMOOTH_ALL)
for(var/obj/structure/wall_frame/WF in T.contents)
if(istype(origin) && istype(opponent))
//is_wall is true for wall turfs and for floors containing a low wall
if(opponent.is_wall())
if(wall_smooth == SMOOTH_ALL)
is_linked = TRUE

//If the floor is the same as us,then we're linked,
if (istype(src, t.flooring))
is_linked = TRUE
else if (floor_smooth == SMOOTH_ALL)
is_linked = TRUE

else if (floor_smooth != SMOOTH_NONE)
//If is_hole is true, then it's space or openspace
else if(opponent.is_open())
if(space_smooth == SMOOTH_ALL)
is_linked = TRUE

//If we get here it must be using a whitelist or blacklist
if (floor_smooth == SMOOTH_WHITELIST)
for (var/v in flooring_whitelist)
if (istype(t.flooring, v))
//Found a match on the list
//If we get here then its a normal floor
else if (istype(opponent, /turf/simulated/floor))
var/turf/simulated/floor/floor_opponent = opponent
//If the floor is the same as us,then we're linked,
if (istype(src, floor_opponent.flooring))
is_linked = TRUE
else if (floor_smooth == SMOOTH_ALL)
is_linked = TRUE
else if (floor_smooth != SMOOTH_NONE)
//If we get here it must be using a whitelist or blacklist
if (floor_smooth == SMOOTH_WHITELIST)
if (flooring_whitelist[floor_opponent.flooring.type])
//Found a match on the typecache
is_linked = TRUE
break
else if(floor_smooth == SMOOTH_BLACKLIST)
is_linked = TRUE //Default to true for the blacklist, then make it false if a match comes up
for (var/v in flooring_whitelist)
if (istype(t.flooring, v))
//Found a match on the list
else if(floor_smooth == SMOOTH_BLACKLIST)
is_linked = TRUE //Default to true for the blacklist, then make it false if a match comes up
if (flooring_blacklist[floor_opponent.flooring.type])
//Found a match on the typecache
is_linked = FALSE
break
//Check for window frames.
if (!is_linked && wall_smooth == SMOOTH_ALL)
if(locate(/obj/structure/wall_frame) in opponent)
is_linked = TRUE
return is_linked

/singleton/flooring/proc/symmetric_test_link(turf/A, turf/B)
Expand Down
2 changes: 1 addition & 1 deletion code/game/turfs/space/space.dm
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
return

//We only need starlight on turfs adjacent to dynamically lit turfs, for example space near bulkhead
for (var/turf/T in RANGE_TURFS(src, 1))
for (var/turf/T as anything in RANGE_TURFS(src, 1))
if (!isloc(T.loc) || !TURF_IS_DYNAMICALLY_LIT_UNSAFE(T))
continue

Expand Down
2 changes: 1 addition & 1 deletion code/game/turfs/turf_ao.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/turf/var/ao_queued = AO_UPDATE_NONE

/turf/proc/regenerate_ao()
for (var/thing in RANGE_TURFS(src, 1))
for (var/thing as anything in RANGE_TURFS(src, 1))
var/turf/T = thing
if (T.permit_ao)
T.queue_ao(TRUE)
Expand Down
2 changes: 1 addition & 1 deletion code/game/turfs/turf_changing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
W.rebuild_zbleed()
// end of lighting stuff

for(var/turf/T in RANGE_TURFS(src, 1))
for(var/turf/T as anything in RANGE_TURFS(src, 1))
T.update_icon()

if(density != old_density)
Expand Down
2 changes: 1 addition & 1 deletion code/game/turfs/unsimulated.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/turf/unsimulated
name = "command"
initial_gas = list(GAS_OXYGEN = MOLES_O2STANDARD, GAS_NITROGEN = MOLES_N2STANDARD)
initial_gas = GAS_STANDARD_AIRMIX
turf_flags = TURF_DISALLOW_BLOB

// the new Diona Death Prevention Feature: gives an average amount of lumination
Expand Down
Loading

0 comments on commit bea01aa

Please sign in to comment.