Skip to content

Commit

Permalink
Merge branch 'dev-sierra' into dev-sierra
Browse files Browse the repository at this point in the history
  • Loading branch information
Teteshnik1 authored Aug 1, 2024
2 parents 32bad22 + 8b8d81f commit 3ae0f96
Show file tree
Hide file tree
Showing 105 changed files with 4,276 additions and 1,394 deletions.
4 changes: 4 additions & 0 deletions code/__defines/lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#define LAZYREMOVE(L, I) if(L) { L -= I; if(!length(L)) { L = null; } }
// Adds I to L, initalizing L if necessary
#define LAZYADD(L, I) if(!L) { L = list(); } L += I;
//[SIERRA-ADD]
///Add an item to the list if not already present, if the list is null it will initialize it
#define LAZYOR(L, I) if(!L) { L = list(); } L |= I;
////[/SIERRA-ADD]
// Insert I into L at position X, initalizing L if necessary
#define LAZYINSERT(L, I, X) if(!L) { L = list(); } L.Insert(X, I);
// Adds I to L, initalizing L if necessary, if I is not already in L
Expand Down
180 changes: 180 additions & 0 deletions code/__defines/misc.dm
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#define DEBUG
//[SIERRA-ADD]
// Flags
#define ALL (~0) //For convenience.
#define NONE 0
//[/SIERRA-ADD]
// Turf-only flags.
#define TURF_FLAG_NOJAUNT FLAG(0) // This is used in literally one place, turf.dm, to block ethereal jaunt.
#define TURF_FLAG_NORUINS FLAG(1)
Expand Down Expand Up @@ -343,3 +348,178 @@
#define SANITY_CHECK_DEFAULT (SANITY_CHECK_TOOL_IN_HAND | SANITY_CHECK_BOTH_ADJACENT)

#define Z_ALL_TURFS(Z) block(locate(1, 1, Z), locate(world.maxx, world.maxy, Z))

//[SIERRA-ADD]
/// Used to trigger signals and call procs registered for that signal
/// The datum hosting the signal is automaticaly added as the first argument
/// Returns a bitfield gathered from all registered procs
/// Arguments given here are packaged in a list and given to _SendSignal
#define SEND_SIGNAL(target, sigtype, arguments...) ( !target._listen_lookup?[sigtype] ? NONE : target._SendSignal(sigtype, list(target, ##arguments)) )

#define SEND_GLOBAL_SIGNAL(sigtype, arguments...) ( SEND_SIGNAL(SSdcs, sigtype, ##arguments) )

/// Signifies that this proc is used to handle signals.
/// Every proc you pass to RegisterSignal must have this.
#define SIGNAL_HANDLER SHOULD_NOT_SLEEP(TRUE)

/// A wrapper for _AddElement that allows us to pretend we're using normal named arguments
#define AddElement(arguments...) _AddElement(list(##arguments))
/// A wrapper for _RemoveElement that allows us to pretend we're using normal named arguments
#define RemoveElement(arguments...) _RemoveElement(list(##arguments))

/// A wrapper for _AddComponent that allows us to pretend we're using normal named arguments
#define AddComponent(arguments...) _AddComponent(list(##arguments))

/// A wrapper for _AddComonent that passes in a source.
/// Necessary if dupe_mode is set to COMPONENT_DUPE_SOURCES.
#define AddComponentFrom(source, arguments...) _AddComponent(list(##arguments), source)

/// A wrapper for _LoadComponent that allows us to pretend we're using normal named arguments
#define LoadComponent(arguments...) _LoadComponent(list(##arguments))

// Main atom signals. Format:
// When the signal is called: (signal arguments)
// All signals send the source datum of the signal as the first argument

// /atom signals

///from base of atom/Entered(): (atom/movable/arrived, atom/old_loc, list/atom/old_locs)
#define COMSIG_ATOM_ENTERED "atom_entered"
/// Sent from the atom that just Entered src. From base of atom/Entered(): (/atom/destination, atom/old_loc, list/atom/old_locs)
#define COMSIG_ATOM_ENTERING "atom_entering"
// Atom movable signals. Format:
// When the signal is called: (signal arguments)
// All signals send the source datum of the signal as the first argument

///from base of atom/movable/Moved(): (/atom)
#define COMSIG_MOVABLE_PRE_MOVE "movable_pre_move"
#define COMPONENT_MOVABLE_BLOCK_PRE_MOVE FLAG(0)

///from base of atom/movable/Moved(): (atom/old_loc, forced)
#define COMSIG_MOVABLE_MOVED "movable_moved"

