Skip to content

Commit

Permalink
Merge pull request Civ13#2823 from Bierkraan/working-branch
Browse files Browse the repository at this point in the history
General fixes
  • Loading branch information
Bierkraan authored May 12, 2024
2 parents 4bb0521 + b16c9f3 commit 678b3a8
Show file tree
Hide file tree
Showing 24 changed files with 270 additions and 201 deletions.
2 changes: 1 addition & 1 deletion code/__defines/dcs/helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/// 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.comp_lookup || !target.comp_lookup[sigtype] ? NONE : target._SendSignal(sigtype, list(target, ##arguments)) )
#define SEND_SIGNAL(target, sigtype, arguments...) ( !target._listen_lookup || !target._listen_lookup[sigtype] ? NONE : target._SendSignal(sigtype, list(target, ##arguments)) )

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

Expand Down
1 change: 1 addition & 0 deletions code/_macros.dm
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ Get the ultimate area of `A`, similarly to [get_turf].
#define SPAN_WARNING(X) SPAN("warning", X)
#define SPAN_DANGER(X) SPAN("danger", X)
#define SPAN_RED(X) SPAN("red", X)
#define SPAN_BLUE(X) SPAN("blue", X)
#define SPAN_GREEN(X) SPAN("green", X)
#define SPAN_GREEN_BOLD(X) SPAN("green_bold", X)
#define SPAN_ALERT(X) SPAN("alert", X)
Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/hud/action.dm
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
/datum/action/proc/Deactivate()
return

/datum/action/Process()
/datum/action/proc/Process()
return

/datum/action/proc/CheckRemoval(mob/living/user) // TRUE if action is no longer valid for this mob and should be removed
Expand Down
35 changes: 16 additions & 19 deletions code/controllers/mc/globals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,11 @@ GLOBAL_REAL(GLOB, /datum/controller/global_vars)

var/datum/controller/exclude_these = new
gvars_datum_in_built_vars = exclude_these.vars + list(NAMEOF(src, gvars_datum_protected_varlist), NAMEOF(src, gvars_datum_in_built_vars), NAMEOF(src, gvars_datum_init_order))
qdel(exclude_these)
QDEL_IN(exclude_these, 0) //signal logging isn't ready

var/global_vars = vars.len - gvars_datum_in_built_vars.len
var/global_procs = length(typesof(/datum/controller/global_vars/proc))
log_world("[vars.len - gvars_datum_in_built_vars.len] global variables")

report_progress("[global_vars] global variables")
report_progress("[global_procs] global init procs")

try
if(global_vars == global_procs)
Initialize()
else
crash_with("Expected [global_vars] global init procs, were [global_procs].")
catch(var/exception/e)
to_world_log("Vars to be initialized: [json_encode((vars - gvars_datum_in_built_vars))]")
to_world_log("Procs used to initialize: [json_encode(typesof(/datum/controller/global_vars/proc))]")
throw e
Initialize()

/datum/controller/global_vars/Destroy(force)
// This is done to prevent an exploit where admins can get around protected vars
Expand All @@ -44,9 +32,18 @@ GLOBAL_REAL(GLOB, /datum/controller/global_vars)
/datum/controller/global_vars/Initialize()
gvars_datum_init_order = list()
gvars_datum_protected_varlist = list(NAMEOF(src, gvars_datum_protected_varlist) = TRUE)

for(var/I in typesof(/datum/controller/global_vars/proc))
var/list/global_procs = typesof(/datum/controller/global_vars/proc)
var/expected_len = vars.len - gvars_datum_in_built_vars.len
if(global_procs.len != expected_len)
warning("Unable to detect all global initialization procs! Expected [expected_len] got [global_procs.len]!")
if(global_procs.len)
var/list/expected_global_procs = vars - gvars_datum_in_built_vars
for(var/I in global_procs)
expected_global_procs -= replacetext("[I]", "InitGlobal", "")
log_world("Missing procs: [expected_global_procs.Join(", ")]")
for(var/I in global_procs)
var/start_tick = world.time
call(src, I)()
if(world.time - start_tick)
warning("[I] slept during initialization!")
var/end_tick = world.time
if(end_tick - start_tick)
warning("Global [replacetext("[I]", "InitGlobal", "")] slept during initialization!")
2 changes: 1 addition & 1 deletion code/controllers/subsystem/dcs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ PROCESSING_SUBSYSTEM_DEF(dcs)
var/list/elements_by_type = list()

