src/set.c File Reference

#include "copyright.h"
#include "config.h"
#include "mudconf.h"
#include "db.h"
#include "match.h"
#include "interface.h"
#include "externs.h"
#include "flags.h"
#include "powers.h"
#include "attrs.h"
#include "alloc.h"
#include "ansi.h"
#include "p.comsys.h"

Include dependency graph for set.c:

Go to the source code of this file.

Functions

void lower_xp (dbref, int)
char * silly_atr_get (int id, int flag)
void silly_atr_set (int id, int flag, char *dat)
dbref match_controlled (dbref player, char *name)
dbref match_controlled_quiet (dbref player, char *name)
dbref match_affected (dbref player, char *name)
dbref match_examinable (dbref player, char *name)
void do_chzone (dbref player, dbref cause, int key, char *name, char *newobj)
void do_name (dbref player, dbref cause, int key, char *name, char *newname)
void do_alias (dbref player, dbref cause, int key, char *name, char *alias)
void do_lock (dbref player, dbref cause, int key, char *name, char *keytext)
void do_unlock (dbref player, dbref cause, int key, char *name)
void do_unlink (dbref player, dbref cause, int key, char *name)
void do_chown (dbref player, dbref cause, int key, char *name, char *newown)
void set_attr_internal (dbref player, dbref thing, int attrnum, char *attrtext, int key)
void do_set (dbref player, dbref cause, int key, char *name, char *flag)
void do_power (dbref player, dbref cause, int key, char *name, char *flag)
void do_setattr (dbref player, dbref cause, int attrnum, char *name, char *attrtext)
void do_cpattr (dbref player, dbref cause, int key, char *oldpair, char *newpair[], int nargs)
void do_mvattr (dbref player, dbref cause, int key, char *what, char *args[], int nargs)
int parse_attrib (dbref player, char *str, dbref *thing, int *atr)
static void find_wild_attrs (dbref player, dbref thing, char *str, int check_exclude, int hash_insert, int get_locks)
int parse_attrib_wild (dbref player, char *str, dbref *thing, int check_parents, int get_locks, int df_star)
void edit_string (char *src, char **dst, char *from, char *to)
void edit_string_ansi (char *src, char **dst, char **returnstr, char *from, char *to)
void do_edit (dbref player, dbref cause, int key, char *it, char *args[], int nargs)
void do_wipe (dbref player, dbref cause, int key, char *it)
void do_trigger (dbref player, dbref cause, int key, char *object, char *argv[], int nargs)
void do_use (dbref player, dbref cause, int key, char *object)
void do_setvattr (dbref player, dbref cause, int key, char *arg1, char *arg2)

Variables

NAMETAB indiv_attraccess_nametab []


Function Documentation

void do_alias ( dbref  player,
dbref  cause,
int  key,
char *  name,
char *  alias 
)

Definition at line 248 of file set.c.

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

00249 {
00250         dbref thing, aowner;
00251         int aflags;
00252         ATTR *ap;
00253         char *oldalias, *trimalias;
00254 
00255         if((thing = match_controlled(player, name)) == NOTHING)
00256                 return;
00257 
00258         /*
00259          * check for renaming a player 
00260          */
00261 
00262         ap = atr_num(A_ALIAS);
00263         if(isPlayer(thing)) {
00264 
00265                 /*
00266                  * Fetch the old alias 
00267                  */
00268 
00269                 oldalias = atr_pget(thing, A_ALIAS, &aowner, &aflags);
00270                 trimalias = trim_spaces(alias);
00271 
00272                 if(!Controls(player, thing)) {
00273 
00274                         /*
00275                          * Make sure we have rights to do it.  We can't do *
00276                          * * * * the normal Set_attr check because ALIAS is * 
00277                          * only * * * writable by GOD and we want to keep *
00278                          * people * from * * doing &ALIAS and bypassing the * 
00279                          * player * name checks. 
00280                          */
00281 
00282                         notify_quiet(player, "Permission denied.");
00283                 } else if(!*trimalias) {
00284 
00285                         /*
00286                          * New alias is null, just clear it 
00287                          */
00288 
00289                         delete_player_name(thing, oldalias);
00290                         atr_clr(thing, A_ALIAS);
00291                         if(!Quiet(player))
00292                                 notify_quiet(player, "Alias removed.");
00293                 } else if(lookup_player(NOTHING, trimalias, 0) != NOTHING) {
00294 
00295                         /*
00296                          * Make sure new alias isn't already in use 
00297                          */
00298 
00299                         notify_quiet(player, "That name is already in use.");
00300                 } else if(!(badname_check(trimalias) && ok_player_name(trimalias))) {
00301                         notify_quiet(player, "That's a silly name for a player!");
00302                 } else {
00303 
00304                         /*
00305                          * Remove the old name and add the new name 
00306                          */
00307 
00308                         delete_player_name(thing, oldalias);
00309                         atr_add(thing, A_ALIAS, trimalias, Owner(player), aflags);
00310                         if(add_player_name(thing, trimalias)) {
00311                                 if(!Quiet(player))
00312                                         notify_quiet(player, "Alias set.");
00313                         } else {
00314                                 notify_quiet(player,
00315                                                          "That name is already in use or is illegal, alias cleared.");
00316                                 atr_clr(thing, A_ALIAS);
00317                         }
00318                 }
00319                 free_lbuf(trimalias);
00320                 free_lbuf(oldalias);
00321         } else {
00322                 atr_pget_info(thing, A_ALIAS, &aowner, &aflags);
00323 
00324                 /*
00325                  * Make sure we have rights to do it 
00326                  */
00327 
00328                 if(!Set_attr(player, thing, ap, aflags)) {
00329                         notify_quiet(player, "Permission denied.");
00330                 } else {
00331                         atr_add(thing, A_ALIAS, alias, Owner(player), aflags);
00332                         if(!Quiet(player))
00333                                 notify_quiet(player, "Set.");
00334                 }
00335         }
00336 }

void do_chown ( dbref  player,
dbref  cause,
int  key,
char *  name,
char *  newown 
)

Definition at line 516 of file set.c.

References add_quota(), AF_LOCK, AMBIGUOUS, atr_chown(), atr_get_info(), atr_num(), atr_set_owner(), canpayfees(), Chown_Any, CHOWN_OK, Chown_ok, controls, Controls, confdata::digcost, confdata::exit_quota, Flags, giveto(), God, HALT, halt_que(), INHERIT, init_match(), isPlayer, isThing, Location, lookup_player(), match_absolute(), match_exit(), match_here(), match_me(), match_player(), match_possession(), match_result(), mudconf, NOTHING, notify_quiet, OBJECT_DEPOSIT, confdata::opencost, Owner, parse_attrib(), Pennies(), confdata::player_quota, Quiet, confdata::quotas, confdata::robotcost, confdata::room_quota, s_Flags, s_Owner, s_Powers, s_Powers2, Set_attr, string_compare(), boolexp::thing, confdata::thing_quota, TYPE_EXIT, TYPE_PLAYER, TYPE_ROOM, TYPE_THING, Typeof, and Wizard.

