mux/src/set.cpp File Reference

#include "copyright.h"
#include "autoconf.h"
#include "config.h"
#include "externs.h"
#include "ansi.h"
#include "attrs.h"
#include "command.h"
#include "powers.h"

Include dependency graph for set.cpp:

Go to the source code of this file.

Functions

void set_modified (dbref thing)
dbref match_controlled_handler (dbref executor, const char *name, bool bQuiet)
void do_chzone (dbref executor, dbref caller, dbref enactor, int key, int nargs, char *name, char *newobj)
void do_name (dbref executor, dbref caller, dbref enactor, int key, int nargs, char *name, char *newname)
void do_alias (dbref executor, dbref caller, dbref enactor, int key, int nargs, char *name, char *alias)
void do_forwardlist (dbref executor, dbref caller, dbref enactor, int key, int nargs, char *target, char *newlist)
void do_lock (dbref executor, dbref caller, dbref enactor, int key, int nargs, char *name, char *keytext)
void do_unlock (dbref executor, dbref caller, dbref enactor, int key, char *name)
void do_unlink (dbref executor, dbref caller, dbref enactor, int key, char *name)
void do_chown (dbref executor, dbref caller, dbref enactor, int key, int nargs, char *name, char *newown)
static void set_attr_internal (dbref player, dbref thing, int attrnum, char *attrtext, int key)
void do_set (dbref executor, dbref caller, dbref enactor, int key, int nargs, char *name, char *flagname)
void do_power (dbref executor, dbref caller, dbref enactor, int key, int nargs, char *name, char *flag)
void do_setattr (dbref executor, dbref caller, dbref enactor, int attrnum, int nargs, char *name, char *attrtext)
void do_cpattr (dbref executor, dbref caller, dbref enactor, int key, char *oldpair, char *newpair[], int nargs)
void do_mvattr (dbref executor, dbref caller, dbref enactor, int key, char *what, char *args[], int nargs)
bool parse_attrib (dbref player, char *str, dbref *thing, ATTR **attr)
static void find_wild_attrs (dbref player, dbref thing, char *str, bool check_exclude, bool hash_insert, bool get_locks)
bool parse_attrib_wild (dbref player, char *str, dbref *thing, bool check_parents, bool get_locks, bool df_star)
void edit_string (char *src, char **dst, char *from, char *to)
static void edit_string_ansi (char *src, char **dst, char **returnstr, char *from, char *to)
void do_edit (dbref executor, dbref caller, dbref enactor, int key, char *it, char *args[], int nargs)
void do_wipe (dbref executor, dbref caller, dbref enactor, int key, char *it)
void do_trigger (dbref executor, dbref caller, dbref enactor, int key, char *object, char *argv[], int nargs)
void do_use (dbref executor, dbref caller, dbref enactor, int key, char *object)
void do_setvattr (dbref executor, dbref caller, dbref enactor, int key, int nargs, char *arg1, char *arg2)


Function Documentation

void do_alias ( dbref  executor,
dbref  caller,
dbref  enactor,
int  key,
int  nargs,
char *  name,
char *  alias 
)

Definition at line 263 of file set.cpp.

References A_ALIAS, add_player_name(), atr_add(), atr_clr(), atr_num(), atr_pget, atr_pget_info(), badname_check(), bCanSetAttr(), Controls, delete_player_name(), free_lbuf, isPlayer, lookup_player(), match_controlled, NOPERM_MESSAGE, NOTHING, notify_quiet, Owner, Quiet, trim_spaces(), UNUSED_PARAMETER, and ValidatePlayerName().

00272 {
00273     UNUSED_PARAMETER(caller);
00274     UNUSED_PARAMETER(enactor);
00275     UNUSED_PARAMETER(key);
00276     UNUSED_PARAMETER(nargs);
00277 
00278     dbref thing = match_controlled(executor, name);
00279     if (thing == NOTHING)
00280     {
00281         return;
00282     }
00283 
00284     // Check for renaming a player.
00285     //
00286     dbref aowner;
00287     int aflags;
00288     ATTR *ap = atr_num(A_ALIAS);
00289     if (isPlayer(thing))
00290     {
00291         // Fetch the old alias.
00292         //
00293         char *oldalias = atr_pget(thing, A_ALIAS, &aowner, &aflags);
00294         char *trimalias = trim_spaces(alias);
00295 
00296         if (!Controls(executor, thing))
00297         {
00298             // Make sure we have rights to do it. We can't do the
00299             // normal Set_attr check because ALIAS is only
00300             // writable by GOD and we want to keep people from
00301             // doing &ALIAS and bypassing the player name checks.
00302             //
00303             notify_quiet(executor, NOPERM_MESSAGE);
00304         }
00305         else if (!*trimalias)
00306         {
00307             // New alias is null, just clear it.
00308             //
00309             delete_player_name(thing, oldalias);
00310             atr_clr(thing, A_ALIAS);
00311             if (!Quiet(executor))
00312             {
00313                 notify_quiet(executor, "Alias removed.");
00314             }
00315         }
00316         else if (lookup_player(NOTHING, trimalias, false) != NOTHING)
00317         {
00318             // Make sure new alias isn't already in use.
00319             //
00320             notify_quiet(executor, "That name is already in use.");
00321         }
00322         else if (  !(badname_check(trimalias)
00323                 && ValidatePlayerName(trimalias)))
00324         {
00325             notify_quiet(executor, "That's a silly name for a player!");
00326         }
00327         else
00328         {
00329             // Remove the old name and add the new name.
00330             //
00331             delete_player_name(thing, oldalias);
00332             atr_add(thing, A_ALIAS, trimalias, Owner(executor), aflags);
00333             if (add_player_name(thing, trimalias))
00334             {
00335                 if (!Quiet(executor))
00336                 {
00337                     notify_quiet(executor, "Alias set.");
00338                 }
00339             }
00340             else
00341             {
00342                 notify_quiet(executor,
00343                     "That name is already in use or is illegal, alias cleared.");
00344                 atr_clr(thing, A_ALIAS);
00345             }
00346         }
00347         free_lbuf(trimalias);
00348         free_lbuf(oldalias);
00349     }
00350     else
00351     {
00352         atr_pget_info(thing, A_ALIAS, &aowner, &aflags);
00353 
00354         // Make sure we have rights to do it.
00355         //
00356         if (!bCanSetAttr(executor, thing, ap))
00357         {
00358             notify_quiet(executor, NOPERM_MESSAGE);
00359         }
00360         else
00361         {
00362             atr_add(thing, A_ALIAS, alias, Owner(executor), aflags);
00363             if (!Quiet(executor))
00364             {
00365                 notify_quiet(executor, "Set.");
00366             }
00367         }
00368     }
00369 }

void do_chown ( dbref  executor,
dbref  caller,
dbref  enactor,
int  key,
int  nargs,
char *  name,
char *  newown 
)

Definition at line 659 of file set.cpp.

References add_quota(), AF_LOCK, alloc_lbuf, AMBIGUOUS, atr_add(), atr_chown(), atr_get, atr_get_info(), bCanSetAttr(), canpayfees(), Chown_Any, CHOWN_OK, Chown_ok, Controls, db, confdata::digcost, confdata::exit_quota, FLAG_WORD1, free_lbuf, object::fs, giveto(), God, HALT, halt_que(), INHERIT, init_match(), isGarbage, isPlayer, isThing, Location, lookup_player(), match_absolute(), match_exit(), match_here(), match_me(), match_player(), match_possession(), match_result(), mudconf, Name, NOPERM_MESSAGE, NOTHING, notify_quiet, attr::number, OBJECT_DEPOSIT, confdata::opencost, Owner, parse_attrib(), Pennies(), confdata::player_quota, Quiet, confdata::quotas, confdata::robotcost, confdata::room_quota, s_Owner, s_Powers, s_Powers2, safe_str, See_attr, string_compare(), boolexp::thing, confdata::thing_quota, tprintf(), TYPE_EXIT, TYPE_PLAYER, TYPE_ROOM, TYPE_THING, Typeof, UNUSED_PARAMETER, Wizard, and flagset::word.

