blob: 7be9bb386b3e56196a6764fb1faef66b50fde563 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001// MorgenGrauen MUDlib
2//
3// who.c
4//
5// $Id: who.c 8755 2014-04-26 13:13:40Z Zesstra $
6
7#include <config.h>
8#include <udp.h>
9
10int last;
11int maxtoday, maxever;
12
13void create()
14{
15 string tmp1, tmp2, dummy;
16
17 if (time()-last<1800) return;
18 last=time();
19 tmp1=read_file("/etc/maxusers.ever",0,1);
20 tmp2=read_file("/etc/maxusers",0,1);
21 if (stringp(tmp1)&&sizeof(tmp1)) sscanf(tmp1,"%d %s",maxever,dummy);
22 if (stringp(tmp2)&&sizeof(tmp2)) sscanf(tmp2,"%d %s",maxtoday,dummy);
23}
24
25string adjust(string str,int wid) {
26 return sprintf("%*|s",wid,str);
27}
28
29void udp_who(mapping data)
30{
31 int i;
32 string *lines;
33 string wholiste,header;
34
35 create();
36 lines="/obj/werliste"->QueryWhoListe(0, 1);
37 wholiste=implode(lines,"\n");
38 lines=({
39 "*------------------------------------------------------------------------*",
40 "","","","",
41 "*------------------------------------------------------------------------*"});
42 header=MUDNAME", LDMud "+__VERSION__;
43 lines[1]="|"+adjust(header,sizeof(lines[0])-2)+"|";
44 header="Adresse: MG.Mud.DE (87.79.24.60) 23 (alternativ 4711)";
45 lines[2]="|"+adjust(header,sizeof(lines[0])-2)+"|";
46 header="Uptime: "+uptime();
47 lines[3]="|"+adjust(header,sizeof(lines[0])-2)+"|";
48 header=_MUDLIB_NAME_"-Mudlib "_MUDLIB_VERSION_;
49 lines[4]="|"+adjust(header,sizeof(lines[0])-2)+"|";
50 header=implode(lines,"\n");
51 wholiste=header+"\n"+wholiste+sprintf("\n*** Anwesende im "MUDNAME": Max. heute %d, Rekord %d\n",maxtoday,maxever);
52 INETD->_send_udp(data[NAME], ([
53 REQUEST: REPLY,
54 RECIPIENT: data[SENDER],
55 ID: data[ID],
56 DATA: wholiste
57 ]) );
58}