/datum/controller/subsystem/processing/dcs/Recover()
comp_lookup = SSdcs.comp_lookup
_listen_lookup = SSdcs._listen_lookup

/datum/controller/subsystem/processing/dcs/proc/GetElement(list/arguments)
var/datum/element/eletype = arguments[1]
Expand Down
32 changes: 16 additions & 16 deletions code/datums/components/_component.dm
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,13 @@
/datum/proc/RegisterSignal(datum/target, sig_type_or_types, proctype, override = FALSE)
if(QDELETED(src) || QDELETED(target))
return
var/list/procs = signal_procs
var/list/procs = (_signal_procs ||= list())
if(!procs)
signal_procs = procs = list()
_signal_procs = procs = list()
var/list/target_procs = procs[target] || (procs[target] = list())
var/list/lookup = target.comp_lookup
var/list/lookup = target._listen_lookup
if(!lookup)
target.comp_lookup = lookup = list()
target._listen_lookup = lookup = list()

for(var/sig_type in (islist(sig_type_or_types) ? sig_type_or_types : list(sig_type_or_types)))
if(!override && target_procs[sig_type])
Expand Down Expand Up @@ -210,37 +210,37 @@
* * sig_typeor_types Signal string key or list of signal keys to stop listening to specifically
*/
/datum/proc/UnregisterSignal(datum/target, sig_type_or_types)
var/list/lookup = target.comp_lookup
if(!signal_procs || !signal_procs[target] || !lookup)
var/list/lookup = target._listen_lookup
if(!_signal_procs || !_signal_procs[target] || !lookup)
return
if(!islist(sig_type_or_types))
sig_type_or_types = list(sig_type_or_types)
for(var/sig in sig_type_or_types)
if(!signal_procs[target][sig])
if(!_signal_procs[target][sig])
continue
switch(length_char(lookup[sig]))
if(2)
lookup[sig] = (lookup[sig]-src)[1]
if(1)
stack_trace("[target] ([target.type]) somehow has single length list inside comp_lookup")
stack_trace("[target] ([target.type]) somehow has single length list inside _listen_lookup")
if(src in lookup[sig])
lookup -= sig
if(!length_char(lookup))
target.comp_lookup = null
target._listen_lookup = null
break
if(0)
if(lookup[sig] != src)
continue
lookup -= sig
if(!length_char(lookup))
target.comp_lookup = null
target._listen_lookup = null
break
else
lookup[sig] -= src

signal_procs[target] -= sig_type_or_types
if(!signal_procs[target].len)
signal_procs -= target
_signal_procs[target] -= sig_type_or_types
if(!_signal_procs[target].len)
_signal_procs -= target

/**
* Called on a component when a component of the same type was added to the same parent
Expand Down Expand Up @@ -304,13 +304,13 @@
* Use the [SEND_SIGNAL] define instead
*/
/datum/proc/_SendSignal(sigtype, list/arguments)
var/target = comp_lookup[sigtype]
var/target = _listen_lookup[sigtype]
if(!length_char(target))
var/datum/listening_datum = target
return NONE | CallAsync(listening_datum, listening_datum.signal_procs[src][sigtype], arguments)
return NONE | CallAsync(listening_datum, listening_datum._signal_procs[src][sigtype], arguments)
. = NONE
for(var/datum/listening_datum as anything in target)
. |= CallAsync(listening_datum, listening_datum.signal_procs[src][sigtype], arguments)
. |= CallAsync(listening_datum, listening_datum._signal_procs[src][sigtype], arguments)

// The type arg is casted so initial works, you shouldn't be passing a real instance into this
/**
Expand Down
18 changes: 7 additions & 11 deletions code/datums/datum.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
*
* Lazy associated list in the structure of `signal:registree/list of registrees`
*/
var/list/comp_lookup
/// Lazy associated list in the structure of `signals:proctype` that are run when the datum receives that signal
var/list/list/datum/callback/signal_procs
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

