From 8ba1054b2a13216fc3ceb3d474d8c19477fc2cdb Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Wed, 10 Apr 2024 21:46:27 +0300 Subject: [PATCH] datumize your singletons --- .../_singletons/code/_defines.dm | 10 ++++----- .../_singletons/code/repository.dm | 22 +++++++++---------- .../_singletons/code/singletons.dm | 8 +++---- modular_bandastation/tts/code/hear.dm | 4 ++-- modular_bandastation/tts/code/shell.dm | 14 ++++++------ .../tts/code/tts_component.dm | 12 +++++----- .../tts/code/tts_subsystem.dm | 8 +++---- 7 files changed, 39 insertions(+), 39 deletions(-) diff --git a/modular_bandastation/_singletons/code/_defines.dm b/modular_bandastation/_singletons/code/_defines.dm index a80391b72e69b..fd4cc7e73d1d0 100644 --- a/modular_bandastation/_singletons/code/_defines.dm +++ b/modular_bandastation/_singletons/code/_defines.dm @@ -4,20 +4,20 @@ /// Get a singleton instance according to path P. Creates it if necessary. Null if abstract or not a singleton. #define GET_SINGLETON(P)\ - (ispath(P, /singleton) ? (GLOB.Singletons.resolved_instances[P] ? GLOB.Singletons.instances[P] : GLOB.Singletons.GetInstance(P)) : null) + (ispath(P, /datum/singleton) ? (GLOB.Singletons.resolved_instances[P] ? GLOB.Singletons.instances[P] : GLOB.Singletons.GetInstance(P)) : null) /// Get a (path = instance) map of valid singletons according to typesof(P). #define GET_SINGLETON_TYPE_MAP(P)\ - (ispath(P, /singleton) ? (GLOB.Singletons.resolved_type_maps[P] ? GLOB.Singletons.type_maps[P] : GLOB.Singletons.GetTypeMap(P)) : list()) + (ispath(P, /datum/singleton) ? (GLOB.Singletons.resolved_type_maps[P] ? GLOB.Singletons.type_maps[P] : GLOB.Singletons.GetTypeMap(P)) : list()) /// Get a (path = instance) map of valid singletons according to subtypesof(P). #define GET_SINGLETON_SUBTYPE_MAP(P)\ - (ispath(P, /singleton) ? (GLOB.Singletons.resolved_subtype_maps[P] ? GLOB.Singletons.subtype_maps[P] : GLOB.Singletons.GetSubtypeMap(P)) : list()) + (ispath(P, /datum/singleton) ? (GLOB.Singletons.resolved_subtype_maps[P] ? GLOB.Singletons.subtype_maps[P] : GLOB.Singletons.GetSubtypeMap(P)) : list()) /// Get a list of valid singletons according to typesof(path). #define GET_SINGLETON_TYPE_LIST(P)\ - (ispath(P, /singleton) ? (GLOB.Singletons.resolved_type_lists[P] ? GLOB.Singletons.type_lists[P] : GLOB.Singletons.GetTypeList(P)) : list()) + (ispath(P, /datum/singleton) ? (GLOB.Singletons.resolved_type_lists[P] ? GLOB.Singletons.type_lists[P] : GLOB.Singletons.GetTypeList(P)) : list()) /// Get a list of valid singletons according to subtypesof(path). #define GET_SINGLETON_SUBTYPE_LIST(P)\ - (ispath(P, /singleton) ? (GLOB.Singletons.resolved_subtype_lists[P] ? GLOB.Singletons.subtype_lists[P] : GLOB.Singletons.GetSubtypeList(P)) : list()) + (ispath(P, /datum/singleton) ? (GLOB.Singletons.resolved_subtype_lists[P] ? GLOB.Singletons.subtype_lists[P] : GLOB.Singletons.GetSubtypeList(P)) : list()) diff --git a/modular_bandastation/_singletons/code/repository.dm b/modular_bandastation/_singletons/code/repository.dm index 39d570e1d7965..007155342f2bc 100644 --- a/modular_bandastation/_singletons/code/repository.dm +++ b/modular_bandastation/_singletons/code/repository.dm @@ -59,25 +59,25 @@ GLOBAL_DATUM_INIT(Singletons, /repository/singletons, new) * Get a singleton instance according to path. Creates it if necessary. Null if abstract or not a singleton. * Prefer the GET_SINGLETON macro to minimize proc calls. */ -/repository/singletons/proc/GetInstance(singleton/path) - if(!ispath(path, /singleton)) +/repository/singletons/proc/GetInstance(datum/singleton/path) + if(!ispath(path, /datum/singleton)) return if(resolved_instances[path]) return instances[path] resolved_instances[path] = TRUE if(path == initial(path.abstract_type)) return - var/singleton/result = new path + var/datum/singleton/result = new path instances[path] = result result.Initialize() return result /// Get a (path = instance) map of valid singletons according to paths. -/repository/singletons/proc/GetMap(list/singleton/paths) +/repository/singletons/proc/GetMap(list/datum/singleton/paths) var/list/result = list() for(var/path in paths) - var/singleton/instance = GetInstance(path) + var/datum/singleton/instance = GetInstance(path) if (!instance) continue result[path] = instance @@ -85,10 +85,10 @@ GLOBAL_DATUM_INIT(Singletons, /repository/singletons, new) /// Get a list of valid singletons according to paths. -/repository/singletons/proc/GetList(list/singleton/paths) +/repository/singletons/proc/GetList(list/datum/singleton/paths) var/list/result = list() for(var/path in paths) - var/singleton/instance = GetInstance(path) + var/datum/singleton/instance = GetInstance(path) if(!instance) continue result += instance @@ -99,7 +99,7 @@ GLOBAL_DATUM_INIT(Singletons, /repository/singletons, new) * Get a (path = instance) map of valid singletons according to typesof(path). * Prefer the GET_SINGLETON_TYPE_MAP macro to minimize proc calls. */ -/repository/singletons/proc/GetTypeMap(singleton/path) +/repository/singletons/proc/GetTypeMap(datum/singleton/path) if(resolved_type_maps[path]) return type_maps[path] || list() resolved_type_maps[path] = TRUE @@ -112,7 +112,7 @@ GLOBAL_DATUM_INIT(Singletons, /repository/singletons, new) * Get a (path = instance) map of valid singletons according to subtypesof(path). * Prefer the GET_SINGLETON_TYPE_MAP macro to minimize proc calls. */ -/repository/singletons/proc/GetSubtypeMap(singleton/path) +/repository/singletons/proc/GetSubtypeMap(datum/singleton/path) if(resolved_subtype_maps[path]) return subtype_maps[path] || list() resolved_subtype_maps[path] = TRUE @@ -125,7 +125,7 @@ GLOBAL_DATUM_INIT(Singletons, /repository/singletons, new) * Get a list of valid singletons according to typesof(path). * Prefer the GET_SINGLETON_TYPE_LIST macro to minimize proc calls. */ -/repository/singletons/proc/GetTypeList(singleton/path) +/repository/singletons/proc/GetTypeList(datum/singleton/path) if(resolved_type_lists[path]) return type_lists[path] || list() resolved_type_lists[path] = TRUE @@ -138,7 +138,7 @@ GLOBAL_DATUM_INIT(Singletons, /repository/singletons, new) * Get a list of valid singletons according to subtypesof(path). * Prefer the GET_SINGLETON_SUBTYPE_LIST macro to minimize proc calls. */ -/repository/singletons/proc/GetSubtypeList(singleton/path) +/repository/singletons/proc/GetSubtypeList(datum/singleton/path) if(resolved_subtype_lists[path]) return subtype_lists[path] || list() resolved_subtype_lists[path] = TRUE diff --git a/modular_bandastation/_singletons/code/singletons.dm b/modular_bandastation/_singletons/code/singletons.dm index f69e8bfffaf35..ee0bf41fcfe57 100644 --- a/modular_bandastation/_singletons/code/singletons.dm +++ b/modular_bandastation/_singletons/code/singletons.dm @@ -1,11 +1,11 @@ -/singleton - var/abstract_type = /singleton +/datum/singleton + var/abstract_type = /datum/singleton -/singleton/proc/Initialize() +/datum/singleton/proc/Initialize() SHOULD_CALL_PARENT(TRUE) SHOULD_NOT_SLEEP(TRUE) -/singleton/Destroy() +/datum/singleton/Destroy() SHOULD_CALL_PARENT(FALSE) . = QDEL_HINT_LETMELIVE CRASH("Prevented attempt to delete a singleton instance: [src]") diff --git a/modular_bandastation/tts/code/hear.dm b/modular_bandastation/tts/code/hear.dm index f14fcc620d051..bdb5e768ad446 100644 --- a/modular_bandastation/tts/code/hear.dm +++ b/modular_bandastation/tts/code/hear.dm @@ -2,10 +2,10 @@ . = ..() if(!.) return - speaker.cast_tts(src, raw_message, effect = radio_freq ? /singleton/sound_effect/radio : null) + speaker.cast_tts(src, raw_message, effect = radio_freq ? /datum/singleton/sound_effect/radio : null) /mob/dead/observer/Hear(message, atom/movable/speaker, message_language, raw_message, radio_freq, list/spans, list/message_mods, message_range) . = ..() if(!.) return - speaker.cast_tts(src, raw_message, effect = radio_freq ? /singleton/sound_effect/radio : null) + speaker.cast_tts(src, raw_message, effect = radio_freq ? /datum/singleton/sound_effect/radio : null) diff --git a/modular_bandastation/tts/code/shell.dm b/modular_bandastation/tts/code/shell.dm index e1cdb465547c0..fb6ffeb98da39 100644 --- a/modular_bandastation/tts/code/shell.dm +++ b/modular_bandastation/tts/code/shell.dm @@ -6,7 +6,7 @@ #define SHELLEO_ERR ".err" #define SHELLEO_OUT ".out" -/proc/apply_sound_effect(singleton/sound_effect/effect, filename_input, filename_output) +/proc/apply_sound_effect(datum/singleton/sound_effect/effect, filename_input, filename_output) if(!effect) CRASH("Invalid sound effect chosen.") @@ -28,27 +28,27 @@ return FALSE return TRUE -/singleton/sound_effect +/datum/singleton/sound_effect var/suffix var/ffmpeg_arguments -/singleton/sound_effect/radio +/datum/singleton/sound_effect/radio suffix = "_radio" ffmpeg_arguments = "highpass=f=1000, lowpass=f=3000, acrusher=1:1:50:0:log" -/singleton/sound_effect/robot +/datum/singleton/sound_effect/robot suffix = "_robot" ffmpeg_arguments = "afftfilt=real='hypot(re,im)*sin(0)':imag='hypot(re,im)*cos(0)':win_size=1024:overlap=0.5, deesser=i=0.4, volume=volume=1.5" -/singleton/sound_effect/radio_robot +/datum/singleton/sound_effect/radio_robot suffix = "_radio_robot" ffmpeg_arguments = "afftfilt=real='hypot(re,im)*sin(0)':imag='hypot(re,im)*cos(0)':win_size=1024:overlap=0.5, deesser=i=0.4, volume=volume=1.5, highpass=f=1000, lowpass=f=3000, acrusher=1:1:50:0:log" -/singleton/sound_effect/megaphone +/datum/singleton/sound_effect/megaphone suffix = "_megaphone" ffmpeg_arguments = "highpass=f=500, lowpass=f=4000, volume=volume=10, acrusher=1:1:45:0:log" -/singleton/sound_effect/megaphone_robot +/datum/singleton/sound_effect/megaphone_robot suffix = "_megaphone_robot" ffmpeg_arguments = "afftfilt=real='hypot(re,im)*sin(0)':imag='hypot(re,im)*cos(0)':win_size=1024:overlap=0.5, deesser=i=0.4, highpass=f=500, lowpass=f=4000, volume=volume=10, acrusher=1:1:45:0:log" diff --git a/modular_bandastation/tts/code/tts_component.dm b/modular_bandastation/tts/code/tts_component.dm index 70dd6e9cb9b82..28edbfdd6d17a 100644 --- a/modular_bandastation/tts/code/tts_component.dm +++ b/modular_bandastation/tts/code/tts_component.dm @@ -106,13 +106,13 @@ switch(.) if(null) if(TTS_TRAIT_ROBOTIZE in traits) - return /singleton/sound_effect/robot - if(/singleton/sound_effect/radio) + return /datum/singleton/sound_effect/robot + if(/datum/singleton/sound_effect/radio) if(TTS_TRAIT_ROBOTIZE in traits) - return /singleton/sound_effect/radio_robot - if(/singleton/sound_effect/megaphone) + return /datum/singleton/sound_effect/radio_robot + if(/datum/singleton/sound_effect/megaphone) if(TTS_TRAIT_ROBOTIZE in traits) - return /singleton/sound_effect/megaphone_robot + return /datum/singleton/sound_effect/megaphone_robot return . /datum/component/tts_component/proc/cast_tts(atom/speaker, mob/listener, message, atom/location, is_local = TRUE, effect = null, traits = TTS_TRAIT_RATE_FASTER, preSFX, postSFX) @@ -129,7 +129,7 @@ speaker = parent if(!location) location = parent - if(effect == /singleton/sound_effect/radio) + if(effect == /datum/singleton/sound_effect/radio) if(listener == speaker && !issilicon(parent)) // don't hear both radio and whisper from yourself return diff --git a/modular_bandastation/tts/code/tts_subsystem.dm b/modular_bandastation/tts/code/tts_subsystem.dm index bd1562985bcdd..df429adbe378e 100644 --- a/modular_bandastation/tts/code/tts_subsystem.dm +++ b/modular_bandastation/tts/code/tts_subsystem.dm @@ -230,7 +230,7 @@ SUBSYSTEM_DEF(tts220) LAZYADD(tts_requests_queue, list(list(text, seed, proc_callback))) return TRUE -/datum/controller/subsystem/tts220/proc/get_tts(atom/speaker, mob/listener, message, datum/tts_seed/tts_seed, is_local = TRUE, singleton/sound_effect/effect = null, traits = TTS_TRAIT_RATE_FASTER, preSFX = null, postSFX = null) +/datum/controller/subsystem/tts220/proc/get_tts(atom/speaker, mob/listener, message, datum/tts_seed/tts_seed, is_local = TRUE, datum/singleton/sound_effect/effect = null, traits = TTS_TRAIT_RATE_FASTER, preSFX = null, postSFX = null) if(!is_enabled) return if(!message) @@ -269,7 +269,7 @@ SUBSYSTEM_DEF(tts220) var/hash = md5(lowertext(text)) var/filename = "data/tts_cache/[tts_seed.name]/[hash]" - var/singleton/sound_effect/effect_singleton = GET_SINGLETON(effect) + var/datum/singleton/sound_effect/effect_singleton = GET_SINGLETON(effect) if(fexists("[filename].ogg")) tts_reused++ @@ -338,7 +338,7 @@ SUBSYSTEM_DEF(tts220) request.cb = output_tts_cb LAZYADD(tts_effects_queue[processed_filename], request) -/datum/controller/subsystem/tts220/proc/play_tts(atom/speaker, mob/listener, pure_filename, is_local = TRUE, singleton/sound_effect/effect = null, preSFX = null, postSFX = null) +/datum/controller/subsystem/tts220/proc/play_tts(atom/speaker, mob/listener, pure_filename, is_local = TRUE, datum/singleton/sound_effect/effect = null, preSFX = null, postSFX = null) if(isnull(listener) || !listener.client) return @@ -480,7 +480,7 @@ SUBSYSTEM_DEF(tts220) /datum/sound_effect_request var/original_filename var/output_filename - var/singleton/sound_effect/effect + var/datum/singleton/sound_effect/effect var/datum/callback/cb #undef TTS_REPLACEMENTS_FILE_PATH