blob: 3cfe28826ae00db72c5da23ce4573d2f12e0c402 [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{
MG Mud User88f12472016-06-24 23:31:02 +020088 string *s,s2,s3,s4;
89 // Daten einlesen, wenn die daten aelter als 1 Tag sind oder sich
Zesstra0db0e6c2020-04-22 00:00:50 +020090 // /data/etc/SPONSOR geaendert hat.
MG Mud User88f12472016-06-24 23:31:02 +020091 if ((time() > filetime+86400) ||
Zesstra0db0e6c2020-04-22 00:00:50 +020092 filetime!=file_time("/data/etc/SPONSOR"))
MG Mud User88f12472016-06-24 23:31:02 +020093 {
94 relatives=m_allocate(0,2);
Zesstra0db0e6c2020-04-22 00:00:50 +020095 filetime=file_time("/data/etc/SPONSOR");
96 s=explode(read_file("/data/etc/SPONSOR"),"\n");
MG Mud User88f12472016-06-24 23:31:02 +020097 foreach(string str: s) {
98 sscanf(str,"%s: %s macht %s zum Learner.",s2,s3,s4);
99 if (IS_LEARNER(lower_case(s3)) && IS_LEARNER(lower_case(s4)))
100 {
101 relatives[lower_case(s4),0]=s3;
102 s3=lower_case(s3);
103 s4+=" ("+query_wiz_level(lower_case(s4))+")";
104 if (!relatives[s3,1]) relatives[s3,1]=({s4});
105 else relatives[s3,1]+=({s4});
106 }
107 }
108 }
109 s2="";
110 if (relatives[name,0])
111 s2+="Vorfahre: "+relatives[name,0]+"\n";
112 if (relatives[name,1])
113 s2+="Nachfahre(n): "+break_string(implode(relatives[name,1],", "),78,14)[14..];
114 return s2;
115}
116
117varargs string finger_single(string str,int local)
118{
MG Mud User88f12472016-06-24 23:31:02 +0200119 string ip,text,ipnum,filename,away;
Zesstrae9c7b6f2021-05-07 09:33:25 +0200120 int wizlevel,idle,flags,last;
MG Mud User88f12472016-06-24 23:31:02 +0200121 mixed h,data,tmp;
122 object player,ob;
123
124 /*DEBUG### tell_object((find_player("loco")||this_object()),"Finger request: '"+str+"'("+local+")\n");/**/
125 str=lower_case(str);
126 text="";
127 away="";
128 hc_play=0;
129
130 h=explode(str," ");
131 if (sizeof(h)==1) h=explode(str,"+");
132 if (member(h,"-n")>=0) flags=FLAG_NOPLAN;
133 if (member(h,"-p")>=0) flags=0;
134 if (member(h,"-l")>=0) flags|=FLAG_LONG;
135 if (member(h,"-s")>=0) flags|=FLAG_SPONSOR;
136 if (member(h,"-v")>=0) flags|=FLAG_VIS_LOGOUT;
137 if (member(h,"-a")>=0) flags|=FLAG_AVATAR;
138
139 h=(h-({"-n","-p","-l","-s", "-v","-a"}));
140 if (!sizeof(h)) {
141 text="Du solltest schon sagen, wer Dich interessiert!\n";
142 if (local) return write(text),0;
143 else return text;
144 }
145 str=h[0];
146 if (!sizeof(str) || str[0]<'a' || str[0]>'z') {
147 text="Also, so ("+str+") heisst bestimmt kein Spieler hier!\n";
148 if (local) return write(text),0;
149 else return text;
150 }
151
152 /* does this player exist? */
153 str=old_explode(str,".")[0];
MG Mud User88f12472016-06-24 23:31:02 +0200154 player=find_player(str)||find_netdead(str);
155
Zesstracd25d262020-01-21 19:36:39 +0100156 if( (!master()->find_userinfo(str) && !player) )
157 {
MG Mud User88f12472016-06-24 23:31:02 +0200158 text="Hmm... diesen Namen gibt es im "MUDNAME" nicht.\n";
159 if (tmp="/secure/master"->QueryBanished(str)){
160 text="Hoppla - dieser Name ist reserviert oder gesperrt (\"gebanisht\")!\n";
161 if ( tmp != "Dieser Name ist gesperrt." )
162 text += "Grund fuer die Sperrung: " + tmp +
163 (member( ({'!','?','.'}), tmp[<1] ) != -1 ? "" : ".") + "\n";
164 }
165 if (local) return write(text),0;
166 else return text;
167 }
168
169 if (player) {
170 hc_play=player->query_hc_play();
171 properties=player->QueryProperties();
172 properties[P_RACE]=player->QueryProp(P_RACE);
173 properties[P_VISIBLE_GUILD]=player->QueryProp(P_VISIBLE_GUILD);
174 properties[P_TITLE]=player->QueryProp(P_TITLE);
175 tmp = player->QueryProp(P_PRESAY);
176 properties[P_PRESAY]=(stringp(tmp) && sizeof(tmp)>1) ? tmp[0..<2] : 0;
177 }
178 else
Bugfix860e85a2020-12-11 12:35:28 +0100179 restore_object(SAVEPATH+str[0..0]+"/"+str);
MG Mud User88f12472016-06-24 23:31:02 +0200180 if (!properties)
181 {
182 text+="Mist!!! Das Einlesen der Daten klappt nicht wie es soll :-(\n";
183 properties=0;
184 if (!local)
185 return text;
186 write(text);
187 return "";
188 }
189 if ( player && interactive(player) )
190 ipnum = query_ip_number(player);
191 else
192 ipnum = properties[P_CALLED_FROM_IP];
193 // frueher stand in P_CALLED_FROM_IP evtl. auch der Name direkt drin
194 // anstelle der numerischen IP
195 ip=query_ip_name(ipnum)||properties[P_CALLED_FROM_IP];
196 if(player) {
197 if (!interactive(player) || (idle=query_idle(player))<MINIDLE)
198 idle=0;
199 if (!(invis=age=player->QueryProp(P_INVIS)))
200 age=player->QueryProp(P_AGE);
201 } else {
202 if (properties[P_INVIS]) age=properties[P_INVIS];
203 idle=properties[P_LAST_LOGOUT];
204 }
205
206 wizlevel=query_wiz_level(str);
Bugfix860e85a2020-12-11 12:35:28 +0100207 if ( (tmp = file_time(SAVEPATH+str[0..0]+"/"+str+".o")) <= 0 )
MG Mud User88f12472016-06-24 23:31:02 +0200208 // Hack, um bei ganz "frischen" Spielern (noch kein Savefile vorhanden)
209 // die Ausgabe von 1.1.1970 zu verhindern
210 tmp = time();
211 last=properties[P_LAST_LOGOUT];
212 if ( last <= 0 || (!(flags&FLAG_VIS_LOGOUT) && wiz && wizlevel > 10
213 && properties[P_INVIS] && tmp - last > 300) )
214 last = tmp;
215
216 /* output routine for all */
217 if(player) {
218 h=player->QueryProp(P_RACE);
219 if(interactive(player) && (wiz || !invis)) {
220 text+=capitalize(str)+" ist anwesend,\n"+
221 "und zwar von: "+
222 (wiz ? (ip+(ipnum?" ("+ipnum+")":"")):"")+
223 (stringp(properties[P_LOCATION]) ? (wiz ? "\n [" : "")
224 +capitalize(properties[P_LOCATION])+
225 ((properties[P_LOCATION] != country(ip, ipnum))
226 ? " (ueber "+country(ip, ipnum)+")" : "" )
227 : (wiz?" [":"")+country(ip, ipnum))+(wiz ? "]":"")+".\n";
228 if(idle)
229 text+="Passiv seit: "+timediff(idle)+"\n";
230 if (local)
231 text+="Eingeloggt seit: "+dtime(properties[P_LAST_LOGIN])+"\n";
232 if (properties[P_AWAY])
233 away="z.Z. abwesend, Grund : "+properties[P_AWAY]+"\n";
234 } else
235 text+=capitalize(str)+" ist nicht anwesend.\nZuletzt eingeloggt von: "+
236 (wiz ? (ip+(ipnum&&ipnum!=ip?" ("+ipnum+")":"")):"")+
237 (stringp(properties[P_LOCATION]) ?
238 (wiz ? "\n [": "")
239 +capitalize(properties[P_LOCATION])+" (ueber "+country(ip, ipnum)+")":
240 (wiz?" [":"")+country(ip, ipnum))+(wiz ? "]":"")+".\n"+
241 "Zuletzt ausgeloggt: "+dtime(last)+" ("+timediff(time()-last)+").\n";
242 }
243 else {
244 text+=capitalize(str)+" ist nicht anwesend.\nZuletzt eingeloggt von: "+
245 (wiz ? (ip+(ipnum&&ipnum!=ip?" ("+ipnum+")":"")):"")+
246 (stringp(properties[P_LOCATION]) ?
247 (wiz ? "\n [": "")
248 +capitalize(properties[P_LOCATION])+" (ueber "+country(ip, ipnum)+")":
249 (wiz?" [":"")+country(ip, ipnum))+(wiz ? "]":"")+".\n"+
250 "Zuletzt ausgeloggt: "+dtime(last)+" ("+timediff(time()-last)+").\n";
251 }
252 text+="Voller Name: "+(((h=properties[P_PRESAY]) && h!="") ? h+" " : "")+
253 capitalize((h=properties[P_NAME]) ? h : str)+" "+
254 ((h=properties[P_TITLE]) ? h :
255 ((mappingp(h=properties["guild_title"]) && (h=(h[properties[P_GUILD]?properties[P_GUILD]:"abenteurer"])) ) ? h : "") )
256 +"\n";
257
258 if (properties[P_GHOST]) text+="Hoppla, ein Geist!\n";
259 if ((flags&FLAG_LONG)&&properties[P_LONG])
260 text+="Beschreibung: \n"+break_string(properties[P_LONG],78,2);
261
262 if(wiz ||
263 (properties[P_SHOWEMAIL]=="alle") ||
264 ( (properties[P_SHOWEMAIL]=="freunde") &&
265 objectp(player) &&
266 this_player() &&
267 (ob=present("\n\bfband",player)) &&
268 pointerp(tmp=ob->QueryProp(P_AUTOLOADOBJ)) &&
269 pointerp(tmp=tmp[1]) &&
270 (member(tmp,getuid(this_player()))!=-1))) tmp = 1;
271 else tmp=0;
272
Zesstra9b9531f2020-01-21 20:45:35 +0100273 string shell=properties[P_RACE];
274 if (!stringp(shell))
Zesstracd25d262020-01-21 19:36:39 +0100275 {
Zesstra9b9531f2020-01-21 20:45:35 +0100276 shell = master()->query_userlist(str, USER_OBJECT);
Zesstracd25d262020-01-21 19:36:39 +0100277 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";
bugfixaf2be4f2020-03-22 19:13:07 +0100347 switch(properties[P_SECOND_MARK]) {
MG Mud User88f12472016-06-24 23:31:02 +0200348 case -1: text+=" unsichtbar markierte"
bugfixaf2be4f2020-03-22 19:13:07 +0100349 +(properties[P_GENDER]!=FEMALE ? "r": "");
MG Mud User88f12472016-06-24 23:31:02 +0200350 break;
351 case 0: text+=" nicht namentlich markierte"
bugfixaf2be4f2020-03-22 19:13:07 +0100352 +(properties[P_GENDER]!=FEMALE ? "r": "");
MG Mud User88f12472016-06-24 23:31:02 +0200353 break;
354 default:
355 }
356 text+=" Zweitspieler"+IN;
357 if (stringp(h))
358 text+=" ("+capitalize(h)+")";
359 text+=".\n";
360 }
bugfixaf2be4f2020-03-22 19:13:07 +0100361 else if (properties[P_SECOND_MARK]>0)
MG Mud User88f12472016-06-24 23:31:02 +0200362 {
363 text+=capitalize(str)+" ist Zweitspieler"+IN;
364 if (stringp(h))
365 text+=" ("+capitalize(h)+")";
366 text+=".\n";
367 }
bugfixaf2be4f2020-03-22 19:13:07 +0100368 else if (properties[P_SECOND_MARK]>-1)
MG Mud User88f12472016-06-24 23:31:02 +0200369 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}