mux/src/predicates.cpp File Reference

#include "copyright.h"
#include "autoconf.h"
#include "config.h"
#include "externs.h"
#include <signal.h>
#include "ansi.h"
#include "attrs.h"
#include "command.h"
#include "interface.h"
#include "powers.h"

Include dependency graph for predicates.cpp:

Go to the source code of this file.

Functions

char *DCL_CDECL tprintf (const char *fmt,...)
void DCL_CDECL safe_tprintf_str (char *str, char **bp, const char *fmt,...)
dbref insert_first (dbref head, dbref thing)
dbref remove_first (dbref head, dbref thing)
dbref reverse_list (dbref list)
bool member (dbref thing, dbref list)
bool could_doit (dbref player, dbref thing, int locknum)
bool can_see (dbref player, dbref thing, bool can_see_loc)
static bool pay_quota (dbref who, int cost)
bool canpayfees (dbref player, dbref who, int pennies, int quota)
bool payfor (dbref who, int cost)
void add_quota (dbref who, int payment)
void giveto (dbref who, int pennies)
char * MakeCanonicalObjectName (const char *pName, int *pnName, bool *pbValid)
char * MakeCanonicalExitName (const char *pName, int *pnName, bool *pbValid)
bool ValidatePlayerName (const char *pName)
bool ok_password (const char *password, const char **pmsg)
void handle_ears (dbref thing, bool could_hear, bool can_hear)
void do_switch (dbref player, dbref caller, dbref enactor, int key, char *expr, char *args[], int nargs, char *cargs[], int ncargs)
void do_if (dbref player, dbref caller, dbref enactor, int key, char *expr, char *args[], int nargs, char *cargs[], int ncargs)
void do_addcommand (dbref player, dbref caller, dbref enactor, int key, int nargs, char *name, char *command)
void do_listcommands (dbref player, dbref caller, dbref enactor, int key, char *name)
void do_delcommand (dbref player, dbref caller, dbref enactor, int key, int nargs, char *name, char *command)
void handle_prog (DESC *d, char *message)
void do_quitprog (dbref player, dbref caller, dbref enactor, int key, char *name)
void do_prog (dbref player, dbref caller, dbref enactor, int key, int nargs, char *name, char *command)
void do_restart (dbref executor, dbref caller, dbref enactor, int key)
void do_backup (dbref player, dbref caller, dbref enactor, int key)
void do_comment (dbref player, dbref caller, dbref enactor, int key)
static dbref promote_dflt (dbref old, dbref new0)
dbref match_possessed (dbref player, dbref thing, char *target, dbref dflt, bool check_enter)
void parse_range (char **name, dbref *low_bound, dbref *high_bound)
bool parse_thing_slash (dbref player, char *thing, char **after, dbref *it)
bool get_obj_and_lock (dbref player, char *what, dbref *it, ATTR **attr, char *errmsg, char **bufc)
bool bCanReadAttr (dbref executor, dbref target, ATTR *tattr, bool bCheckParent)
bool bCanSetAttr (dbref executor, dbref target, ATTR *tattr)
bool bCanLockAttr (dbref executor, dbref target, ATTR *tattr)
dbref where_is (dbref what)
dbref where_room (dbref what)
bool locatable (dbref player, dbref it, dbref enactor)
bool nearby (dbref player, dbref thing)
bool exit_visible (dbref exit, dbref player, int key)
bool exit_displayable (dbref exit, dbref player, int key)
void did_it (dbref player, dbref thing, int what, const char *def, int owhat, const char *odef, int awhat, char *args[], int nargs)
void do_verb (dbref executor, dbref caller, dbref enactor, int key, char *victim_str, char *args[], int nargs)
void OutOfMemory (const char *SourceFile, unsigned int LineNo)
bool AssertionFailed (const char *SourceFile, unsigned int LineNo)


Function Documentation

void add_quota ( dbref  who,
int  payment 
)

Definition at line 276 of file predicates.cpp.

References A_RQUOTA, atr_add_raw(), atr_get, free_lbuf, mux_atol(), and mux_ltoa().

Referenced by chown_all(), destroy_obj(), do_chown(), and link_exit().

00277 {
00278     dbref aowner;
00279     int aflags;
00280     char buf[20];
00281 
00282     char *quota = atr_get(who, A_RQUOTA, &aowner, &aflags);
00283     mux_ltoa(mux_atol(quota) + payment, buf);
00284     free_lbuf(quota);
00285     atr_add_raw(who, A_RQUOTA, buf);
00286 }

