Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIRROR] added typesof_real and subtypesof_real #1489

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions baystation12.dme
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
#include "code\_helpers\tools.dm"
#include "code\_helpers\turfs.dm"
#include "code\_helpers\type2type.dm"
#include "code\_helpers\types.dm"
#include "code\_helpers\unsorted.dm"
#include "code\_helpers\vector.dm"
#include "code\_helpers\washing.dm"
Expand Down
40 changes: 40 additions & 0 deletions code/_helpers/types.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/// `typesof()` without the type of thing (or thing if it is a type) included.
/proc/subtypesof(datum/thing)
RETURN_TYPE(/list)
if (ispath(thing))
return typesof(thing) - thing
if (istype(thing))
return typesof(thing) - thing.type
return list()


/// `typesof()` without abstract types included.
/proc/typesof_real(datum/thing)
RETURN_TYPE(/list)
var/static/list/cache = list()
if (!ispath(thing))
if (!istype(thing))
return list()
thing = thing.type
var/list/result = cache[thing]
if (!result)
result = list()
for (var/path in typesof(thing))
if (!is_abstract(path))
result += path
if (!length(result))
result = TRUE
cache[thing] = result
if (result == TRUE)
return list()
return result.Copy()


/// `subtypesof()` without abstract types included.
/proc/subtypesof_real(datum/thing)
RETURN_TYPE(/list)
if (!ispath(thing))
if (!istype(thing))
return list()
thing = thing.type
return typesof_real(thing) - thing
12 changes: 0 additions & 12 deletions code/_helpers/unsorted.dm
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
/*
* A large number of misc global procs.
*/

/proc/subtypesof(datum/thing)
RETURN_TYPE(/list)
if (ispath(thing))
return typesof(thing) - thing
if (istype(thing))
return typesof(thing) - thing.type
return list()

//Checks if all high bits in req_mask are set in bitfield
#define BIT_TEST_ALL(bitfield, req_mask) ((~(bitfield) & (req_mask)) == 0)

Expand Down