00001
00002
00003
00004
00005
00006 #include "copyright.h"
00007 #include "autoconf.h"
00008 #include "config.h"
00009 #include "externs.h"
00010
00011 #include "command.h"
00012 #include "powers.h"
00013
00014
00015
00016
00017
00018 static bool fh_any(dbref target, dbref player, FLAG flag, int fflags, bool reset)
00019 {
00020
00021
00022 if ( God(target)
00023 && reset
00024 && flag == WIZARD
00025 && fflags == FLAG_WORD1)
00026 {
00027 notify(player, "You cannot make God mortal.");
00028 return false;
00029 }
00030
00031
00032
00033 if (reset)
00034 {
00035 db[target].fs.word[fflags] &= ~flag;
00036 }
00037 else
00038 {
00039 db[target].fs.word[fflags] |= flag;
00040 }
00041 return true;
00042 }
00043
00044
00045
00046
00047
00048 static bool fh_god(dbref target, dbref player, FLAG flag, int fflags, bool reset)
00049 {
00050 if (!God(player))
00051 {
00052 return false;
00053 }
00054 return (fh_any(target, player, flag, fflags, reset));
00055 }
00056
00057
00058
00059
00060
00061
00062 static bool fh_wiz(dbref target, dbref player, FLAG flag, int fflags, bool reset)
00063 {
00064 if (!Wizard(player))
00065 {
00066 return false;
00067 }
00068 return (fh_any(target, player, flag, fflags, reset));
00069 }
00070
00071
00072
00073
00074
00075
00076 static bool fh_wizroy(dbref target, dbref player, FLAG flag, int fflags, bool reset)
00077 {
00078 if (!WizRoy(player))
00079 {
00080 return false;
00081 }
00082 return (fh_any(target, player, flag, fflags, reset));
00083 }
00084
00085
00086
00087
00088
00089
00090
00091 static bool fh_restrict_player
00092 (
00093 dbref target,
00094 dbref player,
00095 FLAG flag,
00096 int fflags,
00097 bool reset
00098 )
00099 {
00100 if ( isPlayer(target)
00101 && !Wizard(player))
00102 {
00103 return false;
00104 }
00105 return (fh_any(target, player, flag, fflags, reset));
00106 }
00107
00108
00109
00110
00111
00112
00113 static bool fh_privileged
00114 (
00115 dbref target,
00116 dbref player,
00117 FLAG flag,
00118 int fflags,
00119 bool reset
00120 )
00121 {
00122 if (!God(player))
00123 {
00124 if ( !isPlayer(player)
00125 || player != Owner(player)
00126 || isPlayer(target)
00127 || (db[player].fs.word[fflags] & flag) == 0)
00128 {
00129 return false;
00130 }
00131 }
00132 return (fh_any(target, player, flag, fflags, reset));
00133 }
00134
00135
00136
00137
00138
00139
00140 static bool fh_inherit(dbref target, dbref player, FLAG flag, int fflags, bool reset)
00141 {
00142 if (!Inherits(player))
00143 {
00144 return false;
00145 }
00146 return (fh_any(target, player, flag, fflags, reset));
00147 }
00148
00149
00150
00151
00152
00153
00154 static bool fh_dark_bit(dbref target, dbref player, FLAG flag, int fflags, bool reset)
00155 {
00156 if ( !reset
00157 && isPlayer(target)
00158 && !( (target == player)
00159 && Can_Hide(player))
00160 && !Wizard(player))
00161 {
00162 return false;
00163 }
00164 return (fh_any(target, player, flag, fflags, reset));
00165 }
00166
00167
00168
00169
00170
00171
00172 static bool fh_going_bit(dbref target, dbref player, FLAG flag, int fflags, bool reset)
00173 {
00174 if ( Going(target)
00175 && reset
00176 && (Typeof(target) != TYPE_GARBAGE))
00177 {
00178 notify(player, "Your object has been spared from destruction.");
00179 return (fh_any(target, player, flag, fflags, reset));
00180 }
00181 if (!God(player))
00182 {
00183 return false;
00184 }
00185
00186
00187
00188 if ( !reset
00189 && ( target == 0
00190 || God(target)
00191 || target == mudconf.start_home
00192 || target == mudconf.start_room
00193 || target == mudconf.default_home
00194 || target == mudconf.master_room))
00195 {
00196 return false;
00197 }
00198 return (fh_any(target, player, flag, fflags, reset));
00199 }
00200
00201
00202
00203
00204
00205
00206 static bool fh_hear_bit(dbref target, dbref player, FLAG flag, int fflags, bool reset)
00207 {
00208 if (isPlayer(target) && (flag & MONITOR))
00209 {
00210 if (Can_Monitor(player))
00211 {
00212 return (fh_any(target, player, flag, fflags, reset));
00213 }
00214 else
00215 {
00216 return false;
00217 }
00218 }
00219
00220 bool could_hear = Hearer(target);
00221 bool result = fh_any(target, player, flag, fflags, reset);
00222 handle_ears(target, could_hear, Hearer(target));
00223 return result;
00224 }
00225
00226
00227
00228
00229
00230 static bool fh_player_bit
00231 (
00232 dbref target,
00233 dbref player,
00234 FLAG flag,
00235 int fflags,
00236 bool reset
00237 )
00238 {
00239 if (isPlayer(target))
00240 {
00241 return false;
00242 }
00243 return (fh_any(target, player, flag, fflags, reset));
00244 }
00245
00246
00247
00248
00249
00250 static bool fh_staff
00251 (
00252 dbref target,
00253 dbref player,
00254 FLAG flag,
00255 int fflags,
00256 bool reset
00257 )
00258 {
00259 if (!Staff(player) && !God(player))
00260 {
00261 return false;
00262 }
00263 return (fh_any(target, player, flag, fflags, reset));
00264 }
00265
00266 static FLAGBITENT fbeAbode = { ABODE, 'A', FLAG_WORD2, 0, fh_any};
00267 static FLAGBITENT fbeAnsi = { ANSI, 'X', FLAG_WORD2, 0, fh_any};
00268 static FLAGBITENT fbeAudible = { HEARTHRU, 'a', FLAG_WORD1, 0, fh_hear_bit};
00269 static FLAGBITENT fbeAuditorium = { AUDITORIUM, 'b', FLAG_WORD2, 0, fh_any};
00270 static FLAGBITENT fbeBlind = { BLIND, 'B', FLAG_WORD2, 0, fh_wiz};
00271 static FLAGBITENT fbeChownOk = { CHOWN_OK, 'C', FLAG_WORD1, 0, fh_any};
00272 static FLAGBITENT fbeConnected = { CONNECTED, 'c', FLAG_WORD2, CA_NO_DECOMP, fh_god};
00273 static FLAGBITENT fbeDark = { DARK, 'D', FLAG_WORD1, 0, fh_dark_bit};
00274 static FLAGBITENT fbeDestroyOk = { DESTROY_OK, 'd', FLAG_WORD1, 0, fh_any};
00275 static FLAGBITENT fbeEnterOk = { ENTER_OK, 'e', FLAG_WORD1, 0, fh_any};
00276 static FLAGBITENT fbeFixed = { FIXED, 'f', FLAG_WORD2, 0, fh_restrict_player};
00277 static FLAGBITENT fbeFloating = { FLOATING, 'F', FLAG_WORD2, 0, fh_any};
00278 static FLAGBITENT fbeGagged = { GAGGED, 'j', FLAG_WORD2, 0, fh_wiz};
00279 static FLAGBITENT fbeGoing = { GOING, 'G', FLAG_WORD1, CA_NO_DECOMP, fh_going_bit};
00280 static FLAGBITENT fbeHalted = { HALT, 'h', FLAG_WORD1, 0, fh_any};
00281 static FLAGBITENT fbeHasDaily = { HAS_DAILY, '*', FLAG_WORD2, CA_GOD|CA_NO_DECOMP, fh_god};
00282 static FLAGBITENT fbeHasForwardList = { HAS_FWDLIST, '&', FLAG_WORD2, CA_GOD|CA_NO_DECOMP, fh_god};
00283 static FLAGBITENT fbeHasListen = { HAS_LISTEN, '@', FLAG_WORD2, CA_GOD|CA_NO_DECOMP, fh_god};
00284 static FLAGBITENT fbeHasStartup = { HAS_STARTUP, '+', FLAG_WORD1, CA_GOD|CA_NO_DECOMP, fh_god};
00285 static FLAGBITENT fbeHaven = { HAVEN, 'H', FLAG_WORD1, 0, fh_any};
00286 static FLAGBITENT fbeHead = { HEAD_FLAG, '?', FLAG_WORD2, 0, fh_wiz};
00287 static FLAGBITENT fbeHtml = { HTML, '(', FLAG_WORD2, 0, fh_any};
00288 static FLAGBITENT fbeImmortal = { IMMORTAL, 'i', FLAG_WORD1, 0, fh_wiz};
00289 static FLAGBITENT fbeInherit = { INHERIT, 'I', FLAG_WORD1, 0, fh_inherit};
00290 static FLAGBITENT fbeJumpOk = { JUMP_OK, 'J', FLAG_WORD1, 0, fh_any};
00291 static FLAGBITENT fbeKeepAlive = { CKEEPALIVE, 'k', FLAG_WORD2, 0, fh_any};
00292 static FLAGBITENT fbeKey = { KEY, 'K', FLAG_WORD2, 0, fh_any};
00293 static FLAGBITENT fbeLight = { LIGHT, 'l', FLAG_WORD2, 0, fh_any};
00294 static FLAGBITENT fbeLinkOk = { LINK_OK, 'L', FLAG_WORD1, 0, fh_any};
00295 static FLAGBITENT fbeMonitor = { MONITOR, 'M', FLAG_WORD1, 0, fh_hear_bit};
00296 static FLAGBITENT fbeMyopic = { MYOPIC, 'm', FLAG_WORD1, 0, fh_any};
00297 static FLAGBITENT fbeNoCommand = { NO_COMMAND, 'n', FLAG_WORD2, 0, fh_any};
00298 static FLAGBITENT fbeNoAccents = { NOACCENTS, '~', FLAG_WORD2, 0, fh_any};
00299 static FLAGBITENT fbeNoBleed = { NOBLEED, '-', FLAG_WORD2, 0, fh_any};
00300 static FLAGBITENT fbeNoSpoof = { NOSPOOF, 'N', FLAG_WORD1, 0, fh_any};
00301 static FLAGBITENT fbeOpaque = { TM_OPAQUE, 'O', FLAG_WORD1, 0, fh_any};
00302 static FLAGBITENT fbeOpenOk = { OPEN_OK, 'z', FLAG_WORD2, 0, fh_wiz};
00303 static FLAGBITENT fbeParentOk = { PARENT_OK, 'Y', FLAG_WORD2, 0, fh_any};
00304 static FLAGBITENT fbePlayerMails = { PLAYER_MAILS, ' ', FLAG_WORD2, CA_GOD|CA_NO_DECOMP, fh_god};
00305 static FLAGBITENT fbePuppet = { PUPPET, 'p', FLAG_WORD1, 0, fh_hear_bit};
00306 static FLAGBITENT fbeQuiet = { QUIET, 'Q', FLAG_WORD1, 0, fh_any};
00307 static FLAGBITENT fbeRobot = { ROBOT, 'r', FLAG_WORD1, 0, fh_player_bit};
00308 static FLAGBITENT fbeRoyalty = { ROYALTY, 'Z', FLAG_WORD1, 0, fh_wiz};
00309 static FLAGBITENT fbeSafe = { SAFE, 's', FLAG_WORD1, 0, fh_any};
00310 static FLAGBITENT fbeSlave = { SLAVE, 'x', FLAG_WORD2, CA_WIZARD, fh_wiz};
00311 static FLAGBITENT fbeStaff = { STAFF, 'w', FLAG_WORD2, 0, fh_wiz};
00312 static FLAGBITENT fbeSticky = { STICKY, 'S', FLAG_WORD1, 0, fh_any};
00313 static FLAGBITENT fbeSuspect = { SUSPECT, 'u', FLAG_WORD2, CA_WIZARD, fh_wiz};
00314 static FLAGBITENT fbeTerse = { TERSE, 'q', FLAG_WORD1, 0, fh_any};
00315 static FLAGBITENT fbeTrace = { TRACE, 'T', FLAG_WORD1, 0, fh_any};
00316 static FLAGBITENT fbeTransparent = { SEETHRU, 't', FLAG_WORD1, 0, fh_any};
00317 static FLAGBITENT fbeUnfindable = { UNFINDABLE, 'U', FLAG_WORD2, 0, fh_any};
00318 static FLAGBITENT fbeUninspected = { UNINSPECTED, 'g', FLAG_WORD2, 0, fh_wizroy};
00319 static FLAGBITENT fbeVacation = { VACATION, '|', FLAG_WORD2, 0, fh_restrict_player};
00320 static FLAGBITENT fbeVerbose = { VERBOSE, 'v', FLAG_WORD1, 0, fh_any};
00321 static FLAGBITENT fbeVisual = { VISUAL, 'V', FLAG_WORD1, 0, fh_any};
00322 static FLAGBITENT fbeWizard = { WIZARD, 'W', FLAG_WORD1, 0, fh_god};
00323 static FLAGBITENT fbeSitemon = { SITEMON, '$', FLAG_WORD3, 0, fh_wiz};
00324 #ifdef WOD_REALMS
00325 static FLAGBITENT fbeFae = { FAE, '0', FLAG_WORD3, CA_STAFF, fh_wizroy};
00326 static FLAGBITENT fbeChimera = { CHIMERA, '1', FLAG_WORD3, CA_STAFF, fh_wizroy};
00327 static FLAGBITENT fbePeering = { PEERING, '2', FLAG_WORD3, CA_STAFF, fh_wizroy};
00328 static FLAGBITENT fbeUmbra = { UMBRA, '3', FLAG_WORD3, CA_STAFF, fh_wizroy};
00329 static FLAGBITENT fbeShroud = { SHROUD, '4', FLAG_WORD3, CA_STAFF, fh_wizroy};
00330 static FLAGBITENT fbeMatrix = { MATRIX, '5', FLAG_WORD3, CA_STAFF, fh_wizroy};
00331 static FLAGBITENT fbeObf = { OBF, '6', FLAG_WORD3, CA_STAFF, fh_wizroy};
00332 static FLAGBITENT fbeHss = { HSS, '7', FLAG_WORD3, CA_STAFF, fh_wizroy};
00333 static FLAGBITENT fbeMedium = { MEDIUM, '8', FLAG_WORD3, CA_STAFF, fh_wizroy};
00334 static FLAGBITENT fbeDead = { DEAD, '9', FLAG_WORD3, CA_STAFF, fh_wizroy};
00335 static FLAGBITENT fbeMarker0 = { MARK_0, ' ', FLAG_WORD3, 0, fh_god};
00336 static FLAGBITENT fbeMarker1 = { MARK_1, ' ', FLAG_WORD3, 0, fh_god};
00337 static FLAGBITENT fbeMarker2 = { MARK_2, ' ', FLAG_WORD3, 0, fh_god};
00338 static FLAGBITENT fbeMarker3 = { MARK_3, ' ', FLAG_WORD3, 0, fh_god};
00339 static FLAGBITENT fbeMarker4 = { MARK_4, ' ', FLAG_WORD3, 0, fh_god};
00340 static FLAGBITENT fbeMarker5 = { MARK_5, ' ', FLAG_WORD3, 0, fh_god};
00341 static FLAGBITENT fbeMarker6 = { MARK_6, ' ', FLAG_WORD3, 0, fh_god};
00342 static FLAGBITENT fbeMarker7 = { MARK_7, ' ', FLAG_WORD3, 0, fh_god};
00343 static FLAGBITENT fbeMarker8 = { MARK_8, ' ', FLAG_WORD3, 0, fh_god};
00344 static FLAGBITENT fbeMarker9 = { MARK_9, ' ', FLAG_WORD3, 0, fh_god};
00345 #else // WOD_REALMS
00346 static FLAGBITENT fbeMarker0 = { MARK_0, '0', FLAG_WORD3, 0, fh_god};
00347 static FLAGBITENT fbeMarker1 = { MARK_1, '1', FLAG_WORD3, 0, fh_god};
00348 static FLAGBITENT fbeMarker2 = { MARK_2, '2', FLAG_WORD3, 0, fh_god};
00349 static FLAGBITENT fbeMarker3 = { MARK_3, '3', FLAG_WORD3, 0, fh_god};
00350 static FLAGBITENT fbeMarker4 = { MARK_4, '4', FLAG_WORD3, 0, fh_god};
00351 static FLAGBITENT fbeMarker5 = { MARK_5, '5', FLAG_WORD3, 0, fh_god};
00352 static FLAGBITENT fbeMarker6 = { MARK_6, '6', FLAG_WORD3, 0, fh_god};
00353 static FLAGBITENT fbeMarker7 = { MARK_7, '7', FLAG_WORD3, 0, fh_god};
00354 static FLAGBITENT fbeMarker8 = { MARK_8, '8', FLAG_WORD3, 0, fh_god};
00355 static FLAGBITENT fbeMarker9 = { MARK_9, '9', FLAG_WORD3, 0, fh_god};
00356 #endif // WOD_REALMS
00357
00358 FLAGNAMEENT gen_flag_names[] =
00359 {
00360 {"ABODE", true, &fbeAbode },
00361 {"ACCENTS", false, &fbeNoAccents },
00362 {"ANSI", true, &fbeAnsi },
00363 {"AUDIBLE", true, &fbeAudible },
00364 {"AUDITORIUM", true, &fbeAuditorium },
00365 {"BLEED", false, &fbeNoBleed },
00366 {"BLIND", true, &fbeBlind },
00367 {"COMMANDS", false, &fbeNoCommand },
00368 {"CHOWN_OK", true, &fbeChownOk },
00369 {"CONNECTED", true, &fbeConnected },
00370 {"DARK", true, &fbeDark },
00371 {"DESTROY_OK", true, &fbeDestroyOk },
00372 {"ENTER_OK", true, &fbeEnterOk },
00373 {"FIXED", true, &fbeFixed },
00374 {"FLOATING", true, &fbeFloating },
00375 {"GAGGED", true, &fbeGagged },
00376 {"GOING", true, &fbeGoing },
00377 {"HALTED", true, &fbeHalted },
00378 {"HAS_DAILY", true, &fbeHasDaily },
00379 {"HAS_FORWARDLIST", true, &fbeHasForwardList },
00380 {"HAS_LISTEN", true, &fbeHasListen },
00381 {"HAS_STARTUP", true, &fbeHasStartup },
00382 {"HAVEN", true, &fbeHaven },
00383 {"HEAD", true, &fbeHead },
00384 {"HTML", true, &fbeHtml },
00385 {"IMMORTAL", true, &fbeImmortal },
00386 {"INHERIT", true, &fbeInherit },
00387 {"JUMP_OK", true, &fbeJumpOk },
00388 {"KEEPALIVE", true, &fbeKeepAlive },
00389 {"KEY", true, &fbeKey },
00390 {"LIGHT", true, &fbeLight },
00391 {"LINK_OK", true, &fbeLinkOk },
00392 {"MARKER0", true, &fbeMarker0 },
00393 {"MARKER1", true, &fbeMarker1 },
00394 {"MARKER2", true, &fbeMarker2 },
00395 {"MARKER3", true, &fbeMarker3 },
00396 {"MARKER4", true, &fbeMarker4 },
00397 {"MARKER5", true, &fbeMarker5 },
00398 {"MARKER6", true, &fbeMarker6 },
00399 {"MARKER7", true, &fbeMarker7 },
00400 {"MARKER8", true, &fbeMarker8 },
00401 {"MARKER9", true, &fbeMarker9 },
00402 {"MONITOR", true, &fbeMonitor },
00403 {"MYOPIC", true, &fbeMyopic },
00404 {"NO_COMMAND", true, &fbeNoCommand },
00405 {"NOACCENTS", true, &fbeNoAccents },
00406 {"NOBLEED", true, &fbeNoBleed },
00407 {"NOSPOOF", true, &fbeNoSpoof },
00408 {"OPAQUE", true, &fbeOpaque },
00409 {"OPEN_OK", true, &fbeOpenOk },
00410 {"PARENT_OK", true, &fbeParentOk },
00411 {"PLAYER_MAILS", true, &fbePlayerMails },
00412 {"PUPPET", true, &fbePuppet },
00413 {"QUIET", true, &fbeQuiet },
00414 {"ROBOT", true, &fbeRobot },
00415 {"ROYALTY", true, &fbeRoyalty },
00416 {"SAFE", true, &fbeSafe },
00417 {"SITEMON", true, &fbeSitemon },
00418 {"SLAVE", true, &fbeSlave },
00419 {"SPOOF", false, &fbeNoSpoof },
00420 {"STAFF", true, &fbeStaff },
00421 {"STICKY", true, &fbeSticky },
00422 {"SUSPECT", true, &fbeSuspect },
00423 {"TERSE", true, &fbeTerse },
00424 {"TRACE", true, &fbeTrace },
00425 {"TRANSPARENT", true, &fbeTransparent },
00426 {"UNFINDABLE", true, &fbeUnfindable },
00427 {"UNINSPECTED", true, &fbeUninspected },
00428 {"VACATION", true, &fbeVacation },
00429 {"VERBOSE", true, &fbeVerbose },
00430 {"VISUAL", true, &fbeVisual },
00431 {"WIZARD", true, &fbeWizard },
00432 #ifdef WOD_REALMS
00433 {"FAE", true, &fbeFae },
00434 {"CHIMERA", true, &fbeChimera },
00435 {"PEERING", true, &fbePeering },
00436 {"UMBRA", true, &fbeUmbra },
00437 {"SHROUD", true, &fbeShroud },
00438 {"MATRIX", true, &fbeMatrix },
00439 {"OBF", true, &fbeObf },
00440 {"HSS", true, &fbeHss },
00441 {"MEDIUM", true, &fbeMedium },
00442 {"DEAD", true, &fbeDead },
00443 #endif // WOD_REALMS
00444 {NULL, false, NULL}
00445 };
00446
00447 OBJENT object_types[8] =
00448 {
00449 {"ROOM", 'R', CA_PUBLIC, OF_CONTENTS|OF_EXITS|OF_DROPTO|OF_HOME},
00450 {"THING", ' ', CA_PUBLIC, OF_CONTENTS|OF_LOCATION|OF_EXITS|OF_HOME|OF_SIBLINGS},
00451 {"EXIT", 'E', CA_PUBLIC, OF_SIBLINGS},
00452 {"PLAYER", 'P', CA_PUBLIC, OF_CONTENTS|OF_LOCATION|OF_EXITS|OF_HOME|OF_OWNER|OF_SIBLINGS},
00453 {"TYPE5", '+', CA_GOD, 0},
00454 {"GARBAGE", '-', CA_PUBLIC, OF_CONTENTS|OF_LOCATION|OF_EXITS|OF_HOME|OF_SIBLINGS},
00455 {"GARBAGE", '#', CA_GOD, 0}
00456 };
00457
00458
00459
00460
00461
00462 void init_flagtab(void)
00463 {
00464 char *nbuf = alloc_sbuf("init_flagtab");
00465 for (FLAGNAMEENT *fp = gen_flag_names; fp->pOrigName; fp++)
00466 {
00467 fp->flagname = fp->pOrigName;
00468 strncpy(nbuf, fp->pOrigName, SBUF_SIZE);
00469 nbuf[SBUF_SIZE-1] = '\0';
00470 mux_strlwr(nbuf);
00471 if (!hashfindLEN(nbuf, strlen(nbuf), &mudstate.flags_htab))
00472 {
00473 hashaddLEN(nbuf, strlen(nbuf), fp, &mudstate.flags_htab);
00474 }
00475 }
00476 free_sbuf(nbuf);
00477 }
00478
00479
00480
00481
00482
00483 void display_flagtab(dbref player)
00484 {
00485 char *buf, *bp;
00486 FLAGNAMEENT *fp;
00487
00488 bp = buf = alloc_lbuf("display_flagtab");
00489 safe_str("Flags:", buf, &bp);
00490 for (fp = gen_flag_names; fp->flagname; fp++)
00491 {
00492 FLAGBITENT *fbe = fp->fbe;
00493 if ( ( (fbe->listperm & CA_WIZARD)
00494 && !Wizard(player))
00495 || ( (fbe->listperm & CA_GOD)
00496 && !God(player)))
00497 {
00498 continue;
00499 }
00500 safe_chr(' ', buf, &bp);
00501 safe_str(fp->flagname, buf, &bp);
00502 if (fbe->flaglett != ' ')
00503 {
00504 safe_chr('(', buf, &bp);
00505 if (!fp->bPositive)
00506 {
00507 safe_chr('!', buf, &bp);
00508 }
00509 safe_chr(fbe->flaglett, buf, &bp);
00510 safe_chr(')', buf, &bp);
00511 }
00512 }
00513 *bp = '\0';
00514 notify(player, buf);
00515 free_lbuf(buf);
00516 }
00517
00518 char *MakeCanonicalFlagName
00519 (
00520 const char *pName,
00521 int *pnName,
00522 bool *pbValid
00523 )
00524 {
00525 static char buff[SBUF_SIZE];
00526 char *p = buff;
00527 int nName = 0;
00528
00529 while (*pName && nName < SBUF_SIZE)
00530 {
00531 *p = mux_tolower(*pName);
00532 p++;
00533 pName++;
00534 nName++;
00535 }
00536 *p = '\0';
00537 if (nName < SBUF_SIZE)
00538 {
00539 *pnName = nName;
00540 *pbValid = true;
00541 return buff;
00542 }
00543 else
00544 {
00545 *pnName = 0;
00546 *pbValid = false;
00547 return NULL;
00548 }
00549 }
00550
00551 static FLAGNAMEENT *find_flag(char *flagname)
00552 {
00553
00554
00555 int nName;
00556 bool bValid;
00557 char *pName = MakeCanonicalFlagName(flagname, &nName, &bValid);
00558 FLAGNAMEENT *fe = NULL;
00559 if (bValid)
00560 {
00561 fe = (FLAGNAMEENT *)hashfindLEN(pName, nName, &mudstate.flags_htab);
00562 }
00563 return fe;
00564 }
00565
00566
00567
00568
00569 void flag_set(dbref target, dbref player, char *flag, int key)
00570 {
00571 bool bDone = false;
00572
00573 do
00574 {
00575
00576
00577 while (mux_isspace(*flag))
00578 {
00579 flag++;
00580 }
00581
00582 bool bNegate = false;
00583 if (*flag == '!')
00584 {
00585 bNegate = true;
00586 do
00587 {
00588 flag++;
00589 } while (mux_isspace(*flag));
00590 }
00591
00592
00593
00594 char *nflag = flag;
00595 while ( *nflag != '\0'
00596 && !mux_isspace(*nflag))
00597 {
00598 nflag++;
00599 }
00600 if (*nflag == '\0')
00601 {
00602 bDone = true;
00603 }
00604 else
00605 {
00606 *nflag = '\0';
00607 }
00608
00609
00610
00611 if (*flag == '\0')
00612 {
00613 if (bNegate)
00614 {
00615 notify(player, "You must specify a flag to clear.");
00616 }
00617 else
00618 {
00619 notify(player, "You must specify a flag to set.");
00620 }
00621 }
00622 else
00623 {
00624 FLAGNAMEENT *fp = find_flag(flag);
00625 if (!fp)
00626 {
00627 notify(player, "I do not understand that flag.");
00628 }
00629 else
00630 {
00631 FLAGBITENT *fbe = fp->fbe;
00632
00633 bool bClearSet = bNegate;
00634 if (!fp->bPositive)
00635 {
00636 bNegate = !bNegate;
00637 }
00638
00639
00640
00641 if (!fbe->handler(target, player, fbe->flagvalue, fbe->flagflag, bNegate))
00642 {
00643 notify(player, NOPERM_MESSAGE);
00644 }
00645 else if (!(key & SET_QUIET) && !Quiet(player))
00646 {
00647 notify(player, (bClearSet ? "Cleared." : "Set."));
00648 }
00649 }
00650 }
00651 flag = nflag + 1;
00652
00653 } while (!bDone);
00654 }
00655
00656
00657
00658
00659
00660
00661 char *decode_flags(dbref player, FLAGSET *fs)
00662 {
00663 char *buf, *bp;
00664 buf = bp = alloc_sbuf("decode_flags");
00665 *bp = '\0';
00666
00667 if (!Good_obj(player))
00668 {
00669 strcpy(buf, "#-2 ERROR");
00670 return buf;
00671 }
00672 int flagtype = fs->word[FLAG_WORD1] & TYPE_MASK;
00673 bool bNeedColon = true;
00674 if (object_types[flagtype].lett != ' ')
00675 {
00676 safe_sb_chr(object_types[flagtype].lett, buf, &bp);
00677 bNeedColon = false;
00678 }
00679
00680 FLAGNAMEENT *fp;
00681 for (fp = gen_flag_names; fp->flagname; fp++)
00682 {
00683 FLAGBITENT *fbe = fp->fbe;
00684 if ( !fp->bPositive
00685 || fbe->flaglett == ' ')
00686 {
00687
00688
00689
00690 continue;
00691 }
00692 if (fs->word[fbe->flagflag] & fbe->flagvalue)
00693 {
00694 if ( ( (fbe->listperm & CA_STAFF)
00695 && !Staff(player))
00696 || ( (fbe->listperm & CA_ADMIN)
00697 && !WizRoy(player))
00698 || ( (fbe->listperm & CA_WIZARD)
00699 && !Wizard(player))
00700 || ( (fbe->listperm & CA_GOD)
00701 && !God(player)))
00702 {
00703 continue;
00704 }
00705
00706
00707
00708 if ( flagtype == TYPE_PLAYER
00709 && fbe->flagflag == FLAG_WORD2
00710 && fbe->flagvalue == CONNECTED
00711 && (fs->word[FLAG_WORD1] & (WIZARD | DARK)) == (WIZARD | DARK)
00712 && !See_Hidden(player))
00713 {
00714 continue;
00715 }
00716
00717 if ( bNeedColon
00718 && mux_isdigit(fbe->flaglett))
00719 {
00720
00721
00722 safe_sb_chr(':', buf, &bp);
00723 }
00724 safe_sb_chr(fbe->flaglett, buf, &bp);
00725 bNeedColon = false;
00726 }
00727 }
00728 *bp = '\0';
00729 return buf;
00730 }
00731
00732
00733
00734
00735
00736
00737 bool has_flag(dbref player, dbref it, char *flagname)
00738 {
00739 FLAGNAMEENT *fp = find_flag(flagname);
00740 if (!fp)
00741 {
00742 return false;
00743 }
00744 FLAGBITENT *fbe = fp->fbe;
00745
00746 if ( ( fp->bPositive
00747 && (db[it].fs.word[fbe->flagflag] & fbe->flagvalue))
00748 || ( !fp->bPositive
00749 && (db[it].fs.word[fbe->flagflag] & fbe->flagvalue) == 0))
00750 {
00751 if ( ( (fbe->listperm & CA_STAFF)
00752 && !Staff(player))
00753 || ( (fbe->