bool AssertionFailed ( const char *  SourceFile,
unsigned int  LineNo 
)

Definition at line 2630 of file predicates.cpp.

References statedata::bCanRestart, statedata::bStandAlone, do_restart(), ENDLINE, CLogFile::Flush(), GOD, Log, mudstate, and CLogFile::tinyprintf().

02631 {
02632     Log.tinyprintf("%s(%u): Assertion failed." ENDLINE, SourceFile, LineNo);
02633     Log.Flush();
02634     if (  !mudstate.bStandAlone
02635        && mudstate.bCanRestart)
02636     {
02637         do_restart(GOD, GOD, GOD, 0);
02638     }
02639     else
02640     {
02641         abort();
02642     }
02643     return false;
02644 }

bool bCanLockAttr ( dbref  executor,
dbref  target,
ATTR tattr 
)

Definition at line 1980 of file predicates.cpp.

References AF_CONST, AF_GOD, AF_INTERNAL, AF_IS_LOCK, AF_WIZARD, atr_get_info(), attr::flags, God, attr::number, Owner, and Wizard.

Referenced by do_lock(), and do_unlock().

01981 {
01982     if (!tattr)
01983     {
01984         return false;
01985     }
01986 
01987     int mDeny = AF_INTERNAL|AF_IS_LOCK|AF_CONST;
01988     if (!God(executor))
01989     {
01990         if (God(target))
01991         {
01992             return false;
01993         }
01994         if (Wizard(executor))
01995         {
01996             mDeny = AF_INTERNAL|AF_IS_LOCK|AF_CONST|AF_GOD;
01997         }
01998         else
01999         {
02000             mDeny = AF_INTERNAL|AF_IS_LOCK|AF_CONST|AF_WIZARD|AF_GOD;
02001         }
02002     }
02003 
02004     dbref aowner;
02005     int aflags;
02006     if (  (tattr->flags & mDeny)
02007        || !atr_get_info(target, tattr->number, &aowner, &aflags)
02008        || (aflags & mDeny))
02009     {
02010         return false;
02011     }
02012     else if (  Wizard(executor)
02013             || Owner(executor) == aowner)
02014     {
02015         return true;
02016     }
02017     else
02018     {
02019         return false;
02020     }
02021 }

bool bCanReadAttr ( dbref  executor,
dbref  target,
ATTR tattr,
bool  bCheckParent 
)

Definition at line 1871 of file predicates.cpp.

References A_DESC, AF_DARK, AF_INTERNAL, AF_MDARK, AF_VISUAL, atr_get_info(), atr_pget_info(), statedata::bStandAlone, Examinable, attr::flags, God, mudconf, mudstate, nearby(), attr::number, Owner, confdata::read_rem_desc, and WizRoy.

Referenced by debug_examine(), do_decomp(), do_verb(), eval_boolexp(), exam_wildattrs(), find_wild_attrs(), FUNCTION(), get_handler(), hasattr_handler(), list_attraccess(), and look_atrs1().

01872 {
01873     if (!tattr)
01874     {
01875         return false;
01876     }
01877 
01878     dbref aowner;
01879     int aflags;
01880 
01881     if (  !mudstate.bStandAlone
01882        && bCheckParent)
01883     {
01884         atr_pget_info(target, tattr->number, &aowner, &aflags);
01885     }
01886     else
01887     {
01888         atr_get_info(target, tattr->number, &aowner, &aflags);
01889     }
01890 
01891     int mAllow = AF_VISUAL;
01892     if (  (tattr->flags & mAllow)
01893        || (aflags & mAllow))
01894     {
01895         if (  mudstate.bStandAlone
01896            || tattr->number != A_DESC
01897            || mudconf.read_rem_desc
01898            || nearby(executor, target))
01899         {
01900             return true;
01901         }
01902     }
01903     int mDeny = 0;
01904     if (WizRoy(executor))
01905     {
01906         if (God(executor))
01907         {
01908             mDeny = AF_INTERNAL;
01909         }
01910         else
01911         {
01912             mDeny = AF_INTERNAL|AF_DARK;
01913         }
01914     }
01915     else if (  Owner(executor) == aowner
01916             || Examinable(executor, target))
01917     {
01918         mDeny = AF_INTERNAL|AF_DARK|AF_MDARK;
01919     }
01920     if (mDeny)
01921     {
01922         if (  (tattr->flags & mDeny)
01923            || (aflags & mDeny))
01924         {
01925             return false;
01926         }
01927         else
01928         {
01929             return true;
01930         }
01931     }
01932     return false;
01933 }

