DESCRIPTION¶
Returns an object pointer to the object that did a call (
call_other
(E),funcall
(E), etc) to the current object, if any. If that object is destructed, the function returns 0.If the optional
i
is given and0 <= i < caller_stack_depth()
, the call_others are followed backi
times (i.e.previous_object(1)
returns the caller of the caller). Ifi
is less than 0, the first previous object is returned (as ifi == 0
was passed).There is an important special case: in functions called by the gamedriver in reaction to some external event (e.g. commands added by add_action),
previous_object()
will returnthis_object()
, butprevious_object(0)
will return 0.USAGE¶
This example shows how we can check if the last call to a function of the current object is secure or if we should abort execution:
int security() { object prev; if (!(prev=previous_object())); else if (getuid(prev) != getuid(this_object())); else if (geteuid(prev) != geteuid(this_object())); else return 1; return 0; } void highly_sensible_func() { if (!security()) return; ... }
See Also: call_other
(E),this_object
(E),this_player
(E),