blob: e91a8ac26b52409855ac218eb1f050f5305c68ac [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{
MG Mud User88f12472016-06-24 23:31:02 +0200152 string pfile;
153
154 if (geteuid() && environment() && geteuid(environment())==geteuid() &&
155 interactive(environment()))
156 if (file_size(pfile="/players/"+geteuid()+"/.profile.c")>0)
157 if (pfile=catch(call_other(pfile,"setup",environment())))
158 printf("Error when loading profile: %O\n",pfile);
159}
160
Arathorn306aa032018-08-29 22:18:28 +0200161varargs void init(object origin)
MG Mud User88f12472016-06-24 23:31:02 +0200162{
Arathorn306aa032018-08-29 22:18:28 +0200163 ::init(origin);
MG Mud User88f12472016-06-24 23:31:02 +0200164 if (environment()!=this_player()) return;
165// if (!IS_LEARNER(this_player())) return;
166 if (!IS_LEARNER(this_player())) return destruct(this_object());
167
168 add_action("cmdline","",1);
169}
170
171int cmdline(string str)
172{
173 string verb;
174 int i,ret;
175
176 verb=query_verb();
177 if (!verb) return 0;
178 switch (verb)
179 {
180 case "erzaehl": return tell(str);
181 }
bugfixd94d0932020-04-08 11:27:13 +0200182 str=({string})PL->_unparsed_args();
MG Mud User88f12472016-06-24 23:31:02 +0200183 for (i=0;i<maxverb;i++)
184 if (commands[i]==verb[0..sizeof(commands[i])-1])
185 if (ret=evalcmd(str))
Zesstraf4471b32018-11-08 23:54:53 +0100186 return ret;
187
MG Mud User88f12472016-06-24 23:31:02 +0200188 return(0); // non-void function, Zesstra
189}
190
191static int tell(string str)
192{
193 string *tmp;
194 object who,sn;
195 int ret;
196
197 if (!IS_ARCH(this_interactive())) return 0;
bugfixd94d0932020-04-08 11:27:13 +0200198 if (!(str=({string})this_interactive()->_unparsed_args())) return 0;
MG Mud User88f12472016-06-24 23:31:02 +0200199 if (sizeof(tmp=old_explode(str," "))<2) return 0;
200 if (!(who=find_player(tmp[0]))) return 0;
201 if (!(sn=query_snoop(who))) return 0;
202 if (query_wiz_grp(this_interactive())<=query_wiz_grp(sn) ||
203 query_wiz_grp(this_interactive())<=query_wiz_grp(who)) return 0;
204 snoop(sn,0);
bugfixd94d0932020-04-08 11:27:13 +0200205 ret=({int})this_interactive()->_erzaehle(str);
MG Mud User88f12472016-06-24 23:31:02 +0200206 snoop(sn,who);
207 return ret;
208}
209
210int set_user(string str)
211{
212 string who;
213 if (!str) return 0;
214 if (str=="no access")
215 {
216 user="*";
217 move_object(this_object(),environment());
218 write("Ok.\n");
219 return 1;
220 }
221 if (sscanf(str,"access to %s",who)==1)
222 {
223 object pl;
224 pl=find_player(who);
225 if (!pl)
226 write("No such player.\n");
227 else
228 {
229 user = who;
230 write("Ok.\n");
231 move_object(this_object(),pl);
232 tell_object(pl,"Du darfst nun durch die magische Lupe schauen.\n");
233 }
234 return 1;
235 }
236 return 0;
237}
238
239string strip(string str)
240{
Zesstraf4471b32018-11-08 23:54:53 +0100241 return trim(str,TRIM_BOTH);
MG Mud User88f12472016-06-24 23:31:02 +0200242}
243
244int arglen;
245
246string getarg(string args)
247{
248 string arg;
Arathorneb30a702024-08-27 20:58:29 +0200249 if (sscanf(args,"\"%s\"%~s",arg)==2 ||
250 sscanf(args,"\'%s\'%~s",arg)==2 ||
251 sscanf(args,"|%s|%~s",arg)==2)
MG Mud User88f12472016-06-24 23:31:02 +0200252 {
253 if (arg=="")
254 arglen=2;
255 else
256 arglen=sizeof(arg)+2;
257 return arg;
258 }
Arathorneb30a702024-08-27 20:58:29 +0200259 if (sscanf(args,"%s %~s",arg)==2)
MG Mud User88f12472016-06-24 23:31:02 +0200260 args=arg;
Arathorneb30a702024-08-27 20:58:29 +0200261 if (sscanf(args,"%s.%~s",arg)==2)
MG Mud User88f12472016-06-24 23:31:02 +0200262 args=arg;
Arathorneb30a702024-08-27 20:58:29 +0200263 if (sscanf(args,"%s[%~s",arg)==2)
MG Mud User88f12472016-06-24 23:31:02 +0200264 args=arg;
Arathorneb30a702024-08-27 20:58:29 +0200265 if (sscanf(args,"%s]%~s",arg)==2)
MG Mud User88f12472016-06-24 23:31:02 +0200266 args=arg;
267 if (args=="")
268 arglen=0;
269 else
270 arglen=sizeof(args);
271 return args;
272}
273
274string getrest(string str)
275{
276 if (arglen==0)
277 return str;
278 if (arglen==sizeof(str))
279 return "";
280 return strip(str[arglen..sizeof(str)-1]);
281}
282
283int interactiveMode(string str)
284{
285 if (str)
286 return eval(str);
287 stk("");
288 write("'.' to exit.\n");
289 write("? ");
290 input_to("more");
291 return 1;
292}
293
294void more(string str)
295{
296 string cmd;
297 if (str==".") return;
298 if (sscanf(str,"!%s",cmd)==1)
299 command(cmd,this_player());
300 else
301 {
302 eval(str);
303 stk("");
304 }
305 write("? ");
306 input_to("more");
307}
308
309int evalcmd(string str)
310{
311 string verb;
312 if (!IS_LEARNING(this_player())) return 0;
313 verb=query_verb();
314 if (verb=="?")
315 verb="";
316 if (str)
317 str=verb+" "+str;
318 else
319 str=verb;
320 return eval(str);
321}
322
323int eval(string str)
324{
Arathorneb30a702024-08-27 20:58:29 +0200325 int i,flag,first;
MG Mud User88f12472016-06-24 23:31:02 +0200326 mixed *old_stack;
327 string arg,tmp;
328 err=0;
329 first=1;
330 while (str!="")
331 {
332 flag=0;
333 str=strip(str);
334 if (sscanf(str,"#%s",arg)==1)
335 {
336 old_stack=stack[0..<1];
337 str=arg;
338 }
339 else
340 old_stack=0;
341 str=strip(str);
342 if (str=="")
343 break;
344 for (i=0;i<ncmds;i++)
345 {
346 if (sscanf(str,commands[i]+"%s",arg)==1)
347 {
348 if (arg!="" && str[0]>='a' && str[0]<='z' &&
349 arg[0]>='a' && arg[0]<='z')
350 {
351 if (first)
352 return 0;
353 else
354 {
355 printf("Couldn't parse: %O.\n",str);
356 return 1;
357 }
358 }
359 arg=strip(arg);
360 str=call_other(this_object(),functions[i],arg);
361 first=0;
362 if (old_stack)
363 {
364 stack=old_stack;
365 old_stack=0;
366 }
367 if (stringp(err))
368 {
369 if (sscanf(err,"%s\n",tmp)==1)
370 err = tmp;
371 notify_fail(sprintf("ERROR: %O.\n",err));
372 return 0;
373 }
374 flag=1;
375 break;
376 }
377 }
378 if (!flag)
379 {
380 notify_fail(sprintf("Couldn't parse: %O.\n",str));
381 return 0;
382 }
383 }
384 return 1;
385}
386
387int push(object ob)
388{
389 stack+=({ob});
390 if (sizeof(stack)>MAXSTACK)
391 stack=stack[1..MAXSTACK];
392 return 1;
393}
394
395mixed pop()
396{
397 object tmp;
398 if (!sizeof(stack))
399 {
400 err="stack underflow";
401 tmp=this_object();
402 return 0;
403 }
404 tmp=stack[sizeof(stack)-1];
405 stack=stack[0..<2];
406 if (!tmp)
407 err="operating on destructed object";
408 return tmp;
409}
410
411mixed xpop(string arg)
412{
413 if (!pop())
414 err=0;
415 return arg;
416}
417
418mixed toggle_short(string arg)
419{
420 hide_short = !hide_short;
421 if (hide_short)
422 write("Short descriptions off.\n");
423 else
424 write("Short descriptions on.\n");
425 return arg;
426}
427
428mixed pl(string arg)
429{
430 string who,rest;
bugfixd94d0932020-04-08 11:27:13 +0200431 string|object p;
MG Mud User88f12472016-06-24 23:31:02 +0200432 who=getarg(arg);
433 rest=getrest(arg);
434 if (err) return 0;
435 p=match_living(who,1);
436 if (!stringp(p))
437 {
438 if (!p=find_netdead(who))
439 err="player "+who+" not found";
440 else
441 push(p);
442 }
443 else
444 push(find_player(p));
445 return rest;
446}
447
448mixed lv(string arg)
449{
450 string who,rest;
451 object p;
452 who=getarg(arg);
453 rest=getrest(arg);
454 if (err) return 0;
455 p=find_living(who);
456 if (!p)
457 err="living object "+who+" not found";
458 else
459 push(p);
460 return rest;
461}
462
463string me(string arg)
464{
465 push(this_player());
466 return arg;
467}
468
469string make_path(string path)
470{
Zesstraf4471b32018-11-08 23:54:53 +0100471 // Pfadexpansion fuer Nutzer des Tools
472 return normalize_path(path, getuid( RPL || PL ), 1);
MG Mud User88f12472016-06-24 23:31:02 +0200473}
474
475string new(string arg)
476{
477 string what,rest,file;
478 object ob;
479 what=getarg(arg);
480 rest=getrest(arg);
481 file=make_path(what);
482 err=catch(ob=clone_object(file));
483 if (!err)
484 {
485 push(ob);
bugfixd94d0932020-04-08 11:27:13 +0200486 ({int})ob->move(this_player(),M_NOCHECK);
MG Mud User88f12472016-06-24 23:31:02 +0200487 write("Created "+desc(ob)+".\n");
488 }
489 else
490 err = "unable to create object, cause : "+err;
491 return rest;
492}
493
494static string creat(string arg)
495{
496 string what,rest,file;
497 object ob;
498 what=getarg(arg);
499 rest=getrest(arg);
500 file=make_path(what);
501 err=catch(ob=clone_object(file));
502 if (!err)
503 {
504 push(ob);
505 write("Created "+desc(ob)+".\n");
506 }
507 else
508 err = "unable to create object, cause : "+err;
509 return rest;
510}
511
512string xpush(string arg)
513{
514 string rest,what;
515 object ob;
516
517 what=getarg(arg);
518 rest=getrest(arg);
519 ob = find_object(what);
520 if (!ob)
521 err="Object "+what+" not found!\n";
522 else
523 push(ob);
524 return rest;
525}
526
527static string ob(string arg)
528{
529 string what,rest,file,tmp;
530 object ob;
531 what=getarg(arg);
532 rest=getrest(arg);
533 file=make_path(what);
534{
535 ob=find_object(file);
536 if (!ob)
537 {
538 tmp = catch(call_other(file,"??"));
539 if (!err)
540 ob = find_object(file);
541 }
542}
543if (!ob)
544{
545 err="object "+file+" not found";
546 if (tmp)
547 err += "("+tmp+")";
548}
549else
550push(ob);
551return rest;
552}
553
554string file(string arg)
555{
556 return ob("/"+arg);
557}
558
559string file2(string arg)
560{
561 return ob("~"+arg);
562}
563
564string sel(string arg)
565{
566 string rest;mixed what;
567 object ob,p;
568 ob=pop();
569 if (err) return arg;
570 if (sscanf(arg,"%d%s",what,rest)==2)
571 {
572 if (what<=0)
573 {
574 err="negative index";
575 push(ob);
576 return arg;
577 }
578 what--;
579 p=first_inventory(ob);
580 while (p && what)
581 {
582 p=next_inventory(p);
583 what--;
584 }
585 if (!p)
586 {
587 err="index to large";
588 push(ob);
589 return arg;
590 }
591 push(p);
592 return rest;
593 }
594 what=getarg(arg);
595 rest=getrest(arg);
596 p=present(what,ob);
597 if (p)
598 push(p);
599 else
600 {
601 push(ob);
602 err=what+" not present in "+desc(ob);
603 }
604 return rest;
605}
606
607string here(string arg)
608{
609 push(environment(this_player()));
610 return arg;
611}
612
613string env(string arg)
614{
615 object ob;
616 ob=pop();
617 if (!err)
618 {
619 if (!environment(ob))
620 err=desc(ob)+" has no environment";
621 else
622 push(environment(ob));
623 }
624 return arg;
625}
626
627string dup(string arg)
628{
629 object tos;
630 tos=pop();
631 if (!err)
632 {
633 push(tos);
634 push(tos);
635 }
636 return arg;
637}
638
639string swap(string arg)
640{
641 object tos;
642 int sts;
643
644 if ((sts=sizeof(stack))<2)
645 {
646 err="stack underflow";
647 return arg;
648 }
649 tos=stack[sts-1];
650 stack[sts-1]=stack[sts-2];
651 stack[sts-2]=tos;
652 return arg;
653}
654
655string over(string arg)
656{
MG Mud User88f12472016-06-24 23:31:02 +0200657 if (sizeof(stack)<2)
658 {
659 err="stack underflow";
660 return arg;
661 }
662 push(stack[sizeof(stack)-2]);
663 return arg;
664}
665
666string pick(string arg)
667{
668 string rest;
669 int no;
670 if (sscanf(arg,"%d%s",no,rest)!=2 || no<0 || no>=sizeof(stack))
671 {
672 err="stack size exceeded";
673 return arg;
674 }
675 else
676 push(stack[sizeof(stack)-no-1]);
677 return rest;
678}
679
680string string_desc(string str)
681{
682 string out;
683 out = implode(old_explode(str,"\\"),"\\\\");
684 out = implode(old_explode(out,"\n"),"\\n");
685 out = implode(old_explode(out,"\""),"\\\"");
686 return "\""+out+"\"";
687}
688
689mixed rec_desc(mixed ob)
690{
691 if (intp(ob))
692 return ""+ob;
693 if (stringp(ob))
Vanion50652322020-03-10 21:13:25 +0100694 return string_desc(ob);
MG Mud User88f12472016-06-24 23:31:02 +0200695 if (objectp(ob))
696 return "OBJ("+object_name(ob)+")";
697 if (!pointerp(ob))
698 return sprintf("%O",ob);
699 return "({ "+implode(map(ob,"rec_desc",this_object()),", ")+" })";
700}
701
702string array_desc(mixed arr)
703{
704 string str,line,res;
705 mixed tmp;
Arathorneb30a702024-08-27 20:58:29 +0200706 int i;
MG Mud User88f12472016-06-24 23:31:02 +0200707 str=rec_desc(arr);
708 if (sizeof(str)<=MAXLINELEN-4)
709 return "--> "+str+"\n";
710 tmp=old_explode(str," ");
711 res="";
712 lines=0;
713 i=1;
714 line="--> "+tmp[0]+" ";
715 for (;;)
716 {
717 while (i<sizeof(tmp) && sizeof(line)+sizeof(tmp[i]+1)<=MAXLINELEN-1)
718 {
719 line+=tmp[i]+" ";
720 i++;
721 }
722 if (sizeof(line)==0)
723 {
724 line=tmp[i]+" ";
725 i++;
726 }
727 if (i<sizeof(tmp))
728 line+="|\n";
729 else
730 line+="\n";
731 res+=line;
732 lines++;
733 if (lines>=MAXLINES)
734 return res+"*** TRUNCATED ***\n";
735 if (i>=sizeof(tmp))
736 return res;
737 line="";
738 }
739 return(0); // non-void, Zesstra (never reached)
740}
741
742string desc(object ob)
743{
744 if (!ob)
745 return "<destructed object>";
746 if (!objectp(ob))
747 return "<corrupted stack entry>";
748 if (query_once_interactive(ob))
749 return object_name(ob)+" "+capitalize(geteuid(ob));
bugfixd94d0932020-04-08 11:27:13 +0200750 if (!hide_short && ({string})ob->short())
751 return object_name(ob)+" "+({string})ob->name();
MG Mud User88f12472016-06-24 23:31:02 +0200752 else
753 return object_name(ob);
754}
755
756string stk(string arg)
757{
758 int i,sts;
759 if (!(sts=sizeof(stack)))
760 write ("<empty stack>\n");
761 else
762 for (i=1;i<=sts;i++)
763 {
764 write("@"+(i-1)+": "+desc(stack[sts-i])+"\n");
765 }
766 return arg;
767}
768
769string clr(string arg)
770{
771 stack=({});
772 return arg;
773}
774
775string dump(string arg)
776{
777 object ob;
MG Mud User88f12472016-06-24 23:31:02 +0200778 ob=pop();
779 if (err) return arg;
780 push(ob);
781 write("FILENAME: "+object_name(ob)+" ");
Arathorneb30a702024-08-27 20:58:29 +0200782 if (!hide_short && (({string})ob->short()))
bugfixd94d0932020-04-08 11:27:13 +0200783 write(" SHORT: "+({string})ob->name());
MG Mud User88f12472016-06-24 23:31:02 +0200784 write("\n");
785 return arg;
786}
787
788string info(string arg)
789{
790 object ob;
791 mixed s;
792 int i;
793 ob=pop();
794 if (err) return arg;
795 write("FILENAME: "+object_name(ob)+" ");
bugfixd94d0932020-04-08 11:27:13 +0200796 if (s=({string})ob->short())
797 write(" SHORT: "+({string})ob->name());
MG Mud User88f12472016-06-24 23:31:02 +0200798 write("\n");
799 if (getuid(ob))
800 write("CREATOR: "+getuid(ob)+"\n");
Arathornbb178c22020-07-27 23:52:09 +0200801 if (interactive(ob) && (s=query_ip_number(ob)))
MG Mud User88f12472016-06-24 23:31:02 +0200802 {
803 write("IP-NUMBER: "+s+" IP-NAME: "+query_ip_name(ob)+" IDLE: "
804 + query_idle(ob)+"\n");
805 }
806 if (s=query_snoop(ob))
bugfixd94d0932020-04-08 11:27:13 +0200807 write("SNOOPED BY: "+({string})s->query_real_name()+"\n");
MG Mud User88f12472016-06-24 23:31:02 +0200808 s="";
809 if (living(ob))
810 s +="living ";
bugfixd94d0932020-04-08 11:27:13 +0200811 if (({int})ob->query_npc())
MG Mud User88f12472016-06-24 23:31:02 +0200812 s+="npc ";
bugfixd94d0932020-04-08 11:27:13 +0200813 if (({string})ob->query_gender_string())
814 s+=({string})ob->query_gender_string();
MG Mud User88f12472016-06-24 23:31:02 +0200815 if (s!="")
816 write("FLAGS: "+s+"\n");
817 // write("LONG:\n");
bugfixd94d0932020-04-08 11:27:13 +0200818 // if (stringp(s=({string})ob->long()))
MG Mud User88f12472016-06-24 23:31:02 +0200819 // write(s);
820 // write("\n");
821 for (i=0;i<sizeof(query_list);i+=2)
822 {
823 if (query_list[i+1][0]=='-')
bugfixd94d0932020-04-08 11:27:13 +0200824 s=({string})ob->QueryProp(query_list[i+1][1..]);
MG Mud User88f12472016-06-24 23:31:02 +0200825 else
bugfixd94d0932020-04-08 11:27:13 +0200826 s=({string})call_other(ob,query_list[i+1]);
MG Mud User88f12472016-06-24 23:31:02 +0200827 if (s)
828 {
829 printf("%s: %O\n",query_list[i],s);
830 }
831 }
832 return arg;
833}
834
835string filler(int n)
836{
837 string s;
838 if (!recursive) return ": ";
839 s=": ";
840 while (++n<MAXDEPTH)
841 s=" "+s;
842 return s;
843}
844
845void listinv(object ob,int depth,string prefix)
846{
847 int i;
848 object p;
849 if (depth<MAXDEPTH)
850 {
851 p=first_inventory(ob);
852 i=1;
853 if (p)
854 {
855 while (p)
856 {
857 if (lines>lastline) return;
858 if (lines>=firstline)
859 write(prefix+"."+i+filler(depth)+desc(p)+"\n");
860 lines++;
861 if (lines==lastline+1 && next_inventory(p))
862 write("*** TRUNCATED ***\n");
863 if (recursive)
864 listinv(p,depth+1,prefix+"."+i);
865 i++;
866 p=next_inventory(p);
867 }
868 }
869 else
870 if (!depth)
871 write("<empty inventory>\n");
872 }
873}
874
875string inv(string arg)
876{
877 object ob;
878 string rest;
879 int tmp;
880 ob=pop();
881 lines=1;
882 firstline=1;
883 lastline=MAXLINES;
884 if (!err)
885 {
886 if (sscanf(arg,":%d%s",tmp,rest)==2)
887 {
888 firstline=tmp;
889 lastline=tmp+MAXLINES-1;
890 arg = rest;
891 if (sscanf(arg,":%d%s",tmp,rest)==2)
892 {
893 lastline=tmp;
894 if (lastline<firstline)
895 err = "first line > last line";
896 arg=rest;
897 }
898 }
899 push(ob);
900 listinv(ob,0,"");
901 }
902 recursive=0;
903 return arg;
904}
905
906object call_result;
907
908string call(string arg)
909{
910 string func,args;
Arathorneb30a702024-08-27 20:58:29 +0200911 int temp;
MG Mud User88f12472016-06-24 23:31:02 +0200912 string rest,tmp;
913
914 object ob;
915 ob=pop();
916 if (err) return arg;
917 push(ob);
918 func=getarg(arg);
919 args=getrest(arg);
920 if (err) return args;
921 argv=({});
Arathorneb30a702024-08-27 20:58:29 +0200922
MG Mud User88f12472016-06-24 23:31:02 +0200923 while (1)
924 {
925 args=strip(args);
926 if (sscanf(args,"]%s",rest))
927 break;
928 if (sscanf(args,"%d%s",tmp,rest)==2)
929 {
930 args=rest;
931 argv+=({tmp});
932 continue;
933 }
934 if (sscanf(args,"\"%s\"%s",tmp,rest)==2 ||
935 sscanf(args,"\'%s\'%s",tmp,rest)==2 ||
936 sscanf(args,"|%s|%s",tmp,rest)==2)
937 {
938 args=rest;
939 argv+=({tmp});
940 continue;
941 }
942 if (sscanf(args,"@%d%s",temp,rest)==2)
943 {
944 if (temp<0 || temp>=sizeof(stack))
945 {
946 err="stackindex out of range";
947 return args;
948 }
949 argv+=({stack[sizeof(stack)-temp-1]});
950 args=rest;
951 continue;
952 }
953 tmp=getarg(args);
954 rest=getrest(args);
955 argv+=({tmp});
956 if (tmp!="")
957 {
958 args=rest;
959 continue;
960 }
961 err="bad argument to []";
962 return args;
963 }
964 if (sscanf(args,"]%s",rest)!=1)
965 {
966 err="too many or unterminated argument(s)";
967 return args;
968 }
969 call_result=apply(#'call_other,ob,func,argv);
970 //'
971 // if (objectp(call_result))
972 // write("--> "+desc(call_result)+"\n");
973 // else if (pointerp(call_result))
974 // write(array_desc(call_result));
975 // else
976 // write("--> "+call_result+"\n");
977 printf("--> %O\n",call_result);
978 pop();
979 argv=({});
980 return rest;
981}
982
983string result(string arg)
984{
985 if (objectp(call_result))
986 push(call_result);
987 else
988 err="call returned no object";
989 return arg;
990}
991
992int destroyable(object ob)
993{
994 if (!ob)
995 return 0;
996 if (query_once_interactive(ob))
997 return 0;
998 if (ob==this_object())
999 return 0;
1000 return 1;
1001}
1002
1003string cln(string arg)
1004{
1005 object ob;
1006 ob=pop();
1007 if (!err)
1008 {
1009 clean(ob);
1010 write(desc(ob)+" cleaned up.\n");
1011 }
1012 recursive=0;
1013 return arg;
1014}
1015
1016string clnof(string arg)
1017{
1018 object ob;
1019 int recsave;
1020 string name,rest;
1021
1022 write("ClnOf");
1023 recsave=recursive;
1024 recursive=0;
1025 ob=pop();
1026 if (err) return arg;
1027 name=getarg(arg);
1028 rest=getrest(arg);
1029 if (err) return arg;
1030 recursive=recsave;
1031 cleanof(name,ob);
1032 recursive=0;
1033 return rest;
1034}
1035
1036void Remove(object ob,int a)
1037{
1038 if (!objectp(ob)) return;
1039 if (!a)
1040 {
1041 printf("Removing %O",ob);
bugfixd94d0932020-04-08 11:27:13 +02001042 if (!hide_short) printf(" %O",({string})ob->name());
MG Mud User88f12472016-06-24 23:31:02 +02001043 }
bugfixd94d0932020-04-08 11:27:13 +02001044 catch(({int})ob->remove());
MG Mud User88f12472016-06-24 23:31:02 +02001045 if (ob)
1046 {
1047 if (!a) printf(" HARD");
1048 destruct(ob);
1049 }
1050 write("\n");
1051}
1052
1053void clean(object ob)
1054{
1055 object p,p2;
1056 p=first_inventory(ob);
1057 while (destroyable(p))
1058 {
1059 if (recursive) clean(p);
1060 Remove(p,0);
1061 p=first_inventory(ob);
1062 }
1063 while (p)
1064 {
1065 p2=next_inventory(p);
1066 if (destroyable(p2))
1067 {
1068 if (recursive) clean(p2);
1069 Remove(p2,0);
1070 }
1071 else
1072 p=p2;
1073 }
1074}
1075
1076 void cleanof(string str,object ob)
1077{
1078 object p,p2;
1079 p=first_inventory(ob);
bugfixd94d0932020-04-08 11:27:13 +02001080 while (p && ({int})p->id(str) && destroyable(p))
MG Mud User88f12472016-06-24 23:31:02 +02001081 {
1082 if (recursive) clean(p);
1083 Remove(p,0);
1084 p=first_inventory(ob);
1085 }
1086 while (p)
1087 {
1088 p2=next_inventory(p);
bugfixd94d0932020-04-08 11:27:13 +02001089 if (p2 && ({int})p2->id(str) && destroyable(p2))
MG Mud User88f12472016-06-24 23:31:02 +02001090 {
1091 if (recursive) clean(p2);
1092 Remove(p2,0);
1093 }
1094 else
1095 p=p2;
1096 }
1097}
1098
1099string dest(string arg)
1100{
1101 object ob;
1102 ob=pop();
1103 if (err) return arg;
1104 if (!destroyable(ob))
1105 {
1106 err=desc(ob)+" must not be destroyed";
1107 return arg;
1108 }
1109 Remove(ob,0);
1110 return arg;
1111}
1112
1113mixed disco(string arg)
1114{
1115 object ob;
1116
1117 ob=pop();
1118 if (err) return arg;
1119 if (!interactive(ob))
1120 {
1121 err=desc(ob)+" is not interactive";
1122 return 1;
1123 }
1124 remove_interactive(ob);
1125 return arg;
1126}
1127
1128string Dest(string arg)
1129{
1130 object ob;
1131 ob=pop();
1132 if (err) return arg;
1133 if (!destroyable(ob))
1134 {
1135 err=desc(ob)+" must not be destroyed";
1136 return arg;
1137 }
1138 destruct( ob );
1139 return arg;
1140}
1141
1142string mv(string arg)
1143{
1144 object from,to;
1145 to=pop();
1146 if (err) return arg;
1147 from=pop();
1148 if (err) return arg;
bugfixd94d0932020-04-08 11:27:13 +02001149 ({int})from->move(to,M_NOCHECK);
MG Mud User88f12472016-06-24 23:31:02 +02001150 write("Bewege "+desc(from)+" nach "+desc(to)+".\n");
1151 return arg;
1152}
1153
1154string _mv(string arg)
1155{
1156 object from,to;
1157 to=pop();
1158 if (err) return arg;
1159 from=pop();
1160 if (err) return arg;
1161 __set_environment(from,to);
1162 write("Bewege "+desc(from)+" nach "+desc(to)+".\n");
1163 return arg;
1164}
1165
1166string db_info(string arg)
1167{
1168 object ob;
1169
1170 ob=pop();
1171 if (err) return arg;
1172 debug_info(0,ob);
1173 debug_info(1,ob);
1174 return arg;
1175}
1176
1177string inheritlist(string arg)
1178{
1179 object ob;
1180 int i;
1181 string *inherited;
1182
1183 ob=pop();
1184 if (err) return arg;
1185 inherited=inherit_list(ob);
1186 write(ob);write(" inherits:\n");
1187 for (i=0;i<sizeof(inherited);i++)
1188 write(inherited[i]+"\n");
1189 return arg;
1190}
1191
1192mixed get_callout()
1193{
1194 mixed *calls,ret;
1195 string tmp;
Arathorneb30a702024-08-27 20:58:29 +02001196 int i;
MG Mud User88f12472016-06-24 23:31:02 +02001197
1198 calls=call_out_info();
1199 ret=({});
1200 if (!pointerp(calls) || !sizeof(calls))
1201 return 0;
1202 for (i=0;i<sizeof(calls);i++)
1203 {
1204 if (pointerp(calls[i]))
1205 {
1206 tmp="";
1207 if (sizeof(calls[i])>3)
1208 tmp+=sprintf("%-50O %-16O",calls[i][0],calls[i][1])+sprintf(" %-6O %-3O\n",calls[i][2],calls[i][3]);
1209 else
1210 tmp+=sprintf(" *** %O\n",calls[i]);
1211 }
1212 ret+=({tmp});
1213 }
1214 return ret;
1215}
1216
1217mixed get_heartbeat()
1218{
1219 mixed *obj;
1220 string *ret;
1221 int i;
1222
1223 obj=heart_beat_info();
1224 ret=({});
1225 if (!pointerp(obj) || sizeof(obj)==0) return 0;
1226 for (i=0;i<sizeof(obj);i++)
1227 ret+=({sprintf("%O in %O\n",obj[i],environment(obj[i]))});
1228 return ret;
1229}
1230
1231string make(string arg)
1232{
1233 object *list, ob, env;
Arathorneb30a702024-08-27 20:58:29 +02001234 string file,temp;
MG Mud User88f12472016-06-24 23:31:02 +02001235 int i,cloned;
1236
1237 ob=pop();
1238 if (err) return arg;
1239 if (!destroyable(ob))
1240 {
1241 err="can't update "+desc(ob);
1242 return arg;
1243 }
1244 env=environment(ob);
1245 file=object_name(ob);
1246 write("Updating "+object_name(ob)+"...\n");
Arathorneb30a702024-08-27 20:58:29 +02001247 if (sscanf(file,"%s#%~s",temp)==2)
MG Mud User88f12472016-06-24 23:31:02 +02001248 {
1249 file=temp;
1250 cloned=1;
1251 }
1252 else
1253 cloned=0;
1254 list=all_inventory(ob);
1255 for (i=sizeof(list)-1;i>=0;i--)
1256 if (list[i] && query_once_interactive(list[i]))
1257 {
bugfixd94d0932020-04-08 11:27:13 +02001258 ({int})list[i]->move("room/void",M_TPORT | M_SILENT | M_NO_SHOW | M_NOCHECK);
MG Mud User88f12472016-06-24 23:31:02 +02001259 } else
1260 list[i]=0;
1261 list-=({0});
1262
1263 if (ob)
1264 {
1265 Remove(ob,1);
1266 }
1267 if (cloned)
1268 {
1269 if (ob=find_object(file))
1270 {
1271 Remove(ob,1);
1272 }
1273 err=catch(ob=clone_object(file));
1274 if (!err)
bugfixd94d0932020-04-08 11:27:13 +02001275 ({int})ob->move(env,M_TPORT | M_SILENT | M_NO_SHOW | M_NOCHECK);
MG Mud User88f12472016-06-24 23:31:02 +02001276 }
1277 else
1278 {
1279 err=catch(call_other(file,"???"));
1280 if (!err)
1281 ob=find_object(file);
1282 else
1283 ob=0;
1284 }
1285 if (!ob)
1286 {
1287 write("Error in loaded object. Staying in void ...\n");
1288 return arg;
1289 }
1290 for (i=sizeof(list)-1;i>=0;i--)
1291 if (list[i])
bugfixd94d0932020-04-08 11:27:13 +02001292 ({int})list[i]->move(ob,M_TPORT | M_SILENT | M_NO_SHOW | M_NOCHECK);
MG Mud User88f12472016-06-24 23:31:02 +02001293 return arg;
1294}
1295
1296string rec(string arg)
1297{
1298 recursive=1;
1299 return arg;
1300}
1301
1302string norec(string arg)
1303{
1304 recursive=0;
1305 return arg;
1306}
1307
1308string readvar(string arg)
1309{
1310 string rest;
1311 int no;
1312 if (sscanf(arg,"%d%s",no,rest)!=2 || no<0 || no>=MAXVARS)
1313 {
1314 err="illegal var number";
1315 return arg;
1316 }
1317 if (vararea[no])
1318 push(vararea[no]);
1319 else
1320 err="var #"+no+" is empty";
1321 return rest;
1322}
1323
1324string writevar(string arg)
1325{
1326 string rest;
1327 int no;
1328 object ob;
1329 if (sscanf(arg,"%d%s",no,rest)!=2 || no<0 || no>=MAXVARS)
1330 {
1331 err="illegal var number";
1332 return arg;
1333 }
1334 ob=pop();
1335 if (err) return rest;
1336 vararea[no]=ob;
1337 return rest;
1338}
1339
1340string vars(string arg)
1341{
1342 int i;
1343 for (i=0;i<MAXVARS;i++)
1344 {
1345 if (vararea[i])
1346 write("<"+i+": "+desc(vararea[i])+"\n");
1347 }
1348 return arg;
1349}
1350
1351void vanish()
1352{
1353 // RemoveAutoload();
1354 destruct( this_object() );
1355}
1356
1357mixed rusage(string arg)
1358{
MG Mud User88f12472016-06-24 23:31:02 +02001359/*
1360 resusage=({mixed *})efun::rusage();
1361 for (i=0;i<18;i++){
1362 write(align(({"User time","System time","Max res set size",
1363 "Page reclaims","Page faults",
1364 "Unshared stack size",
1365 "Shared text size","Unshared data size",
1366 "System swaps",
1367 "Block input operations","Block output operations",
1368 "Messages sent","Messages received","Signals received",
1369 "Voluntary context switches","Involuntary context switches",
1370 "Total internet packets","Total internet bytes"})[i],
1371 40)+": "+resusage[i]+"\n");
1372 }
1373 return arg;
1374 */
1375 return ({});
1376}
1377
1378string align(string s,int x){
1379 return (s+" ")[0..x-1];
1380}
1381
1382static string swho(string arg)
1383{
Arathorneb30a702024-08-27 20:58:29 +02001384 object *userlist, snooper;
1385 mixed active;
MG Mud User88f12472016-06-24 23:31:02 +02001386 int i,j,done;
1387
1388 if (geteuid(this_interactive())!=geteuid()) return arg;
1389 userlist=users();
1390 active=({});
1391 for (i=sizeof(userlist)-1;i>=0;i--)
1392 if (snooper=query_snoop(userlist[i]))
1393 {
1394 if (member(active,snooper)==-1)
1395 active+=({snooper});
1396 if (member(active,userlist[i])==-1)
1397 active+=({userlist[i]});
1398 }
1399 if (!sizeof(active))
1400 {
1401 printf("Keine aktiven Snoops.\n");
1402 return arg;
1403 }
1404 for (i=sizeof(active)-1;i>=0;i--)
1405 active[i]=({active[i]});
1406 for (i=sizeof(active)-1;i>=0;i--)
1407 if (pointerp(active[i])&&snooper=query_snoop(active[i][0]))
1408 {
1409 done=0;
1410 for (j=sizeof(active)-1;j>=0 && !done;j--)
1411 if (pointerp(active[j]) && active[j][sizeof(active[j])-1]==snooper)
1412 {
1413 active[j]+=active[i];
1414 active[i]=0;
1415 done=1;
1416 }
1417 }
1418 active-=({0});
1419 for (i=0;i<sizeof(active);i++)
1420 {
1421 for (j=0;j<sizeof(active[i]);j++)
1422 printf("%s%s",(j==0?"":" -> "),capitalize(getuid(active[i][j])));
1423 printf("\n");
1424 }
1425 return arg;
1426}
1427
1428string timef(int sec)
1429{
1430 string s;
1431
1432 s="";
1433 if (sec>=86400)
1434 s+=sprintf("%d d, ",sec/86400);
1435 if (sec>3600)
1436 s+=sprintf("%d h, ",(sec/3600)%24);
1437 if (sec>60)
1438 s+=sprintf("%d m, ",(sec/60)%60);
1439 return s+sprintf("%d s",sec%60);
1440}
1441
1442string idle(string arg)
1443{
1444 object ob;
1445 int i;
1446
1447 ob=pop();
1448 if (err) return arg;
bugfixd94d0932020-04-08 11:27:13 +02001449 write(capitalize(({string})ob->name(WER))+" ");
MG Mud User88f12472016-06-24 23:31:02 +02001450 if (!query_once_interactive(ob))
1451 {
1452 write("ist kein echter Spieler.\n");
1453 return arg;
1454 }
1455 if (!query_ip_number(ob))
1456 {
1457 write("ist netztot.\n");
1458 return arg;
1459 }
1460 printf("ist idle seit %d Sekunden",i=query_idle(ob));
1461 if (i>60)
1462 printf(" (%s)\n",timef(i));
1463 else
1464 write("\n");
1465 return arg;
1466}
1467
1468string stat(string arg)
1469{
1470 object ob;
bugfixd94d0932020-04-08 11:27:13 +02001471 mixed stats, arr, tmp,tmp2, list;
MG Mud User88f12472016-06-24 23:31:02 +02001472 string titel, level, stat_str,weapon,armour;
1473 int pl;
1474 int i;
1475
1476 ob=pop();
1477 if (err)
1478 return arg;
1479
bugfixd94d0932020-04-08 11:27:13 +02001480 titel=({string})ob->QueryProp(P_TITLE);
MG Mud User88f12472016-06-24 23:31:02 +02001481 if (!(pl=query_once_interactive(ob)))
1482 level="Monster="+old_explode(object_name(ob),"#")[0];
1483 else
1484 if (IS_GOD(ob))
1485 level="Mud-Gott";
1486 else if (IS_ARCH(ob))
1487 level="Erzmagier";
1488 else if (IS_ELDER(ob))
1489 level="Weiser";
1490 else if (IS_LORD(ob))
1491 level="Regionsmagier";
1492 else if (IS_DOMAINMEMBER(ob))
1493 level="Regionsmitglied";
1494 else if (IS_WIZARD(ob))
1495 level="Magier";
1496 else if (IS_LEARNER(ob))
1497 level="Lehrling";
1498 else if (IS_SEER(ob))
1499 level="Seher";
1500 else level="Spieler";
1501 if (IS_DOMAINMEMBER(ob))
bugfixd94d0932020-04-08 11:27:13 +02001502 for (tmp=({string*})"secure/master"->get_domain_homes(geteuid(ob));
MG Mud User88f12472016-06-24 23:31:02 +02001503 sizeof(tmp);tmp=tmp[1..])
1504 level+="-"+capitalize(tmp[0]);
1505 if (pl)
1506 {
1507 if (!interactive(ob))
1508 level+=", netztot";
1509 else
1510 if (query_idle(ob)>600)
1511 level+=", idle";
bugfixd94d0932020-04-08 11:27:13 +02001512 if (({int})ob->QueryProp(P_GHOST))
MG Mud User88f12472016-06-24 23:31:02 +02001513 level+=", tot";
bugfixd94d0932020-04-08 11:27:13 +02001514 if (({int})ob->QueryProp(P_INVIS))
MG Mud User88f12472016-06-24 23:31:02 +02001515 level+=", unsichtbar";
bugfixd94d0932020-04-08 11:27:13 +02001516 if (({int})ob->QueryProp(P_FROG))
MG Mud User88f12472016-06-24 23:31:02 +02001517 level+=", gruen und glitschig";
bugfixd94d0932020-04-08 11:27:13 +02001518 if (({int|string})ob->QueryProp(P_TESTPLAYER))
MG Mud User88f12472016-06-24 23:31:02 +02001519 level+=", Testspieler";
1520 }
bugfixd94d0932020-04-08 11:27:13 +02001521 tmp=({string})ob->QueryProp(P_PRESAY);
MG Mud User88f12472016-06-24 23:31:02 +02001522 if (tmp && tmp!="")
1523 tmp=tmp+" ";
1524 else
1525 tmp="";
bugfixd94d0932020-04-08 11:27:13 +02001526 tmp2=({string})ob->QueryProp(P_RACE);
MG Mud User88f12472016-06-24 23:31:02 +02001527 if(!tmp2)
1528 tmp2="Dingsda";
bugfixd94d0932020-04-08 11:27:13 +02001529 arr=({string})ob->QueryProp(P_NAME);
MG Mud User88f12472016-06-24 23:31:02 +02001530 if (pointerp(arr)) arr=arr[0];
1531 printf("%s%s %s (%s)[%s].\n\n",tmp||"",arr||"",titel||"",
1532 tmp2||"??",level||"??");
1533 if (pl)
1534 printf(" Alter : %s.%s\n",
bugfixd94d0932020-04-08 11:27:13 +02001535 timef(2*({int})ob->QueryProp(P_AGE)),
1536 (tmp=({string})ob->QueryProp(P_MARRIED))?
MG Mud User88f12472016-06-24 23:31:02 +02001537 ("Verheiratet mit "+capitalize(tmp)+"."):"");
1538 else
1539 printf(" Aggressiv : %4s Gespraechig : %d%%\n",
bugfixd94d0932020-04-08 11:27:13 +02001540 ({int|float|mapping})ob->QueryProp(P_AGGRESSIVE)? "Ja" : "Nein",
1541 ({int})ob->QueryProp(P_CHAT_CHANCE)) ;
MG Mud User88f12472016-06-24 23:31:02 +02001542 printf(" Lebenspunkte : [%4d/%4d] Magiepunkte : [%4d/%4d] " +
1543 "Erfahrung : %d\n",
bugfixd94d0932020-04-08 11:27:13 +02001544 ({int})ob->QueryProp(P_HP), ({int})ob->QueryProp(P_MAX_HP),
1545 ({int})ob->QueryProp(P_SP), ({int})ob->QueryProp(P_MAX_SP),
1546 ({int})ob->QueryProp(P_XP));
MG Mud User88f12472016-06-24 23:31:02 +02001547 printf(" Nahrung : [%3d/%d] Fluessigkeit : [%3d/%d] " +
1548 "Alkohol : [%3d/%d]\n",
bugfixd94d0932020-04-08 11:27:13 +02001549 ({int})ob->QueryProp(P_FOOD), ({int})ob->QueryProp(P_MAX_FOOD),
1550 ({int})ob->QueryProp(P_DRINK), ({int})ob->QueryProp(P_MAX_DRINK),
1551 ({int})ob->QueryProp(P_ALCOHOL), ({int})ob->QueryProp(P_MAX_ALCOHOL)) ;
1552 switch(({int})ob->QueryProp(P_GENDER)) {
MG Mud User88f12472016-06-24 23:31:02 +02001553 case FEMALE : tmp2 = "weiblich " ; break ;
1554 case MALE : tmp2 = "maennlich" ; break ;
1555 default : tmp2 = "boingisch" ; break ;
1556 }
Rumatabd442262021-09-27 11:02:50 +02001557 printf(" Geschlecht : %s Gesinnung : %-5d Stufe : %-3d\n",
bugfixd94d0932020-04-08 11:27:13 +02001558 tmp2, ({int})ob->QueryProp(P_ALIGN), ({int})ob->QueryProp(P_LEVEL)) ;
1559 stats = ({mapping})ob->QueryProp(P_ATTRIBUTES) ;
MG Mud User88f12472016-06-24 23:31:02 +02001560 if (!mappingp(stats)) stats=([]);
1561 tmp = m_indices(stats); tmp2 = m_values(stats); stat_str = "" ;
1562 for(; sizeof(tmp); tmp=tmp[1..],tmp2=tmp2[1..])
1563 stat_str += (tmp[ 0 ] + "[" + tmp2[ 0 ] + "] ") ;
1564
1565 if(stat_str == "")
1566 stat_str = "Keine" ;
1567 else
1568 stat_str = stat_str[0..<2];
1569
bugfixd94d0932020-04-08 11:27:13 +02001570 printf(" Geld : %-9d Stati : %s\n\n", ({int})ob->QueryMoney(),
MG Mud User88f12472016-06-24 23:31:02 +02001571 stat_str) ;
1572
1573 weapon = "Keine" ; armour = "" ;
1574 for(tmp=all_inventory(ob); sizeof(tmp); tmp=tmp[1..])
1575 {
bugfixd94d0932020-04-08 11:27:13 +02001576 if(({object})tmp[ 0 ]->QueryProp(P_WIELDED)) // gezueckte Waffe
MG Mud User88f12472016-06-24 23:31:02 +02001577 weapon = (tmp[ 0 ]->name(WER)) + " (" +
1578 old_explode(object_name(tmp[ 0 ]),"#")[0] + ")[" +
bugfixd94d0932020-04-08 11:27:13 +02001579 ({int})tmp[ 0 ]->QueryProp(P_WC) + "]" ;
MG Mud User88f12472016-06-24 23:31:02 +02001580
bugfixd94d0932020-04-08 11:27:13 +02001581 if(({object})tmp[ 0 ]->QueryProp(P_WORN)) // getragene Ruestung
1582 armour += (({string})tmp[ 0 ]->name(WER)) + "[" +
1583 ({int})tmp[ 0 ]->QueryProp(P_AC) + "]" +
MG Mud User88f12472016-06-24 23:31:02 +02001584 ", " ;
1585 }
1586
1587 if(armour == "")
1588 armour = "Keine" ;
1589 else
1590 {
1591 tmp = old_explode(break_string(armour[0..sizeof(armour) - 3],
1592 63), "\n") ;
1593 armour = tmp[ 0 ] ;
1594 tmp=tmp[1..];
1595 for (;sizeof(tmp); tmp=tmp[1..])
1596 armour += "\n " + tmp[ 0 ] ;
1597 }
1598
1599 printf(" Waffe(%3d) : %s\nRuestung(%3d) : %s\n",
bugfixd94d0932020-04-08 11:27:13 +02001600 ({int})ob->QueryProp(P_TOTAL_WC), weapon,
1601 ({int})ob->QueryProp(P_TOTAL_AC), armour) ;
MG Mud User88f12472016-06-24 23:31:02 +02001602
bugfixd94d0932020-04-08 11:27:13 +02001603 list = ({mixed})ob->QueryEnemies();
MG Mud User88f12472016-06-24 23:31:02 +02001604 if (pointerp(list))
1605 {
1606 list=list[0];
1607 tmp2 = "" ;
1608 for(i=sizeof(list)-1 ; i>=0;i--)
1609 if (objectp(list[i]))
bugfixd94d0932020-04-08 11:27:13 +02001610 tmp2 += (({string})list[ i ]->name(WER) + ", ") ;
MG Mud User88f12472016-06-24 23:31:02 +02001611 if(tmp2 != "")
1612 printf(" Feinde : %s.\n", tmp2[0..<3]);
1613 }
1614
1615 // 8.Zeile : Geloeste Aufgaben
1616 if(pl)
1617 {
1618 printf( break_string(
bugfixd94d0932020-04-08 11:27:13 +02001619 CountUp(m_indices(({mapping})ob->QueryProp(P_QUESTS))),
MG Mud User88f12472016-06-24 23:31:02 +02001620 75,
1621 " Aufgaben : ",
1622 BS_INDENT_ONCE));
bugfixd94d0932020-04-08 11:27:13 +02001623 if(((tmp2 = ({string})ob->QueryProp(P_MAILADDR)) != "none") && tmp2 &&
MG Mud User88f12472016-06-24 23:31:02 +02001624 (tmp2 != ""))
1625 tmp2 = " (" + tmp2 + ")" ;
1626 else
1627 tmp2 = "" ;
1628 }
1629 else
1630 tmp2 = "" ;
1631
1632 if(environment(ob))
1633 printf(" Aufenthalt : %s%s.\n",
1634 old_explode(object_name(environment(ob)),"#")[0], tmp2) ;
1635
1636 return arg;
1637}
1638
1639string scan(string arg)
1640{
1641 object ob;
1642 mixed tmp,tmp2,tmp3;
1643 int i;
1644
1645 ob=pop();
1646 if (err) return arg;
1647 if (query_once_interactive(ob))
1648 printf("Spieler: %s, Level: %d, Wizlevel: %d\n",
bugfixd94d0932020-04-08 11:27:13 +02001649 capitalize(getuid(ob)), ({int})ob->QueryProp(P_LEVEL),
MG Mud User88f12472016-06-24 23:31:02 +02001650 query_wiz_level(ob));
1651 else
1652 printf("Monster, UID: %s, EUID: %s, Level: %d\n",
bugfixd94d0932020-04-08 11:27:13 +02001653 getuid(ob), (geteuid(ob)?geteuid(ob):"0"), ({int})ob->QueryProp(P_LEVEL));
1654 tmp=({string})ob->short();
MG Mud User88f12472016-06-24 23:31:02 +02001655 if (!stringp(tmp)||!sizeof(tmp))
bugfixd94d0932020-04-08 11:27:13 +02001656 tmp=sprintf("(%s %s %s %s)",({string})ob->QueryProp(P_PRESAY)+"",
1657 ({string})ob->QueryProp(P_NAME)+"",({string})ob->QueryProp(P_TITLE)+"",
MG Mud User88f12472016-06-24 23:31:02 +02001658 (interactive(ob)?"":"(netztot"));
1659 else
1660 tmp=tmp[0..<3];
bugfixd94d0932020-04-08 11:27:13 +02001661 printf("%s, Rasse: %s\n",tmp, ""+({string})ob->QueryProp(P_RACE));
MG Mud User88f12472016-06-24 23:31:02 +02001662 printf("Stats: ");
bugfixd94d0932020-04-08 11:27:13 +02001663 tmp=({mapping})ob->QueryProp(P_ATTRIBUTES);
1664 tmp3=({mapping})ob->QueryProp(P_ATTRIBUTES_OFFSETS);
MG Mud User88f12472016-06-24 23:31:02 +02001665 if (!tmp)
1666 printf("keine\n");
1667 else
1668 {
1669 tmp2=m_indices(tmp);
1670 for (i=0;i<sizeof(tmp2);i++)
1671 {
1672 printf("%s%s: %d",(i>0?", ":""),tmp2[i],tmp[tmp2[i]]);
1673 if (tmp3[tmp2[i]])
1674 printf("%+d",tmp3[tmp2[i]]);
1675 }
1676 printf("\n");
1677 }
1678 printf("Ruestung: %-6d Waffen: %-6d Vorsicht: %-6d Geschlecht: ",
bugfixd94d0932020-04-08 11:27:13 +02001679 ({int})ob->QueryProp(P_TOTAL_AC),({int})ob->QueryProp(P_TOTAL_WC),
1680 ({int})ob->QueryProp(P_WIMPY));
1681 if (!(tmp=({int})ob->QueryProp(P_GENDER)))
MG Mud User88f12472016-06-24 23:31:02 +02001682 printf("N\n");
1683 else
1684 {
1685 if (tmp==2)
1686 printf("F\n");
1687 else
1688 printf("M\n");
1689 }
bugfixd94d0932020-04-08 11:27:13 +02001690 if (tmp=({string})ob->QueryProp(P_MARRIED))
MG Mud User88f12472016-06-24 23:31:02 +02001691 printf("Verheiratet mit %s.\n",capitalize(tmp));
1692 printf("Lebenspunkte: %4d [%4d], Magiepunkte: %4d [%4d], Erf: %-8d\n",
bugfixd94d0932020-04-08 11:27:13 +02001693 ({int})ob->QueryProp(P_HP), ({int})ob->QueryProp(P_MAX_HP),
1694 ({int})ob->QueryProp(P_SP), ({int})ob->QueryProp(P_MAX_SP),
1695 ({int})ob->QueryProp(P_XP));
MG Mud User88f12472016-06-24 23:31:02 +02001696 if (living(ob))
1697 {
1698 tmp=present("geld",ob);
1699 if (tmp)
bugfixd94d0932020-04-08 11:27:13 +02001700 tmp=({int})tmp->QueryProp(P_AMOUNT);
MG Mud User88f12472016-06-24 23:31:02 +02001701 printf("Traegt %6d (%6d) g. Eigengewicht %6d g. %6d Muenzen.\n",
bugfixd94d0932020-04-08 11:27:13 +02001702 ({int})ob->query_weight_contents(),({int})ob->QueryProp(P_MAX_WEIGHT),
1703 ({int})ob->QueryProp(P_WEIGHT),tmp);
1704 if (tmp=({object})ob->SelectEnemy())
1705 printf("Kaempft gegen %s [%O]\n",({string})tmp->name(WEN),tmp);
MG Mud User88f12472016-06-24 23:31:02 +02001706 }
1707 printf("ENV: %s",
1708 ((tmp=environment(ob))?object_name(tmp):"- fabric of space -"));
1709 if(query_once_interactive(ob))
1710 {
bugfixd94d0932020-04-08 11:27:13 +02001711 printf(", EMail: %s\n", ({string})ob->QueryProp(P_MAILADDR)+"");
1712 tmp=({int})"/secure/master"->find_userinfo(getuid(ob));
MG Mud User88f12472016-06-24 23:31:02 +02001713 if (pointerp(tmp) && sizeof(tmp)>USER_DOMAIN)
1714 {
1715 tmp=tmp[USER_DOMAIN];
1716 if (pointerp(tmp) && sizeof(tmp))
1717 {
1718 printf("Lord in: ");
1719 for (tmp2=0;tmp2<sizeof(tmp);tmp2++)
1720 printf("%s%s",(tmp2>0?", ":""),""+tmp[tmp2]);
1721 printf(".\n");
1722 }
1723 }
bugfixd94d0932020-04-08 11:27:13 +02001724 tmp=({string*})"/secure/master"->get_domain_homes(getuid(ob));
MG Mud User88f12472016-06-24 23:31:02 +02001725 if (pointerp(tmp)&&sizeof(tmp)>0)
1726 {
1727 printf("Mitglied in: ");
1728 for (tmp2=0;tmp2<sizeof(tmp);tmp2++)
1729 printf("%s%s",(tmp2>0?", ":""),""+tmp[tmp2]);
1730 printf(".\n");
1731 }
1732 printf("Quests: ");
bugfixd94d0932020-04-08 11:27:13 +02001733 tmp=({mapping})ob->QueryProp(P_QUESTS);
MG Mud User88f12472016-06-24 23:31:02 +02001734 if (tmp==({})||!pointerp(tmp))
1735 printf("Keine.\n");
1736 else
1737 {
1738 tmp2="";
1739 tmp-=({({}),0});
1740 for (i=0; i<sizeof(tmp); i++)
1741 tmp2+=sprintf("%s%s",(i?", ":""),tmp[i][0]);
1742 tmp=break_string(tmp2,79,8);
1743 tmp=tmp[8..];
1744 printf("%s",tmp);
1745 }
bugfixd94d0932020-04-08 11:27:13 +02001746 printf("PKills: %d ",({int})ob->QueryProp(P_KILLS));
1747 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 +02001748 if (interactive(ob))
1749 {
1750 printf("From: %s (%s) [%s]\n",query_ip_name(ob),query_ip_number(ob),country(query_ip_name(ob)));
1751 tmp=query_idle(ob);
1752 printf("Idle seit %d Sekunden",tmp);
1753 if (tmp>60)
1754 printf(" (%s)",timef(tmp));
bugfixd94d0932020-04-08 11:27:13 +02001755 printf(", cmd avg: %d",({int})ob->QueryProp("command_average"));
MG Mud User88f12472016-06-24 23:31:02 +02001756 printf(", noch %d ZT zu finden.\nGesnooped von: %s\n",
bugfixd94d0932020-04-08 11:27:13 +02001757 ((tmp=({int*})ob->QueryProp(P_POTIONROOMS))?sizeof(tmp):0),
MG Mud User88f12472016-06-24 23:31:02 +02001758 ((tmp=query_snoop(ob))?capitalize(getuid(tmp)):"Niemandem"));
1759 }
1760 else
1761 {
1762 tmp=getuid(ob);
1763 tmp=file_time("save/"+tmp[0..0]+"/"+tmp+".o");
1764 tmp=time()-tmp;
1765 printf("Kam von: %s, vor: %d s(%s)\n",
bugfixd94d0932020-04-08 11:27:13 +02001766 ({string})ob->QueryProp(P_CALLED_FROM_IP),tmp,timef(tmp));
MG Mud User88f12472016-06-24 23:31:02 +02001767 }
1768 }
1769 else
1770 printf("\n");
1771 return arg;
1772}
1773
1774mixed dinfo(string arg)
1775{
1776 object ob;
1777
1778 ob=pop();
1779 if (!ob)
1780 return 1;
1781 debug_info(0,ob);
1782 return arg;
1783}
1784
1785mixed minfo(string arg)
1786{
1787 object ob;
1788
1789 ob=pop();
1790 if (!ob)
1791 return 1;
1792 debug_info(1,ob);
1793 return arg;
1794}
1795
1796void dump_list(mixed what)
1797{
1798 int i,s;
1799
1800 if (!pointerp(what)||!(s=sizeof(what)))
1801 return;
1802 for (i=0;i<s;i++)
1803 write(what[i]);
1804}
1805
1806string callout(string args)
1807{
1808 dump_list(get_callout());
1809 return args;
1810}
1811
1812string heartbeat(string args)
1813{
1814 dump_list(get_heartbeat());
1815 return args;
1816}
1817
1818string dumplists(string args)
1819{
1820 string filen;
1821 string *list;
1822 int i,s;
1823
1824 if (!geteuid(this_object()))
1825 return args;
1826 filen="/players/"+geteuid(this_object())+"/LISTS.LUPE";
1827 write("Dumping to "+filen+" ... ");
1828 if (file_size(filen)>=0)
1829 rm(filen);
1830 write_file(filen,"OBJECT WITH ACTIVE HEART_BEAT:\n");
1831 list=get_heartbeat();
1832 if (!list || !(s=sizeof(list)))
1833 write_file(filen,"NONE\n");
1834 for (i=0;i<s;i++)
1835 write_file(filen,list[i]);
1836 write_file(filen,"\n\nRUNNING CALL_OUTS:\n");
1837 list=get_callout();
1838 if (!list || !(s=sizeof(list)))
1839 write_file(filen,"NONE\n");
1840 for (i=0;i<s;i++)
1841 write_file(filen,list[i]);
1842 write("done.\n");
1843 return args;
1844}
1845
1846mixed renew_player(string arg)
1847{
1848 object ob;
1849
1850 ob=pop();
1851 if (!ob)
1852 return 1;
1853 if (!objectp(ob)&&!interactive(ob))
1854 {
1855 err=desc(ob)+" is not an interactive player";
1856 return arg;
1857 }
bugfixd94d0932020-04-08 11:27:13 +02001858 if ((err=({int})"/secure/master"->renew_player_object(ob))<0)
MG Mud User88f12472016-06-24 23:31:02 +02001859 err="error "+err+" when renewing "+desc(ob);
1860 return arg;
1861}
1862
1863mixed copy_ldfied(string arg)
1864{
1865 object ob, new;
MG Mud User88f12472016-06-24 23:31:02 +02001866
1867 ob=pop();
1868 if (!ob)
1869 return 1;
1870 if (!objectp(ob))
1871 {
1872 err=desc(ob)+" is not an valid object";
1873 return arg;
1874 }
1875 new=clone_object(old_explode(object_name(ob),"#")[0]);
bugfixd94d0932020-04-08 11:27:13 +02001876 ({mapping})new->SetProperties(ob->QueryProperties());
MG Mud User88f12472016-06-24 23:31:02 +02001877 push(new);
bugfixd94d0932020-04-08 11:27:13 +02001878 ({int})new->move(this_player(),M_NOCHECK);
MG Mud User88f12472016-06-24 23:31:02 +02001879 return arg;
1880}
1881