blob: a3c77943149741e2d818083dfe20869d5ca6582c [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001/* a finger
2 * Original (c) 14.03.1993 by Taube @Nightfall
3 * Umsetzung fuer Morgengrauen 09.08.1993 by Loco
4
5 Verwendung ausserhalb von Morgengrauen ist gestattet unter folgenden
6 Bedingungen:
7 - Benutzung erfolgt auf eigene Gefahr. Jegliche Verantwortung wird
8 abgelehnt.
9 - Auch in veraenderten oder abgeleiteten Objekten muss ein Hinweis auf
10 die Herkunft erhalten bleiben.
11 Ein Update-Service besteht nicht.
12
13 * 29.Okt 1993 Seherversion.
14 * spaeter auch fuer externen Aufruf verwendbar gemacht
15 * 13.Okt .plan und .project koennen auch in ~loco/plans sein.
16 * 15.Jan 1994 angepasst an neues Speicherformat
17 * 02-05.Dez94 -n, -p
18 *
19 * Gelegentlich minor changes, zuletzt 04.Okt.95
20 */
21
22#pragma strong_types,save_types
23#pragma no_clone, no_shadow
24
25#include <config.h>
26#include <properties.h>
27#include <wizlevels.h>
28#include <new_skills.h>
29#include <userinfo.h>
30#include <config.h>
31
32#define HBINT 2 /* interval between two heart_beats in seconds */
33#define MINIDLE 60 /* minimum idle time in seconds to be stated idle */
34#define TBANISH_EXTRACT 71.. /* Der benoetigte Teil des TBanish-strings */
35
36#define TP this_player()
37#define wiz (local && IS_LEARNER(TP))
38#define seer (local && IS_SEER(TP))
39#define IN ((properties[P_GENDER]==2)?"in":"")
40
41
42#define FLAG_NOPLAN 1
43#define FLAG_LONG 2
44#define FLAG_SPONSOR 4
45#define FLAG_VIS_LOGOUT 8
46#define FLAG_AVATAR 16
47
48
49mapping properties;
50int age,invis,hc_play;
51int filetime;
52mapping relatives;
53
54
55void create()
56{
57 seteuid(getuid());
58 filetime=0;
59}
60
61
62string timediff(int time)
63{
64 string ret;
65
66 ret="";
67 if ( time >= 86400*365 ) {
68 ret+=time/(86400*365)+"a ";
69 time%=(86400*365);
70 }
71 if(time>=86400) {
72 ret+=time/86400+"d ";
73 time%=86400;
74 }
75 if(time<36000) ret+="0";
76 ret+=time/3600+":";
77 time%=3600;
78 if(time<600) ret+="0";
79 ret+=time/60+":";
80 time%=60;
81 if(time<10) ret+="0";
82 ret+=time+"";
83 return ret;
84}
85
86string sponsoring(string name)
87{
88 int i,w;
89 string *s,s2,s3,s4;
90 // Daten einlesen, wenn die daten aelter als 1 Tag sind oder sich
91 // /log/SPONSORS geaendert hat.
92 if ((time() > filetime+86400) ||
93 filetime!=file_time("/log/SPONSOR"))
94 {
95 relatives=m_allocate(0,2);
96 filetime=file_time("/log/SPONSOR");
97 s=explode(read_file("/log/SPONSOR"),"\n");
98 foreach(string str: s) {
99 sscanf(str,"%s: %s macht %s zum Learner.",s2,s3,s4);
100 if (IS_LEARNER(lower_case(s3)) && IS_LEARNER(lower_case(s4)))
101 {
102 relatives[lower_case(s4),0]=s3;
103 s3=lower_case(s3);
104 s4+=" ("+query_wiz_level(lower_case(s4))+")";
105 if (!relatives[s3,1]) relatives[s3,1]=({s4});
106 else relatives[s3,1]+=({s4});
107 }
108 }
109 }
110 s2="";
111 if (relatives[name,0])
112 s2+="Vorfahre: "+relatives[name,0]+"\n";
113 if (relatives[name,1])
114 s2+="Nachfahre(n): "+break_string(implode(relatives[name,1],", "),78,14)[14..];
115 return s2;
116}
117
118varargs string finger_single(string str,int local)
119{
MG Mud User88f12472016-06-24 23:31:02 +0200120 string ip,text,ipnum,filename,away;
121 int wizlevel,playerlevel,idle,pos,flags,last;
122 mixed h,data,tmp;
123 object player,ob;
124
125 /*DEBUG### tell_object((find_player("loco")||this_object()),"Finger request: '"+str+"'("+local+")\n");/**/
126 str=lower_case(str);
127 text="";
128 away="";
129 hc_play=0;
130
131 h=explode(str," ");
132 if (sizeof(h)==1) h=explode(str,"+");
133 if (member(h,"-n")>=0) flags=FLAG_NOPLAN;
134 if (member(h,"-p")>=0) flags=0;
135 if (member(h,"-l")>=0) flags|=FLAG_LONG;
136 if (member(h,"-s")>=0) flags|=FLAG_SPONSOR;
137 if (member(h,"-v")>=0) flags|=FLAG_VIS_LOGOUT;
138 if (member(h,"-a")>=0) flags|=FLAG_AVATAR;
139
140 h=(h-({"-n","-p","-l","-s", "-v","-a"}));
141 if (!sizeof(h)) {
142 text="Du solltest schon sagen, wer Dich interessiert!\n";
143 if (local) return write(text),0;
144 else return text;
145 }
146 str=h[0];
147 if (!sizeof(str) || str[0]<'a' || str[0]>'z') {
148 text="Also, so ("+str+") heisst bestimmt kein Spieler hier!\n";
149 if (local) return write(text),0;
150 else return text;
151 }
152
153 /* does this player exist? */
154 str=old_explode(str,".")[0];
MG Mud User88f12472016-06-24 23:31:02 +0200155 player=find_player(str)||find_netdead(str);
156
Zesstracd25d262020-01-21 19:36:39 +0100157 if( (!master()->find_userinfo(str) && !player) )
158 {
MG Mud User88f12472016-06-24 23:31:02 +0200159 text="Hmm... diesen Namen gibt es im "MUDNAME" nicht.\n";
160 if (tmp="/secure/master"->QueryBanished(str)){
161 text="Hoppla - dieser Name ist reserviert oder gesperrt (\"gebanisht\")!\n";
162 if ( tmp != "Dieser Name ist gesperrt." )
163 text += "Grund fuer die Sperrung: " + tmp +
164 (member( ({'!','?','.'}), tmp[<1] ) != -1 ? "" : ".") + "\n";
165 }
166 if (local) return write(text),0;
167 else return text;
168 }
169
170 if (player) {
171 hc_play=player->query_hc_play();
172 properties=player->QueryProperties();
173 properties[P_RACE]=player->QueryProp(P_RACE);
174 properties[P_VISIBLE_GUILD]=player->QueryProp(P_VISIBLE_GUILD);
175 properties[P_TITLE]=player->QueryProp(P_TITLE);
176 tmp = player->QueryProp(P_PRESAY);
177 properties[P_PRESAY]=(stringp(tmp) && sizeof(tmp)>1) ? tmp[0..<2] : 0;
178 }
179 else
180 restore_object("/save/"+str[0..0]+"/"+str);
181 if (!properties)
182 {
183 text+="Mist!!! Das Einlesen der Daten klappt nicht wie es soll :-(\n";
184 properties=0;
185 if (!local)
186 return text;
187 write(text);
188 return "";
189 }
190 if ( player && interactive(player) )
191 ipnum = query_ip_number(player);
192 else
193 ipnum = properties[P_CALLED_FROM_IP];
194 // frueher stand in P_CALLED_FROM_IP evtl. auch der Name direkt drin
195 // anstelle der numerischen IP
196 ip=query_ip_name(ipnum)||properties[P_CALLED_FROM_IP];
197 if(player) {
198 if (!interactive(player) || (idle=query_idle(player))<MINIDLE)
199 idle=0;
200 if (!(invis=age=player->QueryProp(P_INVIS)))
201 age=player->QueryProp(P_AGE);
202 } else {
203 if (properties[P_INVIS]) age=properties[P_INVIS];
204 idle=properties[P_LAST_LOGOUT];
205 }
206
207 wizlevel=query_wiz_level(str);
208 if ( (tmp = file_time("/save/"+str[0..0]+"/"+str+".o")) <= 0 )
209 // Hack, um bei ganz "frischen" Spielern (noch kein Savefile vorhanden)
210 // die Ausgabe von 1.1.1970 zu verhindern
211 tmp = time();
212 last=properties[P_LAST_LOGOUT];
213 if ( last <= 0 || (!(flags&FLAG_VIS_LOGOUT) && wiz && wizlevel > 10
214 && properties[P_INVIS] && tmp - last > 300) )
215 last = tmp;
216
217 /* output routine for all */
218 if(player) {
219 h=player->QueryProp(P_RACE);
220 if(interactive(player) && (wiz || !invis)) {
221 text+=capitalize(str)+" ist anwesend,\n"+
222 "und zwar von: "+
223 (wiz ? (ip+(ipnum?" ("+ipnum+")":"")):"")+
224 (stringp(properties[P_LOCATION]) ? (wiz ? "\n [" : "")
225 +capitalize(properties[P_LOCATION])+
226 ((properties[P_LOCATION] != country(ip, ipnum))
227 ? " (ueber "+country(ip, ipnum)+")" : "" )
228 : (wiz?" [":"")+country(ip, ipnum))+(wiz ? "]":"")+".\n";
229 if(idle)
230 text+="Passiv seit: "+timediff(idle)+"\n";
231 if (local)
232 text+="Eingeloggt seit: "+dtime(properties[P_LAST_LOGIN])+"\n";
233 if (properties[P_AWAY])
234 away="z.Z. abwesend, Grund : "+properties[P_AWAY]+"\n";
235 } else
236 text+=capitalize(str)+" ist nicht anwesend.\nZuletzt eingeloggt von: "+
237 (wiz ? (ip+(ipnum&&ipnum!=ip?" ("+ipnum+")":"")):"")+
238 (stringp(properties[P_LOCATION]) ?
239 (wiz ? "\n [": "")
240 +capitalize(properties[P_LOCATION])+" (ueber "+country(ip, ipnum)+")":
241 (wiz?" [":"")+country(ip, ipnum))+(wiz ? "]":"")+".\n"+
242 "Zuletzt ausgeloggt: "+dtime(last)+" ("+timediff(time()-last)+").\n";
243 }
244 else {
245 text+=capitalize(str)+" ist nicht anwesend.\nZuletzt eingeloggt von: "+
246 (wiz ? (ip+(ipnum&&ipnum!=ip?" ("+ipnum+")":"")):"")+
247 (stringp(properties[P_LOCATION]) ?
248 (wiz ? "\n [": "")
249 +capitalize(properties[P_LOCATION])+" (ueber "+country(ip, ipnum)+")":
250 (wiz?" [":"")+country(ip, ipnum))+(wiz ? "]":"")+".\n"+
251 "Zuletzt ausgeloggt: "+dtime(last)+" ("+timediff(time()-last)+").\n";
252 }
253 text+="Voller Name: "+(((h=properties[P_PRESAY]) && h!="") ? h+" " : "")+
254 capitalize((h=properties[P_NAME]) ? h : str)+" "+
255 ((h=properties[P_TITLE]) ? h :
256 ((mappingp(h=properties["guild_title"]) && (h=(h[properties[P_GUILD]?properties[P_GUILD]:"abenteurer"])) ) ? h : "") )
257 +"\n";
258
259 if (properties[P_GHOST]) text+="Hoppla, ein Geist!\n";
260 if ((flags&FLAG_LONG)&&properties[P_LONG])
261 text+="Beschreibung: \n"+break_string(properties[P_LONG],78,2);
262
263 if(wiz ||
264 (properties[P_SHOWEMAIL]=="alle") ||
265 ( (properties[P_SHOWEMAIL]=="freunde") &&
266 objectp(player) &&
267 this_player() &&
268 (ob=present("\n\bfband",player)) &&
269 pointerp(tmp=ob->QueryProp(P_AUTOLOADOBJ)) &&
270 pointerp(tmp=tmp[1]) &&
271 (member(tmp,getuid(this_player()))!=-1))) tmp = 1;
272 else tmp=0;
273
Zesstracd25d262020-01-21 19:36:39 +0100274 string shell = master()->query_userlist(str, USER_OBJECT);
275 if (!(h=properties[P_RACE]) && sizeof(shell))
276 {
277 shell = capitalize(explode(shell, "/")[3]);
278 shell =(["Human":"Mensch","Dwarf":"Zwerg","Darkelf":"Dunkelelf",
279 "Orc":"Ork"])[shell] || shell;
MG Mud User88f12472016-06-24 23:31:02 +0200280 }
281
Zesstracd25d262020-01-21 19:36:39 +0100282 if (!stringp(shell)) shell="<keine>";
283 int creation = master()->query_userlist(str, USER_CREATION_DATE);
284 text+="Rasse: "+shell+", Gilde: "+
MG Mud User88f12472016-06-24 23:31:02 +0200285 ((h=properties[P_VISIBLE_GUILD])?capitalize(h):((h=properties[P_GUILD])?capitalize(h):"Abenteurer"))+
286 ((h=properties[P_VISIBLE_SUBGUILD_TITLE])?" ("+capitalize(h)+")":((h=properties[P_SUBGUILD_TITLE])?" ("+capitalize(h)+")":""))+
287 ", Geschlecht: "+({"neutral ?!","maennlich","weiblich","<verdammt seltsam>"})[properties[P_GENDER]]+"\n"+
288 (seer ? "Alter: "+timediff(age*HBINT)+", " : "")+
289 (wizlevel>=10?"Magierlevel: "+wizlevel+
290 (wizlevel>=GOD_LVL?" (Mudgott)":str=="boing"?" (Mudgott a.D.)":str=="muadib"?" (Apostolischer Visitator)":wizlevel>=ARCH_LVL?" (Erzmagier)":IS_DEPUTY(str)?" (Hilfssheriff)":wizlevel>=ELDER_LVL?" (Weiser)":wizlevel>=LORD_LVL?" (Regionsmagier)":wizlevel>=SPECIAL_LVL?" (Hilfsmagier)":wizlevel>=DOMAINMEMBER_LVL?" (Regionsmitarbeiter)":wizlevel>WIZARD_LVL?" (Vollmagier)":" (Lehrling)"):
291 ("Spielerlevel: "+properties[P_LEVEL]+( wizlevel ? " (Seher"+IN+")" : "" )+
292 (((h=properties[P_GUILD_LEVEL]) && h=h[properties[P_GUILD]]) ?
293 (", Gildenlevel: "+h) : "" )
Zesstracd25d262020-01-21 19:36:39 +0100294 )) + ((sprintf("\nDatum des ersten Login: %s",
295 (creation > 0) ? dtime(creation) : "vor dem 10. Nov 1995")))+
MG Mud User88f12472016-06-24 23:31:02 +0200296 (tmp ? ("\nE-Mail-Adresse: "+((h=properties[P_MAILADDR]) ? h : "keine")+"\n") : "\n");
297
298 if (properties[P_HOMEPAGE])
299 text+="Homepage: "+properties[P_HOMEPAGE]+"\n";
300
301 if (stringp(data=properties[P_MESSENGER])) {
302 text+=sprintf("Messenger: %s", data);
303 if (intp(data=properties[P_ICQ])) {
304 if (data<0 && IS_WIZARD(this_player())) data*=-1;
305 if (data>0) text += sprintf(", ICQ: %d", data);
306 }
307 text+="\n";
308 } else
309 if (intp(data=properties[P_ICQ])) {
310 if (data<0 && IS_WIZARD(this_player()))
311 data*=-1;
312 if (data>0)
313 text+=sprintf("ICQ: %d\n",data);
314 }
315
316 if (properties[P_MARRIED])
317 text+="Verheiratet mit: "+capitalize(properties[P_MARRIED])+"\n";
318
319 if ( pointerp(properties[P_SIBLINGS]) )
320 text += ({ "Es", "Er", "Sie" })[properties[P_GENDER]] + " ist Bluts" +
321 ({ "verwandt mit ", "bruder von ", "schwester von " })
322 [properties[P_GENDER]] +
323 CountUp(properties[P_SIBLINGS]) + ".\n";
324
325 text+=away;
326
327 if(MASTER->check_late_player(str))
328 {
329 text+=capitalize(str)+" hat uns leider fuer immer verlassen.\n";
330 }
331 else
332 {
333 if (h=MASTER->QueryTBanished(str))
334 text+=capitalize(str)+" will fruehestens "+h[TBANISH_EXTRACT];
335 }
336
337 if (h=properties[P_TESTPLAYER])
338 {
339 text+=capitalize(str)+" ist Testspieler"+IN;
340 if (stringp(h)) text+=" ("+h+")";
341 text+=".\n";
342 }
343 if ( h=properties[P_SECOND])
344 {
345 if (IS_WIZARD(this_player())) {
346 text+=capitalize(str)+" ist";
347 switch((int)properties[P_SECOND_MARK]) {
348 case -1: text+=" unsichtbar markierte"
349 +((int)properties[P_GENDER]!=FEMALE ? "r": "");
350 break;
351 case 0: text+=" nicht namentlich markierte"
352 +((int)properties[P_GENDER]!=FEMALE ? "r": "");
353 break;
354 default:
355 }
356 text+=" Zweitspieler"+IN;
357 if (stringp(h))
358 text+=" ("+capitalize(h)+")";
359 text+=".\n";
360 }
361 else if ((int)properties[P_SECOND_MARK]>0)
362 {
363 text+=capitalize(str)+" ist Zweitspieler"+IN;
364 if (stringp(h))
365 text+=" ("+capitalize(h)+")";
366 text+=".\n";
367 }
368 else if ((int)properties[P_SECOND_MARK]>-1)
369 text+=capitalize(str)+" ist Zweitspieler"+IN+".\n";
370 }
371 if (properties[P_DEADS])
372 {
373 text+="Bisher bereits "+properties[P_DEADS]+" mal gestorben\n";
374 // Bezieht sich nur auf den Zeitraum ab dem 30.11.'94
375 }
376 if(hc_play==1)
377 {
378 text+=capitalize(str)+" ist sehr mutig.\n";
379 }
380 if(hc_play>1)
381 {
382 text+=capitalize(str)+" ist am "+dtime(hc_play)+" in das Nirvana eingegangen.\n";
383 }
384
Zesstracd25d262020-01-21 19:36:39 +0100385 data=master()->query_userlist(str, USER_DOMAIN);
386 if (sizeof(data))
387 text+="Regionsmagier"+IN+" von : "
388 +implode(map(data,#'capitalize),", ")+".\n";
389 data="/secure/master"->get_domain_homes(str);
390 data=filter(data-({"erzmagier"}),#'stringp);
391 if ((wizlevel>=DOMAINMEMBER_LVL) && (sizeof(data)))
392 text+="Regionsmitarbeiter"+IN+" von: "
393 +implode(map(data,#'capitalize),", ")+".\n";
MG Mud User88f12472016-06-24 23:31:02 +0200394
Zesstracd25d262020-01-21 19:36:39 +0100395 data=master()->query_userlist(str, USER_GUILD);
MG Mud User88f12472016-06-24 23:31:02 +0200396 if (sizeof(data))
Zesstracd25d262020-01-21 19:36:39 +0100397 text += "Gildenmagier"+IN+" von : "
398 +implode(map(data, #'capitalize), ", ")+".\n";
MG Mud User88f12472016-06-24 23:31:02 +0200399
400 // ggf. Avatar-URI mit ausgeben.
401 if (flags & FLAG_AVATAR
402 && stringp(properties[P_AVATAR_URI]))
403 text += "Avatar-URI: " + properties[P_AVATAR_URI] + "\n";
404
405 if (flags & FLAG_SPONSOR)
406 text+=sponsoring(str);
407
408 filename="/players/"+str+"/.project";
409 if(file_size(filename)>=0)
410 text+="Projekt: "+explode(read_file(filename), "\n")[0]+"\n";
411 else {
412 filename="/p/service/loco/plans/"+str+".project";
413 if(file_size(filename)>=0)
414 text+="Projekt: "+explode(read_file(filename), "\n")[0]+"\n";
415 }
416 if (seer && !(flags&FLAG_NOPLAN)) {
417 filename="/players/"+str+"/.plan";
418 if(file_size(filename)>=0)
419 text+="Plan:\n"+read_file(filename);
420 else {
421 filename="/p/service/loco/plans/"+str+".plan";
422 if(file_size(filename)>=0)
423 text+="Plan:\n"+read_file(filename);
424// else
425// text+="Keine .plan-Datei.\n";
426 }
427 }
428 properties=0;
Bugfix928e56f2018-07-26 17:20:30 +0200429 text=break_string(text,78,0,BS_LEAVE_MY_LFS);
MG Mud User88f12472016-06-24 23:31:02 +0200430 if (!local)
431 return text;
432 this_player()->More(text);
433 return "";
434}
435
436string Finger(string str)
437{
438 if(!str || str=="") { notify_fail("Wen denn?\n"); return 0; }
439 else
440 return finger_single(str,1);
441}