Files
Kashargul 5926589c16 removes var/ inside all procs (#19450)
* removes var/ inside all procs

* .

* ugh
2026-05-05 10:55:17 +02:00

62 lines
1.5 KiB
Plaintext

// module datum.
// this is per-object instance, and shows the condition of the modules in the object
// actual modules needed is referenced through modulestypes and the object type
/datum/module
var/status // bits set if working, 0 if broken
var/installed // bits set if installed, 0 if missing
// moduletypes datum
// this is per-object type, and shows the modules needed for a type of object
/datum/moduletypes
var/list/modcount = list() // assoc list of the count of modules for a type
GLOBAL_LIST_INIT(modules, list( \
"/obj/machinery/power/apc" = "card_reader,power_control,id_auth,cell_power,cell_charge")) // global associative list
/datum/module/New(obj/O)
var/type = O.type // the type of the creating object
var/mneed = GLOB.mods.inmodlist(type) // find if this type has modules defined
if(!mneed) // not found in module list?
qdel(src)
return
var/needed = GLOB.mods.getbitmask(type) // get a bitmask for the number of modules in this object
status = needed
installed = needed
/datum/moduletypes/proc/addmod(type, modtextlist)
GLOB.modules += type // index by type text
GLOB.modules[type] = modtextlist
/datum/moduletypes/proc/inmodlist(type)
return ("[type]" in GLOB.modules)
/datum/moduletypes/proc/getbitmask(type)
var/count = modcount["[type]"]
if(count)
return 2**count-1
var/modtext = GLOB.modules["[type]"]
var/num = 1
var/pos = 1
while(1)
pos = findtext(modtext, ",", pos, 0)
if(!pos)
break
else
pos++
num++
modcount += "[type]"
modcount["[type]"] = num
return 2**num-1