00668 {
00669     UNUSED_PARAMETER(caller);
00670     UNUSED_PARAMETER(enactor);
00671     UNUSED_PARAMETER(key);
00672     UNUSED_PARAMETER(nargs);
00673 
00674     dbref nOwnerOrig, nOwnerNew, thing;
00675     bool bDoit;
00676     ATTR *ap;
00677 
00678     if (  parse_attrib(executor, name, &thing, &ap)
00679        && ap
00680        && See_attr(executor, thing, ap))
00681     {
00682         // An attribute was given, so we worry about changing the owner of the
00683         // attribute.
00684         //
00685         nOwnerOrig = Owner(thing);
00686         if (!*newown)
00687         {
00688             nOwnerNew = nOwnerOrig;
00689         }
00690         else if (!string_compare(newown, "me"))
00691         {
00692             nOwnerNew = Owner(executor);
00693         }
00694         else
00695         {
00696             nOwnerNew = lookup_player(executor, newown, true);
00697         }
00698 
00699         // You may chown an attr to yourself if you own the object and the attr
00700         // is not locked. You may chown an attr to the owner of the object if
00701         // you own the attribute. To do anything else you must be a wizard.
00702         // Only #1 can chown attributes on #1.
00703         //
00704         dbref aowner;
00705         int   aflags;
00706         if (!atr_get_info(thing, ap->number, &aowner, &aflags))
00707         {
00708             notify_quiet(executor, "Attribute not present on object.");
00709             return;
00710         }
00711         bDoit = false;
00712         if (nOwnerNew == NOTHING)
00713         {
00714             notify_quiet(executor, "I couldn't find that player.");
00715         }
00716         else if (  God(thing)
00717                 && !God(executor))
00718         {
00719             notify_quiet(executor, NOPERM_MESSAGE);
00720         }
00721         else if (Wizard(executor))
00722         {
00723             bDoit = true;
00724         }
00725         else if (nOwnerNew == Owner(executor))
00726         {
00727             // Chown to me: only if I own the obj and !locked
00728             //
00729             if (  !Controls(executor, thing)
00730                || (aflags & AF_LOCK))
00731             {
00732                 notify_quiet(executor, NOPERM_MESSAGE);
00733             }
00734             else
00735             {
00736                 bDoit = true;
00737             }
00738         }
00739         else if (nOwnerNew == nOwnerOrig)
00740         {
00741             // chown to obj owner: only if I own attr and !locked
00742             //
00743             if (  Owner(executor) != aowner
00744                || (aflags & AF_LOCK))
00745             {
00746                 notify_quiet(executor, NOPERM_MESSAGE);
00747             }
00748             else
00749             {
00750                 bDoit = true;
00751             }
00752         }
00753         else
00754         {
00755             notify_quiet(executor, NOPERM_MESSAGE);
00756         }
00757 
00758         if (!bDoit)
00759         {
00760             return;
00761         }
00762 
00763         if (!bCanSetAttr(executor, executor, ap))
00764         {
00765             notify_quiet(executor, NOPERM_MESSAGE);
00766             return;
00767         }
00768         char *buff = atr_get(thing, ap->number, &aowner, &aflags);
00769         atr_add(thing, ap->number, buff, nOwnerNew, aflags);
00770         free_lbuf(buff);
00771         if (!Quiet(executor))
00772         {
00773             notify_quiet(executor, "Attribute owner changed.");
00774         }
00775         return;
00776     }
00777 
00778     // An attribute was not specified, so we are being asked to change the
00779     // owner of the object.
00780     //
00781     init_match(executor, name, TYPE_THING);
00782     match_possession();
00783     match_here();
00784     match_exit();
00785     match_me();
00786     if (Chown_Any(executor))
00787     {
00788         match_player();
00789         match_absolute();
00790     }
00791     switch (thing = match_result())
00792     {
00793     case NOTHING:
00794 
00795         notify_quiet(executor, "You don't have that!");
00796         return;
00797 
00798     case AMBIGUOUS:
00799 
00800         notify_quiet(executor, "I don't know which you mean!");
00801         return;
00802     }
00803     nOwnerOrig = Owner(thing);
00804 
00805     if (!*newown || !(string_compare(newown, "me")))
00806     {
00807         nOwnerNew = Owner(executor);
00808     }
00809     else
00810     {
00811         nOwnerNew = lookup_player(executor, newown, true);
00812     }
00813 
00814     int cost = 1, quota = 1;
00815 
00816     switch (Typeof(thing))
00817     {
00818     case TYPE_ROOM:
00819 
00820         cost = mudconf.digcost;
00821         quota = mudconf.room_quota;
00822         break;
00823 
00824     case TYPE_THING:
00825 
00826         cost = OBJECT_DEPOSIT(Pennies(thing));
00827         quota = mudconf.thing_quota;
00828         break;
00829 
00830     case TYPE_EXIT:
00831 
00832         cost = mudconf.opencost;
00833         quota = mudconf.exit_quota;
00834         break;
00835 
00836     case TYPE_PLAYER:
00837 
00838         cost = mudconf.robotcost;
00839         quota = mudconf.player_quota;
00840         break;
00841     }
00842 
00843     bool bPlayerControlsThing = Controls(executor, thing);
00844     if (  isGarbage(thing)
00845        && bPlayerControlsThing)
00846     {
00847         notify_quiet(executor, "You shouldn't be rummaging through the garbage.");
00848     }
00849     else if (nOwnerNew == NOTHING)
00850     {
00851         notify_quiet(executor, "I couldn't find that player.");
00852     }
00853     else if (  isPlayer(thing)
00854             && !God(executor))
00855     {
00856         notify_quiet(executor, "Players always own themselves.");
00857     }
00858     else if (  (  !bPlayerControlsThing
00859                && !Chown_Any(executor)
00860                && !Chown_ok(thing))
00861             || (  isThing(thing)
00862                && Location(thing) != executor
00863                && !Chown_Any(executor))
00864             || !Controls(executor, nOwnerNew)
00865             || God(thing))
00866     {
00867         notify_quiet(executor, NOPERM_MESSAGE);
00868     }
00869     else if (canpayfees(executor, nOwnerNew, cost, quota))
00870     {
00871         giveto(nOwnerOrig, cost);
00872         if (mudconf.quotas)
00873         {
00874             add_quota(nOwnerOrig, quota);
00875         }
00876         if (!God(executor))
00877         {
00878             nOwnerNew = Owner(nOwnerNew);
00879         }
00880         s_Owner(thing, nOwnerNew);
00881         atr_chown(thing);
00882         db[thing].fs.word[FLAG_WORD1] &= ~(CHOWN_OK | INHERIT);
00883         db[thing].fs.word[FLAG_WORD1] |= HALT;
00884         s_Powers(thing, 0);
00885         s_Powers2(thing, 0);
00886         halt_que(NOTHING, thing);
00887         if (!Quiet(executor))
00888         {
00889             char *buff = alloc_lbuf("do_chown.notify");
00890             char *bp = buff;
00891 
00892             char *p;
00893             p = tprintf("Owner of %s(#%d) changed from ", Name(thing), thing);
00894             safe_str(p, buff, &bp);
00895             p = tprintf("%s(#%d) to ", Name(nOwnerOrig), nOwnerOrig);
00896             safe_str(p, buff, &bp);
00897             p = tprintf("%s(#%d).", Name(nOwnerNew), nOwnerNew);
00898             safe_str(p, buff, &bp);
00899             *bp = '\0';
00900             notify_quiet(executor, buff);
00901             free_lbuf(buff);
00902         }
00903     }
00904 }

void do_chzone ( dbref  executor,
dbref  caller,
dbref  enactor,
int  key,
int  nargs,
char *  name,
char *  newobj 
)

Definition at line 52 of file set.cpp.

References check_zone_handler(), Controls, db, Flags, confdata::have_zones, INHERIT, init_match(), isPlayer, isRoom, isThing, match_everything(), mudconf, mux_stricmp(), noisy_match_result(), NOTHING, notify, NOTYPE, Powers, ROYALTY, UNUSED_PARAMETER, WIZARD, Wizard, and object::zone.

