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 "alloc.h"
00018
00019 extern char *next_token(char *, char);
00020 extern int In_IC_Loc(dbref);
00021
00022 int sp_ok(dbref player)
00023 {
00024 if(Gagged(player) && (!(Wizard(player)))) {
00025 notify(player, "Sorry. Gagged players cannot speak.");
00026 return 0;
00027 }
00028
00029 if(!mudconf.robot_speak) {
00030 if(Robot(player) && !controls(player, Location(player))) {
00031 notify(player, "Sorry robots may not speak in public.");
00032 return 0;
00033 }
00034 }
00035 if(Auditorium(Location(player))) {
00036 if(!could_doit(player, Location(player), A_LSPEECH)) {
00037 notify(player, "Sorry, you may not speak in this place.");
00038 return 0;
00039 }
00040 }
00041 return 1;
00042 }
00043
00044 static void say_shout(int target, const char *prefix, int flags, dbref player,
00045 char *message)
00046 {
00047 if(flags & SAY_NOTAG)
00048 raw_broadcast(target, "%s%s", Name(player), message);
00049 else
00050 raw_broadcast(target, "%s%s%s", prefix, Name(player), message);
00051 }
00052
00053 static const char *announce_msg = "Announcement: ";
00054 static const char *broadcast_msg = "Broadcast: ";
00055 static const char *admin_msg = "Admin: ";
00056
00057 void do_think(dbref player, dbref cause, int key, char *message)
00058 {
00059 char *str, buf[LBUF_SIZE], *bp;
00060 int output_length;
00061
00062 bp = buf;
00063 str = message;
00064 exec(buf, &bp, 0, player, cause, EV_FCHECK | EV_EVAL | EV_TOP, &str,
00065 (char **) NULL, 0);
00066 output_length = strnlen(buf, LBUF_SIZE-1);
00067 buf[output_length] = '\0';
00068 notify(player, buf);
00069 }
00070
00071 void do_say(dbref player, dbref cause, int key, char *message)
00072 {
00073 dbref loc;
00074 char *buf2, *bp;
00075 int say_flags, depth;
00076
00077
00078
00079
00080
00081 say_flags = key & (SAY_NOTAG | SAY_HERE | SAY_ROOM );
00082 key &= ~(SAY_NOTAG | SAY_HERE | SAY_ROOM );
00083
00084 if(key == SAY_PREFIX) {
00085 switch (*message++) {
00086 case '"':
00087 key = SAY_SAY;
00088 break;
00089 case ':':
00090 if(*message == ' ') {
00091 message++;
00092 key = SAY_POSE_NOSPC;
00093 } else {
00094 key = SAY_POSE;
00095 }
00096 break;
00097 case ';':
00098 key = SAY_POSE_NOSPC;
00099 break;
00100 case '\\':
00101 key = SAY_EMIT;
00102 break;
00103 default:
00104 return;
00105 }
00106 }
00107
00108
00109
00110
00111 loc = where_is(player);
00112 switch (key) {
00113 case SAY_SAY:
00114 case SAY_POSE:
00115 case SAY_POSE_NOSPC:
00116 case SAY_EMIT:
00117 if(loc == NOTHING)
00118 return;
00119 if(!sp_ok(player))
00120 return;
00121 }
00122
00123
00124
00125
00126
00127 switch (key) {
00128 case SAY_SAY:
00129 notify_printf(player, "You say \"%s\"", message);
00130 notify_except(loc, player, player, tprintf("%s says \"%s\"",
00131 Name(player), message));
00132 break;
00133 case SAY_POSE:
00134 notify_all_from_inside(loc, player, tprintf("%s %s", Name(player),
00135 message));
00136 break;
00137 case SAY_POSE_NOSPC:
00138 notify_all_from_inside(loc, player, tprintf("%s%s", Name(player),
00139 message));
00140 break;
00141 case SAY_EMIT:
00142 if((say_flags & SAY_HERE) || !say_flags) {
00143 notify_all_from_inside(loc, player, message);
00144 }
00145 if(say_flags & SAY_ROOM) {
00146 if((Typeof(loc) == TYPE_ROOM) && (say_flags & SAY_HERE)) {
00147 return;
00148 }
00149 depth = 0;
00150 while ((Typeof(loc) != TYPE_ROOM) && (depth++ < 20)) {
00151 loc = Location(loc);
00152 if((loc == NOTHING) || (loc == Location(loc)))
00153 return;
00154 }
00155 if(Typeof(loc) == TYPE_ROOM) {
00156 notify_all_from_inside(loc, player, message);
00157 }
00158 }
00159 break;
00160 case SAY_SHOUT:
00161 switch (*message) {
00162 case ':':
00163 message[0] = ' ';
00164 say_shout(0, announce_msg, say_flags, player, message);
00165 break;
00166 case ';':
00167 message++;
00168 say_shout(0, announce_msg, say_flags, player, message);
00169 break;
00170 case '"':
00171 message++;
00172 default:
00173 buf2 = alloc_lbuf("do_say.shout");
00174 bp = buf2;
00175 safe_str((char *) " shouts \"", buf2, &bp);
00176 safe_str(message, buf2, &bp);
00177 safe_chr('"', buf2, &bp);
00178 *bp = '\0';
00179 say_shout(0, announce_msg, say_flags, player, buf2);
00180 free_lbuf(buf2);
00181 }
00182 STARTLOG(LOG_SHOUTS, "WIZ", "SHOUT") {
00183 log_name(player);
00184 buf2 = alloc_lbuf("do_say.LOG.shout");
00185 sprintf(buf2, " shouts: '%s'", message);
00186 log_text(buf2);
00187 free_lbuf(buf2);
00188 ENDLOG;
00189 } break;
00190
00191 case SAY_WIZSHOUT:
00192 switch (*message) {
00193 case ':':
00194 message[0] = ' ';
00195 say_shout(WIZARD, broadcast_msg, say_flags, player, message);
00196 break;
00197 case ';':
00198 message++;
00199 say_shout(WIZARD, broadcast_msg, say_flags, player, message);
00200 break;
00201 case '"':
00202 message++;
00203 default:
00204 buf2 = alloc_lbuf("do_say.wizshout");
00205 bp = buf2;
00206 safe_str((char *) " says \"", buf2, &bp);
00207 safe_str(message, buf2, &bp);
00208 safe_chr('"', buf2, &bp);
00209 *bp = '\0';
00210 say_shout(WIZARD, broadcast_msg, say_flags, player, buf2);
00211 free_lbuf(buf2);
00212 }
00213 STARTLOG(LOG_SHOUTS, "WIZ", "BCAST") {
00214 log_name(player);
00215 buf2 = alloc_lbuf("do_say.LOG.wizshout");
00216 sprintf(buf2, " broadcasts: '%s'", message);
00217 log_text(buf2);
00218 free_lbuf(buf2);
00219 ENDLOG;
00220 } break;
00221
00222 case SAY_ADMINSHOUT:
00223 switch (*message) {
00224 case ':':
00225 message[0] = ' ';
00226 say_shout(WIZARD, admin_msg, say_flags, player, message);
00227 say_shout(ROYALTY, admin_msg, say_flags, player, message);
00228 break;
00229 case ';':
00230 message++;
00231 say_shout(WIZARD, admin_msg, say_flags, player, message);
00232 say_shout(ROYALTY, admin_msg, say_flags, player, message);
00233 break;
00234 case '"':
00235 message++;
00236 default:
00237 buf2 = alloc_lbuf("do_say.adminshout");
00238 bp = buf2;
00239 safe_str((char *) " says \"", buf2, &bp);
00240 safe_str(message, buf2, &bp);
00241 safe_chr('"', buf2, &bp);
00242 *bp = '\0';
00243 say_shout(WIZARD, admin_msg, say_flags, player, buf2);
00244 say_shout(ROYALTY, admin_msg, say_flags, player, buf2);
00245 free_lbuf(buf2);
00246 }
00247 STARTLOG(LOG_SHOUTS, "WIZ", "ASHOUT") {
00248 log_name(player);
00249 buf2 = alloc_lbuf("do_say.LOG.adminshout");
00250 sprintf(buf2, " yells: '%s'", message);
00251 log_text(buf2);
00252 free_lbuf(buf2);
00253 ENDLOG;
00254 } break;
00255
00256 case SAY_WALLPOSE:
00257 if(say_flags & SAY_NOTAG)
00258 raw_broadcast(0, "%s %s", Name(player), message);
00259 else
00260 raw_broadcast(0, "Announcement: %s %s", Name(player), message);
00261 STARTLOG(LOG_SHOUTS, "WIZ", "SHOUT") {
00262 log_name(player);
00263 buf2 = alloc_lbuf("do_say.LOG.wallpose");
00264 sprintf(buf2, " WALLposes: '%s'", message);
00265 log_text(buf2);
00266 free_lbuf(buf2);
00267 ENDLOG;
00268 }
00269 break;
00270
00271 case SAY_WIZPOSE:
00272 if(say_flags & SAY_NOTAG)
00273 raw_broadcast(WIZARD, "%s %s", Name(player), message);
00274 else
00275 raw_broadcast(WIZARD, "Broadcast: %s %s", Name(player), message);
00276 STARTLOG(LOG_SHOUTS, "WIZ", "BCAST") {
00277 log_name(player);
00278 buf2 = alloc_lbuf("do_say.LOG.wizpose");
00279 sprintf(buf2, " WIZposes: '%s'", message);
00280 log_text(buf2);
00281 free_lbuf(buf2);
00282 ENDLOG;
00283 }
00284 break;
00285
00286 case SAY_WALLEMIT:
00287 if(say_flags & SAY_NOTAG)
00288 raw_broadcast(0, "%s", message);
00289 else
00290 raw_broadcast(0, "Announcement: %s", message);
00291 STARTLOG(LOG_SHOUTS, "WIZ", "SHOUT") {
00292 log_name(player);
00293 buf2 = alloc_lbuf("do_say.LOG.wallemit");
00294 sprintf(buf2, " WALLemits: '%s'", message);
00295 log_text(buf2);
00296 free_lbuf(buf2);
00297 ENDLOG;
00298 }
00299 break;
00300
00301 case SAY_WIZEMIT:
00302 if(say_flags & SAY_NOTAG)
00303 raw_broadcast(WIZARD, "%s", message);
00304 else
00305 raw_broadcast(WIZARD, "Broadcast: %s", message);
00306 STARTLOG(LOG_SHOUTS, "WIZ", "BCAST") {
00307 log_name(player);
00308 buf2 = alloc_lbuf("do_say.LOG.wizemit");
00309 sprintf(buf2, " WIZemit: '%s'", message);
00310 log_text(buf2);
00311 free_lbuf(buf2);
00312 ENDLOG;
00313 }
00314 break;
00315 }
00316 }
00317
00318
00319
00320
00321
00322
00323
00324 static void page_return(dbref player, dbref target, const char *tag, int anum,
00325 const char *dflt)
00326 {
00327 dbref aowner;
00328 int aflags;
00329 char *str, *str2, *buf, *bp;
00330 struct tm *tp;
00331 time_t t;
00332
00333 str = atr_pget(target, anum, &aowner, &aflags);
00334 if(*str) {
00335 str2 = bp = alloc_lbuf("page_return");
00336 buf = str;
00337 exec(str2, &bp, 0, target, player,
00338 EV_FCHECK | EV_EVAL | EV_TOP | EV_NO_LOCATION, &buf,
00339 (char **) NULL, 0);
00340 *bp = '\0';
00341 if(*str2) {
00342 t = time(NULL);
00343 tp = localtime(&t);
00344 if(Wizard(target) || !In_IC_Loc(target))
00345 notify_with_cause(player, target,
00346 tprintf("%s message from %s: %s", tag,
00347 Name(target), str2));
00348 notify_with_cause(target, player,
00349 tprintf("[%d:%02d] %s message sent to %s.",
00350 tp->tm_hour, tp->tm_min, tag,
00351 Name(player)));
00352 }
00353 free_lbuf(str2);
00354 } else if(dflt && *dflt) {
00355 notify_with_cause(player, target, dflt);
00356 }
00357 free_lbuf(str);
00358 }
00359
00360 static int page_check(dbref player, dbref target)
00361 {
00362 if(!payfor(player, Guest(player) ? 0 : mudconf.pagecost)) {
00363 notify_printf(player, "You don't have enough %s.",
00364 mudconf.many_coins);
00365 return 0;
00366 }
00367 if(In_IC_Loc(player) && !Wizard(target) && !Wizard(player)) {
00368 notify(player, "Permission denied.");
00369 return 0;
00370 }
00371 if(!Connected(target)) {
00372 page_return(player, target, "Away", A_AWAY,
00373 tprintf("Sorry, %s is not connected.", Name(target)));
00374 return 0;
00375 }
00376 if(!could_doit(player, target, A_LPAGE) || (!Wizard(player) &&
00377 In_IC_Loc(target)
00378 && !Wizard(target))) {
00379 if(Wizard(target) && Dark(target))
00380 page_return(player, target, "Away", A_AWAY,
00381 tprintf("Sorry, %s is not connected.", Name(target)));
00382 else
00383 page_return(player, target, "Reject", A_REJECT,
00384 tprintf("Sorry, %s is not accepting pages.",
00385 Name(target)));
00386 return 0;
00387 }
00388 if(!could_doit(target, player, A_LPAGE)) {
00389 if(Wizard(player)) {
00390 notify_printf(player, "Warning: %s can't return your page.",
00391 Name(target));
00392 return 1;
00393 } else {
00394 notify_printf(player, "Sorry, %s can't return your page.",
00395 Name(target));
00396 return 0;
00397 }
00398 }
00399 return 1;
00400 }
00401
00402
00403
00404
00405 static char *dbrefs_to_names(dbref player, char *list, char *namelist,
00406 int ismessage)
00407 {
00408 char *bp, *p;
00409 char oldlist[LBUF_SIZE];
00410
00411 StringCopy(oldlist, list);
00412 bp = namelist;
00413 for(p = (char *) strtok(oldlist, " "); p != NULL;
00414 p = (char *) strtok(NULL, " ")) {
00415 if(ismessage)
00416 safe_str(tprintf("%s, ", Name(atoi(p))), namelist, &bp);
00417 else {
00418 if(lookup_player(player, p, 1) != NOTHING) {
00419 safe_str(tprintf("%s, ", Name(lookup_player(player, p,
00420 1))), namelist,
00421 &bp);
00422 }
00423 }
00424 }
00425 *(bp - 2) = '\0';
00426 return bp;
00427 }
00428
00429 void do_page(dbref player, dbref cause, int key, char *tname, char *message)
00430 {
00431 dbref target, aowner;
00432 char *p, *buf1, *bp, *buf2, *bp2, *mp, *str;
00433 char targetname[LBUF_SIZE];
00434 char alias[LBUF_SIZE];
00435 char aladd[LBUF_SIZE];
00436 int ispose = 0;
00437 int ismessage = 0;
00438 int count = 0;
00439 int n = 0;
00440 int aflags = 0;
00441
00442 buf1 = alloc_lbuf("page_return_list");
00443 bp = buf1;
00444
00445 buf2 = alloc_lbuf("page_list");
00446 bp2 = buf2;
00447
00448 if((tname[0] == ':') || (tname[0] == ';') || (message[0] == ':') ||
00449 (message[0] == ';'))
00450 ispose = 1;
00451
00452 mp = message;
00453
00454 if(!*message) {
00455 atr_get_str(targetname, player, A_LASTPAGE, &aowner, &aflags);
00456 if(!*tname) {
00457 if(!*targetname)
00458 notify(player, "You have not paged anyone.");
00459 else
00460 for(p = (char *) strtok(targetname, " "); p != NULL;
00461 p = (char *) strtok(NULL, " ")) {
00462 target = atoi(p);
00463 notify_printf(player, "You last paged %s.", Name(target));
00464 }
00465
00466 free_lbuf(buf1);
00467 free_lbuf(buf2);
00468 return;
00469 }
00470 StringCopy(message, tname);
00471 StringCopy(tname, targetname);
00472 ismessage = 1;
00473 }
00474
00475 atr_get_str(alias, player, A_ALIAS, &aowner, &aflags);
00476 if(*alias)
00477 sprintf(aladd, " (%s)", alias);
00478 else
00479 aladd[0] = 0;
00480
00481
00482
00483
00484 for(n = 0, str = tname; str; str = (char *) next_token(str, ' '), n++);
00485
00486 if(((target = lookup_player(player, tname, 1)) == NOTHING) && n > 1) {
00487 bp = dbrefs_to_names(player, tname, buf1, ismessage);
00488 for(p = (char *) strtok(tname, " "); p != NULL;
00489 p = (char *) strtok(NULL, " ")) {
00490
00491
00492
00493
00494
00495 if(ismessage) {
00496 target = atoi(p);
00497 } else
00498 target = lookup_player(player, p, 1);
00499
00500 message = mp;
00501
00502 if(target == NOTHING) {
00503 notify_printf(player, "I don't recognize \"%s\".", p);
00504 } else if(!page_check(player, target)) {
00505 ;
00506 } else {
00507 switch (*message) {
00508 case ':':
00509 notify_with_cause(target, player,
00510 tprintf("From afar, to (%s):%s %s %s",
00511 buf1, aladd, Name(player),
00512 message + 1));
00513 break;
00514 case ';':
00515 message++;
00516 notify_with_cause(target, player,
00517 tprintf("From afar, to (%s):%s %s%s",
00518 buf1, aladd, Name(player),
00519 message));
00520 break;
00521 case '"':
00522 message++;
00523 default:
00524 notify_with_cause(target, player,
00525 tprintf("To (%s), %s%s pages you: %s",
00526 buf1, Name(player), aladd,
00527 message));
00528 }
00529 page_return(player, target, "Idle", A_IDLE, NULL);
00530
00531 safe_str(tprintf("%d ", target), buf2, &bp2);
00532 count++;
00533 }
00534 }
00535 } else {
00536 if(ismessage)
00537 target = atoi(tname);
00538 if(target == NOTHING) {
00539 notify_printf(player, "I don't recognize \"%s\".", tname);
00540 } else if(!page_check(player, target)) {
00541 ;
00542 } else {
00543
00544 switch (*message) {
00545 case ':':
00546 notify_with_cause(target, player,
00547 tprintf("From afar,%s %s %s", aladd,
00548 Name(player), message + 1));
00549 break;
00550 case ';':
00551 message++;
00552 notify_with_cause(target, player,
00553 tprintf("From afar,%s %s%s", aladd,
00554 Name(player), message));
00555 break;
00556 case '"':
00557 message++;
00558 default:
00559 notify_with_cause(target, player, tprintf("%s%s pages: %s",
00560 Name(player), aladd,
00561 message));
00562
00563 }
00564 page_return(player, target, "Idle", A_IDLE, NULL);
00565
00566 safe_str(tprintf("%d ", target), buf2, &bp2);
00567 safe_str(tprintf("%s, ", Name(target)), buf1, &bp);
00568 count++;
00569 }
00570 *(bp - 2) = '\0';
00571 }
00572
00573 if(count == 0) {
00574 free_lbuf(buf1);
00575 free_lbuf(buf2);
00576 return;
00577 }
00578 *(bp2 - 1) = '\0';
00579 atr_add(player, A_LASTPAGE, buf2, Owner(player), aflags);
00580
00581 if(count == 1) {
00582 if(*buf1) {
00583 if(ispose != 1) {
00584 notify_printf(player, "You paged %s with '%s'.", buf1, mp);
00585 } else {
00586 if(mp[0] == ':')
00587 notify_printf(player, "Long distance to %s: %s %s",
00588 buf1, Name(player), mp + 1);
00589 else
00590 notify_printf(player, "Long distance to %s: %s%s",
00591 buf1, Name(player), mp + 1);
00592 }
00593 }
00594 } else {
00595 *(bp - 2) = ')';
00596 *(bp - 1) = '\0';
00597
00598 if(*buf1) {
00599 if(ispose != 1) {
00600 notify_printf(player, "You paged (%s with '%s'.", buf1, mp);
00601 } else {
00602 if(mp[0] == ':')
00603 notify_printf(player, "Long distance to (%s: %s %s",
00604 buf1, Name(player), mp + 1);
00605 else
00606 notify_printf(player, "Long distance to (%s: %s%s",
00607 buf1, Name(player), mp + 1);
00608 }
00609 }
00610 }
00611
00612 free_lbuf(buf1);
00613 free_lbuf(buf2);
00614 }
00615
00619 void whisper_pose(dbref player, dbref target, char *message)
00620 {
00621 char *buff;
00622
00623 buff = alloc_lbuf("do_pemit.whisper.pose");
00624 StringCopy(buff, Name(player));
00625 notify_printf(player, "%s senses \"%s%s\"", Name(target), buff, message);
00626 notify_with_cause(target, player, tprintf("You sense %s%s", buff,
00627 message));
00628 free_lbuf(buff);
00629 }
00630
00631 void do_pemit_list(dbref player, char *list, const char *message)
00632 {
00633
00634
00635
00636
00637
00638
00639
00640 char *p;
00641 dbref who;
00642 int ok_to_do;
00643
00644 if(!message || !*message || !list || !*list)
00645 return;
00646
00647 for(p = (char *) strtok(list, " "); p != NULL;
00648 p = (char *) strtok(NULL, " ")) {
00649
00650 ok_to_do = 0;
00651 init_match(player, p, TYPE_PLAYER);
00652 match_everything(0);
00653 who = match_result();
00654
00655 if(!ok_to_do && (Long_Fingers(player) || nearby(player, who) ||
00656 Controls(player, who))) {
00657 ok_to_do = 1;
00658 }
00659 if(!ok_to_do && (isPlayer(who))
00660 && mudconf.pemit_players) {
00661 if(!page_check(player, who))
00662 return;
00663 ok_to_do = 1;
00664 }
00665 switch (who) {
00666 case NOTHING:
00667 notify(player, "Emit to whom?");
00668 break;
00669 case AMBIGUOUS:
00670 notify(player, "I don't know who you mean!");
00671 break;
00672 default:
00673 if(!ok_to_do) {
00674 notify(player, "You cannot do that.");
00675 break;
00676 }
00677 if(Good_obj(who))
00678 notify_with_cause(who, player, message);
00679 }
00680 }
00681 }
00682
00683 void do_pemit(dbref player, dbref cause, int key, char *recipient,
00684 char *message)
00685 {
00686 dbref target, loc;
00687 char *buf2, *bp;
00688 int do_contents, ok_to_do, depth, pemit_flags;
00689
00690 if(key & PEMIT_LIST) {
00691 do_pemit_list(player, recipient, message);
00692 return;
00693 }
00694 if(key & PEMIT_CONTENTS) {
00695 do_contents = 1;
00696 key &= ~PEMIT_CONTENTS;
00697 } else {
00698 do_contents = 0;
00699 }
00700 pemit_flags = key & (PEMIT_HERE | PEMIT_ROOM );
00701 key &= ~(PEMIT_HERE | PEMIT_ROOM );
00702 ok_to_do = 0;
00703
00704 switch (key) {
00705 case PEMIT_FSAY:
00706 case PEMIT_FPOSE:
00707 case PEMIT_FPOSE_NS:
00708 case PEMIT_FEMIT:
00709 target = match_controlled(player, recipient);
00710 if(target == NOTHING)
00711 return;
00712 ok_to_do = 1;
00713 break;
00714 default:
00715 init_match(player, recipient, TYPE_PLAYER);
00716 match_everything(0);
00717 target = match_result();
00718 }
00719
00720 switch (target) {
00721 case NOTHING:
00722 switch (key) {
00723 case PEMIT_WHISPER:
00724 notify(player, "Whisper to whom?");
00725 break;
00726 case PEMIT_PEMIT:
00727 notify(player, "Emit to whom?");
00728 break;
00729 case PEMIT_OEMIT:
00730 notify(player, "Emit except to whom?");
00731 break;
00732 default:
00733 notify(player, "Sorry.");
00734 }
00735 break;
00736 case AMBIGUOUS:
00737 notify(player, "I don't know who you mean!");
00738 break;
00739 default:
00740
00741
00742
00743
00744 if(!ok_to_do && (nearby(player, target) || Long_Fingers(player)
00745 || Controls(player, target))) {
00746 ok_to_do = 1;
00747 }
00748 if(!ok_to_do && (key == PEMIT_PEMIT) &&
00749 (Typeof(target) == TYPE_PLAYER) && mudconf.pemit_players) {
00750 if(!page_check(player, target))
00751 return;
00752 ok_to_do = 1;
00753 }
00754 if(!ok_to_do && (!mudconf.pemit_any || (key != PEMIT_PEMIT))) {
00755 notify(player, "You are too far away to do that.");
00756 return;
00757 }
00758 if(do_contents && !Controls(player, target) && !mudconf.pemit_any) {
00759 notify(player, "Permission denied.");
00760 return;
00761 }
00762 loc = where_is(target);
00763
00764 switch (key) {
00765 case PEMIT_PEMIT:
00766 if(do_contents) {
00767 if(Has_contents(target)) {
00768 notify_all_from_inside(target, player, message);
00769 }
00770 } else {
00771 notify_with_cause(target, player, message);
00772
00773 }
00774 break;
00775 case PEMIT_OEMIT:
00776 notify_except(Location(target), player, target, message);
00777 break;
00778 case PEMIT_WHISPER:
00779 switch (*message) {
00780 case ':':
00781 message[0] = ' ';
00782 whisper_pose(player, target, message);
00783 break;
00784 case ';':
00785 message++;
00786 whisper_pose(player, target, message);
00787 break;
00788 case '"':
00789 message++;
00790 default:
00791 notify_printf(player, "You whisper \"%s\" to %s.",
00792 message, Name(target));
00793 notify_with_cause(target, player,
00794 tprintf("%s whispers \"%s\"", Name(player),
00795 message));
00796 }
00797 if((!mudconf.quiet_whisper) && !Wizard(player)) {
00798 loc = where_is(player);
00799 if(loc != NOTHING) {
00800 buf2 = alloc_lbuf("do_pemit.whisper.buzz");
00801 bp = buf2;
00802 safe_str(Name(player), buf2, &bp);
00803 safe_str((char *) " whispers something to ", buf2, &bp);
00804 safe_str(Name(target), buf2, &bp);
00805 *bp = '\0';
00806 notify_except2(loc, player, player, target, buf2);
00807 free_lbuf(buf2);
00808 }
00809 }
00810 break;
00811 case PEMIT_FSAY:
00812 notify_printf(target, "You say \"%s\"", message);
00813 if(loc != NOTHING) {
00814 notify_except(loc, player, target,
00815 tprintf("%s says \"%s\"", Name(target),
00816 message));
00817 }
00818 break;
00819 case PEMIT_FPOSE:
00820 notify_all_from_inside(loc, player, tprintf("%s %s",
00821 Name(target),
00822 message));
00823 break;
00824 case PEMIT_FPOSE_NS:
00825 notify_all_from_inside(loc, player, tprintf("%s%s",
00826 Name(target),
00827 message));
00828 break;
00829 case PEMIT_FEMIT:
00830 if((pemit_flags & PEMIT_HERE) || !pemit_flags)
00831 notify_all_from_inside(loc, player, message);
00832 if(pemit_flags & PEMIT_ROOM) {
00833 if((Typeof(loc) == TYPE_ROOM) && (pemit_flags & PEMIT_HERE)) {
00834 return;
00835 }
00836 depth = 0;
00837 while ((Typeof(loc) != TYPE_ROOM) && (depth++ < 20)) {
00838 loc = Location(loc);
00839 if((loc == NOTHING) || (loc == Location(loc)))
00840 return;
00841 }
00842 if(Typeof(loc) == TYPE_ROOM) {
00843 notify_all_from_inside(loc, player, message);
00844 }
00845 }
00846 break;
00847
00848 }
00849 }
00850 }