/// From base of /client/Move(): (list/move_args)
#define COMSIG_MOB_CLIENT_PRE_LIVING_MOVE "mob_client_pre_living_move"
/// Should we stop the current living movement attempt
#define COMSIG_MOB_CLIENT_BLOCK_PRE_LIVING_MOVE COMPONENT_MOVABLE_BLOCK_PRE_MOVE

/// From base of /mob/UpdateLyingBuckledAndVerbStatus()
#define COMSIG_MOB_UPDATE_LYING_BUCKLED_VERBSTATUS "mob_update_lying_buckled_verbstatus"

/// from mob/CanPass(): (atom/movable/mover, turf/target, height, air_group)
#define COMSIG_MOB_CAN_PASS "mob_can_pass"
#define COMPONENT_MOB_PASSABLE FLAG(0)

///from base of mob/ranged_attack(): (/atom, modifiers)
#define COMSIG_MOB_ATTACK_RANGED "mob_attack_ranged"
///from base of mob/ranged_attack_secondary(): (/atom, modifiers)
#define COMSIG_MOB_ATTACK_RANGED_SECONDARY "mob_attack_ranged_secondary"

///from base of proc/examinate(): (/atom, list/examine_strings)
#define COMSIG_MOB_EXAMINING "mob_examining"
///from base of proc/examinate(): (/atom)
#define COMSIG_MOB_EXAMINATE "mob_examinate"

/// Return this from `/datum/component/Initialize` or `/datum/component/OnTransfer` or `/datum/component/on_source_add` to have the component be deleted if it's applied to an incorrect type.
/// `parent` must not be modified if this is to be returned.
/// This will be noted in the runtime logs
#define COMPONENT_INCOMPATIBLE 1
/// Returned in PostTransfer to prevent transfer, similar to `COMPONENT_INCOMPATIBLE`
#define COMPONENT_NOTRANSFER 2

/// Return value to cancel attaching
#define ELEMENT_INCOMPATIBLE 1

// /datum/element flags
/// Causes the detach proc to be called when the host object is being deleted.
/// Should only be used if you need to perform cleanup not related to the host object.
/// You do not need this if you are only unregistering signals, for instance.
/// You would need it if you are doing something like removing the target from a processing list.
#define ELEMENT_DETACH_ON_HOST_DESTROY FLAG(0)
/**
* Only elements created with the same arguments given after `argument_hash_start_idx` share an element instance
* The arguments are the same when the text and number values are the same and all other values have the same ref
*/
#define ELEMENT_BESPOKE FLAG(1)
/// Causes all detach arguments to be passed to detach instead of only being used to identify the element
/// When this is used your Detach proc should have the same signature as your Attach proc
#define ELEMENT_COMPLEX_DETACH FLAG(2)
/**
* Elements with this flag will have their datum lists arguments compared as is,
* without the contents being sorted alpha-numerically first.
* This is good for those elements where the position of the keys matter, like in the case of color matrices.
*/
#define ELEMENT_DONT_SORT_LIST_ARGS FLAG(3)
/**
* Elements with this flag will be ignored by the dcs_check_list_arguments test.
* A good example is connect_loc, for which it's pratically undoable unless we force every signal proc to have a different name.
*/
#define ELEMENT_NO_LIST_UNIT_TEST FLAG(4)

// How multiple components of the exact same type are handled in the same datum
/// old component is deleted (default)
#define COMPONENT_DUPE_HIGHLANDER 0
/// duplicates allowed
#define COMPONENT_DUPE_ALLOWED 1
/// new component is deleted
#define COMPONENT_DUPE_UNIQUE 2
/**
* Component uses source tracking to manage adding and removal logic.
* Add a source/spawn to/the component by using AddComponentFrom(source, component_type, args...)
* Removing the last source will automatically remove the component from the parent.
* Arguments will be passed to on_source_add(source, args...); ensure that Initialize and on_source_add have the same signature.
*/
#define COMPONENT_DUPE_SOURCES 3
/// old component is given the initialization args of the new
#define COMPONENT_DUPE_UNIQUE_PASSARGS 4
/// each component of the same type is consulted as to whether the duplicate should be allowed
#define COMPONENT_DUPE_SELECTIVE 5

// Datum signals. Format:
// When the signal is called: (signal arguments)
// All signals send the source datum of the signal as the first argument

// /datum signals
/// when a component is added to a datum: (/datum/component)
#define COMSIG_COMPONENT_ADDED "component_added"
/// before a component is removed from a datum because of ClearFromParent: (/datum/component)
#define COMSIG_COMPONENT_REMOVING "component_removing"