00061 {
00062     UNUSED_PARAMETER(caller);
00063     UNUSED_PARAMETER(enactor);
00064     UNUSED_PARAMETER(key);
00065     UNUSED_PARAMETER(nargs);
00066 
00067     if (!mudconf.have_zones)
00068     {
00069         notify(executor, "Zones disabled.");
00070         return;
00071     }
00072     init_match(executor, name, NOTYPE);
00073     match_everything(0);
00074     dbref thing = noisy_match_result();
00075     if (thing == NOTHING)
00076     {
00077         return;
00078     }
00079 
00080     dbref zone;
00081     if (  newobj[0] == '\0'
00082        || !mux_stricmp(newobj, "none"))
00083     {
00084         zone = NOTHING;
00085     }
00086     else
00087     {
00088         init_match(executor, newobj, NOTYPE);
00089         match_everything(0);
00090         zone = noisy_match_result();
00091         if (zone == NOTHING)
00092         {
00093             return;
00094         }
00095         if (  !isThing(zone)
00096            && !isRoom(zone))
00097         {
00098             notify(executor, "Invalid zone object type.");
00099             return;
00100         }
00101     }
00102 
00103     if (  !Wizard(executor)
00104        && !Controls(executor, thing)
00105        && !check_zone_handler(executor, thing, true)
00106        && db[executor].owner != db[thing].owner)
00107     {
00108         notify(executor, "You don't have the power to shift reality.");
00109         return;
00110     }
00111 
00112     // A player may change an object's zone to NOTHING or to an object he owns.
00113     //
00114     if (  zone != NOTHING
00115        && !Wizard(executor)
00116        && !Controls(executor, zone)
00117        && db[executor].owner != db[zone].owner)
00118     {
00119         notify(executor, "You cannot move that object to that zone.");
00120         return;
00121     }
00122 
00123     // Only rooms may be zoned to other rooms.
00124     //
00125     if (  zone != NOTHING
00126        && isRoom(zone)
00127        && !isRoom(thing))
00128     {
00129         notify(executor, "Only rooms may have parent rooms.");
00130         return;
00131     }
00132 
00133     // Everything is okay, do the change.
00134     //
00135     db[thing].zone = zone;
00136     if (!isPlayer(thing))
00137     {
00138         // If the object is a player, resetting these flags is rather
00139         // inconvenient -- although this may pose a bit of a security risk. Be
00140         // careful when @chzone'ing wizard or royal players.
00141         //
00142         Flags(thing) &= ~(WIZARD | ROYALTY | INHERIT);
00143 
00144         // Wipe out all powers.
00145         //
00146         Powers(thing) = 0;
00147     }
00148     notify(executor, "Zone changed.");
00149 }

void do_cpattr ( dbref  executor,
dbref  caller,
dbref  enactor,
int  key,
char *  oldpair,
char *  newpair[],
int  nargs 
)

Definition at line 1175 of file set.cpp.

References do_set(), parse_to(), tprintf(), and UNUSED_PARAMETER.

01177 {
01178     UNUSED_PARAMETER(key);
01179 
01180     int i;
01181     char *oldthing, *oldattr, *newthing, *newattr;
01182 
01183     if (  !*oldpair
01184        || !**newpair
01185        || !oldpair
01186        || !*newpair
01187        || nargs < 1)
01188     {
01189         return;
01190     }
01191 
01192     oldattr = oldpair;
01193     oldthing = parse_to(&oldattr, '/', 1);
01194 
01195     for (i = 0; i < nargs; i++)
01196     {
01197         newattr = newpair[i];
01198         newthing = parse_to(&newattr, '/', 1);
01199 
01200         if (!oldattr)
01201         {
01202             if (!newattr)
01203             {
01204                 do_set(executor, caller, enactor, 0, 2, newthing,
01205                     tprintf("%s:_%s/%s", oldthing, "me", oldthing));
01206             }
01207             else
01208             {
01209                 do_set(executor, caller, enactor, 0, 2, newthing,
01210                     tprintf("%s:_%s/%s", newattr, "me", oldthing));
01211             }
01212         }
01213         else
01214         {
01215             if (!newattr)
01216             {
01217                 do_set(executor, caller, enactor, 0, 2, newthing,
01218                     tprintf("%s:_%s/%s", oldattr, oldthing, oldattr));
01219             }
01220             else
01221             {
01222                 do_set(executor, caller, enactor, 0, 2, newthing,
01223                     tprintf("%s:_%s/%s", newattr, oldthing, oldattr));
01224             }
01225         }
01226     }
01227 }

void do_edit ( dbref  executor,
dbref  caller,
dbref  enactor,
int  key,
char *  it,
char *  args[],
int  nargs 
)

Definition at line 1638 of file set.cpp.

References alloc_lbuf, atr_add(), atr_get_str(), atr_num(), bCanSetAttr(), edit_string_ansi(), free_lbuf, handle_ears(), Hearer(), attr::name, NOTHING, notify_quiet, attr::number, olist_first(), olist_next(), olist_pop(), olist_push(), Owner, parse_attrib_wild(), Quiet, boolexp::thing, tprintf(), and UNUSED_PARAMETER.

01640 {
01641     UNUSED_PARAMETER(caller);
01642     UNUSED_PARAMETER(enactor);
01643     UNUSED_PARAMETER(key);
01644 
01645     dbref thing, aowner;
01646     int atr, aflags;
01647     bool bGotOne;
01648     char *from, *to, *result, *returnstr, *atext;
01649     ATTR *ap;
01650 
01651     // Make sure we have something to do.
01652     //
01653     if (  nargs < 1
01654        || !*args[0])
01655     {
01656         notify_quiet(executor, "Nothing to do.");
01657         return;
01658     }
01659     from = args[0];
01660     to = (nargs >= 2) ? args[1] : (char *)"";
01661 
01662     // Look for the object and get the attribute (possibly wildcarded)
01663     //
01664     olist_push();
01665     if (  !it
01666        || !*it
01667        || !parse_attrib_wild(executor, it, &thing, false, false, false))
01668     {
01669         notify_quiet(executor, "No match.");
01670         return;
01671     }
01672 
01673     // Iterate through matching attributes, performing edit.
01674     //
01675     bGotOne = 0;
01676     atext = alloc_lbuf("do_edit.atext");
01677     bool could_hear = Hearer(thing);
01678 
01679     for (atr = olist_first(); atr != NOTHING; atr = olist_next())
01680     {
01681         ap = atr_num(atr);
01682         if (ap)
01683         {
01684             // Get the attr and make sure we can modify it.
01685             //
01686             atr_get_str(atext, thing, ap->number, &aowner, &aflags);
01687             if (bCanSetAttr(executor, thing, ap))
01688             {
01689                 // Do the edit and save the result
01690                 //
01691                 bGotOne = true;
01692                 edit_string_ansi(atext, &result, &returnstr, from, to);
01693                 atr_add(thing, ap->number, result, Owner(executor), aflags);
01694                 if (!Quiet(executor))
01695                 {
01696                     notify_quiet(executor, tprintf("Set - %s: %s", ap->name,
01697                                  returnstr));
01698                 }
01699                 free_lbuf(result);
01700                 free_lbuf(returnstr);
01701             }
01702             else
01703             {
01704                 // No rights to change the attr.
01705                 //
01706                 notify_quiet(executor, tprintf("%s: Permission denied.", ap->name));
01707             }
01708 
01709         }
01710     }
01711 
01712     // Clean up.
01713     //
01714     free_lbuf(atext);
01715     olist_pop();
01716 
01717     if (!bGotOne)
01718     {
01719         notify_quiet(executor, "No matching attributes.");
01720     }
01721     else
01722     {
01723         handle_ears(thing, could_hear, Hearer(thing));
01724     }
01725 }

void do_forwardlist ( dbref  executor,
dbref  caller,
dbref  enactor,
int  key,
int  nargs,
char *  target,
char *  newlist 
)

Definition at line 375 of file set.cpp.

References A_FORWARDLIST, atr_add(), atr_clr(), atr_pget_info(), Controls, fwdlist_ck(), match_controlled, NOPERM_MESSAGE, NOTHING, notify_quiet, Owner, Quiet, set_modified(), and UNUSED_PARAMETER.

00384 {
00385     UNUSED_PARAMETER(caller);
00386     UNUSED_PARAMETER(enactor);
00387     UNUSED_PARAMETER(key);
00388     UNUSED_PARAMETER(nargs);
00389 
00390     dbref thing = match_controlled(executor, target);
00391     if (thing == NOTHING)
00392     {
00393         return;
00394     }
00395     dbref aowner, aflags;
00396     atr_pget_info(thing, A_FORWARDLIST, &aowner, &aflags);
00397 
00398     if (!Controls(executor, thing))
00399     {
00400         notify_quiet(executor, NOPERM_MESSAGE);
00401         return;
00402     }
00403     else if (!*newlist)
00404     {
00405         // New forwardlist is null, just clear it.
00406         //
00407         atr_clr(thing, A_FORWARDLIST);
00408         set_modified(thing);
00409         if (!Quiet(executor))
00410         {
00411             notify_quiet(executor, "Forwardlist removed.");
00412         }
00413     }
00414     else if (!fwdlist_ck(executor, thing, A_FORWARDLIST, newlist))
00415     {
00416         notify_quiet(executor, "Invalid forwardlist.");
00417         return;
00418     }
00419     else
00420     {
00421         atr_add(thing, A_FORWARDLIST, newlist, Owner(executor), aflags);
00422         if (!Quiet(executor))
00423         {
00424             notify_quiet(executor, "Set.");
00425         }
00426     }
00427 }

