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         {