User:Monster Iestyn/Source Code Documentation/d_think.h

From SRB2 Wiki
Jump to navigation Jump to search
This article or section is incomplete. It doesn't have all of the necessary core information on this topic. Please help the SRB2 Wiki by finishing this article.
Online link GitHub entry
File type C header file
#include guard __D_THINK__

Typedefs

Name Type Description
actionf_v void (*function)() A pointer to a function without parameters used by actionf_t.
actionf_p1 void (*function)(void *) A pointer to a function with one parameter used by actionf_t.

Note: in older versions of SRB2, there were formerly also two- and three- parameter equivalents, named actionf_p2 and actionf_p3 respectively.

actionf_t union The typedef used for actions – this data type is capable of storing one of several different types of action functions, varying by the number of parameters they are called with.
think_t actionf_t The typedef used for a thinker's function. This is just a simple alias of actionf_t.
thinker_t
struct thinker_s
struct The typedef for thinkers. Note that all thinkers are linked together in a list via thinker->prev and thinker->next.

Unions

actionf_t

Data name Data type Description
acv actionf_v This member is used if the action function is to be called without any parameters; e.g.: actionf.acv();
Note: currently unused by SRB2 in practice, though still referred to in the source code.
acp1 actionf_p1 This member is used if the action function is to be called with one parameter; e.g.: actionf.acp1(param1);
Note: in older versions of SRB2, there were formerly also two- and three- parameter equivalents, named acp2 and acp3 respectively.

Structs

thinker_t

Data name Data type Description
*prev struct thinker_s Previous thinker in the thinkers list.
*next struct thinker_s Next thinker in the thinkers list.
function think_t The thinker's function; thinker.function.acp1(thinker) will be run each time P_RunThinkers is called.
references INT32 Number of references to the thinker from pointers.

Pointer references to a mobj_t (or P_MobjThinker) thinker are added/removed using P_SetTarget. For as long as a reference exists, P_RemoveThinkerDelayed cannot fully remove the thinker itself. This can be handy in case a pointer still needs the thinker to exist temporarily after it has been marked to be removed later with P_RemoveThinkerDelayed – once there are no more pointers referencing the thinker (i.e thinker.references is 0), P_RemoveThinkerDelayed can remove the thinker from the list of thinkers and will free it from memory.