/// before a datum's Destroy() is called: (force), returning a nonzero value will cancel the qdel operation
/// you should only be using this if you want to block deletion
/// that's the only functional difference between it and COMSIG_QDELETING, outside setting QDELETING to detect
#define COMSIG_PREQDELETED "parent_preqdeleted"
/// just before a datum's Destroy() is called: (force), at this point none of the other components chose to interrupt qdel and Destroy will be called
#define COMSIG_QDELETING "parent_qdeleting"
/// generic topic handler (usr, href_list)
#define COMSIG_TOPIC "handle_topic"
/// handler for vv_do_topic (usr, href_list)
#define COMSIG_VV_TOPIC "vv_topic"
#define COMPONENT_VV_HANDLED FLAG(0)
/// from datum ui_act (usr, action)
#define COMSIG_UI_ACT "COMSIG_UI_ACT"

/// fires on the target datum when an element is attached to it (/datum/element)
#define COMSIG_ELEMENT_ATTACH "element_attach"
/// fires on the target datum when an element is attached to it (/datum/element)
#define COMSIG_ELEMENT_DETACH "element_detach"

// Merger datum signals
/// Called on the object being added to a merger group: (datum/merger/new_merger)
#define COMSIG_MERGER_ADDING "comsig_merger_adding"
/// Called on the object being removed from a merger group: (datum/merger/old_merger)
#define COMSIG_MERGER_REMOVING "comsig_merger_removing"
/// Called on the merger after finishing a refresh: (list/leaving_members, list/joining_members)
#define COMSIG_MERGER_REFRESH_COMPLETE "comsig_merger_refresh_complete"

// Gas mixture signals
/// From /datum/gas_mixture/proc/merge: ()
#define COMSIG_GASMIX_MERGED "comsig_gasmix_merged"
/// From /datum/gas_mixture/proc/remove: ()
#define COMSIG_GASMIX_REMOVED "comsig_gasmix_removed"
/// From /datum/gas_mixture/proc/react: ()
#define COMSIG_GASMIX_REACTED "comsig_gasmix_reacted"

///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]
8 changes: 8 additions & 0 deletions code/_helpers/cmp.dm
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@

/proc/cmp_text_dsc(a,b)
return sorttext(a, b)
//[SIERRA-ADD]
/proc/cmp_embed_text_asc(a,b)
if(isdatum(a))
a = REF(a)
if(isdatum(b))
b = REF(b)
return sorttext("[b]", "[a]")
//[/SIERRA-ADD]

/proc/cmp_ruincost_priority(datum/map_template/ruin/A, datum/map_template/ruin/B)
return initial(A.spawn_cost) - initial(B.spawn_cost)
Expand Down
6 changes: 5 additions & 1 deletion code/_helpers/logging.dm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ var/global/log_end= world.system_type == UNIX ? ascii2text(13) : ""
for (var/client/C as anything in GLOB.admins)
if (C.get_preference_value(/datum/client_preference/staff/show_runtime_logs) == GLOB.PREF_SHOW)
to_chat(C, append_admin_tools(SPAN_DEBUG("<b>RUNTIME</b>: [text]"), usr, usr?.loc))

//[SIERRA-ADD]
/proc/log_signal(text)
if(config.log_signals)
game_log("SIGNALS", text)
//[/SIERRA-ADD]
/proc/log_error(text)
error(text)
to_debug_listeners(text, "ERROR")
Expand Down
16 changes: 16 additions & 0 deletions code/_helpers/type2type.dm
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,19 @@
/world/proc/file2list(filename, seperator="\n")
RETURN_TYPE(/list)
return splittext(file2text(filename), seperator)
//[SIERRA-ADD]
/proc/type2parent(child)
var/string_type = "[child]"
var/last_slash = findlasttext(string_type, "/")
if(last_slash == 1)
switch(child)
if(/datum)
return null
if(/obj, /mob)
return /atom/movable
if(/area, /turf)
return /atom
else
return /datum
return text2path(copytext(string_type, 1, last_slash))
//[/SIERRA-ADD]
4 changes: 4 additions & 0 deletions code/_helpers/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1079,3 +1079,7 @@ GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new)
return matches[1]
else
return (input("Select a type", "Select Type", matches[1]) as null|anything in matches)
//[SIERRA-ADD]
/proc/REF(input)
return "\ref[input]"
//[/SIERRA-ADD]
2 changes: 1 addition & 1 deletion code/controllers/admin.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ INITIALIZE_IMMEDIATE(/atom/movable/clickable_stat)
set category = "Debug"
set name = "Restart Controller"
var/client/client = usr?.client
if (!check_rights(R_ADMIN, TRUE, client))
if (!check_rights(R_ADMIN|R_DEBUG, TRUE, client))
return
if (controller == "Master")
Recreate_MC()
Expand Down
9 changes: 8 additions & 1 deletion code/controllers/configuration.dm
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@