void do_lock ( dbref  executor,
dbref  caller,
dbref  enactor,
int  key,
int  nargs,
char *  name,
char *  keytext 
)

Definition at line 435 of file set.cpp.

References A_LOCK, AF_LOCK, AMBIGUOUS, atr_add_raw(), atr_get_info(), atr_set_flags(), bCanLockAttr(), Controls, free_boolexp(), init_match(), MAT_EXIT_PARENTS, match_everything(), match_result(), NOPERM_MESSAGE, NOTHING, notify_quiet, NOTYPE, attr::number, parse_attrib(), parse_boolexp(), Quiet, RemoveSetOfCharacters(), TRUE_BOOLEXP, unparse_boolexp_quiet(), and UNUSED_PARAMETER.

Referenced by CGuests::MakeGuestChar().

00444 {
00445     UNUSED_PARAMETER(caller);
00446     UNUSED_PARAMETER(enactor);
00447     UNUSED_PARAMETER(nargs);
00448 
00449     dbref thing;
00450     ATTR *ap;
00451 
00452     if (  parse_attrib(executor, name, &thing, &ap)
00453        && ap)
00454     {
00455         dbref aowner;
00456         int aflags;
00457         if (!atr_get_info(thing, ap->number, &aowner, &aflags))
00458         {
00459             notify_quiet(executor, "Attribute not present on object.");
00460             return;
00461         }
00462 
00463         if (bCanLockAttr(executor, thing, ap))
00464         {
00465             aflags |= AF_LOCK;
00466             atr_set_flags(thing, ap->number, aflags);
00467             if (  !Quiet(executor)
00468                && !Quiet(thing))
00469             {
00470                 notify_quiet(executor, "Attribute locked.");
00471             }
00472         }
00473         else
00474         {
00475             notify_quiet(executor, NOPERM_MESSAGE);
00476         }
00477         return;
00478     }
00479     init_match(executor, name, NOTYPE);
00480     match_everything(MAT_EXIT_PARENTS);
00481     thing = match_result();
00482 
00483     switch (thing)
00484     {
00485     case NOTHING:
00486         notify_quiet(executor, "I don't see what you want to lock!");
00487         return;
00488 
00489     case AMBIGUOUS:
00490         notify_quiet(executor, "I don't know which one you want to lock!");
00491         return;
00492 
00493     default:
00494         if (!Controls(executor, thing))
00495         {
00496             notify_quiet(executor, "You can't lock that!");
00497             return;
00498         }
00499     }
00500 
00501     char *pRestrictedKeyText = RemoveSetOfCharacters(keytext, "\r\n\t");
00502     struct boolexp *okey = parse_boolexp(executor, pRestrictedKeyText, false);
00503     if (okey == TRUE_BOOLEXP)
00504     {
00505         notify_quiet(executor, "I don't understand that key.");
00506     }
00507     else
00508     {
00509         // Everything ok, do it.
00510         //
00511         if (!key)
00512         {
00513             key = A_LOCK;
00514         }
00515         atr_add_raw(thing, key, unparse_boolexp_quiet(executor, okey));
00516         if (  !Quiet(executor)
00517            && !Quiet(thing))
00518         {
00519             notify_quiet(executor, "Locked.");
00520         }
00521     }
00522     free_boolexp(okey);
00523 }

void do_mvattr ( dbref  executor,
dbref  caller,
dbref  enactor,
int  key,
char *  what,
char *  args[],
int  nargs 
)

Definition at line 1230 of file set.cpp.

References alloc_lbuf, atr_add(), atr_clr(), atr_get_str(), atr_num(), atr_str(), bCanSetAttr(), free_lbuf, match_controlled, mkattr(), attr::name, NOTHING, notify_quiet, attr::number, Owner, Quiet, See_attr, boolexp::thing, tprintf(), and UNUSED_PARAMETER.

01232 {
01233     UNUSED_PARAMETER(caller);
01234     UNUSED_PARAMETER(enactor);
01235     UNUSED_PARAMETER(key);
01236 
01237     // Make sure we have something to do.
01238     //
01239     if (nargs < 2)
01240     {
01241         notify_quiet(executor, "Nothing to do.");
01242         return;
01243     }
01244 
01245     // Find and make sure we control the target object.
01246     //
01247     dbref thing = match_controlled(executor, what);
01248     if (thing == NOTHING)
01249     {
01250         return;
01251     }
01252 
01253     // Look up the source attribute.  If it either doesn't exist or isn't
01254     // readable, use an empty string.
01255     //
01256     int in_anum = -1;
01257     char *astr = alloc_lbuf("do_mvattr");
01258     ATTR *in_attr = atr_str(args[0]);
01259     int aflags = 0;
01260     if (in_attr == NULL)
01261     {
01262         *astr = '\0';
01263     }
01264     else
01265     {
01266         dbref aowner;
01267         atr_get_str(astr, thing, in_attr->number, &aowner, &aflags);
01268         if (See_attr(executor, thing, in_attr))
01269         {
01270             in_anum = in_attr->number;
01271         }
01272         else
01273         {
01274             *astr = '\0';
01275         }
01276     }
01277 
01278     // Copy the attribute to each target in turn.
01279     //
01280     bool bCanDelete = true;
01281     int  nCopied = 0;
01282     for (int i = 1; i < nargs; i++)
01283     {
01284         int anum = mkattr(executor, args[i]);
01285         if (anum <= 0)
01286         {
01287             notify_quiet(executor, tprintf("%s: That's not a good name for an attribute.", args[i]));
01288             continue;
01289         }
01290         ATTR *out_attr = atr_num(anum);
01291         if (!out_attr)
01292         {
01293             notify_quiet(executor, tprintf("%s: Permission denied.", args[i]));
01294         }
01295         else if (out_attr->number == in_anum)
01296         {
01297             // It doesn't make sense to delete a source attribute if it's also
01298             // included as a destination.
01299             //
01300             bCanDelete = false;
01301         }
01302         else
01303         {
01304             if (!bCanSetAttr(executor, thing, out_attr))
01305             {
01306                 notify_quiet(executor, tprintf("%s: Permission denied.", args[i]));
01307             }
01308             else
01309             {
01310                 nCopied++;
01311                 atr_add(thing, out_attr->number, astr, Owner(executor), aflags);
01312                 if (!Quiet(executor))
01313                 {
01314                     notify_quiet(executor, tprintf("%s: Set.", out_attr->name));
01315                 }
01316             }
01317         }
01318     }
01319 
01320     // Remove the source attribute if we were able to copy it successfully to
01321     // even one destination object.
01322     //
01323     if (nCopied <= 0)
01324     {
01325         if (in_attr)
01326         {
01327             notify_quiet(executor, tprintf("%s: Not copied anywhere. Not cleared.", in_attr->name));
01328         }
01329         else
01330         {
01331             notify_quiet(executor, "Not copied anywhere. Non-existent attribute.");
01332         }
01333     }
01334     else if (  in_anum > 0
01335             && bCanDelete)
01336     {
01337         in_attr = atr_num(in_anum);
01338         if (in_attr)
01339         {
01340             if (bCanSetAttr(executor, thing, in_attr))
01341             {
01342                 atr_clr(thing, in_attr->number);
01343                 if (!Quiet(executor))
01344                 {
01345                     notify_quiet(executor, tprintf("%s: Cleared.", in_attr->name));
01346                 }
01347             }
01348             else
01349             {
01350                 notify_quiet(executor,
01351                     tprintf("%s: Could not remove old attribute.  Permission denied.",
01352                     in_attr->name));
01353             }
01354         }
01355         else
01356         {
01357             notify_quiet(executor, "Could not remove old attribute. Non-existent attribute.");
01358         }
01359     }
01360     free_lbuf(astr);
01361 }

void do_name ( dbref  executor,
dbref  caller,
dbref  enactor,
int  key,
int  nargs,
char *  name,
char *  newname 
)

Definition at line 152 of file set.cpp.

References add_player_name(), badname_check(), delete_player_name(), ENDLOG, free_lbuf, isExit, isPlayer, log_name(), LOG_SECURITY, log_text(), lookup_player(), MakeCanonicalExitName(), MakeCanonicalObjectName(), match_controlled, Name, NOTHING, notify_quiet, Quiet, raw_broadcast(), s_Name(), set_modified(), STARTLOG, string_compare(), Suspect, trim_spaces(), UNUSED_PARAMETER, ValidatePlayerName(), and WIZARD.