bool bCanSetAttr ( dbref  executor,
dbref  target,
ATTR tattr 
)

Definition at line 1935 of file predicates.cpp.

References AF_CONST, AF_GOD, AF_INTERNAL, AF_IS_LOCK, AF_LOCK, AF_WIZARD, atr_get_info(), Controls, attr::flags, God, attr::number, and Wizard.

Referenced by do_alias(), do_chown(), do_edit(), do_mvattr(), do_notify(), do_set(), do_wait(), do_wipe(), FUNCTION(), set_attr_internal(), and CGuests::WipeAttrs().

01936 {
01937     if (!tattr)
01938     {
01939         return false;
01940     }
01941 
01942     int mDeny = AF_INTERNAL|AF_IS_LOCK|AF_CONST;
01943     if (!God(executor))
01944     {
01945         if (God(target))
01946         {
01947             return false;
01948         }
01949         if (Wizard(executor))
01950         {
01951             mDeny = AF_INTERNAL|AF_IS_LOCK|AF_CONST|AF_LOCK|AF_GOD;
01952         }
01953         else if (Controls(executor, target))
01954         {
01955             mDeny = AF_INTERNAL|AF_IS_LOCK|AF_CONST|AF_LOCK|AF_WIZARD|AF_GOD;
01956         }
01957         else
01958         {
01959             return false;
01960         }
01961     }
01962 
01963     dbref aowner;
01964     int aflags;
01965     if (  (tattr->flags & mDeny)
01966 #ifdef FIRANMUX
01967        || Immutable(target)
01968 #endif
01969        || (  atr_get_info(target, tattr->number, &aowner, &aflags)
01970           && (aflags & mDeny)))
01971     {
01972         return false;
01973     }
01974     else
01975     {
01976         return true;
01977     }
01978 }

bool can_see ( dbref  player,
dbref  thing,
bool  can_see_loc 
)

Definition at line 134 of file predicates.cpp.

References Connected, Dark, confdata::dark_sleepers, isExit, isPlayer, IsReal, Light, mudconf, MyopicExam, Puppet, and confdata::see_own_dark.

Referenced by look_contents().