00517 {
00518         dbref thing, owner, aowner;
00519         int atr, aflags, do_it, cost, quota;
00520         ATTR *ap;
00521 
00522         if(parse_attrib(player, name, &thing, &atr)) {
00523                 if(atr != NOTHING) {
00524                         if(!*newown) {
00525                                 owner = Owner(thing);
00526                         } else if(!(string_compare(newown, "me"))) {
00527                                 owner = Owner(player);
00528                         } else {
00529                                 owner = lookup_player(player, newown, 1);
00530                         }
00531 
00532                         /*
00533                          * You may chown an attr to yourself if you own the * 
00534                          * 
00535                          * *  * *  * * object and the attr is not locked. *
00536                          * You * may * chown  * an attr to the owner of the
00537                          * object * if * * you own * the attribute. * To do
00538                          * anything * else you  * must be a  * wizard. * Only 
00539                          * #1 can * chown * attributes on #1. 
00540                          */
00541 
00542                         if(!atr_get_info(thing, atr, &aowner, &aflags)) {
00543                                 notify_quiet(player, "Attribute not present on object.");
00544                                 return;
00545                         }
00546                         do_it = 0;
00547                         if(owner == NOTHING) {
00548                                 notify_quiet(player, "I couldn't find that player.");
00549                         } else if(God(thing) && !God(player)) {
00550                                 notify_quiet(player, "Permission denied.");
00551                         } else if(Wizard(player)) {
00552                                 do_it = 1;
00553                         } else if(owner == Owner(player)) {
00554 
00555                                 /*
00556                                  * chown to me: only if I own the obj and * * 
00557                                  * 
00558                                  * *  * * !locked 
00559                                  */
00560 
00561                                 if(!Controls(player, thing) || (aflags & AF_LOCK)) {
00562                                         notify_quiet(player, "Permission denied.");
00563                                 } else {
00564                                         do_it = 1;
00565                                 }
00566                         } else if(owner == Owner(thing)) {
00567 
00568                                 /*
00569                                  * chown to obj owner: only if I own attr * * 
00570                                  * 
00571                                  * *  * * and !locked 
00572                                  */
00573 
00574                                 if((Owner(player) != aowner) || (aflags & AF_LOCK)) {
00575                                         notify_quiet(player, "Permission denied.");
00576                                 } else {
00577                                         do_it = 1;
00578                                 }
00579                         } else {
00580                                 notify_quiet(player, "Permission denied.");
00581                         }
00582 
00583                         if(!do_it)
00584                                 return;
00585 
00586                         ap = atr_num(atr);
00587                         if(!ap || !Set_attr(player, player, ap, aflags)) {
00588                                 notify_quiet(player, "Permission denied.");
00589                                 return;
00590                         }
00591                         atr_set_owner(thing, atr, owner);
00592                         if(!Quiet(player))
00593                                 notify_quiet(player, "Attribute owner changed.");
00594                         return;
00595                 }
00596         }
00597         init_match(player, name, TYPE_THING);
00598         match_possession();
00599         match_here();
00600         match_exit();
00601         match_me();
00602         if(Chown_Any(player)) {
00603                 match_player();
00604                 match_absolute();
00605         }
00606         switch (thing = match_result()) {
00607         case NOTHING:
00608                 notify_quiet(player, "You don't have that!");
00609                 return;
00610         case AMBIGUOUS:
00611                 notify_quiet(player, "I don't know which you mean!");
00612                 return;
00613         }
00614 
00615         if(!*newown || !(string_compare(newown, "me"))) {
00616                 owner = Owner(player);
00617         } else {
00618                 owner = lookup_player(player, newown, 1);
00619         }
00620 
00621         cost = 1;
00622         quota = 1;
00623         switch (Typeof(thing)) {
00624         case TYPE_ROOM:
00625                 cost = mudconf.digcost;
00626                 quota = mudconf.room_quota;
00627                 break;
00628         case TYPE_THING:
00629                 cost = OBJECT_DEPOSIT(Pennies(thing));
00630                 quota = mudconf.thing_quota;
00631                 break;
00632         case TYPE_EXIT:
00633                 cost = mudconf.opencost;
00634                 quota = mudconf.exit_quota;
00635                 break;
00636         case TYPE_PLAYER:
00637                 cost = mudconf.robotcost;
00638                 quota = mudconf.player_quota;
00639         }
00640 
00641         if(owner == NOTHING) {
00642                 notify_quiet(player, "I couldn't find that player.");
00643         } else if(isPlayer(thing) && !God(player)) {
00644                 notify_quiet(player, "Players always own themselves.");
00645         } else if(((!controls(player, thing) && !Chown_Any(player) &&
00646                                 !Chown_ok(thing)) || (isThing(thing) &&
00647                                                                           (Location(thing) != player)
00648                                                                           && !Chown_Any(player)))
00649                           || (!controls(player, owner))) {
00650                 notify_quiet(player, "Permission denied.");
00651         } else if(canpayfees(player, owner, cost, quota)) {
00652                 giveto(Owner(thing), cost);
00653                 if(mudconf.quotas)
00654                         add_quota(Owner(thing), quota);
00655                 if(God(player)) {
00656                         s_Owner(thing, owner);
00657                 } else {
00658                         s_Owner(thing, Owner(owner));
00659                 }
00660                 atr_chown(thing);
00661                 s_Flags(thing, (Flags(thing) & ~(CHOWN_OK | INHERIT)) | HALT);
00662                 s_Powers(thing, 0);
00663                 s_Powers2(thing, 0);
00664                 halt_que(NOTHING, thing);
00665                 if(!Quiet(player))
00666                         notify_quiet(player, "Owner changed.");
00667         }
00668 }

void do_chzone ( dbref  player,
dbref  cause,
int  key,
char *  name,
char *  newobj 
)

Definition at line 85 of file set.c.

References check_zone_for_player(), Controls, flatfiledb::db, Flags, confdata::have_zones, INHERIT, init_match(), match_everything(), mudconf, noisy_match_result(), NOTHING, notify, NOTYPE, Powers, ROYALTY, TYPE_PLAYER, TYPE_ROOM, TYPE_THING, Typeof, WIZARD, and Wizard.

00086 {
00087         dbref thing;
00088         dbref zone;
00089 
00090         if(!mudconf.have_zones) {
00091                 notify(player, "Zones disabled.");
00092                 return;
00093         }
00094         init_match(player, name, NOTYPE);
00095         match_everything(0);
00096         if((thing = noisy_match_result()) == NOTHING)
00097                 return;
00098 
00099         if(!strcasecmp(newobj, "none"))
00100                 zone = NOTHING;
00101         else {
00102                 init_match(player, newobj, NOTYPE);
00103                 match_everything(0);
00104                 if((zone = noisy_match_result()) == NOTHING)
00105                         return;
00106 
00107                 if((Typeof(zone) != TYPE_THING) && (Typeof(zone) != TYPE_ROOM)) {
00108                         notify(player, "Invalid zone object type.");
00109                         return;
00110                 }
00111         }
00112 
00113         if(!Wizard(player) && !(Controls(player, thing)) &&
00114            !(check_zone_for_player(player, thing)) &&
00115            !(db[player].owner == db[thing].owner)) {
00116                 notify(player, "You don't have the power to shift reality.");
00117                 return;
00118         }
00119         /*
00120          * a player may change an object's zone to NOTHING or to an object he 
00121          * 
00122          * *  * *  * * owns 
00123          */
00124         if((zone != NOTHING) && !Wizard(player) && !(Controls(player, zone))
00125            && !(db[player].owner == db[zone].owner)) {
00126                 notify(player, "You cannot move that object to that zone.");
00127                 return;
00128         }
00129         /*
00130          * only rooms may be zoned to other rooms 
00131          */
00132         if((zone != NOTHING) && (Typeof(zone) == TYPE_ROOM) &&
00133            Typeof(thing) != TYPE_ROOM) {
00134                 notify(player, "Only rooms may have parent rooms.");
00135                 return;
00136         }
00137         /*
00138          * everything is okay, do the change 
00139          */
00140         db[thing].zone = zone;
00141         if(Typeof(thing) != TYPE_PLAYER) {
00142                 /*
00143                  * if the object is a player, resetting these flags is rather
00144                  * * * * * inconvenient -- although this may pose a bit of a * 
00145                  * *  * security * risk. Be careful when @chzone'ing wizard or 
00146                  * * * * royal players. 
00147                  */
00148                 Flags(thing) &= ~WIZARD;
00149                 Flags(thing) &= ~ROYALTY;
00150                 Flags(thing) &= ~INHERIT;
00151 #ifdef USE_POWERS
00152                 Powers(thing) = 0;              /*
00153                                                                  * wipe out all powers 
00154                                                                  */
00155 #endif
00156         }
00157         notify(player, "Zone changed.");
00158 }

