blob: 3f2516b35bdf9cb1b18b411bbd136589cddb9f96 [file] [log] [blame]
Bugfixb1d9b4d2021-09-14 20:07:04 +02001#pragma strict_types, save_types, pedantic, range_check
2#pragma no_clone
3
4inherit "/std/living/comm_structs";
5
6#include <thing/language.h>
7
8// Per Default nur an alle Items im Inventar weiterleiten.
9public varargs int ReceiveMsg(string msg, int msg_type, string msg_action,
10 string msg_prefix, object origin)
11{
12 int *res = ({int*})all_inventory()->ReceiveMsg(msg, msg_type, msg_action,
13 msg_prefix,
14 origin || previous_object());
15 if (sizeof(res))
16 return min(res);
17 return 0;
18}
19
20// Sortierfunktion um das Array mit dem kleinsten Wert auszugeben
21
22private int* _minarr(int** arr)
23{
24 if(!sizeof(arr)) return 0;
25 return sort_array(&arr,
26 function int(int* a, int* b)
27 {
28 return a[0] > b[0];
29 })[0];
30}
31
32// Wrapper fuer ReceiveMsg()
33
34public varargs int* ReceiveSay(string msg, string prefix,
35 struct msg_s sense_blocked)
36{
37 // Das muss schon hier passieren, damit previous_object() stimmt
38 if(!prefix)
39 {
40 prefix = ({string})previous_object().Name(WER, 1) + " sagt: ";
41 }
42
43 int** res = ({int**})all_inventory()->ReceiveSay(msg, prefix, sense_blocked);
44 return _minarr(res);
45}
46
47public varargs int* ReceiveMultisense(struct msg_s msgs,
48 string action, int commontypes)
49{
50 int** res = ({int**})all_inventory()->ReceiveMultisense(msgs, action, commontypes);
51 return _minarr(res);
52}