blob: 58f6dca5c28638f565f3b3ed6884d6927ac40d08 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001// This tool was originally written by Macbeth@TUBmud
2//
3// Some changes/extensions by Jof@MorgenGrauen
4
Zesstrad39f73d2018-11-09 00:01:15 +01005inherit "/std/secure_thing";
Zesstraf4471b32018-11-08 23:54:53 +01006protected functions virtual inherit "/std/util/path";
MG Mud User88f12472016-06-24 23:31:02 +02007
8#include <language.h>
9#include <properties.h>
10#include <wizlevels.h>
11#include <moving.h>
12#include <defines.h>
13#include <questmaster.h>
14#include <userinfo.h>
Zesstraf4471b32018-11-08 23:54:53 +010015#include <strings.h>
MG Mud User88f12472016-06-24 23:31:02 +020016
17#define add(s) commands+=({s});functions+=({s});ncmds++
18#define add2(s,f) commands+=({s});functions+=({f});ncmds++
19#define MAXSTACK 10
20#define MAXVARS 10
21#define MAXDEPTH 5
22#define MAXLINES 40
23#define MAXLINELEN 79
24
25mixed *stack, *vararea, err;
26
27string *commands, *functions, user, *query_list, *argv;
28int maxverb,ncmds,argc,recursive,hide_short,lines,firstline,lastline;
29static int tell(string str);
30int evalcmd(string str);
31int eval(string str);
32string stk(string arg);
33string desc(object ob);
34void clean(object ob);
35void cleanof(string str,object ob);
36
37
Zesstraf4471b32018-11-08 23:54:53 +010038protected void create()
MG Mud User88f12472016-06-24 23:31:02 +020039{
40 object owner;
41 string str;
Zesstraf4471b32018-11-08 23:54:53 +010042
43 if (!clonep(ME)) {
44 set_next_reset(-1);
45 return;
46 }
MG Mud User88f12472016-06-24 23:31:02 +020047 ::create();
48 owner=environment()||this_player();
49 if (owner)
50 str=capitalize(((str=geteuid(owner))[<1]=='s'||str[<1]=='x'||str[<1] =='z')?str+="'":str+="s");
51 else
52 str="Eine";
53 SetProp( P_SHORT,str+" Lupe" );
54 SetProp( P_NAME, str+" Lupe" );
55 SetProp( P_LONG, "Mit dieser Lupe kann man die Feinheiten des LPC besser erkennen.\n" );
56 SetProp( P_NEVERDROP, 1 );
57 SetProp( P_NODROP, "Du kannst Deine Lupe nicht wegwerfen. Dazu ist sie zu wertvoll.\n");
58 SetProp( P_NOBUY, 1 );
59 SetProp( P_GENDER, FEMALE );
60 SetProp( P_WEIGHT, 0 );
61 SetProp( P_ARTICLE,0);
62 SetProp( P_GENDER,0);
63 AddId( "lupe" );
64 user="*";
65 stack=({});
66 commands=({});
67 functions=({});
68 ncmds=0;
69 add("Dest");
MG Mud User88f12472016-06-24 23:31:02 +020070 add("clnof");
71 add("cln");
72 add("clr");
73 add("copy_ldfied");
74 add("creat");
75 add("dest");
76 add("dinfo");
77 add("disco");
78 add("dump_lists");
79 add("dup");
80 add("env");
81 add("here");
82 add("info");
83 add("inv");
84 add("lv");
85 add("make");
86 add("me");
87 add("minfo");
88 add("new");
89 add("norec");
90 add("ob");
91 add("over");
92 add("pl");
93 add("rec");
94 add("result");
95 // add("rusage");
96 add("scan");
97 add("stat");
98 add("stk");
99 add("swap");
100 add("swho");
101 add("vars");
102 add2("#","lock");
103 add2(".","sel");
104 add2("/","file");
105 add2("<","readvar");
106 add2("=","dump");
107 add2(">","writevar");
108 add2("@","pick");
109 add2("[","call");
110 add2("_mo","_mv");
111 add2("_mov","_mv");
112 add2("_move","_mv");
113 add2("_mv","_mv");
114 add2("call_out","callout");
115 add2("debug_info", "db_info");
116 add2("desc","toggle_short");
117 add2("dump","dumplists");
118 add2("heart_beat","heartbeat");
119 add2("idle","idle");
120 add2("inherit_list","inheritlist");
121 add2("move","mv");
122 add2("mov","mv");
123 add2("mo","mv");
124 add2("pop","xpop");
125 add2("push","xpush");
126 add2("renew","renew_player");
127 add2("sc","scan");
128 add2("~","file2");
129 maxverb=ncmds;
130 vararea=allocate(MAXVARS);
131 query_list =
132 ({
133 "VALUE","-value","LEVEL","-level","IDS","-ids",
134 "WEAPON CLASS","-wc","ARMOUR CLASS","-ac",
135 "WEIGHT","-weight","TYPE","query_type",
136 "UID","-uid","EUID","-euid"
137 });
138}
139
140int _query_autoloadobj()
141{
142 return 1;
143}
144
145void _set_autoloadobj()
146{
147 call_out("_load_profile",0);
148}
149
150void _load_profile()
151{
152 object profile;
153 string pfile;
154
155 if (geteuid() && environment() && geteuid(environment())==geteuid() &&
156 interactive(environment()))
157 if (file_size(pfile="/players/"+geteuid()+"/.profile.c")>0)
158 if (pfile=catch(call_other(pfile,"setup",environment())))
159 printf("Error when loading profile: %O\n",pfile);
160}
161
Arathorn306aa032018-08-29 22:18:28 +0200162varargs void init(object origin)
MG Mud User88f12472016-06-24 23:31:02 +0200163{
164 int i,ch;
165
Arathorn306aa032018-08-29 22:18:28 +0200166 ::init(origin);
MG Mud User88f12472016-06-24 23:31:02 +0200167 if (environment()!=this_player()) return;
168// if (!IS_LEARNER(this_player())) return;
169 if (!IS_LEARNER(this_player())) return destruct(this_object());
170
171 add_action("cmdline","",1);
172}
173
174int cmdline(string str)
175{
176 string verb;
177 int i,ret;
178
179 verb=query_verb();
180 if (!verb) return 0;
181 switch (verb)
182 {
183 case "erzaehl": return tell(str);
184 }
bugfixd94d0932020-04-08 11:27:13 +0200185 str=({string})PL->_unparsed_args();
MG Mud User88f12472016-06-24 23:31:02 +0200186 for (i=0;i<maxverb;i++)
187 if (commands[i]==verb[0..sizeof(commands[i])-1])
188 if (ret=evalcmd(str))
Zesstraf4471b32018-11-08 23:54:53 +0100189 return ret;
190
MG Mud User88f12472016-06-24 23:31:02 +0200191 return(0); // non-void function, Zesstra
192}
193
194static int tell(string str)
195{
196 string *tmp;
197 object who,sn;
198 int ret;
199
200 if (!IS_ARCH(this_interactive())) return 0;
bugfixd94d0932020-04-08 11:27:13 +0200201 if (!(str=({string})this_interactive()->_unparsed_args())) return 0;
MG Mud User88f12472016-06-24 23:31:02 +0200202 if (sizeof(tmp=old_explode(str," "))<2) return 0;
203 if (!(who=find_player(tmp[0]))) return 0;
204 if (!(sn=query_snoop(who))) return 0;
205 if (query_wiz_grp(this_interactive())<=query_wiz_grp(sn) ||
206 query_wiz_grp(this_interactive())<=query_wiz_grp(who)) return 0;
207 snoop(sn,0);
bugfixd94d0932020-04-08 11:27:13 +0200208 ret=({int})this_interactive()->_erzaehle(str);
MG Mud User88f12472016-06-24 23:31:02 +0200209 snoop(sn,who);
210 return ret;
211}
212
213int set_user(string str)
214{
215 string who;
216 if (!str) return 0;
217 if (str=="no access")
218 {
219 user="*";
220 move_object(this_object(),environment());
221 write("Ok.\n");
222 return 1;
223 }
224 if (sscanf(str,"access to %s",who)==1)
225 {
226 object pl;
227 pl=find_player(who);
228 if (!pl)
229 write("No such player.\n");
230 else
231 {
232 user = who;
233 write("Ok.\n");
234 move_object(this_object(),pl);
235 tell_object(pl,"Du darfst nun durch die magische Lupe schauen.\n");
236 }
237 return 1;
238 }
239 return 0;
240}
241
242string strip(string str)
243{
Zesstraf4471b32018-11-08 23:54:53 +0100244 return trim(str,TRIM_BOTH);
MG Mud User88f12472016-06-24 23:31:02 +0200245}
246
247int arglen;
248
249string getarg(string args)
250{
251 string arg;
252 string rest;
253 if (sscanf(args,"\"%s\"%s",arg,rest)==2 ||
254 sscanf(args,"\'%s\'%s",arg,rest)==2 ||
255 sscanf(args,"|%s|%s",arg,rest)==2)
256 {
257 if (arg=="")
258 arglen=2;
259 else
260 arglen=sizeof(arg)+2;
261 return arg;
262 }
263 if (sscanf(args,"%s %s",arg,rest)==2)
264 args=arg;
265 if (sscanf(args,"%s.%s",arg,rest)==2)
266 args=arg;
267 if (sscanf(args,"%s[%s",arg,rest)==2)
268 args=arg;
269 if (sscanf(args,"%s]%s",arg,rest)==2)
270 args=arg;
271 if (args=="")
272 arglen=0;
273 else
274 arglen=sizeof(args);
275 return args;
276}
277
278string getrest(string str)
279{
280 if (arglen==0)
281 return str;
282 if (arglen==sizeof(str))
283 return "";
284 return strip(str[arglen..sizeof(str)-1]);
285}
286
287int interactiveMode(string str)
288{
289 if (str)
290 return eval(str);
291 stk("");
292 write("'.' to exit.\n");
293 write("? ");
294 input_to("more");
295 return 1;
296}
297
298void more(string str)
299{
300 string cmd;
301 if (str==".") return;
302 if (sscanf(str,"!%s",cmd)==1)
303 command(cmd,this_player());
304 else
305 {
306 eval(str);
307 stk("");
308 }
309 write("? ");
310 input_to("more");
311}
312
313int evalcmd(string str)
314{
315 string verb;
316 if (!IS_LEARNING(this_player())) return 0;
317 verb=query_verb();
318 if (verb=="?")
319 verb="";
320 if (str)
321 str=verb+" "+str;
322 else
323 str=verb;
324 return eval(str);
325}
326
327int eval(string str)
328{
329 int i,flag,old_sp,first;
330 mixed *old_stack;
331 string arg,tmp;
332 err=0;
333 first=1;
334 while (str!="")
335 {
336 flag=0;
337 str=strip(str);
338 if (sscanf(str,"#%s",arg)==1)
339 {
340 old_stack=stack[0..<1];
341 str=arg;
342 }
343 else
344 old_stack=0;
345 str=strip(str);
346 if (str=="")
347 break;
348 for (i=0;i<ncmds;i++)
349 {
350 if (sscanf(str,commands[i]+"%s",arg)==1)
351 {
352 if (arg!="" && str[0]>='a' && str[0]<='z' &&
353 arg[0]>='a' && arg[0]<='z')
354 {
355 if (first)
356 return 0;
357 else
358 {
359 printf("Couldn't parse: %O.\n",str);
360 return 1;
361 }
362 }
363 arg=strip(arg);
364 str=call_other(this_object(),functions[i],arg);
365 first=0;
366 if (old_stack)
367 {
368 stack=old_stack;
369 old_stack=0;
370 }
371 if (stringp(err))
372 {
373 if (sscanf(err,"%s\n",tmp)==1)
374 err = tmp;
375 notify_fail(sprintf("ERROR: %O.\n",err));
376 return 0;
377 }
378 flag=1;
379 break;
380 }
381 }
382 if (!flag)
383 {
384 notify_fail(sprintf("Couldn't parse: %O.\n",str));
385 return 0;
386 }
387 }
388 return 1;
389}
390
391int push(object ob)
392{
393 stack+=({ob});
394 if (sizeof(stack)>MAXSTACK)
395 stack=stack[1..MAXSTACK];
396 return 1;
397}
398
399mixed pop()
400{
401 object tmp;
402 if (!sizeof(stack))
403 {
404 err="stack underflow";
405 tmp=this_object();
406 return 0;
407 }
408 tmp=stack[sizeof(stack)-1];
409 stack=stack[0..<2];
410 if (!tmp)
411 err="operating on destructed object";
412 return tmp;
413}
414
415mixed xpop(string arg)
416{
417 if (!pop())
418 err=0;
419 return arg;
420}
421
422mixed toggle_short(string arg)
423{
424 hide_short = !hide_short;
425 if (hide_short)
426 write("Short descriptions off.\n");
427 else
428 write("Short descriptions on.\n");
429 return arg;
430}
431
432mixed pl(string arg)
433{
434 string who,rest;
bugfixd94d0932020-04-08 11:27:13 +0200435 string|object p;
MG Mud User88f12472016-06-24 23:31:02 +0200436 who=getarg(arg);
437 rest=getrest(arg);
438 if (err) return 0;
439 p=match_living(who,1);
440 if (!stringp(p))
441 {
442 if (!p=find_netdead(who))
443 err="player "+who+" not found";
444 else
445 push(p);
446 }
447 else
448 push(find_player(p));
449 return rest;
450}
451
452mixed lv(string arg)
453{
454 string who,rest;
455 object p;
456 who=getarg(arg);
457 rest=getrest(arg);
458 if (err) return 0;
459 p=find_living(who);
460 if (!p)
461 err="living object "+who+" not found";
462 else
463 push(p);
464 return rest;
465}
466
467string me(string arg)
468{
469 push(this_player());
470 return arg;
471}
472
473string make_path(string path)
474{
Zesstraf4471b32018-11-08 23:54:53 +0100475 // Pfadexpansion fuer Nutzer des Tools
476 return normalize_path(path, getuid( RPL || PL ), 1);
MG Mud User88f12472016-06-24 23:31:02 +0200477}
478
479string new(string arg)
480{
481 string what,rest,file;
482 object ob;
483 what=getarg(arg);
484 rest=getrest(arg);
485 file=make_path(what);
486 err=catch(ob=clone_object(file));
487 if (!err)
488 {
489 push(ob);
bugfixd94d0932020-04-08 11:27:13 +0200490 ({int})ob->move(this_player(),M_NOCHECK);
MG Mud User88f12472016-06-24 23:31:02 +0200491 write("Created "+desc(ob)+".\n");
492 }
493 else
494 err = "unable to create object, cause : "+err;
495 return rest;
496}
497
498static string creat(string arg)
499{
500 string what,rest,file;
501 object ob;
502 what=getarg(arg);
503 rest=getrest(arg);
504 file=make_path(what);
505 err=catch(ob=clone_object(file));
506 if (!err)
507 {
508 push(ob);
509 write("Created "+desc(ob)+".\n");
510 }
511 else
512 err = "unable to create object, cause : "+err;
513 return rest;
514}
515
516string xpush(string arg)
517{
518 string rest,what;
519 object ob;
520
521 what=getarg(arg);
522 rest=getrest(arg);
523 ob = find_object(what);
524 if (!ob)
525 err="Object "+what+" not found!\n";
526 else
527 push(ob);
528 return rest;
529}
530
531static string ob(string arg)
532{
533 string what,rest,file,tmp;
534 object ob;
535 what=getarg(arg);
536 rest=getrest(arg);
537 file=make_path(what);
538{
539 ob=find_object(file);
540 if (!ob)
541 {
542 tmp = catch(call_other(file,"??"));
543 if (!err)
544 ob = find_object(file);
545 }
546}
547if (!ob)
548{
549 err="object "+file+" not found";
550 if (tmp)
551 err += "("+tmp+")";
552}
553else
554push(ob);
555return rest;
556}
557
558string file(string arg)
559{
560 return ob("/"+arg);
561}
562
563string file2(string arg)
564{
565 return ob("~"+arg);
566}
567
568string sel(string arg)
569{
570 string rest;mixed what;
571 object ob,p;
572 ob=pop();
573 if (err) return arg;
574 if (sscanf(arg,"%d%s",what,rest)==2)
575 {
576 if (what<=0)
577 {
578 err="negative index";
579 push(ob);
580 return arg;
581 }
582 what--;
583 p=first_inventory(ob);
584 while (p && what)
585 {
586 p=next_inventory(p);
587 what--;
588 }
589 if (!p)
590 {
591 err="index to large";
592 push(ob);
593 return arg;
594 }
595 push(p);
596 return rest;
597 }
598 what=getarg(arg);
599 rest=getrest(arg);
600 p=present(what,ob);
601 if (p)
602 push(p);
603 else
604 {
605 push(ob);
606 err=what+" not present in "+desc(ob);
607 }
608 return rest;
609}
610
611string here(string arg)
612{
613 push(environment(this_player()));
614 return arg;
615}
616
617string env(string arg)
618{
619 object ob;
620 ob=pop();
621 if (!err)
622 {
623 if (!environment(ob))
624 err=desc(ob)+" has no environment";
625 else
626 push(environment(ob));
627 }
628 return arg;
629}
630
631string dup(string arg)
632{
633 object tos;
634 tos=pop();
635 if (!err)
636 {
637 push(tos);
638 push(tos);
639 }
640 return arg;
641}
642
643string swap(string arg)
644{
645 object tos;
646 int sts;
647
648 if ((sts=sizeof(stack))<2)
649 {
650 err="stack underflow";
651 return arg;
652 }
653 tos=stack[sts-1];
654 stack[sts-1]=stack[sts-2];
655 stack[sts-2]=tos;
656 return arg;
657}
658
659string over(string arg)
660{
661 object ob;
662 if (sizeof(stack)<2)
663 {
664 err="stack underflow";
665 return arg;
666 }
667 push(stack[sizeof(stack)-2]);
668 return arg;
669}
670
671string pick(string arg)
672{
673 string rest;
674 int no;
675 if (sscanf(arg,"%d%s",no,rest)!=2 || no<0 || no>=sizeof(stack))
676 {
677 err="stack size exceeded";
678 return arg;
679 }
680 else
681 push(stack[sizeof(stack)-no-1]);
682 return rest;
683}
684
685string string_desc(string str)
686{
687 string out;
688 out = implode(old_explode(str,"\\"),"\\\\");
689 out = implode(old_explode(out,"\n"),"\\n");
690 out = implode(old_explode(out,"\""),"\\\"");
691 return "\""+out+"\"";
692}
693
694mixed rec_desc(mixed ob)
695{
696 if (intp(ob))
697 return ""+ob;
698 if (stringp(ob))
Vanion50652322020-03-10 21:13:25 +0100699 return string_desc(ob);
MG Mud User88f12472016-06-24 23:31:02 +0200700 if (objectp(ob))
701 return "OBJ("+object_name(ob)+")";
702 if (!pointerp(ob))
703 return sprintf("%O",ob);
704 return "({ "+implode(map(ob,"rec_desc",this_object()),", ")+" })";
705}
706
707string array_desc(mixed arr)
708{
709 string str,line,res;
710 mixed tmp;
711 int i,j;
712 str=rec_desc(arr);
713 if (sizeof(str)<=MAXLINELEN-4)
714 return "--> "+str+"\n";
715 tmp=old_explode(str," ");
716 res="";
717 lines=0;
718 i=1;
719 line="--> "+tmp[0]+" ";
720 for (;;)
721 {
722 while (i<sizeof(tmp) && sizeof(line)+sizeof(tmp[i]+1)<=MAXLINELEN-1)
723 {
724 line+=tmp[i]+" ";
725 i++;
726 }
727 if (sizeof(line)==0)
728 {
729 line=tmp[i]+" ";
730 i++;
731 }
732 if (i<sizeof(tmp))
733 line+="|\n";
734 else
735 line+="\n";
736 res+=line;
737 lines++;
738 if (lines>=MAXLINES)
739 return res+"*** TRUNCATED ***\n";
740 if (i>=sizeof(tmp))
741 return res;
742 line="";
743 }
744 return(0); // non-void, Zesstra (never reached)
745}
746
747string desc(object ob)
748{
749 if (!ob)
750 return "<destructed object>";
751 if (!objectp(ob))
752 return "<corrupted stack entry>";
753 if (query_once_interactive(ob))
754 return object_name(ob)+" "+capitalize(geteuid(ob));
bugfixd94d0932020-04-08 11:27:13 +0200755 if (!hide_short && ({string})ob->short())
756 return object_name(ob)+" "+({string})ob->name();
MG Mud User88f12472016-06-24 23:31:02 +0200757 else
758 return object_name(ob);
759}
760
761string stk(string arg)
762{
763 int i,sts;
764 if (!(sts=sizeof(stack)))
765 write ("<empty stack>\n");
766 else
767 for (i=1;i<=sts;i++)
768 {
769 write("@"+(i-1)+": "+desc(stack[sts-i])+"\n");
770 }
771 return arg;
772}
773
774string clr(string arg)
775{
776 stack=({});
777 return arg;
778}
779
780string dump(string arg)
781{
782 object ob;
783 string s;
784 ob=pop();
785 if (err) return arg;
786 push(ob);
787 write("FILENAME: "+object_name(ob)+" ");
bugfixd94d0932020-04-08 11:27:13 +0200788 if (!hide_short && (({string})s=ob->short()))
789 write(" SHORT: "+({string})ob->name());
MG Mud User88f12472016-06-24 23:31:02 +0200790 write("\n");
791 return arg;
792}
793
794string info(string arg)
795{
796 object ob;
797 mixed s;
798 int i;
799 ob=pop();
800 if (err) return arg;
801 write("FILENAME: "+object_name(ob)+" ");
bugfixd94d0932020-04-08 11:27:13 +0200802 if (s=({string})ob->short())
803 write(" SHORT: "+({string})ob->name());
MG Mud User88f12472016-06-24 23:31:02 +0200804 write("\n");
805 if (getuid(ob))
806 write("CREATOR: "+getuid(ob)+"\n");
Arathornbb178c22020-07-27 23:52:09 +0200807 if (interactive(ob) && (s=query_ip_number(ob)))
MG Mud User88f12472016-06-24 23:31:02 +0200808 {
809 write("IP-NUMBER: "+s+" IP-NAME: "+query_ip_name(ob)+" IDLE: "
810 + query_idle(ob)+"\n");
811 }
812 if (s=query_snoop(ob))
bugfixd94d0932020-04-08 11:27:13 +0200813 write("SNOOPED BY: "+({string})s->query_real_name()+"\n");
MG Mud User88f12472016-06-24 23:31:02 +0200814 s="";
815 if (living(ob))
816 s +="living ";
bugfixd94d0932020-04-08 11:27:13 +0200817 if (({int})ob->query_npc())
MG Mud User88f12472016-06-24 23:31:02 +0200818 s+="npc ";
bugfixd94d0932020-04-08 11:27:13 +0200819 if (({string})ob->query_gender_string())
820 s+=({string})ob->query_gender_string();
MG Mud User88f12472016-06-24 23:31:02 +0200821 if (s!="")
822 write("FLAGS: "+s+"\n");
823 // write("LONG:\n");
bugfixd94d0932020-04-08 11:27:13 +0200824 // if (stringp(s=({string})ob->long()))
MG Mud User88f12472016-06-24 23:31:02 +0200825 // write(s);
826 // write("\n");
827 for (i=0;i<sizeof(query_list);i+=2)
828 {
829 if (query_list[i+1][0]=='-')
bugfixd94d0932020-04-08 11:27:13 +0200830 s=({string})ob->QueryProp(query_list[i+1][1..]);
MG Mud User88f12472016-06-24 23:31:02 +0200831 else
bugfixd94d0932020-04-08 11:27:13 +0200832 s=({string})call_other(ob,query_list[i+1]);
MG Mud User88f12472016-06-24 23:31:02 +0200833 if (s)
834 {
835 printf("%s: %O\n",query_list[i],s);
836 }
837 }
838 return arg;
839}
840
841string filler(int n)
842{
843 string s;
844 if (!recursive) return ": ";
845 s=": ";
846 while (++n<MAXDEPTH)
847 s=" "+s;
848 return s;
849}
850
851void listinv(object ob,int depth,string prefix)
852{
853 int i;
854 object p;
855 if (depth<MAXDEPTH)
856 {
857 p=first_inventory(ob);
858 i=1;
859 if (p)
860 {
861 while (p)
862 {
863 if (lines>lastline) return;
864 if (lines>=firstline)
865 write(prefix+"."+i+filler(depth)+desc(p)+"\n");
866 lines++;
867 if (lines==lastline+1 && next_inventory(p))
868 write("*** TRUNCATED ***\n");
869 if (recursive)
870 listinv(p,depth+1,prefix+"."+i);
871 i++;
872 p=next_inventory(p);
873 }
874 }
875 else
876 if (!depth)
877 write("<empty inventory>\n");
878 }
879}
880
881string inv(string arg)
882{
883 object ob;
884 string rest;
885 int tmp;
886 ob=pop();
887 lines=1;
888 firstline=1;
889 lastline=MAXLINES;
890 if (!err)
891 {
892 if (sscanf(arg,":%d%s",tmp,rest)==2)
893 {
894 firstline=tmp;
895 lastline=tmp+MAXLINES-1;
896 arg = rest;
897 if (sscanf(arg,":%d%s",tmp,rest)==2)
898 {
899 lastline=tmp;
900 if (lastline<firstline)
901 err = "first line > last line";
902 arg=rest;
903 }
904 }
905 push(ob);
906 listinv(ob,0,"");
907 }
908 recursive=0;
909 return arg;
910}
911
912object call_result;
913
914string call(string arg)
915{
916 string func,args;
917 int temp,i;
918 string rest,tmp;
919
920 object ob;
921 ob=pop();
922 if (err) return arg;
923 push(ob);
924 func=getarg(arg);
925 args=getrest(arg);
926 if (err) return args;
927 argv=({});
928 i=0;
929 while (1)
930 {
931 args=strip(args);
932 if (sscanf(args,"]%s",rest))
933 break;
934 if (sscanf(args,"%d%s",tmp,rest)==2)
935 {
936 args=rest;
937 argv+=({tmp});
938 continue;
939 }
940 if (sscanf(args,"\"%s\"%s",tmp,rest)==2 ||
941 sscanf(args,"\'%s\'%s",tmp,rest)==2 ||
942 sscanf(args,"|%s|%s",tmp,rest)==2)
943 {
944 args=rest;
945 argv+=({tmp});
946 continue;
947 }
948 if (sscanf(args,"@%d%s",temp,rest)==2)
949 {
950 if (temp<0 || temp>=sizeof(stack))
951 {
952 err="stackindex out of range";
953 return args;
954 }
955 argv+=({stack[sizeof(stack)-temp-1]});
956 args=rest;
957 continue;
958 }
959 tmp=getarg(args);
960 rest=getrest(args);
961 argv+=({tmp});
962 if (tmp!="")
963 {
964 args=rest;
965 continue;
966 }
967 err="bad argument to []";
968 return args;
969 }
970 if (sscanf(args,"]%s",rest)!=1)
971 {
972 err="too many or unterminated argument(s)";
973 return args;
974 }
975 call_result=apply(#'call_other,ob,func,argv);
976 //'
977 // if (objectp(call_result))
978 // write("--> "+desc(call_result)+"\n");
979 // else if (pointerp(call_result))
980 // write(array_desc(call_result));
981 // else
982 // write("--> "+call_result+"\n");
983 printf("--> %O\n",call_result);
984 pop();
985 argv=({});
986 return rest;
987}
988
989string result(string arg)
990{
991 if (objectp(call_result))
992 push(call_result);
993 else
994 err="call returned no object";
995 return arg;
996}
997
998int destroyable(object ob)
999{
1000 if (!ob)
1001 return 0;
1002 if (query_once_interactive(ob))
1003 return 0;
1004 if (ob==this_object())
1005 return 0;
1006 return 1;
1007}
1008
1009string cln(string arg)
1010{
1011 object ob;
1012 ob=pop();
1013 if (!err)
1014 {
1015 clean(ob);
1016 write(desc(ob)+" cleaned up.\n");
1017 }
1018 recursive=0;
1019 return arg;
1020}
1021
1022string clnof(string arg)
1023{
1024 object ob;
1025 int recsave;
1026 string name,rest;
1027
1028 write("ClnOf");
1029 recsave=recursive;
1030 recursive=0;
1031 ob=pop();
1032 if (err) return arg;
1033 name=getarg(arg);
1034 rest=getrest(arg);
1035 if (err) return arg;
1036 recursive=recsave;
1037 cleanof(name,ob);
1038 recursive=0;
1039 return rest;
1040}
1041
1042void Remove(object ob,int a)
1043{
1044 if (!objectp(ob)) return;
1045 if (!a)
1046 {
1047 printf("Removing %O",ob);
bugfixd94d0932020-04-08 11:27:13 +02001048 if (!hide_short) printf(" %O",({string})ob->name());
MG Mud User88f12472016-06-24 23:31:02 +02001049 }
bugfixd94d0932020-04-08 11:27:13 +02001050 catch(({int})ob->remove());
MG Mud User88f12472016-06-24 23:31:02 +02001051 if (ob)
1052 {
1053 if (!a) printf(" HARD");
1054 destruct(ob);
1055 }
1056 write("\n");
1057}
1058
1059void clean(object ob)
1060{
1061 object p,p2;
1062 p=first_inventory(ob);
1063 while (destroyable(p))
1064 {
1065 if (recursive) clean(p);
1066 Remove(p,0);
1067 p=first_inventory(ob);
1068 }
1069 while (p)
1070 {
1071 p2=next_inventory(p);
1072 if (destroyable(p2))
1073 {
1074 if (recursive) clean(p2);
1075 Remove(p2,0);
1076 }
1077 else
1078 p=p2;
1079 }
1080}
1081
1082 void cleanof(string str,object ob)
1083{
1084 object p,p2;
1085 p=first_inventory(ob);
bugfixd94d0932020-04-08 11:27:13 +02001086 while (p && ({int})p->id(str) && destroyable(p))
MG Mud User88f12472016-06-24 23:31:02 +02001087 {
1088 if (recursive) clean(p);
1089 Remove(p,0);
1090 p=first_inventory(ob);
1091 }
1092 while (p)
1093 {
1094 p2=next_inventory(p);
bugfixd94d0932020-04-08 11:27:13 +02001095 if (p2 && ({int})p2->id(str) && destroyable(p2))
MG Mud User88f12472016-06-24 23:31:02 +02001096 {
1097 if (recursive) clean(p2);
1098 Remove(p2,0);
1099 }
1100 else
1101 p=p2;
1102 }
1103}
1104
1105string dest(string arg)
1106{
1107 object ob;
1108 ob=pop();
1109 if (err) return arg;
1110 if (!destroyable(ob))
1111 {
1112 err=desc(ob)+" must not be destroyed";
1113 return arg;
1114 }
1115 Remove(ob,0);
1116 return arg;
1117}
1118
1119mixed disco(string arg)
1120{
1121 object ob;
1122
1123 ob=pop();
1124 if (err) return arg;
1125 if (!interactive(ob))
1126 {
1127 err=desc(ob)+" is not interactive";
1128 return 1;
1129 }
1130 remove_interactive(ob);
1131 return arg;
1132}
1133
1134string Dest(string arg)
1135{
1136 object ob;
1137 ob=pop();
1138 if (err) return arg;
1139 if (!destroyable(ob))
1140 {
1141 err=desc(ob)+" must not be destroyed";
1142 return arg;
1143 }
1144 destruct( ob );
1145 return arg;
1146}
1147
1148string mv(string arg)
1149{
1150 object from,to;
1151 to=pop();
1152 if (err) return arg;
1153 from=pop();
1154 if (err) return arg;
bugfixd94d0932020-04-08 11:27:13 +02001155 ({int})from->move(to,M_NOCHECK);
MG Mud User88f12472016-06-24 23:31:02 +02001156 write("Bewege "+desc(from)+" nach "+desc(to)+".\n");
1157 return arg;
1158}
1159
1160string _mv(string arg)
1161{
1162 object from,to;
1163 to=pop();
1164 if (err) return arg;
1165 from=pop();
1166 if (err) return arg;
1167 __set_environment(from,to);
1168 write("Bewege "+desc(from)+" nach "+desc(to)+".\n");
1169 return arg;
1170}
1171
1172string db_info(string arg)
1173{
1174 object ob;
1175
1176 ob=pop();
1177 if (err) return arg;
1178 debug_info(0,ob);
1179 debug_info(1,ob);
1180 return arg;
1181}
1182
1183string inheritlist(string arg)
1184{
1185 object ob;
1186 int i;
1187 string *inherited;
1188
1189 ob=pop();
1190 if (err) return arg;
1191 inherited=inherit_list(ob);
1192 write(ob);write(" inherits:\n");
1193 for (i=0;i<sizeof(inherited);i++)
1194 write(inherited[i]+"\n");
1195 return arg;
1196}
1197
1198mixed get_callout()
1199{
1200 mixed *calls,ret;
1201 string tmp;
1202 int i,j;
1203
1204 calls=call_out_info();
1205 ret=({});
1206 if (!pointerp(calls) || !sizeof(calls))
1207 return 0;
1208 for (i=0;i<sizeof(calls);i++)
1209 {
1210 if (pointerp(calls[i]))
1211 {
1212 tmp="";
1213 if (sizeof(calls[i])>3)
1214 tmp+=sprintf("%-50O %-16O",calls[i][0],calls[i][1])+sprintf(" %-6O %-3O\n",calls[i][2],calls[i][3]);
1215 else
1216 tmp+=sprintf(" *** %O\n",calls[i]);
1217 }
1218 ret+=({tmp});
1219 }
1220 return ret;
1221}
1222
1223mixed get_heartbeat()
1224{
1225 mixed *obj;
1226 string *ret;
1227 int i;
1228
1229 obj=heart_beat_info();
1230 ret=({});
1231 if (!pointerp(obj) || sizeof(obj)==0) return 0;
1232 for (i=0;i<sizeof(obj);i++)
1233 ret+=({sprintf("%O in %O\n",obj[i],environment(obj[i]))});
1234 return ret;
1235}
1236
1237string make(string arg)
1238{
1239 object *list, ob, env;
1240 string file,temp,dummy;
1241 int i,cloned;
1242
1243 ob=pop();
1244 if (err) return arg;
1245 if (!destroyable(ob))
1246 {
1247 err="can't update "+desc(ob);
1248 return arg;
1249 }
1250 env=environment(ob);
1251 file=object_name(ob);
1252 write("Updating "+object_name(ob)+"...\n");
1253 if (sscanf(file,"%s#%s",temp,dummy)==2)
1254 {
1255 file=temp;
1256 cloned=1;
1257 }
1258 else
1259 cloned=0;
1260 list=all_inventory(ob);
1261 for (i=sizeof(list)-1;i>=0;i--)
1262 if (list[i] && query_once_interactive(list[i]))
1263 {
bugfixd94d0932020-04-08 11:27:13 +02001264 ({int})list[i]->move("room/void",M_TPORT | M_SILENT | M_NO_SHOW | M_NOCHECK);
MG Mud User88f12472016-06-24 23:31:02 +02001265 } else
1266 list[i]=0;
1267 list-=({0});
1268
1269 if (ob)
1270 {
1271 Remove(ob,1);
1272 }
1273 if (cloned)
1274 {
1275 if (ob=find_object(file))
1276 {
1277 Remove(ob,1);
1278 }
1279 err=catch(ob=clone_object(file));
1280 if (!err)
bugfixd94d0932020-04-08 11:27:13 +02001281 ({int})ob->move(env,M_TPORT | M_SILENT | M_NO_SHOW | M_NOCHECK);
MG Mud User88f12472016-06-24 23:31:02 +02001282 }
1283 else
1284 {
1285 err=catch(call_other(file,"???"));
1286 if (!err)
1287 ob=find_object(file);
1288 else
1289 ob=0;
1290 }
1291 if (!ob)
1292 {
1293 write("Error in loaded object. Staying in void ...\n");
1294 return arg;
1295 }
1296 for (i=sizeof(list)-1;i>=0;i--)
1297 if (list[i])
bugfixd94d0932020-04-08 11:27:13 +02001298 ({int})list[i]->move(ob,M_TPORT | M_SILENT | M_NO_SHOW | M_NOCHECK);
MG Mud User88f12472016-06-24 23:31:02 +02001299 return arg;
1300}
1301
1302string rec(string arg)
1303{
1304 recursive=1;
1305 return arg;
1306}
1307
1308string norec(string arg)
1309{
1310 recursive=0;
1311 return arg;
1312}
1313
1314string readvar(string arg)
1315{
1316 string rest;
1317 int no;
1318 if (sscanf(arg,"%d%s",no,rest)!=2 || no<0 || no>=MAXVARS)
1319 {
1320 err="illegal var number";
1321 return arg;
1322 }
1323 if (vararea[no])
1324 push(vararea[no]);
1325 else
1326 err="var #"+no+" is empty";
1327 return rest;
1328}
1329
1330string writevar(string arg)
1331{
1332 string rest;
1333 int no;
1334 object ob;
1335 if (sscanf(arg,"%d%s",no,rest)!=2 || no<0 || no>=MAXVARS)
1336 {
1337 err="illegal var number";
1338 return arg;
1339 }
1340 ob=pop();
1341 if (err) return rest;
1342 vararea[no]=ob;
1343 return rest;
1344}
1345
1346string vars(string arg)
1347{
1348 int i;
1349 for (i=0;i<MAXVARS;i++)
1350 {
1351 if (vararea[i])
1352 write("<"+i+": "+desc(vararea[i])+"\n");
1353 }
1354 return arg;
1355}
1356
1357void vanish()
1358{
1359 // RemoveAutoload();
1360 destruct( this_object() );
1361}
1362
1363mixed rusage(string arg)
1364{
1365 mixed *resusage;
1366 int i,j;
1367/*
1368 resusage=({mixed *})efun::rusage();
1369 for (i=0;i<18;i++){
1370 write(align(({"User time","System time","Max res set size",
1371 "Page reclaims","Page faults",
1372 "Unshared stack size",
1373 "Shared text size","Unshared data size",
1374 "System swaps",
1375 "Block input operations","Block output operations",
1376 "Messages sent","Messages received","Signals received",
1377 "Voluntary context switches","Involuntary context switches",
1378 "Total internet packets","Total internet bytes"})[i],
1379 40)+": "+resusage[i]+"\n");
1380 }
1381 return arg;
1382 */
1383 return ({});
1384}
1385
1386string align(string s,int x){
1387 return (s+" ")[0..x-1];
1388}
1389
1390static string swho(string arg)
1391{
1392 object *userlist, snooper, found;mixed active;
1393 int i,j,done;
1394
1395 if (geteuid(this_interactive())!=geteuid()) return arg;
1396 userlist=users();
1397 active=({});
1398 for (i=sizeof(userlist)-1;i>=0;i--)
1399 if (snooper=query_snoop(userlist[i]))
1400 {
1401 if (member(active,snooper)==-1)
1402 active+=({snooper});
1403 if (member(active,userlist[i])==-1)
1404 active+=({userlist[i]});
1405 }
1406 if (!sizeof(active))
1407 {
1408 printf("Keine aktiven Snoops.\n");
1409 return arg;
1410 }
1411 for (i=sizeof(active)-1;i>=0;i--)
1412 active[i]=({active[i]});
1413 for (i=sizeof(active)-1;i>=0;i--)
1414 if (pointerp(active[i])&&snooper=query_snoop(active[i][0]))
1415 {
1416 done=0;
1417 for (j=sizeof(active)-1;j>=0 && !done;j--)
1418 if (pointerp(active[j]) && active[j][sizeof(active[j])-1]==snooper)
1419 {
1420 active[j]+=active[i];
1421 active[i]=0;
1422 done=1;
1423 }
1424 }
1425 active-=({0});
1426 for (i=0;i<sizeof(active);i++)
1427 {
1428 for (j=0;j<sizeof(active[i]);j++)
1429 printf("%s%s",(j==0?"":" -> "),capitalize(getuid(active[i][j])));
1430 printf("\n");
1431 }
1432 return arg;
1433}
1434
1435string timef(int sec)
1436{
1437 string s;
1438
1439 s="";
1440 if (sec>=86400)
1441 s+=sprintf("%d d, ",sec/86400);
1442 if (sec>3600)
1443 s+=sprintf("%d h, ",(sec/3600)%24);
1444 if (sec>60)
1445 s+=sprintf("%d m, ",(sec/60)%60);
1446 return s+sprintf("%d s",sec%60);
1447}
1448
1449string idle(string arg)
1450{
1451 object ob;
1452 int i;
1453
1454 ob=pop();
1455 if (err) return arg;
bugfixd94d0932020-04-08 11:27:13 +02001456 write(capitalize(({string})ob->name(WER))+" ");
MG Mud User88f12472016-06-24 23:31:02 +02001457 if (!query_once_interactive(ob))
1458 {
1459 write("ist kein echter Spieler.\n");
1460 return arg;
1461 }
1462 if (!query_ip_number(ob))
1463 {
1464 write("ist netztot.\n");
1465 return arg;
1466 }
1467 printf("ist idle seit %d Sekunden",i=query_idle(ob));
1468 if (i>60)
1469 printf(" (%s)\n",timef(i));
1470 else
1471 write("\n");
1472 return arg;
1473}
1474
1475string stat(string arg)
1476{
1477 object ob;
1478 mapping quests;
bugfixd94d0932020-04-08 11:27:13 +02001479 mixed stats, arr, tmp,tmp2, list;
MG Mud User88f12472016-06-24 23:31:02 +02001480 string titel, level, stat_str,weapon,armour;
1481 int pl;
1482 int i;
1483
1484 ob=pop();
1485 if (err)
1486 return arg;
1487
bugfixd94d0932020-04-08 11:27:13 +02001488 titel=({string})ob->QueryProp(P_TITLE);
MG Mud User88f12472016-06-24 23:31:02 +02001489 if (!(pl=query_once_interactive(ob)))
1490 level="Monster="+old_explode(object_name(ob),"#")[0];
1491 else
1492 if (IS_GOD(ob))
1493 level="Mud-Gott";
1494 else if (IS_ARCH(ob))
1495 level="Erzmagier";
1496 else if (IS_ELDER(ob))
1497 level="Weiser";
1498 else if (IS_LORD(ob))
1499 level="Regionsmagier";
1500 else if (IS_DOMAINMEMBER(ob))
1501 level="Regionsmitglied";
1502 else if (IS_WIZARD(ob))
1503 level="Magier";
1504 else if (IS_LEARNER(ob))
1505 level="Lehrling";
1506 else if (IS_SEER(ob))
1507 level="Seher";
1508 else level="Spieler";
1509 if (IS_DOMAINMEMBER(ob))
bugfixd94d0932020-04-08 11:27:13 +02001510 for (tmp=({string*})"secure/master"->get_domain_homes(geteuid(ob));
MG Mud User88f12472016-06-24 23:31:02 +02001511 sizeof(tmp);tmp=tmp[1..])
1512 level+="-"+capitalize(tmp[0]);
1513 if (pl)
1514 {
1515 if (!interactive(ob))
1516 level+=", netztot";
1517 else
1518 if (query_idle(ob)>600)
1519 level+=", idle";
bugfixd94d0932020-04-08 11:27:13 +02001520 if (({int})ob->QueryProp(P_GHOST))
MG Mud User88f12472016-06-24 23:31:02 +02001521 level+=", tot";
bugfixd94d0932020-04-08 11:27:13 +02001522 if (({int})ob->QueryProp(P_INVIS))
MG Mud User88f12472016-06-24 23:31:02 +02001523 level+=", unsichtbar";
bugfixd94d0932020-04-08 11:27:13 +02001524 if (({int})ob->QueryProp(P_FROG))
MG Mud User88f12472016-06-24 23:31:02 +02001525 level+=", gruen und glitschig";
bugfixd94d0932020-04-08 11:27:13 +02001526 if (({int|string})ob->QueryProp(P_TESTPLAYER))
MG Mud User88f12472016-06-24 23:31:02 +02001527 level+=", Testspieler";
1528 }
bugfixd94d0932020-04-08 11:27:13 +02001529 tmp=({string})ob->QueryProp(P_PRESAY);
MG Mud User88f12472016-06-24 23:31:02 +02001530 if (tmp && tmp!="")
1531 tmp=tmp+" ";
1532 else
1533 tmp="";
bugfixd94d0932020-04-08 11:27:13 +02001534 tmp2=({string})ob->QueryProp(P_RACE);
MG Mud User88f12472016-06-24 23:31:02 +02001535 if(!tmp2)
1536 tmp2="Dingsda";
bugfixd94d0932020-04-08 11:27:13 +02001537 arr=({string})ob->QueryProp(P_NAME);
MG Mud User88f12472016-06-24 23:31:02 +02001538 if (pointerp(arr)) arr=arr[0];
1539 printf("%s%s %s (%s)[%s].\n\n",tmp||"",arr||"",titel||"",
1540 tmp2||"??",level||"??");
1541 if (pl)
1542 printf(" Alter : %s.%s\n",
bugfixd94d0932020-04-08 11:27:13 +02001543 timef(2*({int})ob->QueryProp(P_AGE)),
1544 (tmp=({string})ob->QueryProp(P_MARRIED))?
MG Mud User88f12472016-06-24 23:31:02 +02001545 ("Verheiratet mit "+capitalize(tmp)+"."):"");
1546 else
1547 printf(" Aggressiv : %4s Gespraechig : %d%%\n",
bugfixd94d0932020-04-08 11:27:13 +02001548 ({int|float|mapping})ob->QueryProp(P_AGGRESSIVE)? "Ja" : "Nein",
1549 ({int})ob->QueryProp(P_CHAT_CHANCE)) ;
MG Mud User88f12472016-06-24 23:31:02 +02001550 printf(" Lebenspunkte : [%4d/%4d] Magiepunkte : [%4d/%4d] " +
1551 "Erfahrung : %d\n",
bugfixd94d0932020-04-08 11:27:13 +02001552 ({int})ob->QueryProp(P_HP), ({int})ob->QueryProp(P_MAX_HP),
1553 ({int})ob->QueryProp(P_SP), ({int})ob->QueryProp(P_MAX_SP),
1554 ({int})ob->QueryProp(P_XP));
MG Mud User88f12472016-06-24 23:31:02 +02001555 printf(" Nahrung : [%3d/%d] Fluessigkeit : [%3d/%d] " +
1556 "Alkohol : [%3d/%d]\n",
bugfixd94d0932020-04-08 11:27:13 +02001557 ({int})ob->QueryProp(P_FOOD), ({int})ob->QueryProp(P_MAX_FOOD),
1558 ({int})ob->QueryProp(P_DRINK), ({int})ob->QueryProp(P_MAX_DRINK),
1559 ({int})ob->QueryProp(P_ALCOHOL), ({int})ob->QueryProp(P_MAX_ALCOHOL)) ;
1560 switch(({int})ob->QueryProp(P_GENDER)) {
MG Mud User88f12472016-06-24 23:31:02 +02001561 case FEMALE : tmp2 = "weiblich " ; break ;
1562 case MALE : tmp2 = "maennlich" ; break ;
1563 default : tmp2 = "boingisch" ; break ;
1564 }
Rumatabd442262021-09-27 11:02:50 +02001565 printf(" Geschlecht : %s Gesinnung : %-5d Stufe : %-3d\n",
bugfixd94d0932020-04-08 11:27:13 +02001566 tmp2, ({int})ob->QueryProp(P_ALIGN), ({int})ob->QueryProp(P_LEVEL)) ;
1567 stats = ({mapping})ob->QueryProp(P_ATTRIBUTES) ;
MG Mud User88f12472016-06-24 23:31:02 +02001568 if (!mappingp(stats)) stats=([]);
1569 tmp = m_indices(stats); tmp2 = m_values(stats); stat_str = "" ;
1570 for(; sizeof(tmp); tmp=tmp[1..],tmp2=tmp2[1..])
1571 stat_str += (tmp[ 0 ] + "[" + tmp2[ 0 ] + "] ") ;
1572
1573 if(stat_str == "")
1574 stat_str = "Keine" ;
1575 else
1576 stat_str = stat_str[0..<2];
1577
bugfixd94d0932020-04-08 11:27:13 +02001578 printf(" Geld : %-9d Stati : %s\n\n", ({int})ob->QueryMoney(),
MG Mud User88f12472016-06-24 23:31:02 +02001579 stat_str) ;
1580
1581 weapon = "Keine" ; armour = "" ;
1582 for(tmp=all_inventory(ob); sizeof(tmp); tmp=tmp[1..])
1583 {
bugfixd94d0932020-04-08 11:27:13 +02001584 if(({object})tmp[ 0 ]->QueryProp(P_WIELDED)) // gezueckte Waffe
MG Mud User88f12472016-06-24 23:31:02 +02001585 weapon = (tmp[ 0 ]->name(WER)) + " (" +
1586 old_explode(object_name(tmp[ 0 ]),"#")[0] + ")[" +
bugfixd94d0932020-04-08 11:27:13 +02001587 ({int})tmp[ 0 ]->QueryProp(P_WC) + "]" ;
MG Mud User88f12472016-06-24 23:31:02 +02001588
bugfixd94d0932020-04-08 11:27:13 +02001589 if(({object})tmp[ 0 ]->QueryProp(P_WORN)) // getragene Ruestung
1590 armour += (({string})tmp[ 0 ]->name(WER)) + "[" +
1591 ({int})tmp[ 0 ]->QueryProp(P_AC) + "]" +
MG Mud User88f12472016-06-24 23:31:02 +02001592 ", " ;
1593 }
1594
1595 if(armour == "")
1596 armour = "Keine" ;
1597 else
1598 {
1599 tmp = old_explode(break_string(armour[0..sizeof(armour) - 3],
1600 63), "\n") ;
1601 armour = tmp[ 0 ] ;
1602 tmp=tmp[1..];
1603 for (;sizeof(tmp); tmp=tmp[1..])
1604 armour += "\n " + tmp[ 0 ] ;
1605 }
1606
1607 printf(" Waffe(%3d) : %s\nRuestung(%3d) : %s\n",
bugfixd94d0932020-04-08 11:27:13 +02001608 ({int})ob->QueryProp(P_TOTAL_WC), weapon,
1609 ({int})ob->QueryProp(P_TOTAL_AC), armour) ;
MG Mud User88f12472016-06-24 23:31:02 +02001610
bugfixd94d0932020-04-08 11:27:13 +02001611 list = ({mixed})ob->QueryEnemies();
MG Mud User88f12472016-06-24 23:31:02 +02001612 if (pointerp(list))
1613 {
1614 list=list[0];
1615 tmp2 = "" ;
1616 for(i=sizeof(list)-1 ; i>=0;i--)
1617 if (objectp(list[i]))
bugfixd94d0932020-04-08 11:27:13 +02001618 tmp2 += (({string})list[ i ]->name(WER) + ", ") ;
MG Mud User88f12472016-06-24 23:31:02 +02001619 if(tmp2 != "")
1620 printf(" Feinde : %s.\n", tmp2[0..<3]);
1621 }
1622
1623 // 8.Zeile : Geloeste Aufgaben
1624 if(pl)
1625 {
1626 printf( break_string(
bugfixd94d0932020-04-08 11:27:13 +02001627 CountUp(m_indices(({mapping})ob->QueryProp(P_QUESTS))),
MG Mud User88f12472016-06-24 23:31:02 +02001628 75,
1629 " Aufgaben : ",
1630 BS_INDENT_ONCE));
bugfixd94d0932020-04-08 11:27:13 +02001631 if(((tmp2 = ({string})ob->QueryProp(P_MAILADDR)) != "none") && tmp2 &&
MG Mud User88f12472016-06-24 23:31:02 +02001632 (tmp2 != ""))
1633 tmp2 = " (" + tmp2 + ")" ;
1634 else
1635 tmp2 = "" ;
1636 }
1637 else
1638 tmp2 = "" ;
1639
1640 if(environment(ob))
1641 printf(" Aufenthalt : %s%s.\n",
1642 old_explode(object_name(environment(ob)),"#")[0], tmp2) ;
1643
1644 return arg;
1645}
1646
1647string scan(string arg)
1648{
1649 object ob;
1650 mixed tmp,tmp2,tmp3;
1651 int i;
1652
1653 ob=pop();
1654 if (err) return arg;
1655 if (query_once_interactive(ob))
1656 printf("Spieler: %s, Level: %d, Wizlevel: %d\n",
bugfixd94d0932020-04-08 11:27:13 +02001657 capitalize(getuid(ob)), ({int})ob->QueryProp(P_LEVEL),
MG Mud User88f12472016-06-24 23:31:02 +02001658 query_wiz_level(ob));
1659 else
1660 printf("Monster, UID: %s, EUID: %s, Level: %d\n",
bugfixd94d0932020-04-08 11:27:13 +02001661 getuid(ob), (geteuid(ob)?geteuid(ob):"0"), ({int})ob->QueryProp(P_LEVEL));
1662 tmp=({string})ob->short();
MG Mud User88f12472016-06-24 23:31:02 +02001663 if (!stringp(tmp)||!sizeof(tmp))
bugfixd94d0932020-04-08 11:27:13 +02001664 tmp=sprintf("(%s %s %s %s)",({string})ob->QueryProp(P_PRESAY)+"",
1665 ({string})ob->QueryProp(P_NAME)+"",({string})ob->QueryProp(P_TITLE)+"",
MG Mud User88f12472016-06-24 23:31:02 +02001666 (interactive(ob)?"":"(netztot"));
1667 else
1668 tmp=tmp[0..<3];
bugfixd94d0932020-04-08 11:27:13 +02001669 printf("%s, Rasse: %s\n",tmp, ""+({string})ob->QueryProp(P_RACE));
MG Mud User88f12472016-06-24 23:31:02 +02001670 printf("Stats: ");
bugfixd94d0932020-04-08 11:27:13 +02001671 tmp=({mapping})ob->QueryProp(P_ATTRIBUTES);
1672 tmp3=({mapping})ob->QueryProp(P_ATTRIBUTES_OFFSETS);
MG Mud User88f12472016-06-24 23:31:02 +02001673 if (!tmp)
1674 printf("keine\n");
1675 else
1676 {
1677 tmp2=m_indices(tmp);
1678 for (i=0;i<sizeof(tmp2);i++)
1679 {
1680 printf("%s%s: %d",(i>0?", ":""),tmp2[i],tmp[tmp2[i]]);
1681 if (tmp3[tmp2[i]])
1682 printf("%+d",tmp3[tmp2[i]]);
1683 }
1684 printf("\n");
1685 }
1686 printf("Ruestung: %-6d Waffen: %-6d Vorsicht: %-6d Geschlecht: ",
bugfixd94d0932020-04-08 11:27:13 +02001687 ({int})ob->QueryProp(P_TOTAL_AC),({int})ob->QueryProp(P_TOTAL_WC),
1688 ({int})ob->QueryProp(P_WIMPY));
1689 if (!(tmp=({int})ob->QueryProp(P_GENDER)))
MG Mud User88f12472016-06-24 23:31:02 +02001690 printf("N\n");
1691 else
1692 {
1693 if (tmp==2)
1694 printf("F\n");
1695 else
1696 printf("M\n");
1697 }
bugfixd94d0932020-04-08 11:27:13 +02001698 if (tmp=({string})ob->QueryProp(P_MARRIED))
MG Mud User88f12472016-06-24 23:31:02 +02001699 printf("Verheiratet mit %s.\n",capitalize(tmp));
1700 printf("Lebenspunkte: %4d [%4d], Magiepunkte: %4d [%4d], Erf: %-8d\n",
bugfixd94d0932020-04-08 11:27:13 +02001701 ({int})ob->QueryProp(P_HP), ({int})ob->QueryProp(P_MAX_HP),
1702 ({int})ob->QueryProp(P_SP), ({int})ob->QueryProp(P_MAX_SP),
1703 ({int})ob->QueryProp(P_XP));
MG Mud User88f12472016-06-24 23:31:02 +02001704 if (living(ob))
1705 {
1706 tmp=present("geld",ob);
1707 if (tmp)
bugfixd94d0932020-04-08 11:27:13 +02001708 tmp=({int})tmp->QueryProp(P_AMOUNT);
MG Mud User88f12472016-06-24 23:31:02 +02001709 printf("Traegt %6d (%6d) g. Eigengewicht %6d g. %6d Muenzen.\n",
bugfixd94d0932020-04-08 11:27:13 +02001710 ({int})ob->query_weight_contents(),({int})ob->QueryProp(P_MAX_WEIGHT),
1711 ({int})ob->QueryProp(P_WEIGHT),tmp);
1712 if (tmp=({object})ob->SelectEnemy())
1713 printf("Kaempft gegen %s [%O]\n",({string})tmp->name(WEN),tmp);
MG Mud User88f12472016-06-24 23:31:02 +02001714 }
1715 printf("ENV: %s",
1716 ((tmp=environment(ob))?object_name(tmp):"- fabric of space -"));
1717 if(query_once_interactive(ob))
1718 {
bugfixd94d0932020-04-08 11:27:13 +02001719 printf(", EMail: %s\n", ({string})ob->QueryProp(P_MAILADDR)+"");
1720 tmp=({int})"/secure/master"->find_userinfo(getuid(ob));
MG Mud User88f12472016-06-24 23:31:02 +02001721 if (pointerp(tmp) && sizeof(tmp)>USER_DOMAIN)
1722 {
1723 tmp=tmp[USER_DOMAIN];
1724 if (pointerp(tmp) && sizeof(tmp))
1725 {
1726 printf("Lord in: ");
1727 for (tmp2=0;tmp2<sizeof(tmp);tmp2++)
1728 printf("%s%s",(tmp2>0?", ":""),""+tmp[tmp2]);
1729 printf(".\n");
1730 }
1731 }
bugfixd94d0932020-04-08 11:27:13 +02001732 tmp=({string*})"/secure/master"->get_domain_homes(getuid(ob));
MG Mud User88f12472016-06-24 23:31:02 +02001733 if (pointerp(tmp)&&sizeof(tmp)>0)
1734 {
1735 printf("Mitglied in: ");
1736 for (tmp2=0;tmp2<sizeof(tmp);tmp2++)
1737 printf("%s%s",(tmp2>0?", ":""),""+tmp[tmp2]);
1738 printf(".\n");
1739 }
1740 printf("Quests: ");
bugfixd94d0932020-04-08 11:27:13 +02001741 tmp=({mapping})ob->QueryProp(P_QUESTS);
MG Mud User88f12472016-06-24 23:31:02 +02001742 if (tmp==({})||!pointerp(tmp))
1743 printf("Keine.\n");
1744 else
1745 {
1746 tmp2="";
1747 tmp-=({({}),0});
1748 for (i=0; i<sizeof(tmp); i++)
1749 tmp2+=sprintf("%s%s",(i?", ":""),tmp[i][0]);
1750 tmp=break_string(tmp2,79,8);
1751 tmp=tmp[8..];
1752 printf("%s",tmp);
1753 }
bugfixd94d0932020-04-08 11:27:13 +02001754 printf("PKills: %d ",({int})ob->QueryProp(P_KILLS));
1755 printf(", QuestPoints: %d (%d/%d), Alter: %s\n",({int})ob->QueryProp(P_QP),({int})ob->QueryProp(P_NEEDED_QP),({int})QM->QueryMaxQP(),timef(2*({int})ob->QueryProp(P_AGE)));
MG Mud User88f12472016-06-24 23:31:02 +02001756 if (interactive(ob))
1757 {
1758 printf("From: %s (%s) [%s]\n",query_ip_name(ob),query_ip_number(ob),country(query_ip_name(ob)));
1759 tmp=query_idle(ob);
1760 printf("Idle seit %d Sekunden",tmp);
1761 if (tmp>60)
1762 printf(" (%s)",timef(tmp));
bugfixd94d0932020-04-08 11:27:13 +02001763 printf(", cmd avg: %d",({int})ob->QueryProp("command_average"));
MG Mud User88f12472016-06-24 23:31:02 +02001764 printf(", noch %d ZT zu finden.\nGesnooped von: %s\n",
bugfixd94d0932020-04-08 11:27:13 +02001765 ((tmp=({int*})ob->QueryProp(P_POTIONROOMS))?sizeof(tmp):0),
MG Mud User88f12472016-06-24 23:31:02 +02001766 ((tmp=query_snoop(ob))?capitalize(getuid(tmp)):"Niemandem"));
1767 }
1768 else
1769 {
1770 tmp=getuid(ob);
1771 tmp=file_time("save/"+tmp[0..0]+"/"+tmp+".o");
1772 tmp=time()-tmp;
1773 printf("Kam von: %s, vor: %d s(%s)\n",
bugfixd94d0932020-04-08 11:27:13 +02001774 ({string})ob->QueryProp(P_CALLED_FROM_IP),tmp,timef(tmp));
MG Mud User88f12472016-06-24 23:31:02 +02001775 }
1776 }
1777 else
1778 printf("\n");
1779 return arg;
1780}
1781
1782mixed dinfo(string arg)
1783{
1784 object ob;
1785
1786 ob=pop();
1787 if (!ob)
1788 return 1;
1789 debug_info(0,ob);
1790 return arg;
1791}
1792
1793mixed minfo(string arg)
1794{
1795 object ob;
1796
1797 ob=pop();
1798 if (!ob)
1799 return 1;
1800 debug_info(1,ob);
1801 return arg;
1802}
1803
1804void dump_list(mixed what)
1805{
1806 int i,s;
1807
1808 if (!pointerp(what)||!(s=sizeof(what)))
1809 return;
1810 for (i=0;i<s;i++)
1811 write(what[i]);
1812}
1813
1814string callout(string args)
1815{
1816 dump_list(get_callout());
1817 return args;
1818}
1819
1820string heartbeat(string args)
1821{
1822 dump_list(get_heartbeat());
1823 return args;
1824}
1825
1826string dumplists(string args)
1827{
1828 string filen;
1829 string *list;
1830 int i,s;
1831
1832 if (!geteuid(this_object()))
1833 return args;
1834 filen="/players/"+geteuid(this_object())+"/LISTS.LUPE";
1835 write("Dumping to "+filen+" ... ");
1836 if (file_size(filen)>=0)
1837 rm(filen);
1838 write_file(filen,"OBJECT WITH ACTIVE HEART_BEAT:\n");
1839 list=get_heartbeat();
1840 if (!list || !(s=sizeof(list)))
1841 write_file(filen,"NONE\n");
1842 for (i=0;i<s;i++)
1843 write_file(filen,list[i]);
1844 write_file(filen,"\n\nRUNNING CALL_OUTS:\n");
1845 list=get_callout();
1846 if (!list || !(s=sizeof(list)))
1847 write_file(filen,"NONE\n");
1848 for (i=0;i<s;i++)
1849 write_file(filen,list[i]);
1850 write("done.\n");
1851 return args;
1852}
1853
1854mixed renew_player(string arg)
1855{
1856 object ob;
1857
1858 ob=pop();
1859 if (!ob)
1860 return 1;
1861 if (!objectp(ob)&&!interactive(ob))
1862 {
1863 err=desc(ob)+" is not an interactive player";
1864 return arg;
1865 }
bugfixd94d0932020-04-08 11:27:13 +02001866 if ((err=({int})"/secure/master"->renew_player_object(ob))<0)
MG Mud User88f12472016-06-24 23:31:02 +02001867 err="error "+err+" when renewing "+desc(ob);
1868 return arg;
1869}
1870
1871mixed copy_ldfied(string arg)
1872{
1873 object ob, new;
1874 mapping props;
1875
1876 ob=pop();
1877 if (!ob)
1878 return 1;
1879 if (!objectp(ob))
1880 {
1881 err=desc(ob)+" is not an valid object";
1882 return arg;
1883 }
1884 new=clone_object(old_explode(object_name(ob),"#")[0]);
bugfixd94d0932020-04-08 11:27:13 +02001885 props=({mapping})ob->QueryProperties();
1886 ({mapping})new->SetProperties(ob->QueryProperties());
MG Mud User88f12472016-06-24 23:31:02 +02001887 push(new);
bugfixd94d0932020-04-08 11:27:13 +02001888 ({int})new->move(this_player(),M_NOCHECK);
MG Mud User88f12472016-06-24 23:31:02 +02001889 return arg;
1890}
1891