00161 {
00162     UNUSED_PARAMETER(caller);
00163     UNUSED_PARAMETER(enactor);
00164     UNUSED_PARAMETER(key);
00165 
00166     dbref thing = match_controlled(executor, name);
00167     if (thing == NOTHING)
00168     {
00169         return;
00170     }
00171 
00172     // Check for bad name.
00173     //
00174     if (  nargs < 2
00175        || newname[0] == '\0')
00176     {
00177         notify_quiet(executor, "Give it what new name?");
00178         return;
00179     }
00180 
00181     // Check for renaming a player.
00182     //
00183     if (isPlayer(thing))
00184     {
00185         char *buff = trim_spaces(newname);
00186         if (  !ValidatePlayerName(buff)
00187            || !badname_check(buff))
00188         {
00189             notify_quiet(executor, "You can't use that name.");
00190             free_lbuf(buff);
00191             return;
00192         }
00193         else if (  string_compare(buff, Name(thing))
00194                 && lookup_player(NOTHING, buff, false) != NOTHING)
00195         {
00196             // string_compare allows changing foo to Foo, etc.
00197             //
00198             notify_quiet(executor, "That name is already in use.");
00199             free_lbuf(buff);
00200             return;
00201         }
00202 
00203         // Everything ok, notify.
00204         //
00205         STARTLOG(LOG_SECURITY, "SEC", "CNAME");
00206         log_name(thing),
00207         log_text(" renamed to ");
00208         log_text(buff);
00209         ENDLOG;
00210         if (Suspect(thing))
00211         {
00212             raw_broadcast(WIZARD, "[Suspect] %s renamed to %s", Name(thing), buff);
00213         }
00214         delete_player_name(thing, Name(thing));
00215         s_Name(thing, buff);
00216         set_modified(thing);
00217         add_player_name(thing, Name(thing));
00218         if (!Quiet(executor) && !Quiet(thing))
00219         {
00220             notify_quiet(executor, "Name set.");
00221         }
00222         free_lbuf(buff);
00223         return;
00224     }
00225     else
00226     {
00227         int nValidName;
00228         bool bValid;
00229         char *pValidName;
00230 
00231         if (isExit(thing))
00232         {
00233             pValidName = MakeCanonicalExitName(newname, &nValidName, &bValid);
00234         }
00235         else
00236         {
00237             pValidName = MakeCanonicalObjectName(newname, &nValidName, &bValid);
00238         }
00239 
00240         if (!bValid)
00241         {
00242             notify_quiet(executor, "That is not a reasonable name.");
00243             return;
00244         }
00245 
00246         // Everything ok, change the name.
00247         //
00248         s_Name(thing, pValidName);
00249         set_modified(thing);
00250         if (!Quiet(executor) && !Quiet(thing))
00251         {
00252             notify_quiet(executor, "Name set.");
00253         }
00254     }
00255 }

void do_power ( dbref  executor,
dbref  caller,
dbref  enactor,
int  key,
int  nargs,
char *  name,
char *  flag 
)

Definition at line 1118 of file set.cpp.

References match_controlled, NOTHING, notify_quiet, power_set(), boolexp::thing, and UNUSED_PARAMETER.

01127 {
01128     UNUSED_PARAMETER(caller);
01129     UNUSED_PARAMETER(enactor);
01130     UNUSED_PARAMETER(nargs);
01131 
01132     if (  !flag
01133        || !*flag)
01134     {
01135         notify_quiet(executor, "I don't know what you want to set!");
01136         return;
01137     }
01138 
01139     // Find thing.
01140     //
01141     dbref thing = match_controlled(executor, name);
01142     if (thing == NOTHING)
01143     {
01144         return;
01145     }
01146     power_set(thing, executor, flag, key);
01147 }

void do_set ( dbref  executor,
dbref  caller,
dbref  enactor,
int  key,
int  nargs,
char *  name,
char *  flagname 
)

Definition at line 937 of file set.cpp.

References alloc_lbuf, atr_get_info(), atr_num(), atr_pget_str(), atr_set_flags(), bCanSetAttr(), flag_set(), free_lbuf, Good_obj, handle_ears(), Hearer(), indiv_attraccess_nametab, match_controlled, mkattr(), NOPERM_MESSAGE, NOT_TOKEN, notify_quiet, attr::number, parse_attrib(), Quiet, search_nametab(), See_attr, set_attr_internal(), SET_QUIET, boolexp::thing, and UNUSED_PARAMETER.

Referenced by do_cpattr().

00946 {
00947     UNUSED_PARAMETER(caller);
00948     UNUSED_PARAMETER(enactor);
00949     UNUSED_PARAMETER(nargs);
00950 
00951     dbref thing, aowner;
00952     int aflags;
00953     ATTR *pattr;
00954 
00955     // See if we have the <obj>/<attr> form, which is how you set
00956     // attribute flags.
00957     //
00958     if (parse_attrib(executor, name, &thing, &pattr))
00959     {
00960         if (  pattr
00961            && See_attr(executor, thing, pattr))
00962         {
00963             // You must specify a flag name.
00964             //
00965             if (  !flagname
00966                || flagname[0] == '\0')
00967             {
00968                 notify_quiet(executor, "I don't know what you want to set!");
00969                 return;
00970             }
00971 
00972             // Check for clearing.
00973             //
00974             bool clear = false;
00975             if (flagname[0] == NOT_TOKEN)
00976             {
00977                 flagname++;
00978                 clear = true;
00979             }
00980 
00981             // Make sure player specified a valid attribute flag.
00982             //
00983             int flagvalue;
00984             if (!search_nametab(executor, indiv_attraccess_nametab, flagname, &flagvalue))
00985             {
00986                 notify_quiet(executor, "You can't set that!");
00987                 return;
00988             }
00989 
00990             // Make sure the object has the attribute present.
00991             //
00992             if (!atr_get_info(thing, pattr->number, &aowner, &aflags))
00993             {
00994                 notify_quiet(executor, "Attribute not present on object.");
00995                 return;
00996             }
00997 
00998             // Make sure we can write to the attribute.
00999             //
01000             if (!bCanSetAttr(executor, thing, pattr))
01001             {
01002                 notify_quiet(executor, NOPERM_MESSAGE);
01003                 return;
01004             }
01005 
01006             // Go do it.
01007             //
01008             if (clear)
01009             {
01010                 aflags &= ~flagvalue;
01011             }
01012             else
01013             {
01014                 aflags |= flagvalue;
01015             }
01016             bool could_hear = Hearer(thing);
01017 
01018             atr_set_flags(thing, pattr->number, aflags);
01019 
01020             // Tell the player about it.
01021             //
01022             handle_ears(thing, could_hear, Hearer(thing));
01023 
01024             if (  !(key & SET_QUIET)
01025                && !Quiet(executor)
01026                && !Quiet(thing))
01027             {
01028                 if (clear)
01029                 {
01030                     notify_quiet(executor, "Cleared.");
01031                 }
01032                 else
01033                 {
01034                     notify_quiet(executor, "Set.");
01035                 }
01036             }
01037             return;
01038         }
01039     }
01040 
01041     // Find thing.
01042     //
01043     thing = match_controlled(executor, name);
01044     if (!Good_obj(thing))
01045     {
01046         return;
01047     }
01048 
01049     // Check for attribute set first.
01050     //
01051     char *p;
01052     for (p = flagname; *p && (*p != ':'); p++)
01053     {
01054         ; // Nothing.
01055     }
01056 
01057     if (*p)
01058     {
01059         *p++ = 0;
01060         int atr = mkattr(executor, flagname);
01061         if (atr <= 0)
01062         {
01063             notify_quiet(executor, "Couldn't create attribute.");
01064             return;
01065         }
01066         pattr = atr_num(atr);
01067         if (!pattr)
01068         {
01069             notify_quiet(executor, NOPERM_MESSAGE);
01070             return;
01071         }
01072         if (!bCanSetAttr(executor, thing, pattr))
01073         {
01074             notify_quiet(executor, NOPERM_MESSAGE);
01075             return;
01076         }
01077         char *buff = alloc_lbuf("do_set");
01078 
01079         // Check for _
01080         //
01081         if (*p == '_')
01082         {
01083             ATTR *pattr2;
01084             dbref thing2;
01085 
01086             strcpy(buff, p + 1);
01087             if (!( parse_attrib(executor, p + 1, &thing2, &pattr2)
01088                 && pattr2))
01089             {
01090                 notify_quiet(executor, "No match.");
01091                 free_lbuf(buff);
01092                 return;
01093             }
01094             p = buff;
01095             atr_pget_str(buff, thing2, pattr2->number, &aowner, &aflags);
01096 
01097             if (!See_attr(executor, thing2, pattr2))
01098             {
01099                 notify_quiet(executor, NOPERM_MESSAGE);
01100                 free_lbuf(buff);
01101                 return;
01102             }
01103         }
01104 
01105         // Go set it.
01106         //
01107         set_attr_internal(executor, thing, atr, p, key);
01108         free_lbuf(buff);
01109         return;
01110     }
01111 
01112     // Set or clear a flag.
01113     //
01114     flag_set(thing, executor, flagname, key);
01115 }