void do_cpattr ( dbref  player,
dbref  cause,
int  key,
char *  oldpair,
char *  newpair[],
int  nargs 
)

Definition at line 889 of file set.c.

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

00891 {
00892         int i;
00893         char *oldthing, *oldattr, *newthing, *newattr;
00894 
00895         if(!*oldpair || !**newpair || !oldpair || !*newpair)
00896                 return;
00897 
00898         if(nargs < 1)
00899                 return;
00900 
00901         oldattr = oldpair;
00902         oldthing = parse_to(&oldattr, '/', 1);
00903 
00904         for(i = 0; i < nargs; i++) {
00905                 newattr = newpair[i];
00906                 newthing = parse_to(&newattr, '/', 1);
00907 
00908                 if(!oldattr) {
00909                         if(!newattr) {
00910                                 do_set(player, cause, 0, newthing, tprintf("%s:_%s/%s",
00911                                                                                                                    oldthing, "me",
00912                                                                                                                    oldthing));
00913                         } else {
00914                                 do_set(player, cause, 0, newthing, tprintf("%s:_%s/%s",
00915                                                                                                                    newattr, "me",
00916                                                                                                                    oldthing));
00917                         }
00918                 } else {
00919                         if(!newattr) {
00920                                 do_set(player, cause, 0, newthing, tprintf("%s:_%s/%s",
00921                                                                                                                    oldattr, oldthing,
00922                                                                                                                    oldattr));
00923                         } else {
00924                                 do_set(player, cause, 0, newthing, tprintf("%s:_%s/%s",
00925                                                                                                                    newattr, oldthing,
00926                                                                                                                    oldattr));
00927                         }
00928                 }
00929         }
00930 }

void do_edit ( dbref  player,
dbref  cause,
int  key,
char *  it,
char *  args[],
int  nargs 
)

Definition at line 1313 of file set.c.

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

01315 {
01316         dbref thing, aowner;
01317         int attr, got_one, aflags, doit;
01318         char *from, *to, *result, *returnstr, *atext;
01319         ATTR *ap;
01320 
01321         /*
01322          * Make sure we have something to do. 
01323          */
01324 
01325         if((nargs < 1) || !*args[0]) {
01326                 notify_quiet(player, "Nothing to do.");
01327                 return;
01328         }
01329         from = args[0];
01330         to = (nargs >= 2) ? args[1] : (char *) "";
01331 
01332         /*
01333          * Look for the object and get the attribute (possibly wildcarded) 
01334          */
01335 
01336         olist_push();
01337         if(!it || !*it || !parse_attrib_wild(player, it, &thing, 0, 0, 0)) {
01338                 notify_quiet(player, "No match.");
01339                 olist_pop();
01340                 return;
01341         }
01342         /*
01343          * Iterate through matching attributes, performing edit 
01344          */
01345 
01346         got_one = 0;
01347         atext = alloc_lbuf("do_edit.atext");
01348 
01349         for(attr = olist_first(); attr != NOTHING; attr = olist_next()) {
01350                 ap = atr_num(attr);
01351                 if(ap) {
01352 
01353                         /*
01354                          * Get the attr and make sure we can modify it. 
01355                          */
01356 
01357                         atr_get_str(atext, thing, ap->number, &aowner, &aflags);
01358                         if(Set_attr(player, thing, ap, aflags)) {
01359 
01360                                 /*
01361                                  * Do the edit and save the result 
01362                                  */
01363 
01364                                 got_one = 1;
01365                                 edit_string_ansi(atext, &result, &returnstr, from, to);
01366                                 if(ap->check != NULL) {
01367                                         doit =
01368                                                 (*ap->check) (0, player, thing, ap->number, result);
01369                                 } else {
01370                                         doit = 1;
01371                                 }
01372                                 if(doit) {
01373                                         atr_add(thing, ap->number, result, Owner(player), aflags);
01374                                         if(!Quiet(player))
01375                                                 notify_quiet(player, tprintf("Set - %s: %s",
01376                                                                                                          ap->name, returnstr));
01377                                 }
01378                                 free_lbuf(result);
01379                                 free_lbuf(returnstr);
01380                         } else {
01381 
01382                                 /*
01383                                  * No rights to change the attr 
01384                                  */
01385 
01386                                 notify_quiet(player, tprintf("%s: Permission denied.",
01387                                                                                          ap->name));
01388                         }
01389 
01390                 }
01391         }
01392 
01393         /*
01394          * Clean up 
01395          */
01396 
01397         free_lbuf(atext);
01398         olist_pop();
01399 
01400         if(!got_one) {
01401                 notify_quiet(player, "No matching attributes.");
01402         }
01403 }

void do_lock ( dbref  player,
dbref  cause,
int  key,
char *  name,
char *  keytext 
)

Definition at line 343 of file set.c.

References A_LOCK, AF_LOCK, AMBIGUOUS, atr_add_raw(), atr_get_info(), atr_num(), atr_set_flags(), controls, free_boolexp(), God, init_match(), MAT_EXIT_PARENTS, match_everything(), match_result(), NOTHING, notify_quiet, NOTYPE, Owner, parse_attrib(), parse_boolexp(), Quiet, Set_attr, TRUE_BOOLEXP, unparse_boolexp_quiet(), and Wizard.

Referenced by create_guest().

00344 {
00345         dbref thing, aowner;
00346         int atr, aflags;
00347         ATTR *ap;
00348         struct boolexp *okey;
00349 
00350         if(parse_attrib(player, name, &thing, &atr)) {
00351                 if(atr != NOTHING) {
00352                         if(!atr_get_info(thing, atr, &aowner, &aflags)) {
00353                                 notify_quiet(player, "Attribute not present on object.");
00354                                 return;
00355                         }
00356                         ap = atr_num(atr);
00357 
00358                         /*
00359                          * You may lock an attribute if: * you could write *
00360                          * * * the attribute if it were stored on * yourself
00361                          * * * * * --and-- * you own the attribute or are a * 
00362                          * wizard as  *  * * long as * you are not #1 and are 
00363                          * 
00364                          * * trying to do * * something to #1. 
00365                          */
00366 
00367                         if(ap && (God(player) || (!God(thing) &&
00368                                                                           (Set_attr(player, player, ap, 0)
00369                                                                            && (Wizard(player)
00370                                                                                    || aowner == Owner(player)))))) {
00371                                 aflags |= AF_LOCK;
00372                                 atr_set_flags(thing, atr, aflags);
00373                                 if(!Quiet(player) && !Quiet(thing))
00374                                         notify_quiet(player, "Attribute locked.");
00375                         } else {
00376                                 notify_quiet(player, "Permission denied.");
00377                         }
00378                         return;
00379                 }
00380         }
00381         init_match(player, name, NOTYPE);
00382         match_everything(MAT_EXIT_PARENTS);
00383         thing = match_result();
00384 
00385         switch (thing) {
00386         case NOTHING:
00387                 notify_quiet(player, "I don't see what you want to lock!");
00388                 return;
00389         case AMBIGUOUS:
00390                 notify_quiet(player, "I don't know which one you want to lock!");
00391                 return;
00392         default:
00393                 if(!controls(player, thing)) {
00394                         notify_quiet(player, "You can't lock that!");
00395                         return;
00396                 }
00397         }
00398 
00399         okey = parse_boolexp(player, keytext, 0);
00400         if(okey == TRUE_BOOLEXP) {
00401                 notify_quiet(player, "I don't understand that key.");
00402         } else {
00403 
00404                 /*
00405                  * everything ok, do it 
00406                  */
00407 
00408                 if(!key)
00409                         key = A_LOCK;
00410                 atr_add_raw(thing, key, unparse_boolexp_quiet(player, okey));
00411                 if(!Quiet(player) && !Quiet(thing))
00412                         notify_quiet(player, "Locked.");
00413         }
00414         free_boolexp(okey);
00415 }

void do_mvattr ( dbref  player,
dbref  cause,
int  key,
char *  what,
char *  args[],
int  nargs 
)