/// Datum level flags
var/datum_flags = NONE
Expand Down Expand Up @@ -125,12 +125,8 @@
//END: ECS SHIT
return QDEL_HINT_QUEUE

/datum/proc/Process()
set waitfor = 0
return PROCESS_KILL

/datum/proc/clear_signal_refs()
var/list/lookup = comp_lookup
var/list/lookup = _listen_lookup
if(lookup)
for(var/sig in lookup)
var/list/comps = lookup[sig]
Expand All @@ -140,10 +136,10 @@
else
var/datum/component/comp = comps
comp.UnregisterSignal(src, sig)
comp_lookup = lookup = null
_listen_lookup = lookup = null

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

#ifdef DATUMVAR_DEBUGGING_MODE
/datum/proc/save_vars()
Expand Down
5 changes: 3 additions & 2 deletions code/game/mob/living/carbon/human/death.dm
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,9 @@
. = ..(gibbed)//,species.death_message)
if (!gibbed)
handle_organs() // Handle the following only after we call the parent to get all the proper stat values and etcetra.
handle_piss()
handle_shit()
if (map.civilizations)
handle_piss()
handle_shit()
if (species.death_sound)
playsound(loc, species.death_sound, 80, TRUE, TRUE)
handle_hud_list()
77 changes: 58 additions & 19 deletions code/game/mob/new_player/new_player.dm
Original file line number Diff line number Diff line change
Expand Up @@ -522,68 +522,52 @@ var/global/redirect_all_players = null
return TRUE

if (href_list["SelectedJob"])
if (map.ID == MAP_CAMPAIGN || map.ID == MAP_ROTSTADT)
if (map.ID == MAP_CAMPAIGN && !findtext(href_list["SelectedJob"], "Private") && !findtext(href_list["SelectedJob"], "Machinegunner") && !findtext(href_list["SelectedJob"], "Des. Marksman"))
if (map.ID == MAP_CAMPAIGN)
if (!findtext(href_list["SelectedJob"], "Private") && !findtext(href_list["SelectedJob"], "Machinegunner") && !findtext(href_list["SelectedJob"], "Des. Marksman"))
if ((input(src, "This is a specialist role. You should have decided with your faction on which roles you should pick. If you haven't done so, its probably better if you join as a Private instead. Are you sure you want to join in as a [href_list["SelectedJob"]]?") in list("Yes", "No")) == "No")
return
if(findtext(href_list["SelectedJob"],"BAF"))
var/obj/map_metadata/campaign/MC = map
var/obj/map_metadata/rotstadt/MR = map
if(findtext(href_list["SelectedJob"],"Squad 1"))
if (findtext(href_list["SelectedJob"],"Sniper"))
MC.squad_jobs_blue["Squad 1"]["Sniper"]--
MR.squad_jobs_blue["Squad 1"]["Sniper"]--
if (findtext(href_list["SelectedJob"],"Machinegunner"))
MC.squad_jobs_blue["Squad 1"]["Machinegunner"]--
MR.squad_jobs_blue["Squad 1"]["Machinegunner"]--
if (findtext(href_list["SelectedJob"],"Des. Marksman"))
MC.squad_jobs_blue["Squad 1"]["Des. Marksman"]--
MR.squad_jobs_blue["Squad 1"]["Des. Marksman"]--

else if(findtext(href_list["SelectedJob"],"Squad 2"))
if (findtext(href_list["SelectedJob"],"Sniper"))
MC.squad_jobs_blue["Squad 2"]["Sniper"]--
MR.squad_jobs_blue["Squad 2"]["Sniper"]--
if (findtext(href_list["SelectedJob"],"Machinegunner"))
MC.squad_jobs_blue["Squad 2"]["Machinegunner"]--
MR.squad_jobs_blue["Squad 2"]["Machinegunner"]--
if (findtext(href_list["SelectedJob"],"Des. Marksman"))
MC.squad_jobs_blue["Squad 2"]["Des. Marksman"]--
MR.squad_jobs_blue["Squad 2"]["Des. Marksman"]--