void do_setattr ( dbref  executor,
dbref  caller,
dbref  enactor,
int  attrnum,
int  nargs,
char *  name,
char *  attrtext 
)

Definition at line 1150 of file set.cpp.

References Good_obj, init_match(), MAT_EXIT_PARENTS, match_everything(), noisy_match_result(), NOTYPE, set_attr_internal(), boolexp::thing, and UNUSED_PARAMETER.

Referenced by do_setvattr(), and init_cmdtab().

01159 {
01160     UNUSED_PARAMETER(caller);
01161     UNUSED_PARAMETER(enactor);
01162     UNUSED_PARAMETER(nargs);
01163 
01164     init_match(executor, name, NOTYPE);
01165     match_everything(MAT_EXIT_PARENTS);
01166     dbref thing = noisy_match_result();
01167 
01168     if (!Good_obj(thing))
01169     {
01170         return;
01171     }
01172     set_attr_internal(executor, thing, attrnum, attrtext, 0);
01173 }

void do_setvattr ( dbref  executor,
dbref  caller,
dbref  enactor,
int  key,
int  nargs,
char *  arg1,
char *  arg2 
)

Definition at line 1893 of file set.cpp.

References do_setattr(), mkattr(), mux_isspace, notify_quiet, and UNUSED_PARAMETER.

01902 {
01903     UNUSED_PARAMETER(key);
01904     UNUSED_PARAMETER(nargs);
01905 
01906     char *s;
01907     int anum;
01908 
01909     // Skip the '&'
01910     //
01911     arg1++;
01912 
01913     // Take to the space
01914     //
01915     for (s = arg1; *s && !mux_isspace(*s); s++)
01916     {
01917         ; // Nothing.
01918     }
01919 
01920     // Split it
01921     //
01922     if (*s)
01923     {
01924         *s++ = '\0';
01925     }
01926 
01927     // Get or make attribute
01928     //
01929     anum = mkattr(executor, arg1);
01930 
01931     if (anum <= 0)
01932     {
01933         notify_quiet(executor, "That's not a good name for an attribute.");
01934         return;
01935     }
01936     do_setattr(executor, caller, enactor, anum, 2, s, arg2);
01937 }

void do_trigger ( dbref  executor,
dbref  caller,
dbref  enactor,
int  key,
char *  object,
char *  argv[],
int  nargs 
)

Definition at line 1790 of file set.cpp.

References Controls, did_it(), NOPERM_MESSAGE, notify_quiet, attr::number, parse_attrib(), Quiet, boolexp::thing, TRIG_QUIET, and UNUSED_PARAMETER.

01792 {
01793     UNUSED_PARAMETER(caller);
01794     UNUSED_PARAMETER(enactor);
01795 
01796     dbref thing;
01797     ATTR *pattr;
01798 
01799     if (!( parse_attrib(executor, object, &thing, &pattr)
01800         && pattr))
01801     {
01802         notify_quiet(executor, "No match.");
01803         return;
01804     }
01805     if (!Controls(executor, thing))
01806     {
01807         notify_quiet(executor, NOPERM_MESSAGE);
01808         return;
01809     }
01810     did_it(executor, thing, 0, NULL, 0, NULL, pattr->number, argv, nargs);
01811 
01812     // TODO: Be more descriptive as to what was triggered?
01813     //
01814     if (  !(key & TRIG_QUIET)
01815        && !Quiet(executor))
01816     {
01817         notify_quiet(executor, "Triggered.");
01818     }
01819 }

void do_unlink ( dbref  executor,
dbref  caller,
dbref  enactor,
int  key,
char *  name 
)

Definition at line 591 of file set.cpp.

References AMBIGUOUS, Controls, giveto(), init_match(), confdata::linkcost, match_everything(), match_result(), mudconf, NOPERM_MESSAGE, NOTHING, notify_quiet, Owner, Quiet, s_Dropto, s_Location, TYPE_EXIT, TYPE_ROOM, Typeof, and UNUSED_PARAMETER.

Referenced by do_link().

00592 {
00593     UNUSED_PARAMETER(caller);
00594     UNUSED_PARAMETER(enactor);
00595     UNUSED_PARAMETER(key);
00596 
00597     dbref exit;
00598 
00599     init_match(executor, name, TYPE_EXIT);
00600     match_everything(0);
00601     exit = match_result();
00602 
00603     switch (exit)
00604     {
00605     case NOTHING:
00606 
00607         notify_quiet(executor, "Unlink what?");
00608         break;
00609 
00610     case AMBIGUOUS:
00611 
00612         notify_quiet(executor, "I don't know which one you mean!");
00613         break;
00614 
00615     default:
00616 
00617         if (!Controls(executor, exit))
00618         {
00619             notify_quiet(executor, NOPERM_MESSAGE);
00620         }
00621         else
00622         {
00623             switch (Typeof(exit))
00624             {
00625             case TYPE_EXIT:
00626 
00627                 s_Location(exit, NOTHING);
00628                 if (!Quiet(executor))
00629                 {
00630                     notify_quiet(executor, "Unlinked.");
00631                 }
00632                 giveto(Owner(exit), mudconf.linkcost);
00633                 break;
00634 
00635             case TYPE_ROOM:
00636 
00637                 s_Dropto(exit, NOTHING);
00638                 if (!Quiet(executor))
00639                 {
00640                     notify_quiet(executor, "Dropto removed.");
00641                 }
00642                 break;
00643 
00644             default:
00645 
00646                 notify_quiet(executor, "You can't unlink that!");
00647                 break;
00648             }
00649         }
00650     }
00651 }

void do_unlock ( dbref  executor,
dbref  caller,
dbref  enactor,
int  key,
char *  name 
)

Definition at line 530 of file set.cpp.

References A_LOCK, AF_LOCK, atr_clr(), atr_get_info(), atr_set_flags(), bCanLockAttr(), match_controlled, NOPERM_MESSAGE, NOTHING, notify_quiet, attr::number, parse_attrib(), Quiet, set_modified(), boolexp::thing, and UNUSED_PARAMETER.

00531 {
00532     UNUSED_PARAMETER(caller);
00533     UNUSED_PARAMETER(enactor);
00534 
00535     dbref thing;
00536     ATTR *ap;
00537 
00538     if (  parse_attrib(executor, name, &thing, &ap)
00539        && ap)
00540     {
00541         // We have been asked to unlock an attribute.
00542         //
00543         dbref aowner;
00544         int aflags;
00545         if (!atr_get_info(thing, ap->number, &aowner, &aflags))
00546         {
00547             notify_quiet(executor, "Attribute not present on object.");
00548             return;
00549         }
00550 
00551         if (bCanLockAttr(executor, thing, ap))
00552         {
00553             aflags &= ~AF_LOCK;
00554             atr_set_flags(thing, ap->number, aflags);
00555             if (  !Quiet(executor)
00556                && !Quiet(thing))
00557             {
00558                 notify_quiet(executor, "Attribute unlocked.");
00559             }
00560         }
00561         else
00562         {
00563             notify_quiet(executor, NOPERM_MESSAGE);
00564         }
00565         return;
00566     }
00567 
00568     // We have been asked to change the ownership of an object.
00569     //
00570     if (!key)
00571     {
00572         key = A_LOCK;
00573     }
00574     thing = match_controlled(executor, name);
00575     if (thing != NOTHING)
00576     {
00577         atr_clr(thing, key);
00578         set_modified(thing);
00579         if (!Quiet(executor) && !Quiet(thing))
00580         {
00581             notify_quiet(executor, "Unlocked.");
00582         }
00583     }
00584 }

void do_use ( dbref  executor,
dbref  caller,
dbref  enactor,
int  key,
char *  object 
)

Definition at line 1821 of file set.cpp.

References A_AUFAIL, A_AUSE, A_LUSE, A_OUFAIL, A_OUSE, A_UFAIL, A_USE, alloc_lbuf, atr_pget_str(), could_doit(), did_it(), free_lbuf, init_match(), match_absolute(), match_here(), match_me(), match_neighbor(), match_player(), match_possession(), Name, noisy_match_result(), NOTHING, notify_quiet, NOTYPE, boolexp::thing, UNUSED_PARAMETER, and Wizard.

