blob: a5ed35af0b4e102748e671b5a471b88ac006ca15 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001// ----------------------------------------------------------------------
2// Builtinkommandos der Teller.
3// ----------------------------------------------------------------------
4#include "teller.h"
5inherit T_BASE;
6
Zesstra703da222017-01-31 10:47:36 +01007#include <config.h>
MG Mud User88f12472016-06-24 23:31:02 +02008#include <moving.h>
9#include <attributes.h>
10#include <terminal.h>
11#include <wizlevels.h>
12
13static void do_rinv( object env, int depth );
14static scan_obj( object player, object obj );
15static void mk_waitfor( mixed waitfor );
16static void mk_autoload( mixed autoload );
17static int do_roomupdate( int destflag, int noitems );
18static int do_cleanof( int strong );
19
20// from teller.c
21static int do_cmd( string str );
22
23static int cmd_clear()
24{
25 stack = ({});
26 return TRUE;
27}
28
29static int cmd_pop()
30{
31 if( !sizeof(stack) )
32 return error( "pop: Der Stack ist leer" );
33 pop();
34 return TRUE;
35}
36
37static int cmd_top()
38{
39 if( !sizeof(stack) )
40 return error( "top: Der Stack ist leer" );
41 write( "TOS= " );
42 dump_obj( top(), 5 );
43 return TRUE;
44}
45
46static int cmd_swap()
47{
48 mixed tmp;
49
50 if( sizeof(stack)<2 )
51 return error( "swap: Keine 2 Elemente auf dem Stack" );
52 tmp = stack[0];
53 stack[0] = stack[1];
54 stack[1] = tmp;
55 return TRUE;
56}
57
58static int cmd_dup()
59{
60 if( !sizeof(stack) )
61 return error( "dup: Der Stack ist leer" );
62 push(top());
63 return TRUE;
64}
65
66static int cmd_here()
67{
68 push(environment(PL));
69 return TRUE;
70}
71
72static int cmd_stack()
73{
74 int i;
75 if( !sizeof(stack) )
76 return memo( "Der Stack ist leer" );
77
78 for( i=0; i<sizeof(stack); i++ )
79 {
80 printf( "%2d: ", i );
81 dump_obj( stack[i], 4 );
82 }
83 return TRUE;
84}
85
86static int cmd_inv()
87{
88 int i;
89 object ob;
90
91 if( !becomes_obj() )
92 return error( "inv: TOS ist kein Objekt" );
93 write( "Inventar von " );
94 dump_obj( top(), 13 );
95 for( i=0, ob=first_inventory(top()); ob; ob=next_inventory(ob), i++ )
96 {
97 printf( "%2d. ", i );
98 dump_obj( ob, 4 );
99 }
100 return TRUE;
101}
102
103static int cmd_rekinv()
104{
105 if( !becomes_obj() )
106 return error( "rekinv: TOS ist kein Objekt" );
107 write( "Inventar von " );
108 dump_obj( top(), 13 );
109
110 do_rinv( top(), 2 );
111 return TRUE;
112}
113
114static void do_rinv( object env, int depth )
115{
116 int i;
117 object ob;
118
119 for( i=0, ob=first_inventory(env); ob; ob=next_inventory(ob), i++ )
120 {
121 printf( "%*d. ", depth, i );
122 dump_obj( ob, 2+depth );
123 do_rinv( ob, depth+2 );
124 }
125}
126
127static int cmd_me()
128{
129 push( PL );
130 return TRUE;
131}
132
133// Uebernommen aus dem Teddy (mit freundlicher Genehmigung von Sir).
134static int cmd_scan()
135{
136 object obj;
137
138 if( !becomes_pl() && ( !objectp(top()) || !living(top()) ) )
139 {
Zesstra85576452017-01-30 15:43:21 +0100140 if( stringp(top()) && master()->find_userinfo(top()))
MG Mud User88f12472016-06-24 23:31:02 +0200141 {
142 obj = clone_object( T_PLAYER );
143 obj->Load( top() );
144 obj->SetProp( P_NAME, capitalize( pop() ) );
145 scan_obj( TRUE, obj );
146 destruct( obj );
147 return TRUE;
148 }
149 return error( "scan: TOS ist kein Lebewesen" );
150 }
151
152 scan_obj( query_once_interactive( top() ), pop() );
153 return TRUE;
154}
155
156static int WizLevel( object obj )
157{
158 if( obj->Notlogged() )
159 return query_wiz_level( lower_case(obj->playername()) );
160 else
161 return query_wiz_level( obj );
162}
163
164static string IpName( object obj )
165{
Rumata5ab90702021-05-08 09:25:27 +0200166 string ip_name, nm;
MG Mud User88f12472016-06-24 23:31:02 +0200167
168 if( obj->Notlogged() )
169 {
170 // Aus Umstellungsgruenden werden CALLED_FROM_IP und IP_NAME
171 // abgefragt. IP_NAME ist neuer.
172
173 nm = lower_case(obj->playername());
174 ip_name = obj->QueryProp(P_CALLED_FROM_IP);
175 if( !ip_name ) ip_name = obj->Query(P_IP_NAME);
176 return ip_name + " ("
Zesstra703da222017-01-31 10:47:36 +0100177 + dtime(get_dir(SAVEPATH+nm[0..0]+"/"+nm+".o",4)[0]) +")";
MG Mud User88f12472016-06-24 23:31:02 +0200178 }
179 else
180 {
181 nm = lower_case( obj->name(RAW) );
182 ip_name = query_ip_name( obj );
183 if( ip_name == "" || !ip_name )
184 {
185 ip_name = obj->QueryProp(P_CALLED_FROM_IP);
186 if( !ip_name ) ip_name = obj->Query(P_IP_NAME);
187 return ip_name + " ("
Zesstra703da222017-01-31 10:47:36 +0100188 + dtime(get_dir(SAVEPATH+nm[0..0]+"/"+nm+".o",4)[0]) +")";
MG Mud User88f12472016-06-24 23:31:02 +0200189 }
190 return ip_name + " [" + query_ip_number(obj) + "]";
191 }
192}
193
194string IdleTime( object obj )
195{
196 if( obj->Notlogged() ) return "-nicht da-";
197 if( query_ip_number(obj) ) return ""+query_idle(obj);
198 return "-netztot-";
199}
200
201static scan_obj( object player, object obj )
202{
203 string title, level, gender, room, testpl,
Rumata5ab90702021-05-08 09:25:27 +0200204 weapon, armour, stat_str, *arr;
MG Mud User88f12472016-06-24 23:31:02 +0200205 int i,ac;
Zesstra38121982021-05-07 09:36:14 +0200206 object weaponobj, *list;
207 object** enemies;
208 object* gegner;
Rumata5ab90702021-05-08 09:25:27 +0200209 mixed *hands, *stats;
MG Mud User88f12472016-06-24 23:31:02 +0200210
211 // 1.Zeile : Name Titel - Rasse - [ Wizlevel ]
212 title = obj->QueryProp(P_TITLE);
213
214 if( !player )
215 level = "Monster" ;
216 else if( WizLevel( obj ) < WIZARD_LVL )
217 {
218 if( testpl=obj->QueryProp( P_TESTPLAYER ) )
219 {
220 if( stringp(testpl) )
221 level = "("+testpl+")";
222 else
223 level = "Testspieler";
224 }
225 else if( WizLevel( obj ) >= SEER_LVL )
226 level = "Seher";
227 else
228 level = "Spieler" ;
229 }
230 else if( WizLevel( obj ) >= GOD_LVL )
231 level = "MudGott" ;
232 else if( WizLevel( obj ) >= ARCH_LVL )
233 level = "Erzmagier" ;
234 else if( WizLevel( obj ) >= LORD_LVL )
235 level = "Regionsmagier" ;
236 else
237 level = "Magier" ;
238
239 if( !obj->short() )
240 level += ", unsichtbar" ;
241 if( obj -> QueryProp( P_FROG ) )
242 level += ", Frosch" ;
243 if( obj->QueryProp( P_GHOST ) )
244 level += ", tot";
245 if( obj->Notlogged() )
246 level += ", ausgeloggt";
247 if(obj->QueryProp(P_SECOND) )
248 level +=", Zweitie";
249
250 if( environment(obj) )
251 room = object_name(environment( obj ));
252 else
253 room = "-nirgends-";
254
255 printf( "%s %s %s[ %s ].\nBefindet sich in %s.\n",
256 obj->name(RAW), title? title : "",
257 stringp(obj->QueryProp(P_RACE)) ? "- "+obj->QueryProp(P_RACE)+" - " : "",
258 level, room ) ;
259
260 // 1 abc Zeile : Host,Email,Snooper
261 if( player )
262 {
263 printf( "Host.......: %s\n", IpName(obj) );
264 printf( "E-Mail.....: %s.\n", obj->QueryProp(P_MAILADDR) );
265 if( !obj->Notlogged() && query_snoop(obj) )
266 printf( "Snooper....: %s.\n", capitalize(getuid(query_snoop(obj))) );
267
268 printf( "Vorsicht...: %11d Kurzmodus.: %11s Magierblick....: %11s.\n",
269 obj->QueryProp(P_WIMPY), obj->QueryProp(P_BRIEF) ? "-an-" : "-aus-",
270 obj->QueryProp(P_WANTS_TO_LEARN) ? "-an-" : "-aus-" );
271 printf( "Idlezeit...: %11s Alter.....: %11s Verheiratet mit: %-11s.\n",
272 IdleTime(obj), time2string("%5d:%02h:%02m",obj->QueryProp(P_AGE)*2),
273 (stringp(obj->QueryProp(P_MARRIED)) ? obj->QueryProp(P_MARRIED) : "-" )
274 );
275 }
276
277 // 2.Zeile : HP, SP und XP
278 printf( "Lebenspkt..: [%4d/%4d] Magiepkt..: [%4d/%4d].\n" +
279 "Questpunkte: [%4d/%4d] Erfahrung.: %11d.\n",
280 obj->QueryProp(P_HP), obj->QueryProp(P_MAX_HP),
281 obj->QueryProp(P_SP), obj->QueryProp(P_MAX_SP),
282 obj->QueryProp(P_QP), "/secure/questmaster"->QueryMaxQP(),
283 obj->QueryProp(P_XP) );
284
285 // 3.Zeile : FOOD, DRINK, ALCOHOL
286 printf( "Nahrung....: [%4d/%4d] Fluessigk.: [%4d/%4d] " +
287 "Alkohol........: [%4d/%4d].\n",
288 obj->QueryProp(P_FOOD), obj->QueryProp(P_MAX_FOOD),
289 obj->QueryProp(P_DRINK), obj->QueryProp(P_MAX_DRINK),
290 obj->QueryProp(P_ALCOHOL), obj->QueryProp(P_MAX_ALCOHOL) ) ;
291
292 // 4.Zeile : Geschlecht, Alignment, Level
293 switch( obj->QueryProp(P_GENDER) )
294 {
295 case FEMALE : gender = "weiblich " ; break ;
296 case MALE : gender = "maennlich " ; break ;
297 default : gender = "neutrum " ; break ;
298 }
299 printf(
300 "Geschlecht.: %s Charakter.: %11d (Magier)Stufe..: [%4s/%4d].\n",
301 gender, obj->QueryProp(P_ALIGN),
302 player ? WizLevel(obj)+"" : "-", obj->QueryProp(P_LEVEL) );
303
304 // 5.Zeile : Geld, Gewicht, Playerkills
305 printf( "Geld.......: %11d Traegt....: %11d Playerkills....: %11d.\n",
306 obj->QueryMoney(), obj->query_weight_contents(),
307 obj->QueryProp(P_KILLS) );
308
309 // 6.Zeile : stati
310 stats = obj->QueryProp(P_ATTRIBUTES) ;
311 arr = m_indices( stats );
312 stat_str = "" ;
313 for( i = 0; i < sizeof( arr ); i++ ) {
314 stat_str += capitalize(arr[ i ]) + "[" + stats[arr[ i ]];
315 if( ac = obj->QueryAttributeOffset(arr[i]) ) {
316 stat_str += "+" + ac;
317 }
318 stat_str += "], ";
319 }
320
321 if( stat_str == "" )
322 stat_str = "Keine" ;
323 else
324 stat_str = stat_str[0..sizeof( stat_str ) - 3] ;
325 printf( "Attribute..: %s.\n", stat_str ) ;
326
327 // 7.Zeile : Waffe( Dateiname )[ AC ]
328 // 8.Zeile : Ruestung(en)[ WC ]
329 weaponobj=obj->QueryProp(P_WEAPON);
330 if( weaponobj )
331 weapon = weaponobj->name(RAW) + " (" +
332 object_name( weaponobj ) + ") [" +
333 weaponobj->QueryProp(P_WC) + "]" ;
334 else
335 {
336 hands = obj->QueryProp(P_HANDS);
337 weapon = sprintf( "kaempft%s [%d]", hands[0], hands[1] );
338 }
339 ac = 0;
340 list = obj->QueryProp(P_ARMOURS);
341 armour = "";
342 for( i = 0; i < sizeof( list ); i++ )
343 {
344 armour += ( list[i]->name(RAW) + "[" +
345 list[i]->QueryProp(P_AC) + "]" + ", ") ;
346 ac += list[i]->QueryProp(P_AC);
347 }
348
349 if( armour == "" )
350 armour = "Keine " ;
351
352 arr = old_explode( break_string( armour[0..<3]+sprintf(" =>[%d]",
353 ac+obj->QueryProp(P_BODY) ), 65 ), "\n" ) ;
354 armour = arr[ 0 ] ;
355 for( i = 1; i < sizeof( arr ); i++ )
356 armour += "\n " + arr[ i ] ;
357 printf( "Waffe......: %s.\nRuestung...: %s.\n", weapon, armour ) ;
358
Zesstra38121982021-05-07 09:36:14 +0200359 enemies = obj->QueryEnemies();
360 if( pointerp(enemies) )
MG Mud User88f12472016-06-24 23:31:02 +0200361 {
Zesstra38121982021-05-07 09:36:14 +0200362 gegner = enemies[0];
MG Mud User88f12472016-06-24 23:31:02 +0200363 for( i=0; i<sizeof(gegner); i++ )
364 {
365 if( i==0 ) printf( "Gegner.....: "); else printf( " " );
366 if( !objectp(gegner[i]) )
367 printf( "<%O>\n", gegner[i] );
368 else
369 printf( "%s (%s)\n", gegner[i]->name(WER,0), object_name(gegner[i]) );
370 }
371 }
372
373 mk_waitfor( obj->QueryProp(P_WAITFOR) );
374
375 mk_autoload( obj->QueryProp(P_AUTOLOAD) );
376
377 return TRUE;
378}
379
380static void mk_waitfor( mixed waitfor )
381{
382 string str;
383 int i;
384
385 if( !pointerp(waitfor) || sizeof(waitfor)==0 )
386 return;
387 str = "Waiting for: ";
388 for( i=sizeof(waitfor)-1; i>0; i-- )
389 str += waitfor[i] + ", ";
390 str += waitfor[0];
391 write( str+"\n" );
392}
393
394static void mk_autoload( mixed autoload )
395{
396 string str, *objlist;
397 int i;
398
399 if( !mappingp(autoload) )
400 return;
401 str = "Autoload...: ";
402 objlist = m_indices(autoload);
403 for( i=sizeof(objlist)-1; i>=0; i-- )
404 {
405 str += "\"" + objlist[i] + "\"\n";
406 if( i>0 )
407 str += " ";
408 }
409 write( str );
410}
411
412static void print_memory_line( string key, object data, int flag )
413{
414 printf( " %-10s%s ", key, (flag ? ">" : "=") );
415 dump_obj( data, 13 );
416}
417
418static int cmd_memory()
419{
MG Mud User88f12472016-06-24 23:31:02 +0200420 if( !sizeof(memory) )
421 return memo( "Keine Variablen definiert" );
422
423 walk_mapping( memory, #'print_memory_line );
424 return TRUE;
425}
426
427static int cmd_array()
428{
429 mixed *array;
430 mixed ob;
431
432 if( !sizeof(stack) )
433 return error( "array: Der Stack ist leer" );
434 array = ({});
435 while( sizeof(stack) && (ob=pop()) && ob!=";" )
436 array = ({ob}) + array;
437 push( array );
438 return TRUE;
439}
440
441static int cmd_split()
442{
443 mixed *array;
444 int i;
445
446 if( !pointerp(top()) )
447 return error( "split: TOS ist kein Array" );
448 array=pop();
449 if( sizeof(stack) )
450 push( ";" );
451 for( i=0; i<sizeof(array); i++ )
452 push(array[i]);
453 return TRUE;
454}
455
456static int cmd_player()
457{
458 object ob;
459 string str;
460
461 str = top();
462 if( !stringp(str) )
463 return error( "player: TOS ist kein String" );
464 ob = becomes_pl();
465 if( !ob )
466 return error( "player: Keinen Spieler namens \""+str+"\" gefunden" );
467 //pop();
468 //push(ob);
469 return TRUE;
470}
471
472static int cmd_object()
473{
474 object ob;
475 string err,fnam;
476
477 if( !stringp(top()) )
478 return error( "object: TOS ist kein String" );
479 ob = find_object(top());
480 if( !ob )
481 {
482 if( !(fnam=this_player()->find_file(top(),".c")) )
483 return error( "object: Kein Objekt namens \""+top()+"\" gefunden" );
484 if( err=(catch(call_other(fnam,"?"))) )
485 return error( "object: Fehler beim Laden: "+err[1..<3] );
486 ob = find_object(fnam);
487 }
488 pop();
489 push(ob);
490 return TRUE;
491}
492
493static int cmd_living()
494{
495 object ob;
496 if( !stringp(top()) )
497 return error( "object: TOS ist kein String" );
498 ob = find_living(top());
499 if( !ob )
500 return error( "object: Kein Objekt namens \""+top()+"\" gefunden" );
501 pop();
502 push(ob);
503 return TRUE;
504}
505
506static int cmd_say()
507{
508 mit_say = !mit_say;
509 if( mit_say )
510 memo( "Meldungen an Mitspieler an" );
511 else
512 memo( "Meldungen an Mitspieler aus" );
513 return TRUE;
514}
515
516static int cmd_names()
517{
518 mit_namen = !mit_namen;
519 if( mit_namen )
520 memo( "Namen werden angezeigt" );
521 else
522 memo( "Namen werden nicht angezeigt" );
523 return TRUE;
524}
525
526static int cmd_secureinv()
527{
528 secureinv = !secureinv;
529 if( secureinv )
530 memo( "Inventory wird ueberwacht" );
531 else
532 memo( "Inventory wird nicht ueberwacht" );
533 set_heart_beat(secureinv);
534 return TRUE;
535}
536
537static int cmd_logaccess()
538{
539 dologaccess = !dologaccess;
540 if( dologaccess )
541 memo( "Zugriffe werden gemeldet" );
542 else
543 memo( "Zugriffe werden nicht gemeldet" );
544 return TRUE;
545}
546
547static int cmd_destruct_bang()
548{
549 if( !becomes_obj() )
550 return error( "destruct: TOS ist kein Objekt" );
551 destruct(pop());
552 return TRUE;
553}
554
555static int cmd_destruct()
556{
557 if( !becomes_obj() )
558 return error( "remove: TOS ist kein Objekt" );
559 memo( "destruct: TOS wird 'removed'!" );
560 top()->remove();
561 if( top() )
562 memo( "destruct: TOS lebt noch." );
563 else
564 pop();
565 return TRUE;
566}
567
568static int cmd_remove()
569{
570 if( !becomes_obj() )
571 return error( "remove: TOS ist kein Objekt" );
572 top()->remove();
573 if( top() )
574 memo( "destruct: TOS lebt noch." );
575 else
576 pop();
577 return TRUE;
578}
579
580static int cmd_update()
581{
582 object blue;
583
584 if( !becomes_obj() )
585 return error( "update: TOS ist kein Objekt" );
586 blue = find_object(old_explode(object_name(top()),"#")[0]);
587 blue->remove();
588 if( blue )
589 memo( "update: TOS lebt noch" );
590 else
591 pop();
592 return TRUE;
593}
594
595static int cmd_update_bang()
596{
597 if( !becomes_obj() )
598 return error( "update: TOS ist kein Objekt" );
599 destruct(find_object(old_explode(object_name(pop()),"#")[0]));
600 return TRUE;
601}
602
603static int cmd_roomupdate()
604{
605 return do_roomupdate( FALSE, FALSE );
606}
607
608static int cmd_roomupdate_bang()
609{
610 return do_roomupdate( TRUE, FALSE );
611}
612
613static int cmd_extroomupdate()
614{
615 return do_roomupdate( FALSE, TRUE );
616}
617
618static int cmd_extroomupdate_bang()
619{
620 return do_roomupdate( TRUE, TRUE );
621}
622
623// Hilfsfunktionen zum Filtern von Items
624static object *collect_items;
625static void collect( object* data ) { collect_items += ({ data[0] }); }
626
627static int do_roomupdate( int destflag, int noitems )
628{
629 object tmproom,newroom;
630 object *inv;
631 string errmsg;
632 string *file;
MG Mud User88f12472016-06-24 23:31:02 +0200633 int i;
634
635 if( !becomes_obj() )
636 return error( "roomupdate: TOS ist kein Objekt" );
637 file = old_explode( object_name( top() ), "#" );
638 if( sizeof(file) > 1 )
639 return error( "roomupdate: TOS ist keine Blueprint" );
640 if( file[0] == "/room/void" )
641 return error( "roomupdate: Die `void' darf nicht geupdatet werden" );
642
643 // ----- Rettung
644 tell_room( top(),
645 "Der Raum verschwimmt vor Deinen Augen, um sich zu erneuern.\n"
646 );
647 tmproom = clone_object( "/room/void" );
648
649 if( noitems )
650 // Nur Spieler kommen raus.
651 inv = filter( all_inventory(top()), #'query_once_interactive );
652 else
653 { // Dinge, die P_ITEMS sind, bleiben da!
654 collect_items = ({});
655 map( top()->QueryProp(P_ITEMS), #'collect );
656 inv = all_inventory(top()) - collect_items;
657 }
658
659 for( i=sizeof(inv)-1; i>=0; i-- )
660 inv[i]->move( tmproom, M_NOCHECK | M_SILENT | M_NO_SHOW );
661
662 // ----- Vernichtung
663 if( destflag )
664 destruct( pop() );
665 else
666 {
667 top()->remove();
668 if( top() )
669 memo( "roomupdate : TOS ist nicht verschwunden." );
670 else
671 pop();
672 }
673
674 // ----- Neuerschaffung
675 errmsg = catch( call_other( file[0], "?" ) );
676 if( errmsg )
677 {
678 tell_room( tmproom, "Der Raum verbleicht in ein Nichts.\n" );
679 push( file[0] );
680 return error( "updateroom: " + errmsg[1..<2] );
681 }
682
683 // ----- Restaurierung
684 newroom = find_object( file[0] );
685 for( i=sizeof(inv)-1; i>=0; i-- )
686 if( objectp(inv[i]) ) // Objekte koennten sich beim ersten move zerstoeren.
687 inv[i]->move( newroom, M_NOCHECK | M_SILENT | M_NO_SHOW );
688 tell_room( newroom, "Die Konturen werden wieder scharf.\n" );
689 destruct( tmproom );
690 return TRUE;
691}
692
693static int cmd_clone()
694{
695 if( !stringp(top()) )
696 return error( "clone: TOS ist kein String" );
697 if( file_size(top()+".c")<=0 )
698 return error( "clone: Kein solches File" );
699 push(clone_object(pop()));
700 //do_move( top(), environment(PL) );
701 //top()->move(PL,M_GET|M_SILENT);
702 return TRUE;
703}
704
705static int cmd_move()
706{
707 object ob;
708
709 if( !becomes_obj() )
710 return error( "move: Ziel ist kein Objekt" );
711 ob = pop();
712 if( !becomes_obj() )
713 return error( "move: Kein solcher Gegenstand" );
714 do_move( pop(), ob );
715 return TRUE;
716}
717
718static int cmd_cleanof_bang()
719{
720 return do_cleanof( TRUE );
721}
722
723static int cmd_cleanof()
724{
725 return do_cleanof( FALSE );
726}
727
728static int do_cleanof( int strong )
729{
730 object *inv;
731 int i;
732 string clean_id;
733
734 if( !stringp(top()) )
735 return error( "cleanof: TOS ist kein String" );
736 clean_id = pop();
737 if( !becomes_obj() )
738 {
739 push( clean_id );
740 return error( "cleanof: Kein Objekt zum Leeren" );
741 }
742 for( i=0, inv=all_inventory(pop()); i<sizeof(inv); i++ )
743 if( inv[i]->id(clean_id) )
744 {
745 if( strong )
746 destruct( inv[i] );
747 else
748 inv[i]->remove();
749 }
750 return TRUE;
751}
752
753static int cmd_snoopers()
754{
755 object* u, snooper;
756 int i, flag;
757
758 flag = 0;
759 u = users();
760 for( i=0; i<sizeof(u); i++ )
761 {
762 if( snooper = query_snoop(u[i]) )
763 {
764 flag = 1;
765 printf( "%s wird gesnooped von: %s.\n",
766 capitalize(getuid(u[i])), capitalize(getuid(snooper)) );
767 }
768 }
769 if( !flag )
770 memo( "Momentan wird niemand gesnooped" );
771 return TRUE;
772}
773
774static int cmd_ping()
775{
776 object pl;
777
778 if( !becomes_pl() )
779 return error( "ping: TOS ist kein Spieler" );
780
781 pl=pop();
782 call_out( "ping", 0, ({ pl, 5 }) );
783 return TRUE;
784}
785
786static void ping( mixed* argv )
787{
788 if( !argv[0] || --argv[1] < 0 ) return;
789 tell_object( argv[0], BEEP+PL->name(WER)+" pingt Dich an.\n" );
790 call_out( "ping", 1, argv );
791}
792
793static void do_calloutinfo( mixed* call )
794{
795 int l,i;
796
797 if( pointerp(call) )
798 {
799 printf( "%5d:%O->%O(", call[2], call[0], call[1]);
800 if( (l=sizeof(call))>3 ) {
801 for( ; l>=3 && !call[--l]; ) ;
802 for( i=3; i<=l; i++ ) printf( "%O%s", call[i], (i==l)?"":"," );
803 }
804 write(")\n");
805 }
806}
807
808static int cmd_callouts_bang()
809{
810 mixed *calls;
MG Mud User88f12472016-06-24 23:31:02 +0200811
812 calls = call_out_info();
813 if( !pointerp(calls) || !sizeof(calls) )
814 {
815 memo( "Keine Callouts vorhanden" );
816 return TRUE;
817 }
818 map( calls, #'do_calloutinfo );
819 return TRUE;
820}
821
822static void do_calloutinfo2( mixed* call, string str )
823{
824 string s;
825 int i,l;
826
827 if( pointerp(call) )
828 {
829 s = sprintf( "%5d:%O->%O(", call[2], call[0], call[1]);
830 if( sizeof(explode(s,str)) > 1 )
831 {
832 write( s );
833 if( (l=sizeof(call))>3 ) {
834 for( ; l>=3 && !call[--l]; ) ;
835 for( i=3; i<=l; i++ ) printf( "%O%s", call[i], (i==l)?"":"," );
836 }
837 write(")\n");
838 }
839 }
840}
841
842static int cmd_callouts()
843{
844 mixed *calls;
MG Mud User88f12472016-06-24 23:31:02 +0200845 string str;
MG Mud User88f12472016-06-24 23:31:02 +0200846
847 if( !stringp(top()) )
848 return error( "TOS ist kein String" );
849 str = pop();
850 calls = call_out_info();
851 if( !pointerp(calls) || !sizeof(calls) )
852 {
853 memo( "Keine Callouts vorhanden" );
854 return TRUE;
855 }
856 map( calls, #'do_calloutinfo2, str );
857 return TRUE;
858}
859
860static int cmd_heartbeats()
861{
862 mixed *beats;
863 int i;
864 object env;
865 string enam;
866
867 beats = heart_beat_info();
868 if( !pointerp(beats) || !sizeof(beats) )
869 {
870 memo( "Keine Heartbeats vorhanden" );
871 return TRUE;
872 }
873 for( i=0; i<sizeof(beats); i++ )
874 {
875 env = environment(beats[i]);
876 enam = env ? object_name(env) : "-- nirgends --";
877 printf( "%-35s %-35s\n", object_name(beats[i]), enam );
878 }
879 return TRUE;
880}
881
882static int cmd_wer()
883{
884 object* ppl;
885 string* pl;
886 int i;
887
888 ppl = sort_array( users(), lambda( ({ 'x, 'y }),
889 ({ #'<, ({ #'query_ip_number, 'x }), ({ #'query_ip_number, 'y }) })
890 ));
891 pl = ({});
892 for( i=0; i<sizeof(ppl); i++ )
893 {
894 pl += ({ sprintf( "%'.'-14s %-15s %3d %s \n",
895 capitalize(geteuid(ppl[i])),
896 query_ip_number(ppl[i]),
897 query_wiz_level(ppl[i])>0 ? query_wiz_level(ppl[i])
898 : ppl[i]->QueryProp(P_LEVEL),
899 query_wiz_level(ppl[i])>0 ? "W" : "P"
900 ) });
901 }
902 write( implode(pl,"") );
903 return TRUE;
904}
905
906static int cmd_debuginfo()
907{
908 if( !becomes_obj() )
909 return error( "dinfo: TOS ist kein Objekt" );
910 debug_info( 0, pop() );
911 return TRUE;
912}
913
914static int cmd_pretty()
915{
916 pretty = !pretty;
917 if( pretty )
918 memo( "Schoenmodus an" );
919 else
920 memo( "Schoenmodus aus" );
921 return TRUE;
922}
923
924static int cmd_doprofile()
925{
926 do_profile=!do_profile;
927 if( do_profile )
928 memo( "Profile wird geladen" );
929 else
930 memo( "Profile wird nicht geladen" );
931 return TRUE;
932}
933
934static int cmd_evaluate()
935{
936 string str;
937 if( !sizeof(stack) ) return error( "evaluate: Stack ist leer" );
938 if( !stringp(top()) ) return error( "evaluate: TOS ist kein String" );
939 str = pop();
940 return do_cmd( str );
941}
942
943static void write_memory( string nam, string str, int flag, string file )
944{
945 if( flag ) write_file( file, nam + " = " + str + "\n" );
946}
947
948static int cmd_dump()
949{
950 string file;
951
952 if( !sizeof(stack) || !stringp(top()) )
953 file = "/players/"+getuid(PL)+"/.memory.o";
954 else
955 file = pop();
956 rm( file );
957 write_file( file, "# Dump des Tellerstapels vom " + dtime(time()) + "\n" );
958 write_file( file, "# Owner = "+capitalize(getuid(PL))+"\n" );
959 walk_mapping( memory, #'write_memory, file );
960 return TRUE;
961}
962
963static int restore_line( string line )
964{
965 string nam,str;
966 if( sscanf( line, "%s = %s", nam, str ) != 2 )
967 return error( "restore: Fehler im file" );
968 memory += ([ nam: str; 1 ]);
969 return 1;
970}
971
972static int cmd_restore()
973{
974 string str, *lines;
975
976 if( !sizeof(stack) || !stringp(top()) )
977 str = "/players/"+getuid(PL)+"/.memory.o";
978 else
979 str = pop();
980
981 if(file_size(str)<=0)
982 return error( "restore: kann '"+str+"' nicht laden" );
983 lines = regexp( old_explode( read_file(str), "\n" ), "^[^#]" );
984 map( lines, #'restore_line );
985 return TRUE;
986}
987
988static int cmd_if()
989{
990 if( sizeof(stack) < 3 )
991 return error( "if: zuwenig Argumente" );
992 if( !pop() )
993 cmd_swap();
994 pop();
995 return TRUE;
996}