Skip to content
skull132 edited this page Jul 9, 2017 · 6 revisions

There exist a large amount of helpers in code which make the writing of functions easier and more consistent. Helpers should be used whenever they are applicable, over hardcoded duplicate code.

IsX Helpers

These can be found in the code/_macros.dm file and encompass almost every common type you would require.

For humans specifically, isspecies style helpers exist in code/modules/mob/mob_helpers.dm file. These allow for easy checking of a carbon/human mob's species.

Garbage Collection

Call File Description
QDELETED(atom) code/__defines/qdel.dm Macro. Returns TRUE if atom is either null or it's been qdel-d.
QDEL_NULL(varname) code/__defines/qdel.dm Macro. Invokes qdel(varname) followed by varname = null.
QDEL_IN(atom, time) code/__defines/qdel.dm Macro. Sets up a timer to invoke qdel(atom) in time deciseconds. It returns the timer's ID, so you can save it for cancellation.
SOFTREF(atom) code/__defines/qdel.dm Equivalent to "\ref[atom]". Used to store soft references to objects. Soft-refs do not stop an object from deleting, and thus don't have to be nulled. However, they do have to be checked before use!

Unsorted

Call File Description
/atom/proc/use_check(mob/user, use_flags = 0) code/_helpers/unsorted.dm Used to centralize all sanity checks that could apply for a given source object to validate the user. Applicable values for use_flags can be found in the code for it.
/proc/GetAbove(atom/atom) code/modules/multiz/basic.dm Returns the turf above atom if it is possible. Namely, if there is a valid Z-level above said atom. Otherwise, returns null.
/proc/GetBelow(atom/atom) code/modules/multiz/basic.dm Same as GetAbove(atom), but functions in reverse, returning the applicable turf one Z-level below atom.
/proc/HasAbove(z) code/modules/multiz/basic.dm Checks if z, a number, has a valid Z-level above it.
/proc/HasBelow(z) code/modules/multiz/basic.dm Checks if z, a number, has a valid Z-level blow it.
ROUND_IS_STARTED code/__defines/subsystem-defines.dm Macro. Returns TRUE if the round has been started. FALSE otherwise.
ADD_VERB_IN(atom, time, verb) code/__defines/misc.dm Macro. Returns a timer which invokes /atom/.proc/add_verb on atom after time amount of time. It'll add verb into the atom.verbs list.
ADD_VERB_IN_IF(atom, time, verb, callback) code/__defines/misc.dm Macro. Same effect as ADD_VERB_IN with the extra condition that the CALLBACK datum sent as callback returns a non-0 value.
UNTIL(condition) code/__defines/misc.dm Macro. Invokes stoplang() until the condition evaluates as TRUE. Literally: while(!(condition)) { stoplag(); }
RANGE_TURFS(radius, center) code/__defines/misc.dm Macro. A very fast method for returning a list of turfs within radius distances from center.
DEBUG_REF(atom) code/__defines/misc.dm Macro. Returns a string containing the memory address, name, and type of atom if it exists. "NULL" if it doesn't.
TICK_CHECK code/__defines/misc.dm Macro. Invokes and returns the return value from stoplag() if world.tick_usage exceeds a certain threshold. Returns 0 if sleeping was not done.
CHECK_TICK code/__defines/misc.dm Macro. Invokes stoplag() if necessary. Does not return a value.
REALTIMEOFDAY code/__defines/math_physics.dm Macro. Returns the world.timeofday with midnight rollover taken into account.
PROCLOG_WEIRD(text), PROCLOG(text) code/__defines/misc.dm Macro. Invokes log_debug("[procname]: [text]"). Note that in certain cases, one or both may not compile.

Standards and Guidelines

A collection of standards and guidelines applied to the codebase.

Common API Documentation

Documentation regarding common APIs which speed up feature implementation and should be known by all coders.

Less Common APIs

Documentation for less used APIs that are not often needed.

Subsystems

Documentation regarding our implementation of StonedMC (SMC).

Decrepit

Decrepit or unused systems.

  • Dynamic Maps (Not to be confused with the newer away mission implementation.)
Clone this wiki locally