00001
00002
00003
00004
00005
00006 #include "copyright.h"
00007 #include "autoconf.h"
00008 #include "config.h"
00009 #include "externs.h"
00010
00011 #include "attrs.h"
00012 #include "command.h"
00013 #include "file_c.h"
00014 #include "powers.h"
00015
00016 static void do_teleport_single
00017 (
00018 dbref executor,
00019 dbref caller,
00020 dbref enactor,
00021 int key,
00022 dbref victim,
00023 char *to
00024 )
00025 {
00026 UNUSED_PARAMETER(caller);
00027 UNUSED_PARAMETER(enactor);
00028
00029 dbref loc;
00030 int hush = 0;
00031
00032
00033
00034 if ( !Good_obj(victim)
00035 || isRoom(victim))
00036 {
00037 notify_quiet(executor, "You can't teleport that.");
00038 return;
00039 }
00040
00041
00042
00043 if ( !Controls(executor, victim)
00044 && !Controls(executor, isExit(victim) ? Exits(victim) : Location(victim))
00045 && !Tel_Anything(executor))
00046 {
00047 notify_quiet(executor, NOPERM_MESSAGE);
00048 return;
00049 }
00050
00051
00052
00053 if (!string_compare(to, "home"))
00054 {
00055 if (isExit(victim))
00056 {
00057 notify_quiet(executor, "Bad destination.");
00058 }
00059 else
00060 {
00061 move_via_teleport(victim, HOME, enactor, 0);
00062 }
00063 return;
00064 }
00065
00066
00067
00068 init_match(executor, to, NOTYPE);
00069 match_everything(0);
00070 dbref destination = match_result();
00071
00072 switch (destination)
00073 {
00074 case NOTHING:
00075
00076 notify_quiet(executor, "No match.");
00077 return;
00078
00079 case AMBIGUOUS:
00080
00081 notify_quiet(executor, "I don't know which destination you mean!");
00082 return;
00083
00084 default:
00085
00086 if (victim == destination)
00087 {
00088 notify_quiet(executor, "Bad destination.");
00089 return;
00090 }
00091 }
00092
00093
00094
00095
00096 if (mudconf.fascist_tport)
00097 {
00098 if (isExit(victim))
00099 {
00100 loc = where_room(Home(victim));
00101 }
00102 else
00103 {
00104 loc = where_room(victim);
00105 }
00106
00107 if ( !Good_obj(loc)
00108 || !isRoom(loc)
00109 || !( Controls(executor, loc)
00110 || Jump_ok(loc)
00111 || Tel_Anywhere(executor)))
00112 {
00113 notify_quiet(executor, NOPERM_MESSAGE);
00114 return;
00115 }
00116 }
00117 if ( isGarbage(destination)
00118 || ( Has_location(destination)
00119 && isGarbage(Location(destination))))
00120 {
00121
00122
00123 notify_quiet(executor, "Bad destination.");
00124 return;
00125 }
00126 else if (Has_contents(destination))
00127 {
00128
00129
00130
00131 if ( !( Controls(executor, destination)
00132 || Jump_ok(destination)
00133 || Tel_Anywhere(executor))
00134 || !could_doit(executor, destination, A_LTPORT)
00135 || ( isExit(victim)
00136 && God(destination)
00137 && !God(executor)))
00138 {
00139
00140
00141 if (executor != victim)
00142 {
00143 notify_quiet(executor, NOPERM_MESSAGE);
00144 }
00145 did_it(victim, destination,
00146 A_TFAIL, "You can't teleport there!",
00147 A_OTFAIL, 0, A_ATFAIL, (char **)NULL, 0);
00148 return;
00149 }
00150
00151
00152
00153 if (key & TELEPORT_QUIET)
00154 {
00155 hush = HUSH_ENTER | HUSH_LEAVE;
00156 }
00157
00158 if (move_via_teleport(victim, destination, enactor, hush))
00159 {
00160 if (executor != victim)
00161 {
00162 if (!Quiet(executor))
00163 {
00164 notify_quiet(executor, "Teleported.");
00165 }
00166 }
00167 }
00168 }
00169 else if (isExit(destination))
00170 {
00171 if (isExit(victim))
00172 {
00173 if (executor != victim)
00174 {
00175 notify_quiet(executor, "Bad destination.");
00176 }
00177 did_it(victim, destination,
00178 A_TFAIL, "You can't teleport there!",
00179 A_OTFAIL, 0, A_ATFAIL, (char **)NULL, 0);
00180 return;
00181 }
00182 else
00183 {
00184 if (Exits(destination) == Location(victim))
00185 {
00186 move_exit(victim, destination, false, "You can't go that way.", 0);
00187 }
00188 else
00189 {
00190 notify_quiet(executor, "I can't find that exit.");
00191 }
00192 }
00193 }
00194 }
00195
00196 void do_teleport
00197 (
00198 dbref executor,
00199 dbref caller,
00200 dbref enactor,
00201 int key,
00202 int nargs,
00203 char *arg1,
00204 char *arg2
00205 )
00206 {
00207 if ( ( Fixed(executor)
00208 || Fixed(Owner(executor)))
00209 && !Tel_Anywhere(executor))
00210 {
00211 notify(executor, mudconf.fixed_tel_msg);
00212 return;
00213 }
00214
00215
00216
00217 if (nargs == 1)
00218 {
00219
00220
00221 do_teleport_single(executor, caller, enactor, key, executor, arg1);
00222 }
00223 else if (nargs == 2)
00224 {
00225
00226
00227 if (key & TELEPORT_LIST)
00228 {
00229
00230
00231 char *p;
00232 MUX_STRTOK_STATE tts;
00233 mux_strtok_src(&tts, arg1);
00234 mux_strtok_ctl(&tts, " ");
00235 for (p = mux_strtok_parse(&tts); p; p = mux_strtok_parse(&tts))
00236 {
00237 init_match(executor, p, NOTYPE);
00238 match_everything(0);
00239 dbref victim = noisy_match_result();
00240
00241 if (Good_obj(victim))
00242 {
00243 do_teleport_single(executor, caller, enactor, key, victim,
00244 arg2);
00245 }
00246 }
00247 }
00248 else
00249 {
00250 init_match(executor, arg1, NOTYPE);
00251 match_everything(0);
00252 dbref victim = noisy_match_result();
00253
00254 if (Good_obj(victim))
00255 {
00256 do_teleport_single(executor, caller, enactor, key, victim,
00257 arg2);
00258 }
00259 }
00260 }
00261 }
00262
00263
00264
00265
00266 void do_force_prefixed( dbref executor, dbref caller, dbref enactor, int key,
00267 char *command, char *args[], int nargs )
00268 {
00269 char *cp = parse_to(&command, ' ', 0);
00270 if (!command)
00271 {
00272 return;
00273 }
00274 while (mux_isspace(*command))
00275 {
00276 command++;
00277 }
00278 if (*command)
00279 {
00280 do_force(executor, caller, enactor, key, cp, command, args, nargs);
00281 }
00282 }
00283
00284
00285
00286
00287 void do_force( dbref executor, dbref caller, dbref enactor, int key,
00288 char *what, char *command, char *args[], int nargs )
00289 {
00290 UNUSED_PARAMETER(enactor);
00291 UNUSED_PARAMETER(key);
00292
00293 dbref victim = match_controlled(executor, what);
00294 if (victim != NOTHING)
00295 {
00296
00297
00298 CLinearTimeAbsolute lta;
00299 wait_que(victim, caller, executor, false, lta, NOTHING, 0, command,
00300 args, nargs, mudstate.global_regs);
00301 }
00302 }
00303
00304
00305
00306
00307 void do_toad
00308 (
00309 dbref executor,
00310 dbref caller,
00311 dbref enactor,
00312 int key,
00313 int nargs,
00314 char *toad,
00315 char *newowner
00316 )
00317 {
00318 UNUSED_PARAMETER(caller);
00319 UNUSED_PARAMETER(enactor);
00320
00321 dbref victim, recipient, loc, aowner;
00322 char *buf;
00323 int count, aflags;
00324
00325 init_match(executor, toad, TYPE_PLAYER);
00326 match_neighbor();
00327 match_absolute();
00328 match_player();
00329 if (!Good_obj(victim = noisy_match_result()))
00330 {
00331 return;
00332 }
00333
00334 if (!isPlayer(victim))
00335 {
00336 notify_quiet(executor, "Try @destroy instead.");
00337 return;
00338 }
00339 if (No_Destroy(victim))
00340 {
00341 notify_quiet(executor, "You can't toad that player.");
00342 return;
00343 }
00344 if ( nargs == 2
00345 && *newowner )
00346 {
00347 init_match(executor, newowner, TYPE_PLAYER);
00348 match_neighbor();
00349 match_absolute();
00350 match_player();
00351 if ((recipient = noisy_match_result()) == NOTHING)
00352 {
00353 return;
00354 }
00355 }
00356 else
00357 {
00358 if (mudconf.toad_recipient == NOTHING)
00359 {
00360 recipient = executor;
00361 }
00362 else
00363 {
00364 recipient = mudconf.toad_recipient;
00365 }
00366 }
00367
00368 STARTLOG(LOG_WIZARD, "WIZ", "TOAD");
00369 log_name_and_loc(victim);
00370 log_text(" was @toaded by ");
00371 log_name(executor);
00372 ENDLOG;
00373
00374
00375
00376 if (key & TOAD_NO_CHOWN)
00377 {
00378 count = -1;
00379 }
00380 else
00381 {
00382
00383
00384 count = chown_all(victim, recipient, executor, CHOWN_NOZONE);
00385 s_Owner(victim, recipient);
00386 s_Zone(victim, NOTHING);
00387 }
00388 s_Flags(victim, FLAG_WORD1, TYPE_THING | HALT);
00389 s_Flags(victim, FLAG_WORD2, 0);
00390 s_Flags(victim, FLAG_WORD3, 0);
00391 s_Pennies(victim, 1);
00392
00393
00394
00395 loc = Location(victim);
00396 buf = alloc_mbuf("do_toad");
00397 const char *pVictimName = Name(victim);
00398 sprintf(buf, "%s has been turned into a slimy toad!", pVictimName);
00399 notify_except2(loc, executor, victim, executor, buf);
00400 sprintf(buf, "You toaded %s! (%d objects @chowned)", pVictimName, count + 1);
00401 notify_quiet(executor, buf);
00402
00403
00404
00405 sprintf(buf, "a slimy toad named %s", pVictimName);
00406 delete_player_name(victim, pVictimName);
00407 s_Name(victim, buf);
00408 free_mbuf(buf);
00409
00410
00411
00412 buf = atr_pget(victim, A_ALIAS, &aowner, &aflags);
00413 delete_player_name(victim, buf);
00414 free_lbuf(buf);
00415
00416
00417
00418 count = boot_off(victim, "You have been turned into a slimy toad!");
00419
00420
00421
00422 ReleaseAllResources(victim);
00423
00424 buf = tprintf("%d connection%s closed.", count, (count == 1 ? "" : "s"));
00425 notify_quiet(executor, buf);
00426 }
00427
00428 void do_newpassword
00429 (
00430 dbref executor,
00431 dbref caller,
00432 dbref enactor,
00433 int key,
00434 int nargs,
00435 char *name,
00436 char *password
00437 )
00438 {
00439 UNUSED_PARAMETER(caller);
00440 UNUSED_PARAMETER(enactor);
00441 UNUSED_PARAMETER(key);
00442 UNUSED_PARAMETER(nargs);
00443
00444 dbref victim = lookup_player(executor, name, false);
00445 if (victim == NOTHING)
00446 {
00447 notify_quiet(executor, "No such player.");
00448 return;
00449 }
00450 const char *pmsg;
00451 if ( *password != '\0'
00452 && !ok_password(password, &pmsg))
00453 {
00454
00455
00456 notify_quiet(executor, pmsg);
00457 return;
00458 }
00459 if (God(victim))
00460 {
00461 bool bCan = true;
00462 if (God(executor))
00463 {
00464
00465
00466 int aflags;
00467 dbref aowner;
00468 char *target = atr_get(executor, A_PASS, &aowner, &aflags);
00469 if (target[0] != '\0')
00470 {
00471 bCan = false;
00472 }
00473 free_lbuf(target);
00474 }
00475 else
00476 {
00477 bCan = false;
00478 }
00479 if (!bCan)
00480 {
00481 notify_quiet(executor, "You cannot change that player's password.");
00482 return;
00483 }
00484 }
00485 STARTLOG(LOG_WIZARD, "WIZ", "PASS");
00486 log_name(executor);
00487 log_text(" changed the password of ");
00488 log_name(victim);
00489 ENDLOG;
00490
00491
00492
00493 ChangePassword(victim, password);
00494 notify_quiet(executor, "Password changed.");
00495 char *buf = alloc_lbuf("do_newpassword");
00496 char *bp = buf;
00497 safe_tprintf_str(buf, &bp, "Your password has been changed by %s.", Name(executor));
00498 notify_quiet(victim, buf);
00499 free_lbuf(buf);
00500 }
00501
00502 void do_boot(dbref executor, dbref caller, dbref enactor, int key, char *name)
00503 {
00504 UNUSED_PARAMETER(caller);
00505 UNUSED_PARAMETER(enactor);
00506
00507 if (!Can_Boot(executor))
00508 {
00509 notify(executor, NOPERM_MESSAGE);
00510 return;
00511 }
00512
00513 dbref victim;
00514 int count;
00515 if (key & BOOT_PORT)
00516 {
00517 if (is_integer(name, NULL))
00518 {
00519 victim = mux_atol(name);
00520 }
00521 else
00522 {
00523 notify_quiet(executor, "That's not a number!");
00524 return;
00525 }
00526 STARTLOG(LOG_WIZARD, "WIZ", "BOOT");
00527 log_text(tprintf("Port %d", victim));
00528 log_text(" was @booted by ");
00529 log_name(executor);
00530 ENDLOG;
00531 }
00532 else
00533 {
00534 init_match(executor, name, TYPE_PLAYER);
00535 match_neighbor();
00536 match_absolute();
00537 match_player();
00538 if ((victim = noisy_match_result()) == NOTHING)
00539 {
00540 return;
00541 }
00542
00543 if (God(victim))
00544 {
00545 notify_quiet(executor, "You cannot boot that player!");
00546 return;
00547 }
00548 if ( ( !isPlayer(victim)
00549 && !God(executor))
00550 || executor == victim)
00551 {
00552 notify_quiet(executor, "You can only boot off other players!");
00553 return;
00554 }
00555 STARTLOG(LOG_WIZARD, "WIZ", "BOOT");
00556 log_name_and_loc(victim);
00557 log_text(" was @booted by ");
00558 log_name(executor);
00559 ENDLOG;
00560 notify_quiet(executor, tprintf("You booted %s off!", Name(victim)));
00561 }
00562
00563 const char *buf;
00564 if (key & BOOT_QUIET)
00565 {
00566 buf = NULL;
00567 }
00568 else
00569 {
00570 buf = tprintf("%s gently shows you the door.", Name(executor));
00571 }
00572
00573 if (key & BOOT_PORT)
00574 {
00575 count = boot_by_port(victim, God(executor), buf);
00576 }
00577 else
00578 {
00579 count = boot_off(victim, buf);
00580 }
00581 notify_quiet(executor, tprintf("%d connection%s closed.", count, (count == 1 ? "" : "s")));
00582 }
00583
00584
00585
00586
00587 void do_poor(dbref executor, dbref caller, dbref enactor, int key, char *arg1)
00588 {
00589 UNUSED_PARAMETER(executor);
00590 UNUSED_PARAMETER(caller);
00591 UNUSED_PARAMETER(enactor);
00592 UNUSED_PARAMETER(key);
00593
00594 if (!is_rational(arg1))
00595 {
00596 return;
00597 }
00598
00599 int amt = mux_atol(arg1);
00600 int curamt;
00601 dbref a;
00602 DO_WHOLE_DB(a)
00603 {
00604 if (isPlayer(a))
00605 {
00606 curamt = Pennies(a);
00607 if (amt < curamt)
00608 {
00609 s_Pennies(a, amt);
00610 }
00611 }
00612 }
00613 }
00614
00615
00616
00617
00618 void do_cut(dbref executor, dbref caller, dbref enactor, int key, char *thing)
00619 {
00620 UNUSED_PARAMETER(caller);
00621 UNUSED_PARAMETER(enactor);
00622 UNUSED_PARAMETER(key);
00623
00624 dbref object = match_controlled(executor, thing);
00625 if (Good_obj(object))
00626 {
00627 s_Next(object, NOTHING);
00628 notify_quiet(executor, "Cut.");
00629 }
00630 }
00631
00632
00633
00634
00635 void do_motd(dbref executor, dbref caller, dbref enactor, int key, char *message)
00636 {
00637 UNUSED_PARAMETER(caller);
00638 UNUSED_PARAMETER(enactor);
00639
00640 bool is_brief = false;
00641
00642 if (key & MOTD_BRIEF)
00643 {
00644 is_brief = true;
00645 key = key & ~MOTD_BRIEF;
00646 if (key == MOTD_ALL)
00647 key = MOTD_LIST;
00648 else if (key != MOTD_LIST)
00649 key |= MOTD_BRIEF;
00650 }
00651 switch (key)
00652 {
00653 case MOTD_ALL:
00654
00655 strncpy(mudconf.motd_msg, message, GBUF_SIZE-1);
00656 mudconf.motd_msg[GBUF_SIZE-1] = '\0';
00657 if (!Quiet(executor))
00658 {
00659 notify_quiet(executor, "Set: MOTD.");
00660 }
00661 break;
00662
00663 case MOTD_WIZ:
00664
00665 strncpy(mudconf.wizmotd_msg, message, GBUF_SIZE-1);
00666 mudconf.wizmotd_msg[GBUF_SIZE-1] = '\0';
00667 if (!Quiet(executor))
00668 {
00669 notify_quiet(executor, "Set: Wizard MOTD.");
00670 }
00671 break;
00672
00673 case MOTD_DOWN:
00674
00675 strncpy(mudconf.downmotd_msg, message, GBUF_SIZE-1);
00676 mudconf.downmotd_msg[GBUF_SIZE-1] = '\0';
00677 if (!Quiet(executor))
00678 {
00679 notify_quiet(executor, "Set: Down MOTD.");
00680 }
00681 break;
00682
00683 case MOTD_FULL:
00684
00685 strncpy(mudconf.fullmotd_msg, message, GBUF_SIZE-1);
00686 mudconf.fullmotd_msg[GBUF_SIZE-1] = '\0';
00687 if (!Quiet(executor))
00688 {
00689 notify_quiet(executor, "Set: Full MOTD.");
00690 }
00691 break;
00692
00693 case MOTD_LIST:
00694
00695 if (Wizard(executor))
00696 {
00697 if (!is_brief)
00698 {
00699 notify_quiet(executor, "----- motd file -----");
00700 fcache_send(executor, FC_MOTD);
00701 notify_quiet(executor, "----- wizmotd file -----");
00702 fcache_send(executor, FC_WIZMOTD);
00703 notify_quiet(executor, "----- motd messages -----");
00704 }
00705 notify_quiet(executor, tprintf("MOTD: %s", mudconf.motd_msg));
00706 notify_quiet( executor,
00707 tprintf("Wizard MOTD: %s", mudconf.wizmotd_msg) );
00708 notify_quiet( executor,
00709 tprintf("Down MOTD: %s", mudconf.downmotd_msg) );
00710 notify_quiet( executor,
00711 tprintf("Full MOTD: %s", mudconf.fullmotd_msg) );
00712 }
00713 else
00714 {
00715 if (Guest(executor))
00716 {
00717 fcache_send(executor, FC_CONN_GUEST);
00718 }
00719 else
00720 {
00721 fcache_send(executor, FC_MOTD);
00722 }
00723 notify_quiet(executor, mudconf.motd_msg);
00724 }
00725 break;
00726
00727 default:
00728
00729 notify_quiet(executor, "Illegal combination of switches.");
00730 }
00731 }
00732
00733
00734
00735
00736 NAMETAB enable_names[] =
00737 {
00738 {"building", 1, CA_PUBLIC, CF_BUILD},
00739 {"checkpointing", 2, CA_PUBLIC, CF_CHECKPOINT},
00740 {"cleaning", 2, CA_PUBLIC, CF_DBCHECK},
00741 {"dequeueing", 1, CA_PUBLIC, CF_DEQUEUE},
00742 #ifdef MUSH3
00743 {"god_monitoring", 1, CA_PUBLIC, CF_GODMONITOR},
00744 #endif // MUSH3
00745 {"idlechecking", 2, CA_PUBLIC, CF_IDLECHECK},
00746 {"interpret", 2, CA_PUBLIC, CF_INTERP},
00747 {"logins", 3, CA_PUBLIC, CF_LOGIN},
00748 {"guests", 2, CA_PUBLIC, CF_GUEST},
00749 {"eventchecking", 2, CA_PUBLIC, CF_EVENTCHECK},
00750 { NULL, 0, 0, 0}
00751 };
00752
00753 void do_global(dbref executor, dbref caller, dbref enactor, int key, char *flag)
00754 {
00755 UNUSED_PARAMETER(caller);
00756 UNUSED_PARAMETER(enactor);
00757
00758
00759
00760 int flagvalue;
00761 if (!search_nametab(executor, enable_names, flag, &flagvalue))
00762 {
00763 notify_quiet(executor, "I don't know about that flag.");
00764 }
00765 else if (key == GLOB_ENABLE)
00766 {
00767
00768
00769 if (flagvalue == CF_DEQUEUE)
00770 {
00771 scheduler.SetMinPriority(PRIORITY_CF_DEQUEUE_ENABLED);
00772 }
00773 mudconf.control_flags |= flagvalue;
00774 STARTLOG(LOG_CONFIGMODS, "CFG", "GLOBAL");
00775 log_name(executor);
00776 log_text(" enabled: ");
00777 log_text(flag);
00778 ENDLOG;
00779 if (!Quiet(executor))
00780 {
00781 notify_quiet(executor, "Enabled.");
00782 }
00783 }
00784 else if (key == GLOB_DISABLE)
00785 {
00786 if (flagvalue == CF_DEQUEUE)
00787 {
00788 scheduler.SetMinPriority(PRIORITY_CF_DEQUEUE_DISABLED);
00789 }
00790 mudconf.control_flags &= ~flagvalue;
00791 STARTLOG(LOG_CONFIGMODS, "CFG", "GLOBAL");
00792 log_name(executor);
00793 log_text(" disabled: ");
00794 log_text(flag);
00795 ENDLOG;
00796 if (!Quiet(executor))
00797 {
00798 notify_quiet(executor, "Disabled.");
00799 }
00800 }
00801 else
00802 {
00803 notify_quiet(executor, "Illegal combination of switches.");
00804 }
00805 }