00001
00002
00003
00004
00005 #include "copyright.h"
00006 #include "config.h"
00007
00008 #include "mudconf.h"
00009 #include "config.h"
00010 #include "db.h"
00011 #include "interface.h"
00012 #include "match.h"
00013 #include "externs.h"
00014 #include "flags.h"
00015 #include "powers.h"
00016 #include "attrs.h"
00017 #include "command.h"
00018 #include "alloc.h"
00019 #include "ansi.h"
00020
00021 extern void ufun(char *, char *, int, int, int, dbref, dbref);
00022
00023 static void look_exits(dbref player, dbref loc, const char *exit_name)
00024 {
00025 dbref thing, parent;
00026 char *buff, *e, *s, *buff1, *e1;
00027 int foundany, lev, key;
00028
00029
00030
00031
00032
00033 if(!Good_obj(loc) || !Has_exits(loc))
00034 return;
00035
00036
00037
00038
00039
00040 foundany = 0;
00041 key = 0;
00042 if(Dark(loc))
00043 key |= VE_BASE_DARK;
00044 ITER_PARENTS(loc, parent, lev) {
00045 key &= ~VE_LOC_DARK;
00046 if(Dark(parent))
00047 key |= VE_LOC_DARK;
00048 DOLIST(thing, Exits(parent)) {
00049 if(exit_displayable(thing, player, key)) {
00050 foundany = 1;
00051 break;
00052 }
00053 }
00054 if(foundany)
00055 break;
00056 }
00057
00058 if(!foundany)
00059 return;
00060
00061
00062
00063
00064 notify(player, exit_name);
00065 e = buff = alloc_lbuf("look_exits");
00066 e1 = buff1 = alloc_lbuf("look_exits2");
00067 ITER_PARENTS(loc, parent, lev) {
00068 key &= ~VE_LOC_DARK;
00069 if(Dark(parent))
00070 key |= VE_LOC_DARK;
00071 if(Transparent(loc)) {
00072 DOLIST(thing, Exits(parent)) {
00073 if(exit_displayable(thing, player, key)) {
00074 StringCopy(buff, Name(thing));
00075 for(e = buff; *e && (*e != ';'); e++);
00076 *e = '\0';
00077 notify_printf(player, "%s leads to %s.", buff,
00078 Name(Location(thing)));
00079 }
00080 }
00081 } else {
00082 DOLIST(thing, Exits(parent)) {
00083 if(exit_displayable(thing, player, key)) {
00084 e1 = buff1;
00085
00086
00087
00088
00089
00090
00091
00092
00093 if(buff != e)
00094 safe_str((char *) " ", buff, &e);
00095 for(s = Name(thing); *s && (*s != ';'); s++)
00096 safe_chr(*s, buff1, &e1);
00097 *e1 = 0;
00098
00099
00100 safe_str(buff1, buff, &e);
00101
00102 }
00103 }
00104 }
00105 }
00106
00107 if(!(Transparent(loc))) {
00108 safe_str((char *) "\r\n", buff, &e);
00109 *e = 0;
00110 notify(player, buff);
00111 }
00112 free_lbuf(buff);
00113 free_lbuf(buff1);
00114 }
00115
00116 #define CONTENTS_LOCAL 0
00117 #define CONTENTS_NESTED 1
00118 #define CONTENTS_REMOTE 2
00119
00120 static void look_contents(dbref player, dbref loc, const char *contents_name,
00121 int style)
00122 {
00123 dbref thing;
00124 dbref can_see_loc;
00125 char *buff;
00126 char remote_num[32];
00127
00128
00129
00130
00131
00132 can_see_loc = (!Dark(loc) || (mudconf.see_own_dark &&
00133 Examinable(player, loc)));
00134
00135
00136
00137
00138
00139 DOLIST(thing, Contents(loc)) {
00140 if(can_see(player, thing, can_see_loc)) {
00141
00142
00143
00144
00145
00146 notify(player, contents_name);
00147 DOLIST(thing, Contents(loc)) {
00148 if(can_see(player, thing, can_see_loc)) {
00149 buff = unparse_object(player, thing, 1);
00150 notify(player, buff);
00151 free_lbuf(buff);
00152
00153 }
00154 }
00155 break;
00156
00157
00158 }
00159 }
00160 }
00161
00162 static void view_atr(dbref player, dbref thing, ATTR * ap, char *text,
00163 dbref aowner, int aflags, int skip_tag)
00164 {
00165 char *buf;
00166 char xbuf[6];
00167 char *xbufp;
00168 BOOLEXP *bool;
00169
00170 if(ap->flags & AF_IS_LOCK) {
00171 bool = parse_boolexp(player, text, 1);
00172 text = unparse_boolexp(player, bool);
00173 free_boolexp(bool);
00174 }
00175
00176
00177
00178
00179
00180 if(!Controls(player, thing) && (Owner(player) != aowner)) {
00181 if(skip_tag && (ap->number == A_DESC))
00182 notify_printf(player, "%s", text);
00183 else
00184 notify_printf(player, "\033[1m%s:\033[0m %s", ap->name, text);
00185 return;
00186 }
00187
00188
00189
00190
00191 xbufp = xbuf;
00192 if(aflags & AF_LOCK)
00193 *xbufp++ = '+';
00194 if(aflags & AF_NOPROG)
00195 *xbufp++ = '$';
00196 if(aflags & AF_PRIVATE)
00197 *xbufp++ = 'I';
00198 if(aflags & AF_REGEXP)
00199 *xbufp++ = 'R';
00200 if(aflags & AF_VISUAL)
00201 *xbufp++ = 'V';
00202 if(aflags & AF_MDARK)
00203 *xbufp++ = 'M';
00204 if(aflags & AF_WIZARD)
00205 *xbufp++ = 'W';
00206
00207 *xbufp = '\0';
00208
00209 if((aowner != Owner(thing)) && (aowner != NOTHING)) {
00210 notify_printf(player, "\033[1m%s [#%d%s]:\033[0m %s", ap->name, aowner, xbuf, text);
00211 } else if(*xbuf) {
00212 notify_printf(player, "\033[1m%s [%s]:\033[0m %s", ap->name, xbuf, text);
00213 } else if(!skip_tag || (ap->number != A_DESC)) {
00214 notify_printf(player, "\033[1m%s:\033[0m %s", ap->name, text);
00215 } else {
00216 notify_printf(player, "%s", text);
00217 }
00218 }
00219
00220 static void look_atrs1(dbref player, dbref thing, dbref othing,
00221 int check_exclude, int hash_insert)
00222 {
00223 dbref aowner;
00224 int ca, aflags;
00225 ATTR *attr, *cattr;
00226 char *as, *buf;
00227
00228 cattr = (ATTR *) malloc(sizeof(ATTR));
00229 for(ca = atr_head(thing, &as); ca; ca = atr_next(&as)) {
00230 if((ca == A_DESC) || (ca == A_LOCK))
00231 continue;
00232 attr = atr_num(ca);
00233 if(!attr)
00234 continue;
00235
00236 bcopy((char *) attr, (char *) cattr, sizeof(ATTR));
00237
00238
00239
00240
00241
00242 if(check_exclude && ((attr->flags & AF_PRIVATE) ||
00243 nhashfind(ca, &mudstate.parent_htab)))
00244 continue;
00245
00246 buf = atr_get(thing, ca, &aowner, &aflags);
00247 if(Read_attr(player, othing, attr, aowner, aflags)) {
00248
00249
00250 if(attr->number != cattr->number)
00251 bcopy((char *) cattr, (char *) attr, sizeof(ATTR));
00252
00253 if(!(check_exclude && (aflags & AF_PRIVATE))) {
00254 if(hash_insert)
00255 nhashadd(ca, (int *) attr, &mudstate.parent_htab);
00256 view_atr(player, thing, attr, buf, aowner, aflags, 0);
00257 }
00258 }
00259 free_lbuf(buf);
00260 }
00261 free(cattr);
00262 }
00263
00264 static void look_atrs(dbref player, dbref thing, int check_parents)
00265 {
00266 dbref parent;
00267 int lev, check_exclude, hash_insert;
00268
00269 if(!check_parents) {
00270 look_atrs1(player, thing, thing, 0, 0);
00271 } else {
00272 hash_insert = 1;
00273 check_exclude = 0;
00274 nhashflush(&mudstate.parent_htab, 0);
00275 ITER_PARENTS(thing, parent, lev) {
00276 if(!Good_obj(Parent(parent)))
00277 hash_insert = 0;
00278 look_atrs1(player, parent, thing, check_exclude, hash_insert);
00279 check_exclude = 1;
00280 }
00281 }
00282 }
00283
00284 static void look_simple(dbref player, dbref thing, int obey_terse)
00285 {
00286 int pattr;
00287 char *buff;
00288
00289
00290
00291
00292
00293 if(!Hearer(player))
00294 return;
00295
00296
00297
00298
00299
00300 if(Examinable(player, thing)) {
00301 buff = unparse_object(player, thing, 1);
00302 notify(player, buff);
00303 free_lbuf(buff);
00304
00305 }
00306 pattr = (obey_terse && Terse(player)) ? 0 : A_DESC;
00307 did_it(player, thing, pattr, "You see nothing special.", A_ODESC, NULL,
00308 A_ADESC, (char **) NULL, 0);
00309
00310 if(!mudconf.quiet_look && (!Terse(player) || mudconf.terse_look)) {
00311 look_atrs(player, thing, 0);
00312 }
00313 }
00314
00315 static void show_a_desc(dbref player, dbref loc)
00316 {
00317 char *got2;
00318 dbref aowner;
00319 int aflags, indent = 0;
00320
00321 indent = (isRoom(loc) && mudconf.indent_desc && atr_get_raw(loc, A_DESC));
00322
00323 if(indent)
00324 raw_notify_newline(player);
00325 did_it(player, loc, A_DESC, NULL, A_ODESC, NULL, A_ADESC,
00326 (char **) NULL, 0);
00327 if(indent)
00328 raw_notify_newline(player);
00329
00330 }
00331
00332 static void show_desc(dbref player, dbref loc, int key)
00333 {
00334 char *got;
00335 dbref aowner;
00336 int aflags;
00337
00338 if((key & LK_OBEYTERSE) && Terse(player))
00339 did_it(player, loc, 0, NULL, A_ODESC, NULL, A_ADESC,
00340 (char **) NULL, 0);
00341 else if((Typeof(loc) != TYPE_ROOM) && (key & LK_IDESC)) {
00342 if(*(got = atr_pget(loc, A_IDESC, &aowner, &aflags)))
00343 did_it(player, loc, A_IDESC, NULL, A_ODESC, NULL, A_ADESC,
00344 (char **) NULL, 0);
00345 else
00346 show_a_desc(player, loc);
00347 free_lbuf(got);
00348 } else {
00349 show_a_desc(player, loc);
00350 }
00351 }
00352
00353 void look_in(dbref player, dbref loc, int key)
00354 {
00355 int pattr, oattr, aattr, is_terse, showkey;
00356 char *buff;
00357
00358 is_terse = (key & LK_OBEYTERSE) ? Terse(player) : 0;
00359
00360
00361
00362
00363
00364 if(!Hearer(player))
00365 return;
00366
00367
00368
00369
00370
00371 buff = unparse_object(player, loc, 1);
00372 notify(player, buff);
00373 free_lbuf(buff);
00374
00375 if(!Good_obj(loc))
00376 return;
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386 showkey = 0;
00387 if(loc == Location(player))
00388 showkey |= LK_IDESC;
00389 if(key & LK_OBEYTERSE)
00390 showkey |= LK_OBEYTERSE;
00391 show_desc(player, loc, showkey);
00392
00393
00394
00395
00396
00397 if(Typeof(loc) == TYPE_ROOM) {
00398 if(could_doit(player, loc, A_LOCK)) {
00399 pattr = A_SUCC;
00400 oattr = A_OSUCC;
00401 aattr = A_ASUCC;
00402 } else {
00403 pattr = A_FAIL;
00404 oattr = A_OFAIL;
00405 aattr = A_AFAIL;
00406 }
00407 if(is_terse)
00408 pattr = 0;
00409 did_it(player, loc, pattr, NULL, oattr, NULL, aattr,
00410 (char **) NULL, 0);
00411 }
00412
00413
00414
00415
00416 if((key & LK_SHOWATTR) && !mudconf.quiet_look && !is_terse)
00417 look_atrs(player, loc, 0);
00418 if(!is_terse || mudconf.terse_contents)
00419 look_contents(player, loc, "Contents:", CONTENTS_LOCAL);
00420 if((key & LK_SHOWEXIT) && (!is_terse || mudconf.terse_exits))
00421 look_exits(player, loc, "Obvious exits:");
00422 }
00423
00424 void do_look(dbref player, dbref cause, int key, char *name)
00425 {
00426 dbref thing, loc, look_key;
00427
00428 look_key = LK_SHOWATTR | LK_SHOWEXIT;
00429 if(!mudconf.terse_look)
00430 look_key |= LK_OBEYTERSE;
00431
00432 loc = Location(player);
00433 if(!name || !*name) {
00434 thing = loc;
00435 if(Good_obj(thing)) {
00436 if(key & LOOK_OUTSIDE) {
00437 if((Typeof(thing) == TYPE_ROOM) || Opaque(thing)) {
00438 notify_quiet(player, "You can't look outside.");
00439 return;
00440 }
00441 thing = Location(thing);
00442 }
00443 look_in(player, thing, look_key);
00444 }
00445 return;
00446 }
00447
00448
00449
00450
00451 thing = (key & LOOK_OUTSIDE) ? loc : player;
00452 init_match(thing, name, NOTYPE);
00453 match_exit_with_parents();
00454 match_neighbor();
00455 match_possession();
00456 if(Long_Fingers(player)) {
00457 match_absolute();
00458 match_player();
00459 }
00460 match_here();
00461 match_me();
00462 match_master_exit();
00463 thing = match_result();
00464
00465
00466
00467
00468
00469 if(!Good_obj(thing)) {
00470 thing =
00471 match_status(player, match_possessed(player,
00472 ((key & LOOK_OUTSIDE) ? loc :
00473 player), (char *) name,
00474 thing, 0));
00475 }
00476
00477
00478
00479
00480 if(Good_obj(thing)) {
00481 switch (Typeof(thing)) {
00482 case TYPE_ROOM:
00483 look_in(player, thing, look_key);
00484 break;
00485 case TYPE_THING:
00486 case TYPE_PLAYER:
00487 look_simple(player, thing, !mudconf.terse_look);
00488 if(!Opaque(thing) && (!Terse(player) || mudconf.terse_contents)) {
00489 look_contents(player, thing, "Carrying:", CONTENTS_NESTED);
00490 }
00491 break;
00492 case TYPE_EXIT:
00493 look_simple(player, thing, !mudconf.terse_look);
00494 if(Transparent(thing) && (Location(thing) != NOTHING)) {
00495 look_key &= ~LK_SHOWATTR;
00496 look_in(player, Location(thing), look_key);
00497 }
00498 break;
00499 default:
00500 look_simple(player, thing, !mudconf.terse_look);
00501 }
00502 }
00503 }
00504
00505 static void debug_examine(dbref player, dbref thing)
00506 {
00507 dbref aowner;
00508 char *buf;
00509 int aflags, ca;
00510 BOOLEXP *bool;
00511 ATTR *attr;
00512 char *as, *cp;
00513
00514 notify_printf(player, "Number = %d", thing);
00515 if(!Good_obj(thing))
00516 return;
00517
00518 notify_printf(player, "Name = %s", Name(thing));
00519 notify_printf(player, "Location= %d", Location(thing));
00520 notify_printf(player, "Contents= %d", Contents(thing));
00521 notify_printf(player, "Exits = %d", Exits(thing));
00522 notify_printf(player, "Link = %d", Link(thing));
00523 notify_printf(player, "Next = %d", Next(thing));
00524 notify_printf(player, "Owner = %d", Owner(thing));
00525 notify_printf(player, "Pennies = %d", Pennies(thing));
00526 notify_printf(player, "Zone = %d", Zone(thing));
00527 buf = flag_description(player, thing);
00528 notify_printf(player, "Flags = %s", buf);
00529 free_mbuf(buf);
00530 buf = power_description(player, thing);
00531 notify_printf(player, "Powers = %s", buf);
00532 free_mbuf(buf);
00533 buf = atr_get(thing, A_LOCK, &aowner, &aflags);
00534 bool = parse_boolexp(player, buf, 1);
00535 free_lbuf(buf);
00536 notify_printf(player, "Lock = %s", unparse_boolexp(player, bool));
00537 free_boolexp(bool);
00538
00539 buf = alloc_lbuf("debug_dexamine");
00540 cp = buf;
00541 safe_str((char *) "Attr list: ", buf, &cp);
00542
00543 for(ca = atr_head(thing, &as); ca; ca = atr_next(&as)) {
00544 attr = atr_num(ca);
00545 if(!attr)
00546 continue;
00547
00548 atr_get_info(thing, ca, &aowner, &aflags);
00549 if(Read_attr(player, thing, attr, aowner, aflags)) {
00550 if(attr) {
00551
00552
00553 safe_str((char *) attr->name, buf, &cp);
00554 safe_chr(' ', buf, &cp);
00555 } else {
00556 safe_str(tprintf("%d ", ca), buf, &cp);
00557 }
00558 }
00559 }
00560 *cp = '\0';
00561 notify(player, buf);
00562 free_lbuf(buf);
00563
00564 for(ca = atr_head(thing, &as); ca; ca = atr_next(&as)) {
00565 attr = atr_num(ca);
00566 if(!attr)
00567 continue;
00568
00569 buf = atr_get(thing, ca, &aowner, &aflags);
00570 if(Read_attr(player, thing, attr, aowner, aflags))
00571 view_atr(player, thing, attr, buf, aowner, aflags, 0);
00572 free_lbuf(buf);
00573 }
00574 }
00575
00576 static void exam_wildattrs(dbref player, dbref thing, int do_parent)
00577 {
00578 int atr, aflags, got_any;
00579 char *buf;
00580 dbref aowner;
00581 ATTR *ap;
00582
00583 got_any = 0;
00584 for(atr = olist_first(); atr != NOTHING; atr = olist_next()) {
00585 ap = atr_num(atr);
00586 if(!ap)
00587 continue;
00588
00589 if(do_parent && !(ap->flags & AF_PRIVATE))
00590 buf = atr_pget(thing, atr, &aowner, &aflags);
00591 else
00592 buf = atr_get(thing, atr, &aowner, &aflags);
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604 if(Examinable(player, thing) &&
00605 Read_attr(player, thing, ap, aowner, aflags)) {
00606 got_any = 1;
00607 view_atr(player, thing, ap, buf, aowner, aflags, 0);
00608 } else if((Typeof(thing) == TYPE_PLAYER) &&
00609 Read_attr(player, thing, ap, aowner, aflags)) {
00610 got_any = 1;
00611 if(aowner == Owner(player)) {
00612 view_atr(player, thing, ap, buf, aowner, aflags, 0);
00613 } else if((atr == A_DESC) && (mudconf.read_rem_desc ||
00614 nearby(player, thing))) {
00615 show_desc(player, thing, 0);
00616 } else if(atr != A_DESC) {
00617 view_atr(player, thing, ap, buf, aowner, aflags, 0);
00618 } else {
00619 notify(player, "<Too far away to get a good look>");
00620 }
00621 } else if(Read_attr(player, thing, ap, aowner, aflags)) {
00622 got_any = 1;
00623 if(aowner == Owner(player)) {
00624 view_atr(player, thing, ap, buf, aowner, aflags, 0);
00625 } else if((atr == A_DESC) && (mudconf.read_rem_desc ||
00626 nearby(player, thing))) {
00627 show_desc(player, thing, 0);
00628 } else if(nearby(player, thing)) {
00629 view_atr(player, thing, ap, buf, aowner, aflags, 0);
00630 } else {
00631 notify(player, "<Too far away to get a good look>");
00632 }
00633 }
00634 free_lbuf(buf);
00635 }
00636 if(!got_any)
00637 notify_quiet(player, "No matching attributes found.");
00638
00639 }
00640
00641 void do_examine(dbref player, dbref cause, int key, char *name)
00642 {
00643 dbref thing, content, exit, aowner, loc;
00644 char savec;
00645 char *temp, *buf, *buf2;
00646 BOOLEXP *bool;
00647 int control, aflags, do_parent;
00648
00649
00650
00651
00652
00653 if(!Hearer(player))
00654 return;
00655
00656 do_parent = key & EXAM_PARENT;
00657 thing = NOTHING;
00658 if(!name || !*name) {
00659 if((thing = Location(player)) == NOTHING)
00660 return;
00661 } else {
00662
00663
00664
00665 olist_push();
00666 if(parse_attrib_wild(player, name, &thing, do_parent, 1, 0)) {
00667 exam_wildattrs(player, thing, do_parent);
00668 olist_pop();
00669 return;
00670 }
00671 olist_pop();
00672
00673
00674
00675 init_match(player, name, NOTYPE);
00676 match_everything(MAT_EXIT_PARENTS);
00677 thing = noisy_match_result();
00678 if(!Good_obj(thing))
00679 return;
00680 }
00681
00682
00683
00684
00685
00686 if(key == EXAM_DEBUG) {
00687 if(!Examinable(player, thing)) {
00688 notify_quiet(player, "Permission denied.");
00689 } else {
00690 debug_examine(player, thing);
00691 }
00692 return;
00693 }
00694 control = (Examinable(player, thing) || Link_exit(player, thing));
00695
00696 if(control) {
00697 buf2 = unparse_object(player, thing, 0);
00698 notify(player, buf2);
00699 free_lbuf(buf2);
00700 if(mudconf.ex_flags) {
00701 buf2 = flag_description(player, thing);
00702 notify(player, buf2);
00703 free_mbuf(buf2);
00704 }
00705 } else {
00706 if((key == EXAM_DEFAULT) && !mudconf.exam_public) {
00707 if(mudconf.read_rem_name) {
00708 buf2 = alloc_lbuf("do_examine.pub_name");
00709 StringCopy(buf2, Name(thing));
00710 notify_printf(player, "%s is owned by %s", buf2,
00711 Name(Owner(thing)));
00712 free_lbuf(buf2);
00713 } else {
00714 notify_printf(player, "Owned by %s", Name(Owner(thing)));
00715 }
00716 return;
00717 }
00718 }
00719
00720 temp = alloc_lbuf("do_examine.info");
00721
00722 if(control || mudconf.read_rem_desc || nearby(player, thing)) {
00723 temp = atr_get_str(temp, thing, A_DESC, &aowner, &aflags);
00724 if(*temp) {
00725 if(Examinable(player, thing) || (aowner == Owner(player))) {
00726 view_atr(player, thing, atr_num(A_DESC), temp, aowner,
00727 aflags, 1);
00728 } else {
00729 show_desc(player, thing, 0);
00730 }
00731 }
00732 } else {
00733 notify(player, "<Too far away to get a good look>");
00734 }
00735
00736 if(control) {
00737
00738
00739
00740
00741
00742 savec = mudconf.many_coins[0];
00743 mudconf.many_coins[0] = (islower(savec) ? toupper(savec) : savec);
00744 buf2 = atr_get(thing, A_LOCK, &aowner, &aflags);
00745 bool = parse_boolexp(player, buf2, 1);
00746 buf = unparse_boolexp(player, bool);
00747 free_boolexp(bool);
00748 StringCopy(buf2, Name(Owner(thing)));
00749 notify_printf(player, "Owner: %s Key: %s %s: %d", buf2, buf,
00750 mudconf.many_coins, Pennies(thing));
00751 free_lbuf(buf2);
00752 mudconf.many_coins[0] = savec;
00753
00754 if(mudconf.have_zones) {
00755 buf2 = unparse_object(player, Zone(thing), 0);
00756 notify_printf(player, "Zone: %s", buf2);
00757 free_lbuf(buf2);
00758 }
00759
00760
00761
00762
00763 loc = Parent(thing);
00764 if(loc != NOTHING) {
00765 buf2 = unparse_object(player, loc, 0);
00766 notify_printf(player, "Parent: %s", buf2);
00767 free_lbuf(buf2);
00768 }
00769 buf2 = power_description(player, thing);
00770 notify(player, buf2);
00771 free_mbuf(buf2);
00772
00773 }
00774 if(key != EXAM_BRIEF)
00775 look_atrs(player, thing, do_parent);
00776
00777
00778
00779
00780
00781 if(control) {
00782
00783
00784
00785
00786
00787 if(Contents(thing) != NOTHING) {
00788 notify(player, "Contents:");
00789 DOLIST(content, Contents(thing)) {
00790 buf2 = unparse_object(player, content, 0);
00791 notify(player, buf2);
00792 free_lbuf(buf2);
00793 }
00794 }
00795
00796
00797
00798
00799 switch (Typeof(thing)) {
00800 case TYPE_ROOM:
00801
00802
00803
00804
00805
00806 if(Exits(thing) != NOTHING) {
00807 notify(player, "Exits:");
00808 DOLIST(exit, Exits(thing)) {
00809 buf2 = unparse_object(player, exit, 0);
00810 notify(player, buf2);
00811 free_lbuf(buf2);
00812 }
00813 } else {
00814 notify(player, "No exits.");
00815 }
00816
00817
00818
00819
00820
00821 if(Dropto(thing) != NOTHING) {
00822 buf2 = unparse_object(player, Dropto(thing), 0);
00823 notify_printf(player, "Dropped objects go to: %s", buf2);
00824 free_lbuf(buf2);
00825 }
00826 break;
00827 case TYPE_THING:
00828 case TYPE_PLAYER:
00829
00830
00831
00832
00833
00834 if(Exits(thing) != NOTHING) {
00835 notify(player, "Exits:");
00836 DOLIST(exit, Exits(thing)) {
00837 buf2 = unparse_object(player, exit, 0);
00838 notify(player, buf2);
00839 free_lbuf(buf2);
00840 }
00841 } else {
00842 notify(player, "No exits.");
00843 }
00844
00845
00846
00847
00848
00849 loc = Home(thing);
00850 buf2 = unparse_object(player, loc, 0);
00851 notify_printf(player, "Home: %s", buf2);
00852 free_lbuf(buf2);
00853
00854
00855
00856
00857
00858 loc = Location(thing);
00859 if((Location(thing) != NOTHING) && (Examinable(player, loc) ||
00860 Examinable(player, thing)
00861 || Linkable(player, loc))) {
00862 buf2 = unparse_object(player, loc, 0);
00863 notify_printf(player, "Location: %s", buf2);
00864 free_lbuf(buf2);
00865 }
00866 break;
00867 case TYPE_EXIT:
00868 buf2 = unparse_object(player, Exits(thing), 0);
00869 notify_printf(player, "Source: %s", buf2);
00870 free_lbuf(buf2);
00871
00872
00873
00874
00875
00876 switch (Location(thing)) {
00877 case NOTHING:
00878 break;
00879 case HOME:
00880 notify(player, "Destination: *HOME*");
00881 break;
00882 default:
00883 buf2 = unparse_object(player, Location(thing), 0);
00884 notify_printf(player, "Destination: %s", buf2);
00885 free_lbuf(buf2);
00886 break;
00887 }
00888 break;
00889 default:
00890 break;
00891 }
00892 } else if(!Opaque(thing) && nearby(player, thing)) {
00893 if(Has_contents(thing))
00894 look_contents(player, thing, "Contents:", CONTENTS_REMOTE);
00895 if(Typeof(thing) != TYPE_EXIT)
00896 look_exits(player, thing, "Obvious exits:");
00897 }
00898 free_lbuf(temp);
00899
00900 if(!control) {
00901 if(mudconf.read_rem_name) {
00902 buf2 = alloc_lbuf("do_examine.pub_name");
00903 StringCopy(buf2, Name(thing));
00904 notify_printf(player, "%s is owned by %s", buf2,
00905 Name(Owner(thing)));
00906 free_lbuf(buf2);
00907 } else {
00908 notify_printf(player, "Owned by %s", Name(Owner(thing)));
00909 }
00910 }
00911 }
00912
00913 void do_score(dbref player, dbref cause, int key)
00914 {
00915 notify_printf(player, "You have %d %s.", Pennies(player),
00916 (Pennies(player) ==
00917 1) ? mudconf.one_coin : mudconf.many_coins);
00918 }
00919
00920 void do_inventory(dbref player, dbref cause, int key)
00921 {
00922 dbref thing;
00923 char *buff, *s, *e;
00924
00925 thing = Contents(player);
00926 if(thing == NOTHING) {
00927 notify(player, "You aren't carrying anything.");
00928 } else {
00929 notify(player, "You are carrying:");
00930 DOLIST(thing, thing) {
00931 buff = unparse_object(player, thing, 1);
00932 notify(player, buff);
00933 free_lbuf(buff);
00934 }
00935 }
00936
00937 thing = Exits(player);
00938 if(thing != NOTHING) {
00939 notify(player, "Exits:");
00940 e = buff = alloc_lbuf("look_exits");
00941 DOLIST(thing, thing) {
00942
00943
00944
00945 for(s = Name(thing); *s && (*s != ';'); s++)
00946 safe_chr(*s, buff, &e);
00947 safe_str((char *) " ", buff, &e);
00948 }
00949 *e = 0;
00950 notify(player, buff);
00951 free_lbuf(buff);
00952 }
00953 do_score(player, player, 0);
00954 }
00955
00956 void do_entrances(dbref player, dbref cause, int key, char *name)
00957 {
00958 dbref thing, i, j;
00959 char *exit, *message;
00960 int control_thing, count, low_bound, high_bound;
00961 FWDLIST *fp;
00962
00963 parse_range(&name, &low_bound, &high_bound);
00964 if(!name || !*name) {
00965 if(Has_location(player))
00966 thing = Location(player);
00967 else
00968 thing = player;
00969 if(!Good_obj(thing))
00970 return;
00971 } else {
00972 init_match(player, name, NOTYPE);
00973 match_everything(MAT_EXIT_PARENTS);
00974 thing = noisy_match_result();
00975 if(!Good_obj(thing))
00976 return;
00977 }
00978
00979 if(!payfor(player, mudconf.searchcost)) {
00980 notify_printf(player, "You don't have enough %s.",
00981 mudconf.many_coins);
00982 return;
00983 }
00984 message = alloc_lbuf("do_entrances");
00985 control_thing = Examinable(player, thing);
00986 count = 0;
00987 for(i = low_bound; i <= high_bound; i++) {
00988 if(control_thing || Examinable(player, i)) {
00989 switch (Typeof(i)) {
00990 case TYPE_EXIT:
00991 if(Location(i) == thing) {
00992 exit = unparse_object(player, Exits(i), 0);
00993 notify_printf(player, "%s (%s)", exit, Name(i));
00994 free_lbuf(exit);
00995 count++;
00996 }
00997 break;
00998 case TYPE_ROOM:
00999 if(Dropto(i) == thing) {
01000 exit = unparse_object(player, i, 0);
01001 notify_printf(player, "%s [dropto]", exit);
01002 free_lbuf(exit);
01003 count++;
01004 }
01005 break;
01006 case TYPE_THING:
01007 case TYPE_PLAYER:
01008 if(Home(i) == thing) {
01009 exit = unparse_object(player, i, 0);
01010 notify_printf(player, "%s [home]", exit);
01011 free_lbuf(exit);
01012 count++;
01013 }
01014 break;
01015 }
01016
01017
01018
01019
01020
01021 if(Parent(i) == thing) {
01022 exit = unparse_object(player, i, 0);
01023 notify_printf(player, "%s [parent]", exit);
01024 free_lbuf(exit);
01025 count++;
01026 }
01027
01028
01029
01030
01031 if(H_Fwdlist(i)) {
01032 fp = fwdlist_get(i);
01033 if(!fp)
01034 continue;
01035 for(j = 0; j < fp->count; j++) {
01036 if(fp->data[j] != thing)
01037 continue;
01038 exit = unparse_object(player, i, 0);
01039 notify_printf(player, "%s [forward]", exit);
01040 free_lbuf(exit);
01041 count++;
01042 }
01043 }
01044 }
01045 }
01046 free_lbuf(message);
01047 notify_printf(player, "%d entrance%s found.", count,
01048 (count == 1) ? "" : "s");
01049 }
01050
01051
01052
01053
01054
01055 static void sweep_check(dbref player, dbref what, int key, int is_loc)
01056 {
01057 dbref aowner, parent;
01058 int canhear, cancom, isplayer, ispuppet, isconnected, attr, aflags;
01059 int is_parent, lev;
01060 char *buf, *buf2, *bp, *as, *buff, *s;
01061 ATTR *ap;
01062
01063 if(Dark(what) && !WizRoy(player) && !mudconf.sweep_dark)
01064 return;
01065 canhear = 0;
01066 cancom = 0;
01067 isplayer = 0;
01068 ispuppet = 0;
01069 isconnected = 0;
01070 is_parent = 0;
01071
01072 if((key & SWEEP_LISTEN) && (((Typeof(what) == TYPE_EXIT) || is_loc) &&
01073 Audible(what))) {
01074 canhear = 1;
01075 } else if(key & SWEEP_LISTEN) {
01076 if(Monitor(what))
01077 buff = alloc_lbuf("Hearer");
01078 else
01079 buff = NULL;
01080
01081 for(attr = atr_head(what, &as); attr; attr = atr_next(&as)) {
01082 if(attr == A_LISTEN) {
01083 canhear = 1;
01084 break;
01085 }
01086 if(Monitor(what)) {
01087 ap = atr_num(attr);
01088 if(!ap || (ap->flags & AF_NOPROG))
01089 continue;
01090
01091 atr_get_str(buff, what, attr, &aowner, &aflags);
01092
01093
01094
01095
01096
01097 if((buff[0] != AMATCH_LISTEN) || (aflags & AF_NOPROG))
01098 continue;
01099
01100
01101
01102
01103
01104 for(s = buff + 1; *s && (*s != ':'); s++);
01105 if(s) {
01106 canhear = 1;
01107 break;
01108 }
01109 }
01110 }
01111 if(buff)
01112 free_lbuf(buff);
01113 }
01114 if((key & SWEEP_COMMANDS) && (Typeof(what) != TYPE_EXIT)) {
01115
01116
01117
01118
01119
01120 ITER_PARENTS(what, parent, lev) {
01121 if(Commer(parent)) {
01122 cancom = 1;
01123 if(lev) {
01124 is_parent = 1;
01125 break;
01126 }
01127 }
01128 }
01129 }
01130 if(key & SWEEP_CONNECT) {
01131 if(Connected(what) || (Puppet(what) && Connected(Owner(what))) ||
01132 (mudconf.player_listen && (Typeof(what) == TYPE_PLAYER) &&
01133 canhear && Connected(Owner(what))))
01134 isconnected = 1;
01135 }
01136 if(key & SWEEP_PLAYER || isconnected) {
01137 if(Typeof(what) == TYPE_PLAYER)
01138 isplayer = 1;
01139 if(Puppet(what))
01140 ispuppet = 1;
01141 }
01142 if(canhear || cancom || isplayer || ispuppet || isconnected) {
01143 buf = alloc_lbuf("sweep_check.types");
01144 bp = buf;
01145
01146 if(cancom)
01147 safe_str((char *) "commands ", buf, &bp);
01148 if(canhear)
01149 safe_str((char *) "messages ", buf, &bp);
01150 if(isplayer)
01151 safe_str((char *) "player ", buf, &bp);
01152 if(ispuppet) {
01153 safe_str((char *) "puppet(", buf, &bp);
01154 safe_str(Name(Owner(what)), buf, &bp);
01155 safe_str((char *) ") ", buf, &bp);
01156 }
01157 if(isconnected)
01158 safe_str((char *) "connected ", buf, &bp);
01159 if(is_parent)
01160 safe_str((char *) "parent ", buf, &bp);
01161 bp[-1] = '\0';
01162 if(Typeof(what) != TYPE_EXIT) {
01163 notify_printf(player, " %s is listening. [%s]", Name(what), buf);
01164 } else {
01165 buf2 = alloc_lbuf("sweep_check.name");
01166 StringCopy(buf2, Name(what));
01167 for(bp = buf2; *bp && (*bp != ';'); bp++);
01168 *bp = '\0';
01169 notify_printf(player, " %s is listening. [%s]", buf2, buf);
01170 free_lbuf(buf2);
01171 }
01172 free_lbuf(buf);
01173 }
01174 }
01175
01176 void do_sweep(dbref player, dbref cause, int key, char *where)
01177 {
01178 dbref here, sweeploc;
01179 int where_key, what_key;
01180
01181 where_key = key & (SWEEP_ME | SWEEP_HERE | SWEEP_EXITS);
01182 what_key =
01183 key & (SWEEP_COMMANDS | SWEEP_LISTEN | SWEEP_PLAYER | SWEEP_CONNECT);
01184
01185 if(where && *where) {
01186 sweeploc = match_controlled(player, where);
01187 if(!Good_obj(sweeploc))
01188 return;
01189 } else {
01190 sweeploc = player;
01191 }
01192
01193 if(!where_key)
01194 where_key = -1;
01195 if(!what_key)
01196 what_key = -1;
01197 else if(what_key == SWEEP_VERBOSE)
01198 what_key = SWEEP_VERBOSE | SWEEP_COMMANDS;
01199
01200
01201
01202
01203
01204 if(where_key & SWEEP_HERE) {
01205 notify(player, "Sweeping location...");
01206 if(Has_location(sweeploc)) {
01207 here = Location(sweeploc);
01208 if((here == NOTHING) || (Dark(here) && !mudconf.sweep_dark &&
01209 !Examinable(player, here))) {
01210 notify_quiet(player,
01211 "Sorry, it is dark here and you can't search for bugs");
01212 sweep_check(player, sweeploc, what_key, 0);
01213 } else {
01214 sweep_check(player, here, what_key, 1);
01215 for(here = Contents(here); here != NOTHING; here = Next(here))
01216 sweep_check(player, here, what_key, 0);
01217 }
01218 } else {
01219 sweep_check(player, sweeploc, what_key, 0);
01220 }
01221 }
01222
01223
01224
01225
01226 if((where_key & SWEEP_EXITS) && Has_location(sweeploc)) {
01227 notify(player, "Sweeping exits...");
01228 for(here = Exits(Location(sweeploc)); here != NOTHING;
01229 here = Next(here))
01230 sweep_check(player, here, what_key, 0);
01231 }
01232
01233
01234
01235
01236 if((where_key & SWEEP_ME) && Has_contents(sweeploc)) {
01237 notify(player, "Sweeping inventory...");
01238 for(here = Contents(sweeploc); here != NOTHING; here = Next(here))
01239 sweep_check(player, here, what_key, 0);
01240 }
01241
01242
01243
01244
01245 if((where_key & SWEEP_EXITS) && Has_exits(sweeploc)) {
01246 notify(player, "Sweeping carried exits...");
01247 for(here = Exits(sweeploc); here != NOTHING; here = Next(here))
01248 sweep_check(player, here, what_key, 0);
01249 }
01250 notify(player, "Sweep complete.");
01251 }
01252
01253
01254
01255
01256
01257
01258
01259 extern NAMETAB indiv_attraccess_nametab[];
01260
01261 void do_decomp(dbref player, dbref cause, int key, char *name, char *qual)
01262 {
01263 BOOLEXP *bool;
01264 char *got, *thingname, *as, *ltext, *buff, *s;
01265 dbref aowner, thing;
01266 int val, aflags, ca, atr;
01267 ATTR *attr;
01268 NAMETAB *np;
01269 char new[LBUF_SIZE];
01270
01271
01272
01273 olist_push();
01274 if(parse_attrib_wild(player, name, &thing, 0, 1, 0)) {
01275 buff = alloc_mbuf("do_decomp.attr_name");
01276 thingname = alloc_lbuf("do_decomp");
01277 if(key & DECOMP_DBREF) {
01278 sprintf(thingname, "%d", (int) thing);
01279 } else {
01280 StringCopy(thingname, Name(thing));
01281 }
01282 strncpy(new, thingname, LBUF_SIZE-1);
01283 for(atr = olist_first(); atr != NOTHING; atr = olist_next()) {
01284 if((atr == A_NAME || atr == A_LOCK))
01285 continue;
01286 attr = atr_num(atr);
01287 if(!attr)
01288 continue;
01289
01290 got = atr_get(thing, atr, &aowner, &aflags);
01291 if(Read_attr(player, thing, attr, aowner, aflags)) {
01292 if(attr->flags & AF_IS_LOCK) {
01293 bool = parse_boolexp(player, got, 1);
01294 ltext = unparse_boolexp_decompile(player, bool);
01295 free_boolexp(bool);
01296 notify_printf(player, "@lock/%s %s=%s", attr->name,
01297 strip_ansi_r(new,thingname,strlen(thingname)), ltext);
01298 } else {
01299 StringCopy(buff, attr->name);
01300 for(s = thingname; *s; s++) {
01301 if(*s == EXIT_DELIMITER) {
01302 *s = '\0';
01303 break;
01304 }
01305 }
01306 notify_printf(player, "%c%s %s=%s",
01307 ((atr < A_USER_START) ? '@' : '&'), buff,
01308 strip_ansi_r(new,thingname,strlen(thingname)), got);
01309
01310 if(aflags & AF_LOCK) {
01311 notify_printf(player, "@lock %s/%s",
01312 strip_ansi_r(new,thingname,strlen(thingname)), buff);
01313 }
01314
01315 for(np = indiv_attraccess_nametab; np->name; np++) {
01316
01317 if((aflags & np->flag) &&
01318 check_access(player, np->perm) &&
01319 (!(np->perm & CA_NO_DECOMP))) {
01320
01321 notify_printf(player, "@set %s/%s = %s",
01322 strip_ansi_r(new,thingname,strlen(thingname)), buff,
01323 np->name);
01324 }
01325 }
01326 }
01327 }
01328 free_lbuf(got);
01329 }
01330 free_mbuf(buff);
01331 free_lbuf(thingname);
01332 olist_pop();
01333 return;
01334 }
01335 olist_pop();
01336
01337 init_match(player, name, TYPE_THING);
01338 match_everything(MAT_EXIT_PARENTS);
01339 thing = noisy_match_result();
01340
01341
01342
01343
01344 if(thing == NOTHING)
01345 return;
01346
01347 if(!Examinable(player, thing)) {
01348 notify_quiet(player,
01349 "You can only decompile things you can examine.");
01350 return;
01351 }
01352 thingname = atr_get(thing, A_LOCK, &aowner, &aflags);
01353 bool = parse_boolexp(player, thingname, 1);
01354
01355
01356
01357
01358
01359
01360 if(qual && *qual) {
01361 StringCopy(thingname, qual);
01362 } else {
01363 switch (Typeof(thing)) {
01364 case TYPE_THING:
01365 StringCopy(thingname, Name(thing));
01366 val = OBJECT_DEPOSIT(Pennies(thing));
01367 notify_printf(player, "@create %s=%d",
01368 translate_string(thingname, 1), val);
01369 break;
01370 case TYPE_ROOM:
01371 StringCopy(thingname, "here");
01372 notify_printf(player, "@dig/teleport %s",
01373 translate_string(Name(thing), 1));
01374 break;
01375 case TYPE_EXIT:
01376 StringCopy(thingname, Name(thing));
01377 notify_printf(player, "@open %s",
01378 translate_string(Name(thing), 1));
01379 for(got = thingname; *got; got++) {
01380 if(*got == EXIT_DELIMITER) {
01381 *got = '\0';
01382 break;
01383 }
01384 }
01385 break;
01386 case TYPE_PLAYER:
01387 StringCopy(thingname, "me");
01388 break;
01389 }
01390 }
01391
01392
01393
01394
01395
01396 strncpy(new, thingname, LBUF_SIZE-1);
01397 if(bool != TRUE_BOOLEXP) {
01398 notify_printf(player, "@lock %s=%s", strip_ansi_r(new,thingname,strlen(thingname)),
01399 unparse_boolexp_decompile(player, bool));
01400 }
01401 free_boolexp(bool);
01402
01403
01404
01405
01406
01407 buff = alloc_mbuf("do_decomp.attr_name");
01408 for(ca = atr_head(thing, &as); ca; ca = atr_next(&as)) {
01409 if((ca == A_NAME) || (ca == A_LOCK))
01410 continue;
01411 attr = atr_num(ca);
01412 if(!attr)
01413 continue;
01414 if((attr->flags & AF_NOCMD) && !(attr->flags & AF_IS_LOCK))
01415 continue;
01416
01417 got = atr_get(thing, ca, &aowner, &aflags);
01418 if(Read_attr(player, thing, attr, aowner, aflags)) {
01419 if(attr->flags & AF_IS_LOCK) {
01420 bool = parse_boolexp(player, got, 1);
01421 ltext = unparse_boolexp_decompile(player, bool);
01422 free_boolexp(bool);
01423 notify_printf(player, "@lock/%s %s=%s", attr->name,
01424 thingname, ltext);
01425 } else {
01426 StringCopy(buff, attr->name);
01427 notify_printf(player, "%c%s %s=%s",
01428 ((ca < A_USER_START) ? '@' : '&'), buff,
01429 strip_ansi_r(new,thingname,strlen(thingname)), got);
01430
01431 if(aflags & AF_LOCK) {
01432 notify_printf(player, "@lock %s/%s",
01433 strip_ansi_r(new,thingname,strlen(thingname)), buff);
01434 }
01435 for(np = indiv_attraccess_nametab; np->name; np++) {
01436
01437 if((aflags & np->flag) &&
01438 check_access(player, np->perm) &&
01439 (!(np->perm & CA_NO_DECOMP))) {
01440
01441 notify_printf(player, "@set %s/%s = %s",
01442 strip_ansi_r(new,thingname,strlen(thingname)), buff, np->name);
01443 }
01444 }
01445 }
01446 }
01447 free_lbuf(got);
01448 }
01449 free_mbuf(buff);
01450
01451 decompile_flags(player, thing, thingname);
01452 decompile_powers(player, thing, thingname);
01453
01454
01455
01456
01457
01458 if(Parent(thing) != NOTHING)
01459 notify_printf(player, "@parent %s=#%d", strip_ansi_r(new,thingname,strlen(thingname)),
01460 Parent(thing));
01461
01462
01463
01464
01465 if(Zone(thing) != NOTHING)
01466 notify_printf(player, "@chzone %s=#%d", strip_ansi_r(new,thingname,strlen(thingname)),
01467 Zone(thing));
01468
01469 free_lbuf(thingname);
01470 }
01471