Skip to content

Commit

Permalink
Merge branch 'dev-sierra' into jetpacks
Browse files Browse the repository at this point in the history
  • Loading branch information
UEDCommander authored Nov 2, 2024
2 parents d518750 + dd7683b commit bcdbbab
Show file tree
Hide file tree
Showing 96 changed files with 795 additions and 453 deletions.
3 changes: 3 additions & 0 deletions baystation12.dme
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@
#include "code\controllers\subsystems\initialization\persistence.dm"
#include "code\controllers\subsystems\initialization\robots.dm"
#include "code\controllers\subsystems\initialization\webhooks.dm"
#include "code\controllers\subsystems\initialization\xenoarch.dm"
#include "code\controllers\subsystems\processing\circuit.dm"
#include "code\controllers\subsystems\processing\disposals.dm"
#include "code\controllers\subsystems\processing\fast_process.dm"
Expand Down Expand Up @@ -3337,6 +3338,7 @@
#include "mods\_master_files\code\game\world.dm"
#include "mods\_master_files\code\game\gamemodes\ert.dm"
#include "mods\_master_files\code\game\objects\effects\decals\contraband.dm"
#include "mods\_master_files\code\game\objects\structures\mineral_bath.dm"
#include "mods\_master_files\code\game\objects\structures\signs.dm"
#include "mods\_master_files\code\game\objects\structures\crates_lockers\closets\_closet_appearance_definitions.dm"
#include "mods\_master_files\code\modules\client\asset_cache.dm"
Expand Down Expand Up @@ -3375,6 +3377,7 @@
#include "mods\_master_files\code\modules\overmap\panicbutton.dm"
#include "mods\_master_files\code\modules\power\gravitygenerator.dm"
#include "mods\_master_files\code\modules\projectiles\projectile\bullets.dm"
#include "mods\_master_files\code\modules\psionics\events\mini_spasm.dm"
#include "mods\_master_files\code\modules\species\species.dm"
#include "mods\_master_files\code\modules\species\station\adherent.dm"
#include "mods\_master_files\code\modules\species\station\human_subspecies.dm"
Expand Down
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 ;
9 changes: 5 additions & 4 deletions code/__defines/subsystem-priority.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
// SS_BACKGROUND handles high server load differently than Normal and SS_TICKER do.
// Higher priority also means a larger share of a given tick before sleep checks.


// [SIERRA-ADD] - SSINPUT
#define SS_PRIORITY_INPUT 1000 // Input MUST ALWAYS BE HIGHEST PRIORITY!!!

#define SS_PRIORITY_DEFAULT 50 // Default priority for all processes levels

// SS_TICKER
Expand All @@ -12,10 +16,7 @@

// Normal
#define SS_PRIORITY_TICKER 100 // Gameticker.
// [SIERRA-ADD] - SSINPUT
#define SS_PRIORITY_INPUT 99 // Input things.
#define SS_PRIORITY_EXPLOSIVES 90 // Explosion processing.
// [/SIERRA-ADD]
#define SS_PRIORITY_EXPLOSIVES 90 // Explosion processing. // [/SIERRA-ADD]
#define SS_PRIORITY_MOB 95 // Mob Life().
#define SS_PRIORITY_MACHINERY 95 // Machinery + powernet ticks.
#define SS_PRIORITY_AIR 80 // ZAS processing.
Expand Down
20 changes: 13 additions & 7 deletions code/_helpers/lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,19 @@ Checks if a list has the same entries and values as an element of big.
return len
return null

//Pick a random element from the list and remove it from the list.
/proc/pick_n_take(list/listfrom)
if (length(listfrom) > 0)
var/picked = pick(listfrom)
listfrom -= picked
return picked
return null
/// Pick a random element from the list and remove it from the list.
/proc/pick_n_take(list/list_to_pick)
RETURN_TYPE(list_to_pick[_].type)

var/list_length = length(list_to_pick)
if(!list_length)
return null