/// log world.log to game log
var/static/log_world_output = FALSE

//[SIERRA-ADD]
/// log signals messages
var/static/log_signals = FALSE
//[/SIERRA-ADD]
/// Allows admins with relevant permissions to have their own ooc colour
var/static/allow_admin_ooccolor = FALSE

Expand Down Expand Up @@ -534,6 +537,10 @@
log_adminwarn = TRUE
if ("log_world_output")
log_world_output = TRUE
//[SIERRA-ADD]
if ("log_signals")
log_signals = TRUE
//[/SIERRA-ADD]
if ("log_hrefs")
log_hrefs = TRUE
if ("log_runtime")
Expand Down
5 changes: 3 additions & 2 deletions code/controllers/evacuation/evacuation.dm
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ var/global/datum/evacuation_controller/evacuation_controller
for(var/area/A in world)
if(istype(A, /area/hallway))
A.readyalert()
if(!skip_announce)
GLOB.using_map.emergency_shuttle_called_announcement()
//[SIERRA-EDIT]
GLOB.using_map.emergency_shuttle_called_announcement()
//[/SIERRA-EDIT]
else
if(!skip_announce)
// [SIERRA-EDIT] - ERIS_ANNOUNCER
Expand Down
2 changes: 1 addition & 1 deletion code/controllers/evacuation/evacuation_pods.dm
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,4 @@
#undef EVAC_OPT_ABANDON_SHIP
#undef EVAC_OPT_BLUESPACE_JUMP
#undef EVAC_OPT_CANCEL_ABANDON_SHIP
#undef EVAC_OPT_CANCEL_BLUESPACE_JUMP
#undef EVAC_OPT_CANCEL_BLUESPACE_JUMP
54 changes: 52 additions & 2 deletions code/datums/datum.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,22 @@

/// If this datum is pooled, the last configurator applied (if any).
var/singleton/instance_configurator/instance_configurator


//[SIERRA-ADD]
/**
* Components attached to this datum
*
* Lazy associated list in the structure of `type -> component/list of components`
*/
var/list/_datum_components
/**
* Any datum registered to receive signals from this datum is in this list
*
* Lazy associated list in the structure of `signal -> registree/list of registrees`
*/
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
//[/SIERRA-ADD]
// Default implementation of clean-up code.
// This should be overridden to remove all references pointing to the object being destroyed.
// Return the appropriate QDEL_HINT; in most cases this is QDEL_HINT_QUEUE.
Expand All @@ -25,6 +39,23 @@
else
qdel(extension)
extensions = null
//[SIERRA-ADD]
//BEGIN: ECS SHIT
var/list/dc = _datum_components
if(dc)
for(var/component_key in dc)
var/component_or_list = dc[component_key]
if(islist(component_or_list))
for(var/datum/component/component as anything in component_or_list)
qdel(component, FALSE)
else
var/datum/component/C = component_or_list
qdel(C, FALSE)
dc.Cut()

_clear_signal_refs()
//END: ECS SHIT
//[/SIERRA-ADD]
GLOB.destroyed_event && GLOB.destroyed_event.raise_event(src)
cleanup_events(src)
var/list/machines = global.state_machines["\ref[src]"]
Expand All @@ -39,6 +70,25 @@
weakref = null
return QDEL_HINT_QUEUE

//[SIERRA-ADD]
///Only override this if you know what you're doing. You do not know what you're doing
///This is a threat
/datum/proc/_clear_signal_refs()
var/list/lookup = _listen_lookup
if(lookup)
for(var/sig in lookup)
var/list/comps = lookup[sig]
if(length(comps))
for(var/datum/component/comp as anything in comps)
comp.UnregisterSignal(src, sig)
else
var/datum/component/comp = comps
comp.UnregisterSignal(src, sig)
_listen_lookup = lookup = null
//[/SIERRA-ADD]

for(var/target in _signal_procs)
UnregisterSignal(target, _signal_procs[target])

/datum/proc/Process()
set waitfor = 0
Expand Down
4 changes: 4 additions & 0 deletions code/datums/observation/entered.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ GLOBAL_DATUM_INIT(entered_event, /singleton/observ/entered, new)

/atom/Entered(atom/movable/enterer, atom/old_loc)
..()
//[SIERRA-ADD]
SEND_SIGNAL(src, COMSIG_ATOM_ENTERED, enterer, old_loc)
SEND_SIGNAL(enterer, COMSIG_ATOM_ENTERING, src, old_loc)
//[/SIERRA-ADD]
GLOB.entered_event.raise_event(src, enterer, old_loc)
Loading

0 comments on commit 3ae0f96

Please sign in to comment.