01822 {
01823     UNUSED_PARAMETER(caller);
01824     UNUSED_PARAMETER(enactor);
01825     UNUSED_PARAMETER(key);
01826 
01827     char *df_use, *df_ouse, *temp;
01828     dbref thing, aowner;
01829     int aflags;
01830 
01831     init_match(executor, object, NOTYPE);
01832     match_neighbor();
01833     match_possession();
01834     if (Wizard(executor))
01835     {
01836         match_absolute();
01837         match_player();
01838     }
01839     match_me();
01840     match_here();
01841     thing = noisy_match_result();
01842     if (thing == NOTHING)
01843         return;
01844 
01845     // Make sure player can use it.
01846     //
01847     if (!could_doit(executor, thing, A_LUSE))
01848     {
01849         did_it(executor, thing, A_UFAIL,
01850                "You can't figure out how to use that.",
01851                A_OUFAIL, NULL, A_AUFAIL, (char **)NULL, 0);
01852         return;
01853     }
01854     temp = alloc_lbuf("do_use");
01855     bool doit = false;
01856     if (*atr_pget_str(temp, thing, A_USE, &aowner, &aflags))
01857     {
01858         doit = true;
01859     }
01860     else if (*atr_pget_str(temp, thing, A_OUSE, &aowner, &aflags))
01861     {
01862         doit = true;
01863     }
01864     else if (*atr_pget_str(temp, thing, A_AUSE, &aowner, &aflags))
01865     {
01866         doit = true;
01867     }
01868     free_lbuf(temp);
01869 
01870     if (doit)
01871     {
01872         df_use = alloc_lbuf("do_use.use");
01873         df_ouse = alloc_lbuf("do_use.ouse");
01874         sprintf(df_use, "You use %s", Name(thing));
01875         sprintf(df_ouse, "uses %s", Name(thing));
01876         did_it(executor, thing, A_USE, df_use, A_OUSE, df_ouse, A_AUSE,
01877                (char **)NULL, 0);
01878         free_lbuf(df_use);
01879         free_lbuf(df_ouse);
01880     }
01881     else
01882     {
01883         notify_quiet(executor, "You can't figure out how to use that.");
01884     }
01885 }

void do_wipe ( dbref  executor,
dbref  caller,
dbref  enactor,
int  key,
char *  it 
)

Definition at line 1727 of file set.cpp.

References atr_clr(), atr_num(), bCanSetAttr(), handle_ears(), has_flag(), Hearer(), mudconf, NOTHING, notify_quiet, attr::number, olist_first(), olist_next(), olist_pop(), olist_push(), parse_attrib_wild(), Quiet, confdata::safe_wipe, set_modified(), boolexp::thing, and UNUSED_PARAMETER.

01728 {
01729     UNUSED_PARAMETER(caller);
01730     UNUSED_PARAMETER(enactor);
01731     UNUSED_PARAMETER(key);
01732 
01733     dbref thing;
01734 
01735     olist_push();
01736     if (  !it
01737        || !*it
01738        || !parse_attrib_wild(executor, it, &thing, false, false, true))
01739     {
01740         notify_quiet(executor, "No match.");
01741         return;
01742     }
01743     if (  mudconf.safe_wipe
01744        && has_flag(NOTHING, thing, "SAFE"))
01745     {
01746         notify_quiet(executor, "SAFE objects may not be @wiped.");
01747         return;
01748     }
01749 
01750     // Iterate through matching attributes, zapping the writable ones
01751     //
01752     int atr;
01753     ATTR *ap;
01754     bool bGotOne = false, could_hear = Hearer(thing);
01755 
01756     for (atr = olist_first(); atr != NOTHING; atr = olist_next())
01757     {
01758         ap = atr_num(atr);
01759         if (ap)
01760         {
01761             // Get the attr and make sure we can modify it.
01762             //
01763             if (bCanSetAttr(executor, thing, ap))
01764             {
01765                 atr_clr(thing, ap->number);
01766                 bGotOne = true;
01767             }
01768         }
01769     }
01770 
01771     // Clean up
01772     //
01773     olist_pop();
01774 
01775     if (!bGotOne)
01776     {
01777         notify_quiet(executor, "No matching attributes.");
01778     }
01779     else
01780     {
01781         set_modified(thing);
01782         handle_ears(thing, could_hear, Hearer(thing));
01783         if (!Quiet(executor))
01784         {
01785             notify_quiet(executor, "Wiped.");
01786         }
01787     }
01788 }

void edit_string ( char *  src,
char **  dst,
char *  from,
char *  to 
)

Definition at line 1529 of file set.cpp.

References alloc_lbuf, replace_string(), and safe_str.

Referenced by FUNCTION().

01530 {
01531     char *cp;
01532 
01533     // Do the substitution.  Idea for prefix/suffix from R'nice@TinyTIM.
01534     //
01535     if (!strcmp(from, "^"))
01536     {
01537         // Prepend 'to' to string.
01538         //
01539         *dst = alloc_lbuf("edit_string.^");
01540         cp = *dst;
01541         safe_str(to, *dst, &cp);
01542         safe_str(src, *dst, &cp);
01543         *cp = '\0';
01544     }
01545     else if (!strcmp(from, "$"))
01546     {
01547         // Append 'to' to string.
01548         //
01549         *dst = alloc_lbuf("edit_string.$");
01550         cp = *dst;
01551         safe_str(src, *dst, &cp);
01552         safe_str(to, *dst, &cp);
01553         *cp = '\0';
01554     }
01555     else
01556     {
01557         // Replace all occurances of 'from' with 'to'. Handle the special
01558         // cases of from = \$ and \^.
01559         //
01560         if (  (  from[0] == '\\'
01561               || from[0] == '%')
01562            && (  from[1] == '$'
01563               || from[1] == '^')
01564            && from[2] == '\0')
01565         {
01566             from++;
01567         }
01568         *dst = replace_string(from, to, src);
01569     }
01570 }

static void edit_string_ansi ( char *  src,
char **  dst,
char **  returnstr,
char *  from,
char *  to 
) [static]

Definition at line 1572 of file set.cpp.

References alloc_lbuf, ANSI_HILITE, ANSI_NORMAL, replace_string(), safe_str, and tprintf().

Referenced by do_edit().

01573 {
01574     char *cp, *rp;
01575 
01576     // Do the substitution.  Idea for prefix/suffix from R'nice@TinyTIM
01577     //
01578     if (!strcmp(from, "^"))
01579     {
01580         // Prepend 'to' to string.
01581         //
01582         *dst = alloc_lbuf("edit_string.^");
01583         cp = *dst;
01584         safe_str(to, *dst, &cp);
01585         safe_str(src, *dst, &cp);
01586         *cp = '\0';
01587 
01588         // Do the ansi string used to notify.
01589         //
01590         *returnstr = alloc_lbuf("edit_string_ansi.^");
01591         rp = *returnstr;
01592         safe_str(ANSI_HILITE, *returnstr, &rp);
01593         safe_str(to, *returnstr, &rp);
01594         safe_str(ANSI_NORMAL, *returnstr, &rp);
01595         safe_str(src, *returnstr, &rp);
01596         *rp = '\0';
01597 
01598     }
01599     else if (!strcmp(from, "$"))
01600     {
01601         // Append 'to' to string
01602         //
01603         *dst = alloc_lbuf("edit_string.$");
01604         cp = *dst;
01605         safe_str(src, *dst, &cp);
01606         safe_str(to, *dst, &cp);
01607         *cp = '\0';
01608 
01609         // Do the ansi string used to notify.
01610         //
01611         *returnstr = alloc_lbuf("edit_string_ansi.$");
01612         rp = *returnstr;
01613         safe_str(src, *returnstr, &rp);
01614         safe_str(ANSI_HILITE, *returnstr, &rp);
01615         safe_str(to, *returnstr, &rp);
01616         safe_str(ANSI_NORMAL, *returnstr, &rp);
01617         *rp = '\0';
01618 
01619     }
01620     else
01621     {
01622         // Replace all occurances of 'from' with 'to'. Handle the special
01623         // cases of from = \$ and \^.
01624         //
01625         if (  ((from[0] == '\\') || (from[0] == '%'))
01626            && ((from[1] == '$')  || (from[1] == '^'))
01627            && ( from[2] == '\0'))
01628         {
01629             from++;
01630         }
01631 
01632         *dst = replace_string(from, to, src);
01633         *returnstr = replace_string(from, tprintf("%s%s%s", ANSI_HILITE,
01634                              to, ANSI_NORMAL), src);
01635     }
01636 }