var/picked_index = rand(1, list_length)
var/picked = list_to_pick[picked_index]
list_to_pick.Cut(picked_index, picked_index + 1)

return picked


/// Remove and return the last element of the list, or null.
Expand Down
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
89 changes: 0 additions & 89 deletions code/controllers/subsystems/initialization/misc_late.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ SUBSYSTEM_DEF(init_misc_late)
var/singleton/asset_cache/asset_cache = GET_SINGLETON(/singleton/asset_cache)
asset_cache.load()
init_recipes()
init_xenoarch()


GLOBAL_VAR_INIT(microwave_maximum_item_storage, 0)
Expand Down Expand Up @@ -54,91 +53,3 @@ GLOBAL_LIST_EMPTY(microwave_accepts_items)

/proc/cmp_microwave_recipes_by_weight_dsc(datum/microwave_recipe/a, datum/microwave_recipe/b)
return a.weight - b.weight


GLOBAL_LIST_EMPTY(xeno_artifact_turfs)
GLOBAL_LIST_EMPTY(xeno_digsite_turfs)

/datum/controller/subsystem/init_misc_late/proc/init_xenoarch()
var/list/queue = list()
var/list/site_turfs = list()
var/list/artifact_turfs = list()
var/datum/map/map = GLOB.using_map
if (!map)
GLOB.xeno_artifact_turfs = list()
GLOB.xeno_digsite_turfs = list()
return
var/list/banned_levels = map.admin_levels + map.escape_levels
for (var/turf/simulated/mineral/M in world)
if (!M.density)
continue
if (M.z in banned_levels)
continue
if (!M.geologic_data)
M.geologic_data = new (M)
if (!prob(0.5))
continue
var/has_space = TRUE
for (var/turf/T as anything in site_turfs)
if (T.z != M.z)
continue
if (abs(T.x - M.x) > 3)
continue
if (abs(T.y - M.y) > 3)
continue
has_space = FALSE
break
if (!has_space)
continue
site_turfs += M
queue.Cut()
queue += M
for (var/turf/simulated/mineral/T in orange(2, M))
if (!T.density)
continue
if (T.finds)
continue
queue += T
var/site_turf_count = rand(4, 12)
if (site_turf_count < length(queue))
for (var/i = length(queue) - site_turf_count to 1 step -1)
var/selected = rand(1, length(queue))
queue.Cut(selected, selected + 1)
var/site_type = get_random_digsite_type()
for (var/turf/simulated/mineral/T as anything in queue)
if (!T.finds)
var/list/finds = list()
if (prob(50))
finds += new /datum/find (site_type, rand(10, 190))
else if (prob(75))
finds += new /datum/find (site_type, rand(10, 90))
finds += new /datum/find (site_type, rand(110, 190))
else
finds += new /datum/find (site_type, rand(10, 50))
finds += new /datum/find (site_type, rand(60, 140))
finds += new /datum/find (site_type, rand(150, 190))
var/datum/find/F = finds[1]
if (F.excavation_required <= F.view_range)
T.archaeo_overlay = "overlay_archaeo[rand(1, 3)]"
T.update_icon()
T.finds = finds
if (site_type == DIGSITE_GARDEN)
continue
if (site_type == DIGSITE_ANIMAL)
continue
artifact_turfs += T
CHECK_TICK
GLOB.xeno_digsite_turfs = site_turfs
GLOB.xeno_artifact_turfs = list()
for (var/i = rand(6, 12) to 1 step -1)
var/len = length(artifact_turfs)
if (len < 1)
break
var/selected = rand(1, len)
var/turf/simulated/mineral/T = artifact_turfs[selected]
artifact_turfs.Cut(selected, selected + 1)
// Failsafe for invalid turf types
if (!istype(T))
continue
GLOB.xeno_artifact_turfs += T
T.artifact_find = new
85 changes: 85 additions & 0 deletions code/controllers/subsystems/initialization/xenoarch.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
SUBSYSTEM_DEF(xenoarch)
name = "Xenoarcheology"
flags = SS_NO_FIRE
init_order = SS_INIT_XENOARCH
var/static/list/xeno_artifact_turfs = list()
var/static/list/xeno_digsite_turfs = list()

