blob: bdd10d28ba083491cc929a660e4de2c898fa502e [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001// MorgenGrauen MUDlib
2//
3// utils/executer.c - Helfer zum Ausfuehren vom Kram
4//
5// $Id: skills.c 6673 2008-01-05 20:57:43Z Zesstra $
6#pragma strict_types
7#pragma save_types
8#pragma range_check
9#pragma no_clone
MG Mud User88f12472016-06-24 23:31:02 +020010
11protected mixed execute_anything(mixed fun, varargs mixed args)
12{
13 if ( closurep(fun) && objectp(query_closure_object(fun)) )
14 return apply(fun, args);
15
16 if (stringp(fun))
bugfixd94d0932020-04-08 11:27:13 +020017 return ({mixed})call_other(this_object(), fun, args...);
MG Mud User88f12472016-06-24 23:31:02 +020018
Zesstraa8592412018-12-03 22:14:12 +010019 if ( pointerp(fun))
MG Mud User88f12472016-06-24 23:31:02 +020020 {
Zesstraa8592412018-12-03 22:14:12 +010021 if (sizeof(fun) != 2)
22 raise_error(sprintf("execute_anything(): <fun> argument must "
MG Mud User88f12472016-06-24 23:31:02 +020023 "have 2 elements if array.\n"));
Zesstraa8592412018-12-03 22:14:12 +010024 object ob;
MG Mud User88f12472016-06-24 23:31:02 +020025 if ( stringp(fun[0]) )
26 ob=find_object(fun[0]);
27 else
28 ob=fun[0];
29
30 if ( !objectp(ob) || !stringp(fun[1]) )
31 return 0;
32
bugfixd94d0932020-04-08 11:27:13 +020033 return ({mixed})call_other(ob, fun[1], args...);
MG Mud User88f12472016-06-24 23:31:02 +020034 }
35 return 0;
36}
37