Definition at line 932 of file set.c.

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

00934 {
00935         dbref thing, aowner, axowner;
00936         ATTR *in_attr, *out_attr;
00937         int i, anum, in_anum, aflags, axflags, no_delete;
00938         char *astr;
00939 
00940         /*
00941          * Make sure we have something to do. 
00942          */
00943 
00944         if(nargs < 2) {
00945                 notify_quiet(player, "Nothing to do.");
00946                 return;
00947         }
00948         /*
00949          * FInd and make sure we control the target object. 
00950          */
00951 
00952         thing = match_controlled(player, what);
00953         if(thing == NOTHING)
00954                 return;
00955 
00956         /*
00957          * Look up the source attribute.  If it either doesn't exist or isn't
00958          * * * * * readable, use an empty string. 
00959          */
00960 
00961         in_anum = -1;
00962         astr = alloc_lbuf("do_mvattr");
00963         in_attr = atr_str(args[0]);
00964         if(in_attr == NULL) {
00965                 *astr = '\0';
00966         } else {
00967                 atr_get_str(astr, thing, in_attr->number, &aowner, &aflags);
00968                 if(!See_attr(player, thing, in_attr, aowner, aflags)) {
00969                         *astr = '\0';
00970                 } else {
00971                         in_anum = in_attr->number;
00972                 }
00973         }
00974 
00975         /*
00976          * Copy the attribute to each target in turn. 
00977          */
00978 
00979         no_delete = 0;
00980         for(i = 1; i < nargs; i++) {
00981                 anum = mkattr(args[i]);
00982                 if(anum <= 0) {
00983                         notify_quiet(player,
00984                                                  tprintf
00985                                                  ("%s: That's not a good name for an attribute.",
00986                                                   args[i]));
00987                         continue;
00988                 }
00989                 out_attr = atr_num(anum);
00990                 if(!out_attr) {
00991                         notify_quiet(player, tprintf("%s: Permission denied.", args[i]));
00992                 } else if(out_attr->number == in_anum) {
00993                         no_delete = 1;
00994                 } else {
00995                         atr_get_info(thing, out_attr->number, &axowner, &axflags);
00996                         if(!Set_attr(player, thing, out_attr, axflags)) {
00997                                 notify_quiet(player, tprintf("%s: Permission denied.",
00998                                                                                          args[i]));
00999                         } else {
01000                                 atr_add(thing, out_attr->number, astr, Owner(player), aflags);
01001                                 if(!Quiet(player))
01002                                         notify_printf(player, "%s/%s - Set.", Name(thing),
01003                                                                   out_attr->name);
01004                         }
01005                 }
01006         }
01007 
01008         /*
01009          * Remove the source attribute if we can. 
01010          */
01011 
01012         if((in_anum > 0) && !no_delete) {
01013                 in_attr = atr_num(in_anum);
01014                 if(in_attr && Set_attr(player, thing, in_attr, aflags)) {
01015                         atr_clr(thing, in_attr->number);
01016                         if(!Quiet(player))
01017                                 notify_printf(player, "%s/%s - Cleared.", Name(thing),
01018                                                           in_attr->name);
01019                 } else {
01020                         if(in_attr)
01021                                 notify_quiet(player,
01022                                                          tprintf
01023                                                          ("%s: Could not remove old attribute.  Permission denied.",
01024                                                           in_attr->name));
01025                 }
01026         }
01027         free_lbuf(astr);
01028 }

void do_name ( dbref  player,
dbref  cause,
int  key,
char *  name,
char *  newname 
)

Definition at line 160 of file set.c.

References A_LASTNAME, add_player_name(), badname_check(), delete_player_name(), ENDLOG, free_lbuf, In_Character, isPlayer, LBUF_SIZE, log_name(), LOG_SECURITY, log_text(), lookup_player(), lower_xp(), match_controlled(), mudconf, mudstate, Name(), confdata::namechange_days, NOTHING, notify_quiet, statedata::now, ok_name(), ok_player_name(), Quiet, s_Name(), send_channel(), silly_atr_get(), silly_atr_set(), STARTLOG, string_compare(), strip_ansi_r(), Suspect, tprintf(), trim_spaces(), and Wizard.

00161 {
00162         dbref thing;
00163         char *buff;
00164         char *buff2;
00165         char new[LBUF_SIZE];
00166 
00167         if((thing = match_controlled(player, name)) == NOTHING)
00168                 return;
00169 
00170         /*
00171          * check for bad name 
00172          */
00173         strncpy(new, newname, LBUF_SIZE-1);
00174         if((*newname == '\0') || (strlen(strip_ansi_r(new,newname,strlen(newname))) == 0)) {
00175                 notify_quiet(player, "Give it what new name?");
00176                 return;
00177         }
00178         /*
00179          * check for renaming a player 
00180          */
00181         if(isPlayer(thing)) {
00182 
00183                 buff = trim_spaces((char *) newname);
00184                 if(!ok_player_name(buff) || !badname_check(buff)) {
00185                         notify_quiet(player, "You can't use that name.");
00186                         free_lbuf(buff);
00187                         return;
00188                 } else if(string_compare(buff, Name(thing)) &&
00189                                   (lookup_player(NOTHING, buff, 0) != NOTHING)) {
00190 
00191                         /*
00192                          * string_compare allows changing foo to Foo, etc. 
00193                          */
00194 
00195                         notify_quiet(player, "That name is already in use.");
00196                         free_lbuf(buff);
00197                         return;
00198                 }
00199 
00200                 if(player == thing && In_Character(player) && !Wizard(player)) {
00201                         buff2 = silly_atr_get(player, A_LASTNAME);
00202                         if(!(buff2 && atoi(buff2) &&
00203                                  ((atoi(buff2) + (mudconf.namechange_days * 86400)) <
00204                                   mudstate.now)))
00205                                 lower_xp(player, 900);
00206 
00207                         silly_atr_set(player, A_LASTNAME, tprintf("%u", mudstate.now));
00208                 }
00209                 /*
00210                  * everything ok, notify 
00211                  */
00212                 STARTLOG(LOG_SECURITY, "SEC", "CNAME") {
00213                         log_name(thing), log_text((char *) " renamed to ");
00214                         log_text(buff);
00215                         ENDLOG;
00216                 }
00217                 if(Suspect(thing)) {
00218                         send_channel("Suspect", tprintf("%s renamed to %s",
00219                                                                                         Name(thing), buff));
00220                 }
00221                 delete_player_name(thing, Name(thing));
00222 
00223                 s_Name(thing, buff);
00224                 add_player_name(thing, Name(thing));
00225                 if(!Quiet(player) && !Quiet(thing))
00226                         notify_quiet(player, "Name set.");
00227                 free_lbuf(buff);
00228                 return;
00229         } else {
00230                 if(!ok_name(newname)) {
00231                         notify_quiet(player, "That is not a reasonable name.");
00232                         return;
00233                 }
00234                 /*
00235                  * everything ok, change the name 
00236                  */
00237                 s_Name(thing, newname);
00238                 if(!Quiet(player) && !Quiet(thing))
00239                         notify_quiet(player, "Name set.");
00240         }
00241 }

void do_power ( dbref  player,
dbref  cause,
int  key,
char *  name,
char *  flag 
)

Definition at line 857 of file set.c.

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

00858 {
00859         dbref thing;
00860 
00861         if(!flag || !*flag) {
00862                 notify_quiet(player, "I don't know what you want to set!");
00863                 return;
00864         }
00865         /*
00866          * find thing 
00867          */
00868 
00869         if((thing = match_controlled(player, name)) == NOTHING)
00870                 return;
00871 
00872         power_set(thing, player, flag, key);
00873 }

void do_set ( dbref  player,
dbref  cause,
int  key,
char *  name,
char *  flag 
)

Definition at line 702 of file set.c.