else if(findtext(href_list["SelectedJob"],"Squad 3"))
if (findtext(href_list["SelectedJob"],"Sniper"))
MC.squad_jobs_blue["Squad 3"]["Sniper"]--
MR.squad_jobs_blue["Squad 3"]["Sniper"]--
if (findtext(href_list["SelectedJob"],"Machinegunner"))
MC.squad_jobs_blue["Squad 3"]["Machinegunner"]--
MR.squad_jobs_blue["Squad 3"]["Machinegunner"]--
if (findtext(href_list["SelectedJob"],"Des. Marksman"))
MC.squad_jobs_blue["Squad 3"]["Des. Marksman"]--
MR.squad_jobs_blue["Squad 3"]["Des. Marksman"]--

else if(findtext(href_list["SelectedJob"],"BAF Doctor"))
MC.squad_jobs_blue["none"]["Doctor"]--
MR.squad_jobs_blue["none"]["Doctor"]--

else if(findtext(href_list["SelectedJob"],"BAF Officer"))
MC.squad_jobs_blue["none"]["Officer"]--
MR.squad_jobs_blue["none"]["Officer"]--
else if(findtext(href_list["SelectedJob"],"BAF Commander"))
MC.squad_jobs_blue["none"]["Commander"]--
MR.squad_jobs_blue["none"]["Commander"]--

else if(findtext(href_list["SelectedJob"],"BAF Recon"))
MC.squad_jobs_blue["Recon"]["Sniper"]--
MR.squad_jobs_blue["Recon"]["Sniper"]--
else if(findtext(href_list["SelectedJob"],"BAF Anti-Tank"))
MC.squad_jobs_blue["AT"]["Anti-Tank"]--
MR.squad_jobs_blue["AT"]["Anti-Tank"]--
else if(findtext(href_list["SelectedJob"],"BAF Armored Crew"))
MC.squad_jobs_blue["Armored"]["Crew"]--
MR.squad_jobs_blue["Armored"]["Crew"]--
else if(findtext(href_list["SelectedJob"],"BAF Engineer"))
MC.squad_jobs_blue["Engineer"]["Engineer"]--
MR.squad_jobs_blue["Engineer"]["Engineer"]--
AttemptLateSpawn(href_list["SelectedJob"])
return

Expand All @@ -594,18 +578,24 @@ var/global/redirect_all_players = null
MC.squad_jobs_red["Squad 1"]["Sniper"]--
if (findtext(href_list["SelectedJob"],"Machinegunner"))
MC.squad_jobs_red["Squad 1"]["Machinegunner"]--
if (findtext(href_list["SelectedJob"],"Des. Marksman"))
MC.squad_jobs_red["Squad 1"]["Des. Marksman"]--

else if(findtext(href_list["SelectedJob"],"Squad 2"))
if (findtext(href_list["SelectedJob"],"Sniper"))
MC.squad_jobs_red["Squad 2"]["Sniper"]--
if (findtext(href_list["SelectedJob"],"Machinegunner"))
MC.squad_jobs_red["Squad 2"]["Machinegunner"]--
if (findtext(href_list["SelectedJob"],"Des. Marksman"))
MC.squad_jobs_red["Squad 2"]["Des. Marksman"]--

else if(findtext(href_list["SelectedJob"],"Squad 3"))
if (findtext(href_list["SelectedJob"],"Sniper"))
MC.squad_jobs_red["Squad 3"]["Sniper"]--
if (findtext(href_list["SelectedJob"],"Machinegunner"))
MC.squad_jobs_red["Squad 3"]["Machinegunner"]--
if (findtext(href_list["SelectedJob"],"Des. Marksman"))
MC.squad_jobs_red["Squad 3"]["Des. Marksman"]--

else if(findtext(href_list["SelectedJob"],"RDF Doctor"))
MC.squad_jobs_red["none"]["Doctor"]--
Expand All @@ -626,6 +616,55 @@ var/global/redirect_all_players = null
AttemptLateSpawn(href_list["SelectedJob"])
return

