src/wiz.c

Go to the documentation of this file.
00001 /*
00002  * wiz.c -- Wizard-only commands 
00003  */
00004 
00005 #include "copyright.h"
00006 #include "config.h"
00007 
00008 #include "mudconf.h"
00009 #include "config.h"
00010 #include "file_c.h"
00011 #include "db.h"
00012 #include "interface.h"
00013 #include "match.h"
00014 #include "externs.h"
00015 #include "command.h"
00016 #include "htab.h"
00017 #include "alloc.h"
00018 #include "attrs.h"
00019 #include "powers.h"
00020 
00021 #ifdef SQL_SUPPORT
00022 #include "sqlchild.h"
00023 #endif
00024 
00025 int recursive_check_contents(dbref victim, dbref destination)
00026 {
00027         dbref i;
00028 
00029         DOLIST(i, Contents(victim)) {
00030                 if(destination == i)
00031                         return 1;
00032                 else if(recursive_check_contents(i, destination))
00033                         return 1;
00034         }
00035         return 0;
00036 }
00037 
00038 extern char *crypt(const char *, const char *);
00039 
00040 void do_teleport(dbref player, dbref cause, int key, char *arg1, char *arg2)
00041 {
00042         dbref victim, destination, loc, exitloc;
00043         char *to;
00044         int hush = 0;
00045 
00046         if(((Fixed(player)) || (Fixed(Owner(player)))) && !(Tel_Anywhere(player))) {
00047                 notify(player, mudconf.fixed_tel_msg);
00048                 return;
00049         }
00050         /*
00051          * get victim 
00052          */
00053 
00054         if(*arg2 == '\0') {
00055                 victim = player;
00056                 to = arg1;
00057         } else {
00058                 init_match(player, arg1, NOTYPE);
00059                 match_everything(0);
00060                 victim = noisy_match_result();
00061 
00062                 if(victim == NOTHING)
00063                         return;
00064                 to = arg2;
00065         }
00066 
00067         /*
00068          * Validate type of victim 
00069          */
00070 
00071         if(!Has_location(victim) && Typeof(victim) != TYPE_EXIT) {
00072                 notify_quiet(player, "You can't teleport that.");
00073                 return;
00074         }
00075         /*
00076          * Fail if we don't control the victim or the victim's location 
00077          */
00078 
00079         if(!Controls(player, victim) && !Controls(player, Location(victim)) &&
00080            !Tel_Anything(player)) {
00081                 notify_quiet(player, "Permission denied.");
00082                 return;
00083         }
00084         /*
00085          * Check for teleporting home
00086          * Also, can't teleport exits 'home'
00087          */
00088 
00089         if(!string_compare(to, "home") && Typeof(victim) != TYPE_EXIT) {
00090                 (void) move_via_teleport(victim, HOME, cause, 0);
00091                 return;
00092         }
00093         /*
00094          * Find out where to send the victim 
00095          */
00096 
00097         init_match(player, to, NOTYPE);
00098         match_everything(0);
00099         destination = match_result();
00100 
00101         switch (destination) {
00102         case NOTHING:
00103                 notify_quiet(player, "No match.");
00104                 return;
00105         case AMBIGUOUS:
00106                 notify_quiet(player, "I don't know which destination you mean!");
00107                 return;
00108         default:
00109                 if(victim == destination) {
00110                         notify_quiet(player, "Bad destination.");
00111                         return;
00112                 }
00113         }
00114 
00115         /*
00116          * If fascist teleport is on, you must control the victim's ultimate
00117          * location (after LEAVEing any objects) or it must be JUMP_OK.  
00118          */
00119 
00120         if(mudconf.fascist_tport) {
00121                 loc = where_room(victim);
00122                 if(!Good_obj(loc) || !isRoom(loc) || (((!Controls(player, loc) &&
00123                                                                                                 !Jump_ok(loc)))
00124                                                                                           && !Tel_Anywhere(player))) {
00125                         notify_quiet(player, "Permission denied.");
00126                         return;
00127                 }
00128         }
00129         if(Has_contents(destination)) {
00130 
00131                 /*
00132                  * You must control the destination, or it must be a JUMP_OK
00133                  * room where you pass its TELEPORT lock. 
00134                  */
00135 
00136                 if(((!Controls(player, destination) && !Jump_ok(destination)) &&
00137                         !Tel_Anywhere(player)) ||
00138                    !could_doit(player, destination, A_LTPORT)) {
00139 
00140                         /*
00141                          * Nope, report failure 
00142                          */
00143 
00144                         if(player != victim)
00145                                 notify_quiet(player, "Permission denied.");
00146                         did_it(victim, destination, A_TFAIL,
00147                                    "You can't teleport there!", A_OTFAIL, 0, A_ATFAIL,
00148                                    (char **) NULL, 0);
00149                         return;
00150                 }
00151                 /*
00152                  * We're OK, do the teleport 
00153                  */
00154 
00155                 if((key & TELEPORT_QUIET) || Dark(victim))
00156                         hush = HUSH_ENTER | HUSH_LEAVE;
00157 
00158                 if(Typeof(victim) == TYPE_EXIT) {
00159                         exitloc = Exits(victim);
00160                         s_Exits(exitloc, remove_first(Exits(exitloc), victim));
00161                         s_Exits(destination, insert_first(Exits(destination), victim));
00162                         s_Exits(victim, destination);
00163 
00164                         if(!Quiet(player))
00165                                 notify_quiet(player, "Exit teleported.");
00166                 } else if(move_via_teleport(victim, destination, cause, hush)) {
00167                         if(player != victim && !Quiet(player))
00168                                 notify_quiet(player, "Teleported.");
00169                 }
00170         } else if(isExit(destination)) {
00171                 if(Exits(destination) == Location(victim)) {
00172                         move_exit(victim, destination, 0, "You can't go that way.", 0);
00173                 } else {
00174                         notify_quiet(player, "I can't find that exit.");
00175                 }
00176         }
00177 }
00178 
00182 void do_force_prefixed(dbref player, dbref cause, int key, char *command,
00183                                            char *args[], int nargs)
00184 {
00185         char *cp;
00186 
00187         cp = parse_to(&command, ' ', 0);
00188         if(!command)
00189                 return;
00190         while (*command && isspace(*command))
00191                 command++;
00192         if(*command)
00193                 do_force(player, cause, key, cp, command, args, nargs);
00194 }
00195 
00199 void do_force(dbref player, dbref cause, int key, char *what, char *command,
00200                           char *args[], int nargs)
00201 {
00202         dbref victim;
00203 
00204         if((victim = match_controlled(player, what)) == NOTHING)
00205                 return;
00206 
00207         /*
00208          * force victim to do command 
00209          */
00210 
00211         wait_que(victim, player, 0, NOTHING, 0, command, args, nargs,
00212                          mudstate.global_regs);
00213 }
00214 
00215 #ifdef SQL_SUPPORT
00216 void do_query_sub(dbref player, dbref cause, int key, char *what, char *qry);
00217 void do_query(dbref player, dbref cause, int key, char *what, char *qry)
00218 {
00219         switch (key) {
00220         case QUERY_SQL:
00221                 do_query_sub(player, cause, key, what, qry);
00222                 break;
00223         case LIST_SQL:
00224                 sqlchild_list(player);
00225                 break;
00226         case KILL_SQL:
00227                 notify(player, "not implemented.");
00228                 break;
00229         default:
00230                 notify(player, "Invalid Syntax. Try Again.");
00231                 break;
00232         }
00233 }
00234 
00238 void do_query_sub(dbref player, dbref cause, int key, char *what, char *qry)
00239 {
00240         dbref thing, aowner;
00241         int aflags, attr = -1;
00242         ATTR *ap;
00243         char *obj;
00244         char *rdelim = "|";
00245         char *cdelim = ":";
00246         char db_slot;
00247         static char preserve[LBUF_SIZE];
00248 
00249         if(!what) {
00250                 notify(player, "Invalid DB slot.");
00251         }
00252 
00253         obj = parse_to(&what, '/', 0);
00254         db_slot = toupper(obj[0]);
00255         if(!(db_slot >= 'A' && db_slot <= 'E')) {
00256                 notify(player, "Invalid DB slot. Try A through E.");
00257                 return;
00258         }
00259 
00260         if(!what) {
00261                 notify(player, "Invalid object.");
00262                 return;
00263         }
00264 
00265         obj = parse_to(&what, '/', 0);
00266         init_match(player, obj, NOTYPE);
00267         match_everything(0);
00268 
00269         if((thing = noisy_match_result()) < 0) {
00270                 // noisy_match_result will inform the player.
00271                 return;
00272         } else if(!controls(player, thing)) {
00273                 notify(player, "Permission Denied.");
00274                 return;
00275         }
00276 
00277         if(!what) {
00278                 notify(player, "Invalid attribute.");
00279                 return;
00280         }
00281 
00282         obj = parse_to(&what, '/', 0);
00283         if(!obj || !*obj)
00284                 ap = NULL;
00285         else
00286                 ap = atr_str(obj);
00287 
00288         if(!ap) {
00289                 notify(player, "Attribute error.");
00290                 return;
00291         }
00292 
00293         atr_pget_info(thing, ap->number, &aowner, &aflags);
00294 
00295         if(Set_attr(player, thing, ap, aflags)) {
00296                 attr = ap->number;
00297         } else {
00298                 notify_quiet(player, "Permission denied.");
00299                 return;
00300         }
00301 
00302         obj = parse_to(&what, '/', 0);
00303 
00304         if(!obj || !*obj) {
00305                 notify(player, "Invalid preservation data.");
00306                 return;
00307         }
00308 
00309         memset(preserve, '\0', LBUF_SIZE);
00310         strncpy(preserve, obj, LBUF_SIZE);
00311 
00312         if(what) {
00313                 obj = parse_to(&what, '/', 0);
00314                 if(obj && *obj) {
00315                         cdelim = obj;
00316 
00317                         if(what) {
00318                                 obj = parse_to(&what, '/', 0);
00319                                 if(obj && *obj) {
00320                                         rdelim = obj;
00321                                 }
00322                         }
00323                 }
00324         }
00325 
00326         if(!qry || !*qry) {
00327                 notify(player, "Query error.");
00328                 return;
00329         }
00330 
00331         if(key & QUERY_SQL) {
00332                 sqlchild_request(thing, attr, db_slot, preserve, qry, rdelim, cdelim);
00333                 notify_quiet(player, "SQL query sent.");
00334         } else {
00335                 notify_quiet(player, "Switch not supported.");
00336                 return;
00337         }
00338 }
00339 #endif
00340 
00344 void do_toad(dbref player, dbref cause, int key, char *toad, char *newowner)
00345 {
00346         dbref victim, recipient, loc, aowner;
00347         char *buf;
00348         int count, aflags;
00349 
00350         init_match(player, toad, TYPE_PLAYER);
00351         match_neighbor();
00352         match_absolute();
00353         match_player();
00354         if((victim = noisy_match_result()) == NOTHING)
00355                 return;
00356 
00357         if(!isPlayer(victim)) {
00358                 notify_quiet(player, "Try @destroy instead.");
00359                 return;
00360         }
00361         if(No_Destroy(victim)) {
00362                 notify_quiet(player, "You can't toad that player.");
00363                 return;
00364         }
00365         if((newowner != NULL) && *newowner) {
00366                 init_match(player, newowner, TYPE_PLAYER);
00367                 match_neighbor();
00368                 match_absolute();
00369                 match_player();
00370                 if((recipient = noisy_match_result()) == NOTHING)
00371                         return;
00372         } else {
00373                 recipient = player;
00374         }
00375 
00376         STARTLOG(LOG_WIZARD, "WIZ", "TOAD") {
00377                 log_name_and_loc(victim);
00378                 log_text((char *) " was @toaded by ");
00379                 log_name(player);
00380                 ENDLOG;
00381         }
00382         /*
00383          * Clear everything out 
00384          */
00385         if(key & TOAD_NO_CHOWN) {
00386                 count = -1;
00387         } else {
00388                 count = chown_all(victim, recipient);
00389                 s_Owner(victim, recipient);     /*
00390                                                                          * you get it 
00391                                                                          */
00392         }
00393         s_Flags(victim, TYPE_THING | HALT);
00394         s_Flags2(victim, 0);
00395         s_Flags3(victim, 0);
00396         s_Pennies(victim, 1);
00397 
00398         /*
00399          * notify people 
00400          */
00401 
00402         loc = Location(victim);
00403         buf = alloc_mbuf("do_toad");
00404         sprintf(buf, "%s has been turned into a slimy toad!", Name(victim));
00405         notify_except2(loc, player, victim, player, buf);
00406         sprintf(buf, "You toaded %s! (%d objects @chowned)", Name(victim),
00407                         count + 1);
00408         notify_quiet(player, buf);
00409 
00410         /*
00411          * Zap the name from the name hash table 
00412          */
00413 
00414         delete_player_name(victim, Name(victim));
00415         sprintf(buf, "a slimy toad named %s", Name(victim));
00416         s_Name(victim, buf);
00417         free_mbuf(buf);
00418 
00419         /*
00420          * Zap the alias too 
00421          */
00422 
00423         buf = atr_pget(victim, A_ALIAS, &aowner, &aflags);
00424         delete_player_name(victim, buf);
00425         free_lbuf(buf);
00426 
00427         count =
00428                 boot_off(victim, (char *) "You have been turned into a slimy toad!");
00429         notify_quiet(player, tprintf("%d connection%s closed.", count,
00430                                                                  (count == 1 ? "" : "s")));
00431 }
00432 
00433 void do_newpassword(dbref player, dbref cause, int key, char *name,
00434                                         char *password)
00435 {
00436         dbref victim;
00437         char *buf;
00438 
00439         if((victim = lookup_player(player, name, 0)) == NOTHING) {
00440                 notify_quiet(player, "No such player.");
00441                 return;
00442         }
00443         if(*password != '\0' && !ok_password(password)) {
00444 
00445                 /*
00446                  * Can set null passwords, but not bad passwords 
00447                  */
00448                 notify_quiet(player, "Bad password");
00449                 return;
00450         }
00451         if(God(victim)) {
00452                 notify_quiet(player, "You cannot change that player's password.");
00453                 return;
00454         }
00455         STARTLOG(LOG_WIZARD, "WIZ", "PASS") {
00456                 log_name(player);
00457                 log_text((char *) " changed the password of ");
00458                 log_name(victim);
00459                 ENDLOG;
00460         }
00461         /*
00462          * it's ok, do it 
00463          */
00464         s_Pass(victim, crypt((const char *) password, "XX"));
00465         buf = alloc_lbuf("do_newpassword");
00466         notify_quiet(player, "Password changed.");
00467         sprintf(buf, "Your password has been changed by %s.", Name(player));
00468         notify_quiet(victim, buf);
00469         free_lbuf(buf);
00470 }
00471 
00472 void do_boot(dbref player, dbref cause, int key, char *name)
00473 {
00474         dbref victim;
00475         char *buf, *bp;
00476         int count;
00477 
00478         if(!(Can_Boot(player))) {
00479                 notify(player, "Permission denied.");
00480                 return;
00481         }
00482         if(key & BOOT_PORT) {
00483                 if(is_number(name)) {
00484                         victim = atoi(name);
00485                 } else {
00486                         notify_quiet(player, "That's not a number!");
00487                         return;
00488                 }
00489                 STARTLOG(LOG_WIZARD, "WIZ", "BOOT") {
00490                         buf = alloc_sbuf("do_boot.port");
00491                         sprintf(buf, "Port %d", victim);
00492                         log_text(buf);
00493                         log_text((char *) " was @booted by ");
00494                         log_name(player);
00495                         free_sbuf(buf);
00496                         ENDLOG;
00497         }} else {
00498                 init_match(player, name, TYPE_PLAYER);
00499                 match_neighbor();
00500                 match_absolute();
00501                 match_player();
00502                 if((victim = noisy_match_result()) == NOTHING)
00503                         return;
00504 
00505                 if(God(victim)) {
00506                         notify_quiet(player, "You cannot boot that player!");
00507                         return;
00508                 }
00509                 if((!isPlayer(victim) && !God(player)) || (player == victim)) {
00510                         notify_quiet(player, "You can only boot off other players!");
00511                         return;
00512                 }
00513                 STARTLOG(LOG_WIZARD, "WIZ", "BOOT") {
00514                         log_name_and_loc(victim);
00515                         log_text((char *) " was @booted by ");
00516                         log_name(player);
00517                         ENDLOG;
00518                 }
00519                 notify_quiet(player, tprintf("You booted %s off!", Name(victim)));
00520         }
00521         if(key & BOOT_QUIET) {
00522                 buf = NULL;
00523         } else {
00524                 bp = buf = alloc_lbuf("do_boot.msg");
00525                 safe_str(Name(player), buf, &bp);
00526                 safe_str((char *) " gently shows you the door.", buf, &bp);
00527                 *bp = '\0';
00528         }
00529 
00530         if(key & BOOT_PORT)
00531                 count = boot_by_port(victim, !God(player), buf);
00532         else
00533                 count = boot_off(victim, buf);
00534         notify_quiet(player, tprintf("%d connection%s closed.", count,
00535                                                                  (count == 1 ? "" : "s")));
00536         if(buf)
00537                 free_lbuf(buf);
00538 }
00539 
00543 void do_poor(dbref player, dbref cause, int key, char *arg1)
00544 {
00545         dbref a;
00546         int amt, curamt;
00547 
00548         if(!is_number(arg1))
00549                 return;
00550         amt = atoi(arg1);
00551         DO_WHOLE_DB(a) {
00552                 if(isPlayer(a)) {
00553                         curamt = Pennies(a);
00554                         if(amt < curamt)
00555                                 s_Pennies(a, amt);
00556                 }
00557         }
00558 }
00559 
00563 void do_cut(dbref player, dbref cause, int key, char *thing)
00564 {
00565         dbref object;
00566 
00567         object = match_controlled(player, thing);
00568         switch (object) {
00569         case NOTHING:
00570                 notify_quiet(player, "No match.");
00571                 break;
00572         case AMBIGUOUS:
00573                 notify_quiet(player, "I don't know which one");
00574                 break;
00575         default:
00576                 s_Next(object, NOTHING);
00577                 notify_quiet(player, "Cut.");
00578         }
00579 }
00580 
00584 static int count_quota(dbref player)
00585 {
00586         int i, q;
00587 
00588         q = 0 - mudconf.player_quota;
00589         DO_WHOLE_DB(i) {
00590                 if(Owner(i) != player)
00591                         continue;
00592                 if(Going(i) && (!isRoom(i)))
00593                         continue;
00594                 switch (Typeof(i)) {
00595                 case TYPE_EXIT:
00596                         q += mudconf.exit_quota;
00597                         break;
00598                 case TYPE_ROOM:
00599                         q += mudconf.room_quota;
00600                         break;
00601                 case TYPE_THING:
00602                         q += mudconf.thing_quota;
00603                         break;
00604                 case TYPE_PLAYER:
00605                         q += mudconf.player_quota;
00606                         break;
00607                 }
00608         }
00609         return q;
00610 }
00611 
00612 static void mung_quotas(dbref player, int key, int value)
00613 {
00614         dbref aowner;
00615         int aq, rq, xq, aflags;
00616         char *buff;
00617 
00618         if(key & QUOTA_FIX) {
00619 
00620                 /*
00621                  * Get value of stuff owned and good value, set other value 
00622                  * from that. 
00623                  */
00624 
00625                 xq = count_quota(player);
00626                 if(key & QUOTA_TOT) {
00627                         buff = atr_get(player, A_RQUOTA, &aowner, &aflags);
00628                         aq = atoi(buff) + xq;
00629                         atr_add_raw(player, A_QUOTA, tprintf("%d", aq));
00630                         free_lbuf(buff);
00631                 } else {
00632                         buff = atr_get(player, A_QUOTA, &aowner, &aflags);
00633                         rq = atoi(buff) - xq;
00634                         atr_add_raw(player, A_RQUOTA, tprintf("%d", rq));
00635                         free_lbuf(buff);
00636                 }
00637         } else {
00638 
00639                 /*
00640                  * Obtain (or calculate) current relative and absolute quota 
00641                  */
00642 
00643                 buff = atr_get(player, A_QUOTA, &aowner, &aflags);
00644                 if(!*buff) {
00645                         free_lbuf(buff);
00646                         buff = atr_get(player, A_RQUOTA, &aowner, &aflags);
00647                         rq = atoi(buff);
00648                         free_lbuf(buff);
00649                         aq = rq + count_quota(player);
00650                 } else {
00651                         aq = atoi(buff);
00652                         free_lbuf(buff);
00653                         buff = atr_get(player, A_RQUOTA, &aowner, &aflags);
00654                         rq = atoi(buff);
00655                         free_lbuf(buff);
00656                 }
00657 
00658                 /*
00659                  * Adjust values 
00660                  */
00661 
00662                 if(key & QUOTA_REM) {
00663                         aq += (value - rq);
00664                         rq = value;
00665                 } else {
00666                         rq += (value - aq);
00667                         aq = value;
00668                 }
00669 
00670                 /*
00671                  * Set both abs and relative quota 
00672                  */
00673 
00674                 atr_add_raw(player, A_QUOTA, tprintf("%d", aq));
00675                 atr_add_raw(player, A_RQUOTA, tprintf("%d", rq));
00676         }
00677 }
00678 
00679 static void show_quota(dbref player, dbref victim)
00680 {
00681         dbref aowner;
00682         int aq, rq, aflags;
00683         char *buff;
00684 
00685         buff = atr_get(victim, A_QUOTA, &aowner, &aflags);
00686         aq = atoi(buff);
00687         free_lbuf(buff);
00688         buff = atr_get(victim, A_RQUOTA, &aowner, &aflags);
00689         rq = aq - atoi(buff);
00690         free_lbuf(buff);
00691         if(!Free_Quota(victim))
00692                 notify_quiet(player, tprintf("%-16s Quota: %9d  Used: %9d",
00693                                                                          Name(victim), aq, rq));
00694         else
00695                 notify_quiet(player, tprintf("%-16s Quota: UNLIMITED  Used: %9d",
00696                                                                          Name(victim), rq));
00697 }
00698 
00699 void do_quota(dbref player, dbref cause, int key, char *arg1, char *arg2)
00700 {
00701         dbref who;
00702         int set, value, i;
00703 
00704         if(!(mudconf.quotas | Quota(player))) {
00705                 notify_quiet(player, "Quotas are not enabled.");
00706                 return;
00707         }
00708         if((key & QUOTA_TOT) && (key & QUOTA_REM)) {
00709                 notify_quiet(player, "Illegal combination of switches.");
00710                 return;
00711         }
00712         /*
00713          * Show or set all quotas if requested 
00714          */
00715 
00716         value = 0;
00717         set = 0;
00718         if(key & QUOTA_ALL) {
00719                 if(arg1 && *arg1) {
00720                         value = atoi(arg1);
00721                         set = 1;
00722                 } else if(key & (QUOTA_SET | QUOTA_FIX)) {
00723                         value = 0;
00724                         set = 1;
00725                 }
00726                 if(set) {
00727                         STARTLOG(LOG_WIZARD, "WIZ", "QUOTA") {
00728                                 log_name(player);
00729                                 log_text((char *) " changed everyone's quota");
00730                                 ENDLOG;
00731                 }}
00732                 DO_WHOLE_DB(i) {
00733                         if(isPlayer(i)) {
00734                                 if(set)
00735                                         mung_quotas(i, key, value);
00736                                 show_quota(player, i);
00737                         }
00738                 }
00739                 return;
00740         }
00741         /*
00742          * Find out whose quota to show or set 
00743          */
00744 
00745         if(!arg1 || *arg1 == '\0') {
00746                 who = Owner(player);
00747         } else {
00748                 who = lookup_player(player, arg1, 1);
00749                 if(!Good_obj(who)) {
00750                         notify_quiet(player, "Not found.");
00751                         return;
00752                 }
00753         }
00754 
00755         /*
00756          * Make sure we have permission to do it 
00757          */
00758 
00759         if(!Quota(player)) {
00760                 if(arg2 && *arg2) {
00761                         notify_quiet(player, "Permission denied.");
00762                         return;
00763                 }
00764                 if(Owner(player) != who) {
00765                         notify_quiet(player, "Permission denied.");
00766                         return;
00767                 }
00768         }
00769         if(arg2 && *arg2) {
00770                 set = 1;
00771                 value = atoi(arg2);
00772         } else if(key & QUOTA_FIX) {
00773                 set = 1;
00774                 value = 0;
00775         }
00776         if(set) {
00777                 STARTLOG(LOG_WIZARD, "WIZ", "QUOTA") {
00778                         log_name(player);
00779                         log_text((char *) " changed the quota of ");
00780                         log_name(who);
00781                         ENDLOG;
00782                 } mung_quotas(who, key, value);
00783         }
00784         show_quota(player, who);
00785 }
00786 
00790 void do_motd(dbref player, dbref cause, int key, char *message)
00791 {
00792         int is_brief;
00793 
00794         is_brief = 0;
00795         if(key & MOTD_BRIEF) {
00796                 is_brief = 1;
00797                 key = key & ~MOTD_BRIEF;
00798                 if(key == MOTD_ALL)
00799                         key = MOTD_LIST;
00800                 else if(key != MOTD_LIST)
00801                         key |= MOTD_BRIEF;
00802         }
00803         switch (key) {
00804         case MOTD_ALL:
00805                 StringCopy(mudconf.motd_msg, message);
00806                 if(!Quiet(player))
00807                         notify_quiet(player, "Set: MOTD.");
00808                 break;
00809         case MOTD_WIZ:
00810                 StringCopy(mudconf.wizmotd_msg, message);
00811                 if(!Quiet(player))
00812                         notify_quiet(player, "Set: Wizard MOTD.");
00813                 break;
00814         case MOTD_DOWN:
00815                 StringCopy(mudconf.downmotd_msg, message);
00816                 if(!Quiet(player))
00817                         notify_quiet(player, "Set: Down MOTD.");
00818                 break;
00819         case MOTD_FULL:
00820                 StringCopy(mudconf.fullmotd_msg, message);
00821                 if(!Quiet(player))
00822                         notify_quiet(player, "Set: Full MOTD.");
00823                 break;
00824         case MOTD_LIST:
00825                 if(Wizard(player)) {
00826                         if(!is_brief) {
00827                                 notify_quiet(player, "----- motd file -----");
00828                                 fcache_send(player, FC_MOTD);
00829                                 notify_quiet(player, "----- wizmotd file -----");
00830                                 fcache_send(player, FC_WIZMOTD);
00831                                 notify_quiet(player, "----- motd messages -----");
00832                         }
00833                         notify_quiet(player, tprintf("MOTD: %s", mudconf.motd_msg));
00834                         notify_quiet(player, tprintf("Wizard MOTD: %s",
00835                                                                                  mudconf.wizmotd_msg));
00836                         notify_quiet(player, tprintf("Down MOTD: %s",
00837                                                                                  mudconf.downmotd_msg));
00838                         notify_quiet(player, tprintf("Full MOTD: %s",
00839                                                                                  mudconf.fullmotd_msg));
00840                 } else {
00841                         if(Guest(player))
00842                                 fcache_send(player, FC_CONN_GUEST);
00843                         else
00844                                 fcache_send(player, FC_MOTD);
00845                         notify_quiet(player, mudconf.motd_msg);
00846                 }
00847                 break;
00848         default:
00849                 notify_quiet(player, "Illegal combination of switches.");
00850         }
00851 }
00852 
00856 NAMETAB enable_names[] = {
00857         {(char *) "building", 1, CA_PUBLIC, CF_BUILD},
00858         {(char *) "checkpointing", 2, CA_PUBLIC, CF_CHECKPOINT},
00859         {(char *) "cleaning", 2, CA_PUBLIC, CF_DBCHECK},
00860         {(char *) "dequeueing", 1, CA_PUBLIC, CF_DEQUEUE},
00861         {(char *) "idlechecking", 2, CA_PUBLIC, CF_IDLECHECK},
00862         {(char *) "interpret", 2, CA_PUBLIC, CF_INTERP},
00863         {(char *) "logins", 3, CA_PUBLIC, CF_LOGIN},
00864         {(char *) "eventchecking", 2, CA_PUBLIC, CF_EVENTCHECK},
00865         {NULL, 0, 0, 0}
00866 };
00867 
00868 void do_global(dbref player, dbref cause, int key, char *flag)
00869 {
00870         int flagvalue;
00871 
00872         /*
00873          * Set or clear the indicated flag 
00874          */
00875 
00876         flagvalue = search_nametab(player, enable_names, flag);
00877         if(flagvalue < 0) {
00878                 notify_quiet(player, "I don't know about that flag.");
00879         } else if(key == GLOB_ENABLE) {
00880                 mudconf.control_flags |= flagvalue;
00881                 if(!Quiet(player))
00882                         notify_quiet(player, "Enabled.");
00883         } else if(key == GLOB_DISABLE) {
00884                 mudconf.control_flags &= ~flagvalue;
00885                 if(!Quiet(player))
00886                         notify_quiet(player, "Disabled.");
00887         } else {
00888                 notify_quiet(player, "Illegal combination of switches.");
00889         }
00890 }

Generated on Mon May 28 04:25:26 2007 for BattletechMUX by  doxygen 1.4.7