References alloc_lbuf, atr_get_info(), atr_num(), atr_pget_str(), atr_set_flags(), attr, find_nametab_ent(), flag_set(), free_lbuf, handle_ears(), handle_xcode(), Hardcode, confdata::have_specials, Hearer(), indiv_attraccess_nametab, match_controlled(), mkattr(), mudconf, name_table::name, attr::name, Name(), NOT_TOKEN, NOTHING, notify_printf(), notify_quiet, parse_attrib(), Quiet, search_nametab(), See_attr, Set_attr, set_attr_internal(), SET_QUIET, StringCopy, and boolexp::thing.

Referenced by do_cpattr().

00703 {
00704         dbref thing, thing2, aowner;
00705         char *p, *buff;
00706         int atr, atr2, aflags, clear, flagvalue, could_hear, have_xcode;
00707         ATTR *attr, *attr2;
00708 
00709         /*
00710          * See if we have the <obj>/<attr> form, which is how you set * * *
00711          * attribute * flags. 
00712          */
00713 
00714         if(parse_attrib(player, name, &thing, &atr)) {
00715                 if(atr != NOTHING) {
00716 
00717                         /*
00718                          * You must specify a flag name 
00719                          */
00720 
00721                         if(!flag || !*flag) {
00722                                 notify_quiet(player, "I don't know what you want to set!");
00723                                 return;
00724                         }
00725                         /*
00726                          * Check for clearing 
00727                          */
00728 
00729                         clear = 0;
00730                         if(*flag == NOT_TOKEN) {
00731                                 flag++;
00732                                 clear = 1;
00733                         }
00734                         /*
00735                          * Make sure player specified a valid attribute flag 
00736                          */
00737 
00738                         flagvalue =
00739                                 search_nametab(player, indiv_attraccess_nametab, flag);
00740                         if(flagvalue < 0) {
00741                                 notify_quiet(player, "You can't set that!");
00742                                 return;
00743                         }
00744                         /*
00745                          * Make sure the object has the attribute present 
00746                          */
00747 
00748                         if(!atr_get_info(thing, atr, &aowner, &aflags)) {
00749                                 notify_quiet(player, "Attribute not present on object.");
00750                                 return;
00751                         }
00752                         /*
00753                          * Make sure we can write to the attribute 
00754                          */
00755 
00756                         attr = atr_num(atr);
00757                         if(!attr || !Set_attr(player, thing, attr, aflags)) {
00758                                 notify_quiet(player, "Permission denied.");
00759                                 return;
00760                         }
00761                         /*
00762                          * Go do it 
00763                          */
00764 
00765                         if(clear)
00766                                 aflags &= ~flagvalue;
00767                         else
00768                                 aflags |= flagvalue;
00769                         have_xcode = Hardcode(thing);
00770                         atr_set_flags(thing, atr, aflags);
00771 
00772                         /*
00773                          * Tell the player about it. 
00774                          */
00775 
00776                         if(mudconf.have_specials)
00777                                 handle_xcode(player, thing, have_xcode, Hardcode(thing));
00778                         if(!(key & SET_QUIET) && !Quiet(player) && !Quiet(thing)) {
00779                 NAMETAB *nt;
00780                 nt = find_nametab_ent(player, indiv_attraccess_nametab, flag);
00781                 notify_printf(player, "%s/%s - %s %s", Name(thing),
00782                               attr->name, nt->name,
00783                               clear ? "cleared." : "set.");
00784                         }
00785                         could_hear = Hearer(thing);
00786                         handle_ears(thing, could_hear, Hearer(thing));
00787                         return;
00788                 }
00789         }
00790         /*
00791          * find thing 
00792          */
00793 
00794         if((thing = match_controlled(player, name)) == NOTHING)
00795                 return;
00796 
00797         /*
00798          * check for attribute set first 
00799          */
00800         for(p = flag; *p && (*p != ':'); p++);
00801 
00802         if(*p) {
00803                 *p++ = 0;
00804                 atr = mkattr(flag);
00805                 if(atr <= 0) {
00806                         notify_quiet(player, "Couldn't create attribute.");
00807                         return;
00808                 }
00809                 attr = atr_num(atr);
00810                 if(!attr) {
00811                         notify_quiet(player, "Permission denied.");
00812                         return;
00813                 }
00814                 atr_get_info(thing, atr, &aowner, &aflags);
00815                 if(!Set_attr(player, thing, attr, aflags)) {
00816                         notify_quiet(player, "Permission denied.");
00817                         return;
00818                 }
00819                 buff = alloc_lbuf("do_set");
00820 
00821                 /*
00822                  * check for _ 
00823                  */
00824                 if(*p == '_') {
00825                         StringCopy(buff, p + 1);
00826                         if(!parse_attrib(player, p + 1, &thing2, &atr2) ||
00827                            (atr2 == NOTHING)) {
00828                                 notify_quiet(player, "No match.");
00829                                 free_lbuf(buff);
00830                                 return;
00831                         }
00832                         attr2 = atr_num(atr2);
00833                         p = buff;
00834                         atr_pget_str(buff, thing2, atr2, &aowner, &aflags);
00835 
00836                         if(!attr2 || !See_attr(player, thing2, attr2, aowner, aflags)) {
00837                                 notify_quiet(player, "Permission denied.");
00838                                 free_lbuf(buff);
00839                                 return;
00840                         }
00841                 }
00842                 /*
00843                  * Go set it 
00844                  */
00845 
00846                 set_attr_internal(player, thing, atr, p, key);
00847                 free_lbuf(buff);
00848                 return;
00849         }
00850         /*
00851          * Set or clear a flag 
00852          */
00853 
00854         flag_set(thing, player, flag, key);
00855 }

void do_setattr ( dbref  player,
dbref  cause,
int  attrnum,
char *  name,
char *  attrtext 
)

Definition at line 875 of file set.c.

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

Referenced by do_setvattr(), and init_cmdtab().

00877 {
00878         dbref thing;
00879 
00880         init_match(player, name, NOTYPE);
00881         match_everything(MAT_EXIT_PARENTS);
00882         thing = noisy_match_result();
00883 
00884         if(thing == NOTHING)
00885                 return;
00886         set_attr_internal(player, thing, attrnum, attrtext, 0);
00887 }

void do_setvattr ( dbref  player,
dbref  cause,
int  key,
char *  arg1,
char *  arg2 
)

Definition at line 1537 of file set.c.

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

01538 {
01539         char *s;
01540         int anum;
01541 
01542         arg1++;                                         /*
01543                                                                  * skip the '&' 
01544                                                                  */
01545         for(s = arg1; *s && !isspace(*s); s++); /*
01546                                                                                          * take to the space 
01547                                                                                          */
01548         if(*s)
01549                 *s++ = '\0';                    /*
01550                                                                  * split it 
01551                                                                  */
01552 
01553         anum = mkattr(arg1);            /*
01554                                                                  * Get or make attribute 
01555                                                                  */
01556         if(anum <= 0) {
01557                 notify_quiet(player, "That's not a good name for an attribute.");
01558                 return;
01559         }
01560         do_setattr(player, cause, anum, s, arg2);
01561 }

void do_trigger ( dbref  player,
dbref  cause,
int  key,
char *  object,
char *  argv[],
int  nargs 
)

Definition at line 1455 of file set.c.

References controls, did_it(), NOTHING, notify_quiet, parse_attrib(), Quiet, boolexp::thing, and TRIG_QUIET.

01457 {
01458         dbref thing;
01459         int attrib;
01460 
01461         if(!parse_attrib(player, object, &thing, &attrib) || (attrib == NOTHING)) {
01462                 notify_quiet(player, "No match.");
01463                 return;
01464         }
01465         if(!controls(player, thing)) {
01466                 notify_quiet(player, "Permission denied.");
01467                 return;
01468         }
01469         did_it(player, thing, 0, NULL, 0, NULL, attrib, argv, nargs);
01470 
01471         /*
01472          * XXX be more descriptive as to what was triggered? 
01473          */
01474         if(!(key & TRIG_QUIET) && !Quiet(player))
01475                 notify_quiet(player, "Triggered.");
01476 
01477 }