/datum/controller/subsystem/xenoarch/Initialize(start_uptime)
var/datum/map/map = GLOB.using_map
if (!map)
return

var/list/artifact_turfs = list()
var/static/excavation_turf_chance = 0.5
var/list/banned_levels = map.admin_levels + map.escape_levels
for(var/z_level_index in mining_walls)
if(text2num(z_level_index) in banned_levels)
continue

var/list/mining_turfs = mining_walls[z_level_index]
if(!length(mining_turfs))
continue

for(var/turf/simulated/mineral/mineral_turf as anything in mining_turfs)
if (!mineral_turf.density)
continue

if (!mineral_turf.geologic_data)
mineral_turf.geologic_data = new(mineral_turf)

if(!prob(excavation_turf_chance))
continue

xeno_digsite_turfs += mineral_turf
var/list/possible_site_turfs = list()
for(var/turf/simulated/mineral/T in RANGE_TURFS(mineral_turf, 2))
if(!T.density)
continue

if(T.finds)
continue

possible_site_turfs += T

possible_site_turfs = shuffle(possible_site_turfs)
LIST_RESIZE(possible_site_turfs, min(rand(4, 12), length(possible_site_turfs)))

var/site_type = get_random_digsite_type()
for(var/turf/simulated/mineral/T as anything in possible_site_turfs)
if(!T.finds)
var/list/finds = list()
if (prob(50))
finds += new /datum/find (site_type, rand(10, 190))
else if (prob(75))
finds += new /datum/find (site_type, rand(10, 90))
finds += new /datum/find (site_type, rand(110, 190))
else
finds += new /datum/find (site_type, rand(10, 50))
finds += new /datum/find (site_type, rand(60, 140))
finds += new /datum/find (site_type, rand(150, 190))
var/datum/find/F = finds[1]
if (F.excavation_required <= F.view_range)
T.archaeo_overlay = "overlay_archaeo[rand(1, 3)]"
T.update_icon()
T.finds = finds

if(site_type == DIGSITE_GARDEN)
continue

if(site_type == DIGSITE_ANIMAL)
continue

artifact_turfs += T

CHECK_TICK

var/xeno_artifact_turfs_amount = min(rand(6, 12), length(artifact_turfs))
for (var/i = 1 to xeno_artifact_turfs_amount)
var/turf/simulated/mineral/selected_mineral = pick_n_take(artifact_turfs)
// Failsafe for invalid turf types
if (!istype(selected_mineral))
continue

xeno_artifact_turfs += selected_mineral
selected_mineral.artifact_find = new
5 changes: 2 additions & 3 deletions code/controllers/subsystems/machines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,12 @@ SUBSYSTEM_DEF(machines)
var/static/cost_powernets = 0
var/static/cost_power_objects = 0
var/static/list/pipenets = list()
var/static/list/machinery = list()
var/static/list/machinery_by_type = list()
var/static/list/powernets = list()
var/static/list/power_objects = list()
var/static/list/processing = list()
var/static/list/queue = list()

var/static/list/machinery = list()
var/static/list/machinery_by_type = list()

/datum/controller/subsystem/machines/Recover()
current_step = SSMACHINES_PIPENETS
Expand Down
2 changes: 2 additions & 0 deletions code/controllers/subsystems/mapping.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ SUBSYSTEM_DEF(mapping)
space_ruins_templates = SSmapping.space_ruins_templates
exoplanet_ruins_templates = SSmapping.exoplanet_ruins_templates
away_sites_templates = SSmapping.away_sites_templates
submaps = SSmapping.submaps
submap_archetypes = SSmapping.submap_archetypes

/datum/controller/subsystem/mapping/proc/preloadTemplates(path = "maps/templates/") //see master controller setup
var/list/filelist = flist(path)
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
Loading

0 comments on commit bcdbbab

Please sign in to comment.