00135 {
00136     // Don't show if all the following apply: Sleeping players should not be
00137     // seen.  The thing is a disconnected player.  The player is not a
00138     // puppet.
00139     //
00140     if (  mudconf.dark_sleepers
00141        && isPlayer(thing)
00142        && !Connected(thing)
00143        && !Puppet(thing))
00144     {
00145         return false;
00146     }
00147 
00148     // You don't see yourself or exits.
00149     //
00150     if (  player == thing
00151        || isExit(thing))
00152     {
00153         return false;
00154     }
00155 
00156     // If loc is not dark, you see it if it's not dark or you control it.  If
00157     // loc is dark, you see it if you control it.  Seeing your own dark
00158     // objects is controlled by mudconf.see_own_dark.  In dark locations, you
00159     // also see things that are LIGHT and !DARK.
00160     //
00161     if (can_see_loc)
00162     {
00163 #ifdef REALITY_LVLS
00164        return ((!Dark(thing) && IsReal(player, thing)) ||
00165 #else
00166         return (!Dark(thing) ||
00167 #endif /* REALITY_LVLS */
00168             (mudconf.see_own_dark && MyopicExam(player, thing)));
00169     }
00170     else
00171     {
00172 #ifdef REALITY_LVLS
00173         return ((Light(thing) && !Dark(thing) && IsReal(player, thing)) ||
00174 #else
00175         return ((Light(thing) && !Dark(thing)) ||
00176 #endif /* REALITY_LVLS */
00177             (mudconf.see_own_dark && MyopicExam(player, thing)));
00178     }
00179 }

bool canpayfees ( dbref  player,
dbref  who,
int  pennies,
int  quota 
)

Definition at line 217 of file predicates.cpp.

References Free_Money, confdata::many_coins, mudconf, notify, Owner, pay_quota(), payfor(), Pennies(), confdata::quotas, tprintf(), and Wizard.

Referenced by create_obj(), do_chown(), and link_exit().

00218 {
00219     if (  !Wizard(who)
00220        && !Wizard(Owner(who))
00221        && !Free_Money(who)
00222        && !Free_Money(Owner(who))
00223        && (Pennies(Owner(who)) < pennies))
00224     {
00225         if (player == who)
00226         {
00227             notify(player, tprintf("Sorry, you don't have enough %s.",
00228                        mudconf.many_coins));
00229         }
00230         else
00231         {
00232             notify(player, tprintf("Sorry, that player doesn't have enough %s.",
00233                 mudconf.many_coins));
00234         }
00235         return false;
00236     }
00237     if (mudconf.quotas)
00238     {
00239         if (!pay_quota(who, quota))
00240         {
00241             if (player == who)
00242             {
00243                 notify(player, "Sorry, your building contract has run out.");
00244             }
00245             else
00246             {
00247                 notify(player,
00248                     "Sorry, that player's building contract has run out.");
00249             }
00250             return false;
00251         }
00252     }
00253     payfor(who, pennies);
00254     return true;
00255 }

bool could_doit ( dbref  player,
dbref  thing,
int  locknum 
)

Definition at line 107 of file predicates.cpp.

References atr_get, eval_boolexp_atr(), free_lbuf, HOME, isPlayer, Key, and Pass_Locks.

Referenced by atr_match1(), check_zone_handler(), do_drop(), do_enter_internal(), do_get(), do_leave(), do_link(), do_teleport_single(), do_use(), fwdlist_load(), give_money(), give_thing(), link_exit(), look_in(), mail_check(), move_exit(), move_via_teleport(), notify_check(), open_exit(), page_check(), promote_match(), sp_ok(), test_join_access(), test_receive_access(), and test_transmit_access().

00108 {
00109     if (thing == HOME)
00110     {
00111         return true;
00112     }
00113 
00114     // If nonplayer tries to get key, then no.
00115     //
00116     if (  !isPlayer(player)
00117        && Key(thing))
00118     {
00119         return false;
00120     }
00121     if (Pass_Locks(player))
00122     {
00123         return true;
00124     }
00125 
00126     dbref aowner;
00127     int   aflags;
00128     char *key = atr_get(thing, locknum, &aowner, &aflags);
00129     bool doit = eval_boolexp_atr(player, thing, thing, key);
00130     free_lbuf(key);
00131     return doit;
00132 }

void did_it ( dbref  player,
dbref  thing,
int  what,
const char *  def,
int  owhat,
const char *  odef,
int  awhat,
char *  args[],
int  nargs 
)

Definition at line 2261 of file predicates.cpp.

References A_CHARGES, A_RUNOUT, AF_HTML, alloc_lbuf, alloc_sbuf, atr_add_raw(), atr_pget, CMuxAlarm::bAlarmed, EV_EVAL, EV_FCHECK, EV_FIGNORE, EV_TOP, free_lbuf, free_sbuf, statedata::global_regs, Good_obj, Has_location, Html, IsReal, Location, MAX_GLOBAL_REGS, mudstate, mux_atol(), mux_exec(), mux_ltoa(), MuxAlarm, Name, NOTHING, notify, notify_except2(), notify_except2_rlevel(), notify_html, PopIntegers(), PopPointers(), PushIntegers(), PushPointers(), restore_global_regs(), safe_str, save_global_regs(), tprintf(), and wait_que().

Referenced by check_events(), do_clone(), do_drop(), do_enter_internal(), do_get(), do_kill(), do_leave(), do_teleport_single(), do_trigger(), do_use(), do_verb(), give_money(), give_thing(), look_in(), look_simple(), move_exit(), move_via_exit(), move_via_generic(), move_via_teleport(), notify_check(), process_enter_loc(), process_leave_loc(), process_preload(), send_mail(), show_a_desc(), and show_desc().

02263 {
02264     if (MuxAlarm.bAlarmed)
02265     {
02266         return;
02267     }
02268 
02269     char *d, *buff, *act, *charges, *bp, *str;
02270     dbref loc, aowner;
02271     int num, aflags;
02272 
02273     // If we need to call exec() from within this function, we first save
02274     // the state of the global registers, in order to avoid munging them
02275     // inappropriately. Do note that the restoration to their original
02276     // values occurs BEFORE the execution of the @a-attribute. Therefore,
02277     // any changing of setq() values done in the @-attribute and @o-attribute
02278     // will NOT be passed on. This prevents odd behaviors that result from
02279     // odd @verbs and so forth (the idea is to preserve the caller's control
02280     // of the global register values).
02281     //
02282 
02283     bool need_pres = false;
02284     char **preserve = NULL;
02285     int *preserve_len = NULL;
02286 
02287     // message to player.
02288     //
02289     if (what > 0)
02290     {
02291         d = atr_pget(thing, what, &aowner, &aflags);
02292         if (*d)
02293         {
02294             need_pres = true;
02295             preserve = PushPointers(MAX_GLOBAL_REGS);
02296             preserve_len = PushIntegers(MAX_GLOBAL_REGS);
02297             save_global_regs("did_it_save", preserve, preserve_len);
02298             buff = bp = alloc_lbuf("did_it.1");
02299             str = d;
02300             mux_exec(buff, &bp, thing, player, player,
02301                 EV_EVAL | EV_FIGNORE | EV_FCHECK | EV_TOP, &str, args, nargs);
02302             *bp = '\0';
02303             if (  (aflags & AF_HTML)
02304                && Html(player))
02305             {
02306                 safe_str("\r\n", buff, &bp);
02307                 *bp = '\0';
02308                 notify_html(player, buff);
02309             }
02310             else
02311             {
02312                 notify(player, buff);
02313             }
02314             free_lbuf(buff);
02315         }
02316         else if (def)
02317         {
02318             notify(player, def);
02319         }
02320         free_lbuf(d);
02321     }
02322     if (what < 0 && def)
02323     {
02324         notify(player, def);
02325     }
02326 
02327     // message to neighbors.
02328     //
02329     if (  owhat > 0
02330        && Has_location(player)
02331        && Good_obj(loc = Location(player)))
02332     {
02333         d = atr_pget(thing, owhat, &aowner, &aflags);
02334         if (*d)
02335         {
02336             if (!need_pres)
02337             {
02338                 need_pres = true;
02339                 preserve = PushPointers(MAX_GLOBAL_REGS);
02340                 preserve_len = PushIntegers(MAX_GLOBAL_REGS);
02341                 save_global_regs("did_it_save", preserve, preserve_len);
02342             }
02343             buff = bp = alloc_lbuf("did_it.2");
02344             str = d;
02345             mux_exec(buff, &bp, thing, player, player,
02346                      EV_EVAL | EV_FIGNORE | EV_FCHECK | EV_TOP, &str, args, nargs);
02347             *bp = '\0';
02348             if (*buff)
02349             {
02350 #ifdef REALITY_LVLS
02351                 notify_except2_rlevel(loc, player, player, thing, tprintf("%s %s", Name(player), buff));
02352 #else
02353                 notify_except2(loc, player, player, thing, tprintf("%s %s", Name(player), buff));
02354 #endif /* REALITY_LVLS */
02355             }
02356             free_lbuf(buff);
02357         }
02358         else if (odef)
02359         {
02360 #ifdef REALITY_LVLS
02361             notify_except2_rlevel(loc, player, player, thing, tprintf("%s %s", Name(player), odef));
02362 #else
02363             notify_except2(loc, player, player, thing, tprintf("%s %s", Name(player), odef));
02364 #endif /* REALITY_LVLS */
02365         }
02366         free_lbuf(d);
02367     }
02368     if (  owhat < 0
02369        && odef
02370        && Has_location(player)
02371        && Good_obj(loc = Location(player)))
02372     {
02373 #ifdef REALITY_LVLS
02374         notify_except2_rlevel(loc, player, player, thing, tprintf("%s %s", Name(player), odef));
02375 #else
02376         notify_except2(loc, player, player, thing, tprintf("%s %s", Name(player), odef));
02377 #endif /* REALITY_LVLS */
02378     }
02379 
02380     // If we preserved the state of the global registers, restore them.
02381     //
02382     if (need_pres)
02383     {
02384         restore_global_regs("did_it_restore", preserve, preserve_len);
02385         PopIntegers(preserve_len, MAX_GLOBAL_REGS);
02386         PopPointers(preserve, MAX_GLOBAL_REGS);
02387     }
02388 
02389     // do the action attribute.
02390     //
02391 #ifdef REALITY_LVLS
02392     if (awhat > 0 && IsReal(thing, player))
02393 #else
02394     if (awhat > 0)
02395 #endif /* REALITY_LVLS */
02396     {
02397         if (*(act = atr_pget(thing, awhat, &aowner, &aflags)))
02398         {
02399             charges = atr_pget(thing, A_CHARGES, &aowner, &aflags);
02400             if (*charges)
02401             {
02402                 num = mux_atol(charges);
02403                 if (num > 0)
02404                 {
02405                     buff = alloc_sbuf("did_it.charges");
02406                     mux_ltoa(num-1, buff);
02407                     atr_add_raw(thing, A_CHARGES, buff);
02408                     free_sbuf(buff);
02409                 }
02410                 else if (*(buff = atr_pget(thing, A_RUNOUT, &aowner, &aflags)))
02411                 {
02412                     free_lbuf(act);
02413                     act = buff;
02414                 }
02415                 else
02416                 {
02417                     free_lbuf(act);
02418                     free_lbuf(buff);
02419                     free_lbuf(charges);
02420                     return;
02421                 }
02422             }
02423             free_lbuf(charges);
02424             CLinearTimeAbsolute lta;
02425             wait_que(thing, player, player, false, lta, NOTHING, 0, act,
02426                 args, nargs, mudstate.global_regs);
02427         }
02428         free_lbuf(act);
02429     }
02430 }

void do_addcommand ( dbref  player,
dbref  caller,
dbref  enactor,
int  key,
int  nargs,
char *  name,
char *  command 
)

Definition at line 768 of file predicates.cpp.

References CMDENT::addent, addedentry::atr, CMDENT::callseq, CMDENT::cmdname, statedata::command_htab, CS_ADDED, CS_LEADIN, CS_ONE_ARG, CMDENT::extra, hashaddLEN(), hashdeleteLEN(), hashfindLEN(), hashreplall(), CMDENT::hookmask, ISOUTOFMEMORY, MEMALLOC, mudstate, mux_strlwr(), addedentry::name, addedentry::next, NOPERM_MESSAGE, notify, attr::number, parse_attrib(), CMDENT::perms, RemoveSetOfCharacters(), See_attr, set_prefix_cmds(), StringClone(), strip_ansi(), CMDENT::switches, addedentry::thing, tprintf(), and UNUSED_PARAMETER.

00777 {
00778     UNUSED_PARAMETER(caller);
00779     UNUSED_PARAMETER(enactor);
00780     UNUSED_PARAMETER(key);
00781 
00782     // Validate command name.
00783     //
00784     char *pName = NULL;
00785     if (1 <= nargs)
00786     {
00787         char *pStripped = strip_ansi(name);
00788         pName = RemoveSetOfCharacters(pStripped, "\r\n\t ");
00789         mux_strlwr(pName);
00790     }
00791     if (  !pName
00792        || pName[0] == '\0'
00793        || (  pName[0] == '_'
00794           && pName[1] == '_'))
00795     {
00796         notify(player, "That is not a valid command name.");
00797         return;
00798     }
00799 
00800     // Validate object/attribute.
00801     //
00802     dbref thing;
00803     ATTR *pattr;
00804     if (  !parse_attrib(player, command, &thing, &pattr)
00805        || !pattr)
00806     {
00807         notify(player, "No such attribute.");
00808         return;
00809     }
00810     if (!See_attr(player, thing, pattr))
00811     {
00812         notify(player, NOPERM_MESSAGE);
00813         return;
00814     }
00815 
00816     CMDENT *old = (CMDENT *)hashfindLEN(pName, strlen(pName),
00817         &mudstate.command_htab);
00818 
00819     CMDENT *cmd;
00820     ADDENT *add, *nextp;
00821 
00822     if (  old
00823        && (old->callseq & CS_ADDED))
00824     {
00825         // Don't allow the same (thing,atr) in the list.
00826         //
00827         for (nextp = old->addent; nextp != NULL; nextp = nextp->next)
00828         {
00829             if (  nextp->thing == thing
00830                && nextp->atr == pattr->number)
00831             {
00832                 notify(player, tprintf("%s already added.", pName));
00833                 return;
00834             }
00835         }
00836 
00837         // Otherwise, add another (thing,atr) to the list.
00838         //
00839         add = (ADDENT *)MEMALLOC(sizeof(ADDENT));
00840         ISOUTOFMEMORY(add);
00841         add->thing = thing;
00842         add->atr = pattr->number;
00843         add->name = StringClone(pName);
00844         add->next = old->addent;
00845         old->addent = add;
00846     }
00847     else
00848     {
00849         if (old)
00850         {
00851             // Delete the old built-in (which will later be added back as
00852             // __name).
00853             //
00854             hashdeleteLEN(pName, strlen(pName), &mudstate.command_htab);
00855         }
00856 
00857         cmd = (CMDENT *)MEMALLOC(sizeof(CMDENT));
00858         ISOUTOFMEMORY(cmd);
00859         cmd->cmdname = StringClone(pName);
00860         cmd->switches = NULL;
00861         cmd->perms = 0;
00862         cmd->extra = 0;
00863         if (  old
00864            && (old->callseq & CS_LEADIN))
00865         {
00866             cmd->callseq = CS_ADDED|CS_ONE_ARG|CS_LEADIN;
00867         }
00868         else
00869         {
00870             cmd->callseq = CS_ADDED|CS_ONE_ARG;
00871         }
00872         cmd->hookmask = 0;
00873         add = (ADDENT *)MEMALLOC(sizeof(ADDENT));
00874         ISOUTOFMEMORY(add);
00875         add->thing = thing;
00876         add->atr = pattr->number;
00877         add->name = StringClone(pName);
00878         add->next = NULL;
00879         cmd->addent = add;
00880 
00881         hashaddLEN(pName, strlen(pName), cmd, &mudstate.command_htab);
00882 
00883         if (  old
00884            && strcmp(pName, old->cmdname) == 0)
00885         {
00886             // We are @addcommand'ing over a built-in command by its
00887             // unaliased name, therefore, we want to re-target all the
00888             // aliases.
00889             //
00890             char *p = tprintf("__%s", pName);
00891             hashdeleteLEN(p, strlen(p), &mudstate.command_htab);
00892             hashreplall(old, cmd, &mudstate.command_htab);
00893             hashaddLEN(p, strlen(p), old, &mudstate.command_htab);
00894         }
00895     }
00896 
00897     // We reset the one letter commands here so you can overload them.
00898     //
00899     set_prefix_cmds();
00900     notify(player, tprintf("Command %s added.", pName));
00901 }

void do_backup ( dbref  player,
dbref  caller,
dbref  enactor,
int  key 
)

Definition at line 1540 of file predicates.cpp.

References dump_database_internal(), DUMP_I_FLAT, DUMP_I_NORMAL, statedata::dumping, ENDLOG, confdata::indb, LOG_ALWAYS, log_name(), log_text(), mudconf, mudstate, notify, raw_broadcast(), STARTLOG, and tprintf().

01541 {
01542 #ifndef WIN32
01543     if (mudstate.dumping)
01544     {
01545         notify(player, "Dumping. Please try again later.");
01546     }
01547 #endif // !WIN32
01548 
01549     raw_broadcast(0, "GAME: Backing up database. Please wait.");
01550     STARTLOG(LOG_ALWAYS, "WIZ", "BACK");
01551     log_text("Backup by ");
01552     log_name(player);
01553     ENDLOG;
01554 
01555 #ifdef MEMORY_BASED
01556     // Invoking _backupflat.sh with an argument prompts the backup script
01557     // to use it as the flatfile.
01558     //
01559     dump_database_internal(DUMP_I_FLAT);
01560     system(tprintf("./_backupflat.sh %s.FLAT 1>&2", mudconf.indb));
01561 #else // MEMORY_BASED
01562     // Invoking _backupflat.sh without an argument prompts the backup script
01563     // to use dbconvert itself.
01564     //
01565     dump_database_internal(DUMP_I_NORMAL);
01566     system(tprintf("./_backupflat.sh 1>&2"));
01567 #endif // MEMORY_BASED
01568     raw_broadcast(0, "GAME: Backup finished.");
01569 }

void do_comment ( dbref  player,
dbref  caller,
dbref  enactor,
int  key 
)

Definition at line 1576 of file predicates.cpp.

References UNUSED_PARAMETER.

01577 {
01578     UNUSED_PARAMETER(player);
01579     UNUSED_PARAMETER(caller);
01580     UNUSED_PARAMETER(enactor);
01581     UNUSED_PARAMETER(key);
01582 }

void do_delcommand ( dbref  player,
dbref  caller,
dbref  enactor,
int  key,
int  nargs,
char *  name,
char *  command 
)