void do_unlink ( dbref  player,
dbref  cause,
int  key,
char *  name 
)

Definition at line 473 of file set.c.

References AMBIGUOUS, controls, init_match(), match_everything(), match_result(), NOTHING, notify_quiet, Quiet, s_Dropto, s_Location, TYPE_EXIT, TYPE_ROOM, and Typeof.

Referenced by do_link().

00474 {
00475         dbref exit;
00476 
00477         init_match(player, name, TYPE_EXIT);
00478         match_everything(0);
00479         exit = match_result();
00480 
00481         switch (exit) {
00482         case NOTHING:
00483                 notify_quiet(player, "Unlink what?");
00484                 break;
00485         case AMBIGUOUS:
00486                 notify_quiet(player, "I don't know which one you mean!");
00487                 break;
00488         default:
00489                 if(!controls(player, exit)) {
00490                         notify_quiet(player, "Permission denied.");
00491                 } else {
00492                         switch (Typeof(exit)) {
00493                         case TYPE_EXIT:
00494                                 s_Location(exit, NOTHING);
00495                                 if(!Quiet(player))
00496                                         notify_quiet(player, "Unlinked.");
00497                                 break;
00498                         case TYPE_ROOM:
00499                                 s_Dropto(exit, NOTHING);
00500                                 if(!Quiet(player))
00501                                         notify_quiet(player, "Dropto removed.");
00502                                 break;
00503                         default:
00504                                 notify_quiet(player, "You can't unlink that!");
00505                                 break;
00506                         }
00507                 }
00508         }
00509 }

void do_unlock ( dbref  player,
dbref  cause,
int  key,
char *  name 
)

Definition at line 422 of file set.c.

References A_LOCK, AF_LOCK, atr_clr(), atr_get_info(), atr_num(), atr_set_flags(), God, match_controlled(), NOTHING, notify_quiet, Owner, parse_attrib(), Quiet, Set_attr, boolexp::thing, and Wizard.

00423 {
00424         dbref thing, aowner;
00425         int atr, aflags;
00426         ATTR *ap;
00427 
00428         if(parse_attrib(player, name, &thing, &atr)) {
00429                 if(atr != NOTHING) {
00430                         if(!atr_get_info(thing, atr, &aowner, &aflags)) {
00431                                 notify_quiet(player, "Attribute not present on object.");
00432                                 return;
00433                         }
00434                         ap = atr_num(atr);
00435 
00436                         /*
00437                          * You may unlock an attribute if: * you could write
00438                          * * * * the attribute if it were stored on *
00439                          * yourself * * * * --and-- * you own the attribute
00440                          * or are a * wizard * as  * long as * you are not #1 
00441                          * and are * trying to * do * something to #1. 
00442                          */
00443 
00444                         if(ap && (God(player) || ((!God(thing)) &&
00445                                                                           (Set_attr(player, player, ap, 0)
00446                                                                            && (Wizard(player)
00447                                                                                    || aowner == Owner(player)))))) {
00448                                 aflags &= ~AF_LOCK;
00449                                 atr_set_flags(thing, atr, aflags);
00450                                 if(Owner(player != Owner(thing)))
00451                                         if(!Quiet(player) && !Quiet(thing))
00452                                                 notify_quiet(player, "Attribute unlocked.");
00453                         } else {
00454                                 notify_quiet(player, "Permission denied.");
00455                         }
00456                         return;
00457                 }
00458         }
00459         if(!key)
00460                 key = A_LOCK;
00461         if((thing = match_controlled(player, name)) != NOTHING) {
00462                 atr_clr(thing, key);
00463                 if(!Quiet(player) && !Quiet(thing))
00464                         notify_quiet(player, "Unlocked.");
00465         }
00466 }

void do_use ( dbref  player,
dbref  cause,
int  key,
char *  object 
)

Definition at line 1479 of file set.c.

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, and Wizard.

01480 {
01481         char *df_use, *df_ouse, *temp;
01482         dbref thing, aowner;
01483         int aflags, doit;
01484 
01485         init_match(player, object, NOTYPE);
01486         match_neighbor();
01487         match_possession();
01488         if(Wizard(player)) {
01489                 match_absolute();
01490                 match_player();
01491         }
01492         match_me();
01493         match_here();
01494         thing = noisy_match_result();
01495         if(thing == NOTHING)
01496                 return;
01497 
01498         /*
01499          * Make sure player can use it 
01500          */
01501 
01502         if(!could_doit(player, thing, A_LUSE)) {
01503                 did_it(player, thing, A_UFAIL,
01504                            "You can't figure out how to use that.", A_OUFAIL, NULL,
01505                            A_AUFAIL, (char **) NULL, 0);
01506                 return;
01507         }
01508         temp = alloc_lbuf("do_use");
01509         doit = 0;
01510         if(*atr_pget_str(temp, thing, A_USE, &aowner, &aflags))
01511                 doit = 1;
01512         else if(*atr_pget_str(temp, thing, A_OUSE, &aowner, &aflags))
01513                 doit = 1;
01514         else if(*atr_pget_str(temp, thing, A_AUSE, &aowner, &aflags))
01515                 doit = 1;
01516         free_lbuf(temp);
01517 
01518         if(doit) {
01519                 df_use = alloc_lbuf("do_use.use");
01520                 df_ouse = alloc_lbuf("do_use.ouse");
01521                 sprintf(df_use, "You use %s", Name(thing));
01522                 sprintf(df_ouse, "uses %s", Name(thing));
01523                 did_it(player, thing, A_USE, df_use, A_OUSE, df_ouse, A_AUSE,
01524                            (char **) NULL, 0);
01525                 free_lbuf(df_use);
01526                 free_lbuf(df_ouse);
01527         } else {
01528                 notify_quiet(player, "You can't figure out how to use that.");
01529         }
01530 }

void do_wipe ( dbref  player,
dbref  cause,
int  key,
char *  it 
)

Definition at line 1405 of file set.c.

References alloc_lbuf, atr_clr(), atr_get_str(), atr_num(), free_lbuf, Name(), NOTHING, notify_printf(), notify_quiet, attr::number, olist_first(), olist_next(), olist_pop(), olist_push(), parse_attrib_wild(), Quiet, Set_attr, and boolexp::thing.

01406 {
01407         dbref thing, aowner;
01408         int attr, got_one, aflags;
01409         ATTR *ap;
01410         char *atext;
01411 
01412         olist_push();
01413         if(!it || !*it || !parse_attrib_wild(player, it, &thing, 0, 0, 1)) {
01414                 notify_quiet(player, "No match.");
01415                 olist_pop();
01416                 return;
01417         }
01418         /*
01419          * Iterate through matching attributes, zapping the writable ones 
01420          */
01421 
01422         got_one = 0;
01423         atext = alloc_lbuf("do_wipe.atext");
01424         for(attr = olist_first(); attr != NOTHING; attr = olist_next()) {
01425                 ap = atr_num(attr);
01426                 if(ap) {
01427 
01428                         /*
01429                          * Get the attr and make sure we can modify it. 
01430                          */
01431 
01432                         atr_get_str(atext, thing, ap->number, &aowner, &aflags);
01433                         if(Set_attr(player, thing, ap, aflags)) {
01434                                 atr_clr(thing, ap->number);
01435                                 got_one++;
01436                         }
01437                 }
01438         }
01439         /*
01440          * Clean up 
01441          */
01442 
01443         if(!got_one) {
01444                 notify_quiet(player, "No matching attributes.");
01445         } else {
01446                 if(!Quiet(player))
01447                         notify_printf(player, "%s - %d attribute(s) wiped.", Name(thing), got_one);
01448         }
01449 
01450         free_lbuf(atext);
01451         olist_pop();
01452 
01453 }

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

Definition at line 1199 of file set.c.

References alloc_lbuf, replace_string(), and safe_str.

Referenced by fun_edit().

