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