static void find_wild_attrs ( dbref  player,
dbref  thing,
char *  str,
bool  check_exclude,
bool  hash_insert,
bool  get_locks 
) [static]

Definition at line 1398 of file set.cpp.

References AF_PRIVATE, atr_get_info(), atr_head(), atr_next(), atr_num(), atr_pop(), atr_push(), bCanReadAttr(), attr::flags, hashaddLEN(), hashfindLEN(), mudstate, attr::name, olist_add(), statedata::parent_htab, quick_wild(), See_attr, and statedata::wild_invk_ctr.

Referenced by parse_attrib_wild().

01399 {
01400     ATTR *pattr;
01401     char *as;
01402     dbref aowner;
01403     int ca, ok, aflags;
01404 
01405     // Walk the attribute list of the object.
01406     //
01407     atr_push();
01408     for (ca = atr_head(thing, &as); ca; ca = atr_next(&as))
01409     {
01410         pattr = atr_num(ca);
01411 
01412         // Discard bad attributes and ones we've seen before.
01413         //
01414         if (!pattr)
01415         {
01416             continue;
01417         }
01418 
01419         if (  check_exclude
01420            && (  (pattr->flags & AF_PRIVATE)
01421               || hashfindLEN(&ca, sizeof(ca), &mudstate.parent_htab)))
01422         {
01423             continue;
01424         }
01425 
01426         // If we aren't the top level remember this attr so we exclude it in
01427         // any parents.
01428         //
01429         atr_get_info(thing, ca, &aowner, &aflags);
01430         if (  check_exclude
01431            && (aflags & AF_PRIVATE))
01432         {
01433             continue;
01434         }
01435 
01436         if (get_locks)
01437         {
01438             ok = bCanReadAttr(player, thing, pattr, false);
01439         }
01440         else
01441         {
01442             ok = See_attr(player, thing, pattr);
01443         }
01444 
01445         mudstate.wild_invk_ctr = 0;
01446         if (  ok
01447            && quick_wild(str, pattr->name))
01448         {
01449             olist_add(ca);
01450             if (hash_insert)
01451             {
01452                 hashaddLEN(&ca, sizeof(ca), pattr, &mudstate.parent_htab);
01453             }
01454         }
01455     }
01456     atr_pop();
01457 }

dbref match_controlled_handler ( dbref  executor,
const char *  name,
bool  bQuiet 
)

Definition at line 22 of file set.cpp.

References Controls, Good_obj, init_match(), MAT_EXIT_PARENTS, match_everything(), match_result(), noisy_match_result(), NOPERM_MESSAGE, NOTHING, notify_quiet, and NOTYPE.

00023 {
00024     dbref mat;
00025     init_match(executor, name, NOTYPE);
00026     match_everything(MAT_EXIT_PARENTS);
00027     if (bQuiet)
00028     {
00029         mat = match_result();
00030     }
00031     else
00032     {
00033         mat = noisy_match_result();
00034     }
00035     if (!Good_obj(mat))
00036     {
00037         return mat;
00038     }
00039 
00040     if (Controls(executor, mat))
00041     {
00042         return mat;
00043     }
00044     if (!bQuiet)
00045     {
00046         notify_quiet(executor, NOPERM_MESSAGE);
00047     }
00048     return NOTHING;
00049 }

bool parse_attrib ( dbref  player,
char *  str,
dbref thing,
ATTR **  attr 
)

Definition at line 1368 of file set.cpp.

References alloc_lbuf, atr_str(), attr, free_lbuf, NOTHING, and parse_thing_slash().

Referenced by default_handler(), do_addcommand(), do_chown(), do_delcommand(), do_function(), do_lock(), do_prog(), do_set(), do_trigger(), do_unlock(), FUNCTION(), get_handler(), and parse_and_get_attrib().

01369 {
01370     ATTR *tattr = NULL;
01371     *thing = NOTHING;
01372 
01373     if (!str)
01374     {
01375         *attr = tattr;
01376         return false;
01377     }
01378 
01379     // Break apart string into obj and attr.
01380     //
01381     char *buff = alloc_lbuf("parse_attrib");
01382     strcpy(buff, str);
01383     char *AttrName;
01384     bool retval = parse_thing_slash(player, buff, &AttrName, thing);
01385 
01386     // Get the named attribute from the object if we can.
01387     //
01388     if (retval)
01389     {
01390         tattr = atr_str(AttrName);
01391     }
01392 
01393     free_lbuf(buff);
01394     *attr = tattr;
01395     return retval;
01396 }

bool parse_attrib_wild ( dbref  player,
char *  str,
dbref thing,
bool  check_parents,
bool  get_locks,
bool  df_star 
)

Definition at line 1459 of file set.cpp.

References alloc_lbuf, find_wild_attrs(), free_lbuf, Good_obj, hashflush(), init_match(), ITER_PARENTS, MAT_EXIT_PARENTS, match_everything(), match_result(), mudstate, NOTYPE, Parent, statedata::parent_htab, and parse_thing_slash().

Referenced by do_decomp(), do_edit(), do_examine(), do_wipe(), FUNCTION(), grep_util(), and lattr_handler().

01461 {
01462     if (!str)
01463     {
01464         return false;
01465     }
01466 
01467     dbref parent;
01468     int lev;
01469     bool check_exclude, hash_insert;
01470     char *buff = alloc_lbuf("parse_attrib_wild");
01471     strcpy(buff, str);
01472 
01473     // Separate name and attr portions at the first /.
01474     //
01475     if (!parse_thing_slash(player, buff, &str, thing))
01476     {
01477         // Not in obj/attr format, return if not defaulting to.
01478         //
01479         if (!df_star)
01480         {
01481             free_lbuf(buff);
01482             return false;
01483         }
01484 
01485         // Look for the object, return failure if not found.
01486         //
01487         init_match(player, buff, NOTYPE);
01488         match_everything(MAT_EXIT_PARENTS);
01489         *thing = match_result();
01490 
01491         if (!Good_obj(*thing))
01492         {
01493             free_lbuf(buff);
01494             return false;
01495         }
01496         str = (char *)"*";
01497     }
01498 
01499     // Check the object (and optionally all parents) for attributes.
01500     //
01501     if (check_parents)
01502     {
01503         check_exclude = false;
01504         hash_insert = check_parents;
01505         hashflush(&mudstate.parent_htab);
01506         ITER_PARENTS(*thing, parent, lev)
01507         {
01508             if (!Good_obj(Parent(parent)))
01509             {
01510                 hash_insert = false;
01511             }
01512             find_wild_attrs(player, parent, str, check_exclude, hash_insert, get_locks);
01513             check_exclude = true;
01514         }
01515     }
01516     else
01517     {
01518         find_wild_attrs(player, *thing, str, false, false, get_locks);
01519     }
01520     free_lbuf(buff);
01521     return true;
01522 }

static void set_attr_internal ( dbref  player,
dbref  thing,
int  attrnum,
char *  attrtext,
int  key 
) [static]

Definition at line 911 of file set.cpp.

References atr_add(), atr_num(), atr_pget_info(), bCanSetAttr(), handle_ears(), Hearer(), NOPERM_MESSAGE, notify_quiet, Owner, Quiet, and SET_QUIET.

00912 {
00913     dbref aowner;
00914     int aflags;
00915     ATTR *pattr = atr_num(attrnum);
00916     atr_pget_info(thing, attrnum, &aowner, &aflags);
00917     if (  pattr
00918        && bCanSetAttr(player, thing, pattr))
00919     {
00920         bool could_hear = Hearer(thing);
00921         atr_add(thing, attrnum, attrtext, Owner(player), aflags);
00922         handle_ears(thing, could_hear, Hearer(thing));
00923         if (  !(key & SET_QUIET)
00924            && !Quiet(player)
00925            && !Quiet(thing))
00926         {
00927             notify_quiet(player, "Set.");
00928         }
00929     }
00930     else
00931     {
00932         notify_quiet(player, NOPERM_MESSAGE);
00933     }
00934 }

void set_modified ( dbref  thing  ) 

Definition at line 15 of file set.cpp.

References A_MODIFIED, atr_add_raw(), CLinearTimeAbsolute::GetLocal(), and CLinearTimeAbsolute::ReturnDateString().

Referenced by atr_add(), do_forwardlist(), do_moniker(), do_name(), do_unlock(), and do_wipe().

00016 {
00017     CLinearTimeAbsolute ltaNow;
00018     ltaNow.GetLocal();
00019     atr_add_raw(thing, A_MODIFIED, ltaNow.ReturnDateString(7));
00020 }


Generated on Mon May 28 04:40:22 2007 for MUX by  doxygen 1.4.7