if(map.ID == MAP_ROTSTADT)
if(findtext(href_list["SelectedJob"],"BAF"))
var/obj/map_metadata/rotstadt/MR = map
if(findtext(href_list["SelectedJob"],"Squad 1"))
if (findtext(href_list["SelectedJob"],"Sniper"))
MR.squad_jobs_blue["Squad 1"]["Sniper"]--
if (findtext(href_list["SelectedJob"],"Machinegunner"))
MR.squad_jobs_blue["Squad 1"]["Machinegunner"]--
if (findtext(href_list["SelectedJob"],"Des. Marksman"))
MR.squad_jobs_blue["Squad 1"]["Des. Marksman"]--

else if(findtext(href_list["SelectedJob"],"Squad 2"))
if (findtext(href_list["SelectedJob"],"Sniper"))
MR.squad_jobs_blue["Squad 2"]["Sniper"]--
if (findtext(href_list["SelectedJob"],"Machinegunner"))
MR.squad_jobs_blue["Squad 2"]["Machinegunner"]--
if (findtext(href_list["SelectedJob"],"Des. Marksman"))
MR.squad_jobs_blue["Squad 2"]["Des. Marksman"]--

else if(findtext(href_list["SelectedJob"],"Squad 3"))
if (findtext(href_list["SelectedJob"],"Sniper"))
MR.squad_jobs_blue["Squad 3"]["Sniper"]--
if (findtext(href_list["SelectedJob"],"Machinegunner"))
MR.squad_jobs_blue["Squad 3"]["Machinegunner"]--
if (findtext(href_list["SelectedJob"],"Des. Marksman"))
MR.squad_jobs_blue["Squad 3"]["Des. Marksman"]--

else if(findtext(href_list["SelectedJob"],"BAF Doctor"))
MR.squad_jobs_blue["none"]["Doctor"]--

else if(findtext(href_list["SelectedJob"],"BAF Officer"))
MR.squad_jobs_blue["none"]["Officer"]--
else if(findtext(href_list["SelectedJob"],"BAF Commander"))
MR.squad_jobs_blue["none"]["Commander"]--
else if(findtext(href_list["SelectedJob"],"BAF Recon"))
MR.squad_jobs_blue["Recon"]["Sniper"]--
else if(findtext(href_list["SelectedJob"],"BAF Anti-Tank"))
MR.squad_jobs_blue["AT"]["Anti-Tank"]--
else if(findtext(href_list["SelectedJob"],"BAF Armored Crew"))
MR.squad_jobs_blue["Armored"]["Crew"]--
else if(findtext(href_list["SelectedJob"],"BAF Engineer"))
MR.squad_jobs_blue["Engineer"]["Engineer"]--
AttemptLateSpawn(href_list["SelectedJob"])
return

else if (findtext(href_list["SelectedJob"],"RDF"))
AttemptLateSpawn(href_list["SelectedJob"])
return

if(href_list["SelectedJob"] == "Company Member")
AttemptLateSpawn(href_list["SelectedJob"])
return
Expand Down
8 changes: 4 additions & 4 deletions code/game/mob/observer/ghost/ghost.dm
Original file line number Diff line number Diff line change
Expand Up @@ -375,17 +375,17 @@ var/global/list/image/ghost_sightless_images = list() //this is a list of images

/mob/observer/ghost/verb/follow_bluefaction(input in getfitmobs(BLUEFACTION)+"Cancel")
set category = "Ghost"
set name = "Follow a Bluefaction"
set desc = "Follow and haunt a living Bluefaction."
set name = "Follow a Blugoslavian"
set desc = "Follow and haunt a living Blugoslavian."
if (input != "Cancel")
var/list/mobs = getfitmobs(BLUEFACTION)
if (mobs[input])
ManualFollow(mobs[input])

/mob/observer/ghost/verb/follow_redfaction(input in getfitmobs(REDFACTION)+"Cancel")
set category = "Ghost"
set name = "Follow a Redfaction"
set desc = "Follow and haunt a living Redfaction."
set name = "Follow a Redmenian"
set desc = "Follow and haunt a living Redmenian."
if (input != "Cancel")
var/list/mobs = getfitmobs(REDFACTION)
if (mobs[input])
Expand Down
Loading

0 comments on commit 678b3a8

Please sign in to comment.