01200 {
01201         char *cp;
01202 
01203         /*
01204          * Do the substitution.  Idea for prefix/suffix from R'nice@TinyTIM 
01205          */
01206 
01207         if(!strcmp(from, "^")) {
01208                 /*
01209                  * Prepend 'to' to string 
01210                  */
01211 
01212                 *dst = alloc_lbuf("edit_string.^");
01213                 cp = *dst;
01214                 safe_str(to, *dst, &cp);
01215                 safe_str(src, *dst, &cp);
01216                 *cp = '\0';
01217         } else if(!strcmp(from, "$")) {
01218                 /*
01219                  * Append 'to' to string 
01220                  */
01221 
01222                 *dst = alloc_lbuf("edit_string.$");
01223                 cp = *dst;
01224                 safe_str(src, *dst, &cp);
01225                 safe_str(to, *dst, &cp);
01226                 *cp = '\0';
01227         } else {
01228                 /*
01229                  * replace all occurances of 'from' with 'to'.  Handle the *
01230                  * * * * special cases of from = \$ and \^. 
01231                  */
01232 
01233                 if(((from[0] == '\\') || (from[0] == '%')) && ((from[1] == '$') ||
01234                                                                                                            (from[1] == '^'))
01235                    && (from[2] == '\0'))
01236                         from++;
01237                 *dst = replace_string(from, to, src);
01238         }
01239 }

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

Definition at line 1241 of file set.c.

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

Referenced by do_edit().

01243 {
01244         char *cp, *rp;
01245 
01246         /*
01247          * Do the substitution.  Idea for prefix/suffix from R'nice@TinyTIM 
01248          */
01249 
01250         if(!strcmp(from, "^")) {
01251                 /*
01252                  * Prepend 'to' to string 
01253                  */
01254 
01255                 *dst = alloc_lbuf("edit_string.^");
01256                 cp = *dst;
01257                 safe_str(to, *dst, &cp);
01258                 safe_str(src, *dst, &cp);
01259                 *cp = '\0';
01260 
01261                 /*
01262                  * Do the ansi string used to notify 
01263                  */
01264                 *returnstr = alloc_lbuf("edit_string_ansi.^");
01265                 rp = *returnstr;
01266                 safe_str(ANSI_HILITE, *returnstr, &rp);
01267                 safe_str(to, *returnstr, &rp);
01268                 safe_str(ANSI_NORMAL, *returnstr, &rp);
01269                 safe_str(src, *returnstr, &rp);
01270                 *rp = '\0';
01271 
01272         } else if(!strcmp(from, "$")) {
01273                 /*
01274                  * Append 'to' to string 
01275                  */
01276 
01277                 *dst = alloc_lbuf("edit_string.$");
01278                 cp = *dst;
01279                 safe_str(src, *dst, &cp);
01280                 safe_str(to, *dst, &cp);
01281                 *cp = '\0';
01282 
01283                 /*
01284                  * Do the ansi string used to notify 
01285                  */
01286 
01287                 *returnstr = alloc_lbuf("edit_string_ansi.$");
01288                 rp = *returnstr;
01289                 safe_str(src, *returnstr, &rp);
01290                 safe_str(ANSI_HILITE, *returnstr, &rp);
01291                 safe_str(to, *returnstr, &rp);
01292                 safe_str(ANSI_NORMAL, *returnstr, &rp);
01293                 *rp = '\0';
01294 
01295         } else {
01296                 /*
01297                  * replace all occurances of 'from' with 'to'.  Handle the *
01298                  * * * * special cases of from = \$ and \^. 
01299                  */
01300 
01301                 if(((from[0] == '\\') || (from[0] == '%')) && ((from[1] == '$') ||
01302                                                                                                            (from[1] == '^'))
01303                    && (from[2] == '\0'))
01304                         from++;
01305 
01306                 *dst = replace_string(from, to, src);
01307                 *returnstr =
01308                         replace_string(from, tprintf("%s%s%s", ANSI_HILITE, to,
01309                                                                                  ANSI_NORMAL), src);
01310         }
01311 }

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

Definition at line 1074 of file set.c.

References A_DESC, AF_PRIVATE, atr_get_info(), atr_head(), atr_next(), atr_num(), attr, Examinable, attr::flags, mudconf, mudstate, attr::name, nearby(), nhashadd(), nhashfind(), attr::number, olist_add(), statedata::parent_htab, quick_wild(), Read_attr, confdata::read_rem_desc, and See_attr.

Referenced by parse_attrib_wild().

01076 {
01077         ATTR *attr;
01078         char *as;
01079         dbref aowner;
01080         int ca, ok, aflags;
01081 
01082         /*
01083          * Walk the attribute list of the object 
01084          */
01085 
01086         for(ca = atr_head(thing, &as); ca; ca = atr_next(&as)) {
01087                 attr = atr_num(ca);
01088 
01089                 /*
01090                  * Discard bad attributes and ones we've seen before. 
01091                  */
01092 
01093                 if(!attr)
01094                         continue;
01095 
01096                 if(check_exclude && ((attr->flags & AF_PRIVATE) ||
01097                                                          nhashfind(ca, &mudstate.parent_htab)))
01098                         continue;
01099 
01100                 /*
01101                  * If we aren't the top level remember this attr so we * * *
01102                  * exclude * it in any parents. 
01103                  */
01104 
01105                 atr_get_info(thing, ca, &aowner, &aflags);
01106                 if(check_exclude && (aflags & AF_PRIVATE))
01107                         continue;
01108 
01109                 if(get_locks)
01110                         ok = Read_attr(player, thing, attr, aowner, aflags);
01111                 else
01112                         ok = See_attr(player, thing, attr, aowner, aflags);
01113 
01114                 /*
01115                  * Enforce locality restriction on descriptions 
01116                  */
01117 
01118                 if(ok && (attr->number == A_DESC) && !mudconf.read_rem_desc &&
01119                    !Examinable(player, thing) && !nearby(player, thing))
01120                         ok = 0;
01121 
01122                 if(ok && quick_wild(str, (char *) attr->name)) {
01123                         olist_add(ca);
01124                         if(hash_insert) {
01125                                 nhashadd(ca, (int *) attr, &mudstate.parent_htab);
01126                         }
01127                 }
01128         }
01129 }

void lower_xp ( dbref  ,
int   
)

Definition at line 1072 of file btechstats.c.

References figure_xp_bonus(), retrieve_stats(), VALUES_ALL, and XP_MAX.

Referenced by do_name(), and tele_contents().

01073 {
01074         PSTATS *s;
01075         int i;
01076 
01077         s = retrieve_stats(player, VALUES_ALL);
01078         for(i = 0; i < NUM_CHARVALUES; i++) {
01079                 if(!s->xp[i])
01080                         continue;
01081                 if(s->xp[i] < 0) {
01082                         s->xp[i] = 0;
01083                         continue;
01084                 }
01085                 s->xp[i] = (s->xp[i] % XP_MAX) * promillage / 1000;
01086                 s->xp[i] = s->xp[i] % XP_MAX + XP_MAX * figure_xp_bonus(player, s, i);
01087         }
01088         store_stats(player, s, VALUES_ALL);
01089 }

dbref match_affected ( dbref  player,
char *  name 
)

Definition at line 55 of file set.c.

References Affects, init_match(), MAT_EXIT_PARENTS, match_everything(), noisy_match_result(), NOTHING, notify_quiet, and NOTYPE.

00056 {
00057         dbref mat;
00058 
00059         init_match(player, name, NOTYPE);
00060         match_everything(MAT_EXIT_PARENTS);
00061         mat = noisy_match_result();
00062         if(mat != NOTHING && !Affects(player, mat)) {
00063                 notify_quiet(player, "Permission denied.");
00064                 return NOTHING;
00065         } else {
00066                 return (mat);
00067         }
00068 }

dbref match_controlled ( dbref  player,
char *  name 
)

Definition at line 26 of file set.c.

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

Referenced by do_alias(), do_cut(), do_force(), do_halt(), do_mvattr(), do_name(), do_pemit(), do_power(), do_ps(), do_set(), do_sweep(), do_unlock(), fun_locate(), fun_set(), and search_setup().

00027 {
00028         dbref mat;
00029 
00030         init_match(player, name, NOTYPE);
00031         match_everything(MAT_EXIT_PARENTS);
00032         mat = noisy_match_result();
00033         if(Good_obj(mat) && !Controls(player, mat)) {
00034                 notify_quiet(player, "Permission denied.");
00035                 return NOTHING;
00036         } else {
00037                 return (mat);
00038         }
00039 }

dbref match_controlled_quiet ( dbref  player,
char *  name 
)

Definition at line 41 of file set.c.

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

Referenced by do_destroy().

00042 {
00043         dbref mat;
00044 
00045         init_match(player, name, NOTYPE);
00046         match_everything(MAT_EXIT_PARENTS);
00047         mat = match_result();
00048         if(Good_obj(mat) && !Controls(player, mat)) {
00049                 return NOTHING;
00050         } else {
00051                 return (mat);
00052         }
00053 }

dbref match_examinable ( dbref  player,
char *  name 
)

Definition at line 70 of file set.c.

References Examinable, init_match(), MAT_EXIT_PARENTS, match_everything(), noisy_match_result(), NOTHING, notify_quiet, and NOTYPE.

00071 {
00072         dbref mat;
00073 
00074         init_match(player, name, NOTYPE);
00075         match_everything(MAT_EXIT_PARENTS);
00076         mat = noisy_match_result();
00077         if(mat != NOTHING && !Examinable(player, mat)) {
00078                 notify_quiet(player, "Permission denied.");
00079                 return NOTHING;
00080         } else {
00081                 return (mat);
00082         }
00083 }

int parse_attrib ( dbref  player,
char *  str,
dbref thing,
int *  atr 
)

Definition at line 1035 of file set.c.

References alloc_lbuf, atr_pget_info(), atr_str(), attr, free_lbuf, NOTHING, attr::number, parse_thing_slash(), See_attr, and StringCopy.

Referenced by do_addcommand(), do_chown(), do_delcommand(), do_lock(), do_prog(), do_set(), do_trigger(), do_ufun(), do_unlock(), fun_colorpairs(), fun_default(), fun_edefault(), fun_eval(), fun_filter(), fun_fold(), fun_foreach(), fun_get(), fun_get_eval(), fun_map(), fun_mix(), fun_munge(), fun_owner(), fun_pairs(), fun_set(), fun_setlock(), fun_sortby(), fun_udefault(), fun_visible(), and fun_xget().

01036 {
01037         ATTR *attr;
01038         char *buff;
01039         dbref aowner;
01040         int aflags;
01041 
01042         if(!str)
01043                 return 0;
01044 
01045         /*
01046          * Break apart string into obj and attr.  Return on failure 
01047          */
01048 
01049         buff = alloc_lbuf("parse_attrib");
01050         StringCopy(buff, str);
01051         if(!parse_thing_slash(player, buff, &str, thing)) {
01052                 free_lbuf(buff);
01053                 return 0;
01054         }
01055         /*
01056          * Get the named attribute from the object if we can 
01057          */
01058 
01059         attr = atr_str(str);
01060         free_lbuf(buff);
01061         if(!attr) {
01062                 *atr = NOTHING;
01063         } else {
01064                 atr_pget_info(*thing, attr->number, &aowner, &aflags);
01065                 if(!See_attr(player, *thing, attr, aowner, aflags)) {
01066                         *atr = NOTHING;
01067                 } else {
01068                         *atr = attr->number;
01069                 }
01070         }
01071         return 1;
01072 }

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

Definition at line 1131 of file set.c.

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

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

01133 {
01134         char *buff;
01135         dbref parent;
01136         int check_exclude, hash_insert, lev;
01137 
01138         if(!str)
01139                 return 0;
01140 
01141         buff = alloc_lbuf("parse_attrib_wild");
01142         StringCopy(buff, str);
01143 
01144         /*
01145          * Separate name and attr portions at the first / 
01146          */
01147 
01148         if(!parse_thing_slash(player, buff, &str, thing)) {
01149 
01150                 /*
01151                  * Not in obj/attr format, return if not defaulting to * 
01152                  */
01153 
01154                 if(!df_star) {
01155                         free_lbuf(buff);
01156                         return 0;
01157                 }
01158                 /*
01159                  * Look for the object, return failure if not found 
01160                  */
01161 
01162                 init_match(player, buff, NOTYPE);
01163                 match_everything(MAT_EXIT_PARENTS);
01164                 *thing = match_result();
01165 
01166                 if(!Good_obj(*thing)) {
01167                         free_lbuf(buff);
01168                         return 0;
01169                 }
01170                 str = (char *) "*";
01171         }
01172         /*
01173          * Check the object (and optionally all parents) for attributes 
01174          */
01175 
01176         if(check_parents) {
01177                 check_exclude = 0;
01178                 hash_insert = check_parents;
01179                 nhashflush(&mudstate.parent_htab, 0);
01180                 ITER_PARENTS(*thing, parent, lev) {
01181                         if(!Good_obj(Parent(parent)))
01182                                 hash_insert = 0;
01183                         find_wild_attrs(player, parent, str, check_exclude,
01184                                                         hash_insert, get_locks);
01185                         check_exclude = 1;
01186                 }
01187         } else {
01188                 find_wild_attrs(player, *thing, str, 0, 0, get_locks);
01189         }
01190         free_lbuf(buff);
01191         return 1;
01192 }

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

Definition at line 675 of file set.c.

References atr_add(), atr_num(), atr_pget_info(), attr, attr::check, handle_ears(), handle_xcode(), Hardcode, confdata::have_specials, Hearer(), mudconf, attr::name, Name(), notify_printf(), notify_quiet, Owner, Quiet, Set_attr, and SET_QUIET.

00677 {
00678         dbref aowner;
00679         int aflags, could_hear, have_xcode;
00680         ATTR *attr;
00681 
00682         attr = atr_num(attrnum);
00683         atr_pget_info(thing, attrnum, &aowner, &aflags);
00684         if(attr && Set_attr(player, thing, attr, aflags)) {
00685                 if((attr->check != NULL) &&
00686                    (!(*attr->check) (0, player, thing, attrnum, attrtext)))
00687                         return;
00688                 have_xcode = Hardcode(thing);
00689                 atr_add(thing, attrnum, attrtext, Owner(player), aflags);
00690                 if(mudconf.have_specials)
00691                         handle_xcode(player, thing, have_xcode, Hardcode(thing));
00692                 if(!(key & SET_QUIET) && !Quiet(player) && !Quiet(thing))
00693                         notify_printf(player, "%s/%s - %s", Name(thing),
00694                                                   attr->name, strlen(attrtext) ? "Set." : "Cleared.");
00695                 could_hear = Hearer(thing);
00696                 handle_ears(thing, could_hear, Hearer(thing));
00697         } else {
00698                 notify_quiet(player, "Permission denied.");
00699         }
00700 }

char* silly_atr_get ( int  id,
int  flag 
)

Definition at line 44 of file glue.hcode.c.

References atr_get_str(), atr_pget(), and LBUF_SIZE.

00045 {
00046         int i, j;
00047         static char buf[LBUF_SIZE];
00048 
00049         atr_get_str(buf, id, flag, &i, &j);
00050         return buf;
00051 #if 0                                                   /* This would waste memory, so.. :P */
00052         return atr_pget(id, flag, &i, &j);
00053 #endif
00054 }

void silly_atr_set ( int  id,
int  flag,
char *  dat 
)

Definition at line 56 of file glue.hcode.c.

References atr_add_raw().

00057 {
00058         atr_add_raw(id, flag, dat);
00059 }


Variable Documentation

NAMETAB indiv_attraccess_nametab[]

Definition at line 1806 of file command.c.

Referenced by do_decomp(), do_set(), and fun_set().


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