PennMUSH Community

Changeset 435

Show
Ignore:
Timestamp:
08/12/06 18:55:36 (2 years ago)
Author:
pennmush
Message:

PennMUSH 1.7.7p18 Archival

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • 1.7.7/CHANGES.177

    r433 r435  
    1818 
    1919========================================================================== 
     20 
     21Version 1.7.7 patchlevel 18                     August 19, 2003 
     22 
     23Major Changes: 
     24  * The flag handling code has been additionally abstracted to  
     25    allow, in a future patchlevel, @powers to be handled in the 
     26    same way that flags are now. 
     27Minor Changes: 
     28  * Wrap the OS-dependant code for making sure the mush always has a free 
     29    file descriptor available for use in a pair of functions. [SW] 
     30Fixes: 
     31  * Linted some ssl-related warnings. Reported by Cheetah@M*U*S*H. 
     32  * Compile failed in timer.c unless USE_MAILER was defined. 
     33    Reported by Sunny@M*U*S*H. 
     34  * Bug allowing players to view internal and mortal_dark attributes 
     35    introduced in p17 has been fixed. [TAP] 
     36 
    2037 
    2138Version 1.7.7 patchlevel 17                     August 11, 2003 
  • 1.7.7/Patchlevel

    r433 r435  
    11Do not edit this file. It is maintained by the official PennMUSH patches. 
    2 This is PennMUSH 1.7.7p17 
     2This is PennMUSH 1.7.7p18 
  • 1.7.7/game/txt/hlp/pennv177.hlp

    r433 r435  
    1 & 1.7.7p17 
     1& 1.7.7p18 
    22& changes 
    33This is a list of changes in this patchlevel which are probably of 
     
    1212be read in 'help patchlevels'. 
    1313 
     14Version 1.7.7 patchlevel 18                     August 19, 2003 
     15 
     16Major Changes: 
     17  * The flag handling code has been additionally abstracted to  
     18    allow, in a future patchlevel, @powers to be handled in the 
     19    same way that flags are now. 
     20Minor Changes: 
     21  * Wrap the OS-dependant code for making sure the mush always has a free 
     22    file descriptor available for use in a pair of functions. [SW] 
     23Fixes: 
     24  * Linted some ssl-related warnings. Reported by Cheetah@M*U*S*H. 
     25  * Compile failed in timer.c unless USE_MAILER was defined. 
     26    Reported by Sunny@M*U*S*H. 
     27  * Bug allowing players to view internal and mortal_dark attributes 
     28    introduced in p17 has been fixed. [TAP] 
     29 
     30 
     31& 1.7.7p17 
    1432Version 1.7.7 patchlevel 17                     August 11, 2003 
    1533 
  • 1.7.7/game/txt/hlp/pennvOLD.hlp

    r433 r435  
    44184418type 'help <version>p<patchlevel>'. For example, 'help 1.7.2p3' 
    44194419 
    4420 1.7.7: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 
     44201.7.7: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 
    442144211.7.6: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 
    442244221.7.5: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 
  • 1.7.7/hdrs/csrimalloc.h

    r427 r435  
    9191 */ 
    9292#ifdef __GNUC__ 
     93#ifndef alloca 
    9394#define alloca(n) __builtin_alloca(n) 
     95#endif 
    9496#endif              /* __GNUC__ */ 
    9597#ifdef sparc 
  • 1.7.7/hdrs/externs.h

    r433 r435  
    182182int parse_chat(dbref player, char *command); 
    183183extern void fork_and_dump(int forking); 
     184void reserve_fd(void); 
     185void release_fd(void); 
     186 
    184187 
    185188/* From look.c */ 
  • 1.7.7/hdrs/flags.h

    r423 r435  
    77 
    88#include "conf.h" 
     9#include "ptab.h" 
     10 
    911typedef struct flag_info FLAG; 
    1012 
     
    5355}; 
    5456 
     57typedef struct flagspace FLAGSPACE; 
     58 
     59/** A flagspace. 
     60 * A structure that contains all the information necessary to manage 
     61 * a set of flags, powers, or whatever. 
     62 */ 
     63struct flagspace { 
     64  PTAB *tab;            /**< Prefix table storing flags by name/alias */ 
     65  FLAG **flags;         /**< Variable-length array of pointers to canonical flags, indexed by bit */ 
     66  int flagbits;         /**< Current length of the flags array */ 
     67  FLAG *flag_table;     /**< Pointer to flag table */ 
     68  FLAG_ALIAS *flag_alias_table; /**< Pointer to flag alias table */ 
     69}; 
     70 
     71 
    5572/* From flags.c */ 
    56 extern FLAG *flag_hash_lookup(const char *name, int type); 
    5773extern int has_flag_by_name(dbref thing, const char *flag, int type); 
    5874extern const char *unparse_flags(dbref thing, dbref player); 
     
    6379extern const char *power_description(dbref thing); 
    6480extern int find_power(const char *name); 
    65 extern int flaglist_check(dbref player, dbref it, const char *fstr, int type); 
    66 extern int flaglist_check_long(dbref player, dbref it, const char *fstr, 
    67                    int type); 
     81extern int flaglist_check(const char *ns, dbref player, dbref it, 
     82              const char *fstr, int type); 
     83extern int flaglist_check_long(const char *ns, dbref player, dbref it, 
     84                   const char *fstr, int type); 
    6885extern FLAG *match_flag(const char *name); 
    6986extern int match_power(const char *name); 
    7087extern const char *show_command_flags(object_flag_type flags, int powers); 
    71 extern void twiddle_flag_internal(dbref thing, const char *flag, int negate); 
    72 extern object_flag_type new_flag_bitmask(void); 
    73 extern object_flag_type clone_flag_bitmask(object_flag_type given); 
    74 extern void copy_flag_bitmask(object_flag_type dest, object_flag_type given); 
     88extern void twiddle_flag_internal(const char *ns, dbref thing, const char *flag, 
     89                  int negate); 
     90extern object_flag_type new_flag_bitmask(const char *ns); 
     91extern object_flag_type clone_flag_bitmask(const char *ns, 
     92                       object_flag_type given); 
     93extern void copy_flag_bitmask(const char *ns, object_flag_type dest, 
     94                  object_flag_type given); 
    7595extern void destroy_flag_bitmask(object_flag_type bitmask); 
    7696extern void set_flag_bitmask(object_flag_type bitmask, int bit); 
    7797extern void clear_flag_bitmask(object_flag_type bitmask, int bit); 
    7898extern int has_bit(object_flag_type bitmask, int bitpos); 
    79 extern int has_all_bits(object_flag_type source, object_flag_type bitmask); 
    80 extern int null_flagmask(object_flag_type source); 
    81 extern int has_any_bits(object_flag_type source, object_flag_type bitmask); 
    82 extern object_flag_type string_to_bits(const char *str); 
    83 extern const char *bits_to_string(object_flag_type bitmask, dbref privs, 
    84                   dbref thing); 
    85 extern void flag_write_all(FILE *); 
    86 extern void flag_read_all(FILE *); 
     99extern int has_all_bits(const char *ns, object_flag_type source, 
     100            object_flag_type bitmask); 
     101extern int null_flagmask(const char *ns, object_flag_type source); 
     102extern int has_any_bits(const char *ns, object_flag_type source, 
     103            object_flag_type bitmask); 
     104extern object_flag_type string_to_bits(const char *ns, const char *str); 
     105extern const char *bits_to_string(const char *ns, object_flag_type bitmask, 
     106                  dbref privs, dbref thing); 
     107extern void flag_write_all(FILE *, const char *); 
     108extern void flag_read_all(FILE *, const char *); 
    87109extern int type_from_old_flags(long old_flags); 
    88110extern object_flag_type flags_from_old_flags(long old_flags, long old_toggles, 
     
    91113             int perms, int negate_perms); 
    92114extern void do_list_flags(dbref player, const char *arg, int lc); 
    93 extern char *list_all_flags(const char *name, dbref privs, int which); 
    94 extern void do_flag_info(dbref player, const char *name); 
     115extern char *list_all_flags(const char *ns, const char *name, dbref privs, 
     116                int which); 
     117extern void do_flag_info(const char *ns, dbref player, const char *name); 
    95118extern void do_flag_delete(dbref player, const char *name); 
    96119extern void do_flag_disable(dbref player, const char *name); 
     
    104127#define twiddle_flag_bitmask(bm,b,neg) (neg ? clear_flag_bitmask(bm,b) : \ 
    105128                                                set_flag_bitmask(bm,b)) 
    106 #define has_all_flags_by_mask(x,bm) has_all_bits(Flags(x),bm) 
    107 #define has_any_flags_by_mask(x,bm) has_any_bits(Flags(x),bm) 
     129#define has_all_flags_by_mask(x,bm) has_all_bits("FLAG",Flags(x),bm) 
     130#define has_any_flags_by_mask(x,bm) has_any_bits("FLAG",Flags(x),bm) 
    108131#define twiddle_flag(thing,f,negate) \ 
    109132  twiddle_flag_bitmask(Flags(thing),f->bitpos,negate) 
    110 #define set_flag_internal(t,f) twiddle_flag_internal(t,f,0) 
    111 #define clear_flag_internal(t,f) twiddle_flag_internal(t,f,1) 
     133#define set_flag_internal(t,f) twiddle_flag_internal("FLAG",t,f,0) 
     134#define clear_flag_internal(t,f) twiddle_flag_internal("FLAG",t,f,1) 
    112135 
    113136/*--------------------------------------------------------------------- 
  • 1.7.7/hdrs/game.h

    r417 r435  
    1717extern void init_math_hashtab(void);    /* funmath.c */ 
    1818extern void init_aname_table(void); /* atr_tab.c */ 
    19 extern void init_flag_table(void);  /* flags.c */ 
     19extern void init_flagspaces(void);  /* flags.c */ 
     20extern void init_flag_table(const char *ns);    /* flags.c */ 
    2021extern void init_tag_hashtab(void); /* funstr.c */ 
    2122extern void init_pronouns(void);    /* funstr.c */ 
  • 1.7.7/hdrs/version.h

    r433 r435  
    1 #define VERSION "PennMUSH version 1.7.7 patchlevel 17 [08/11/2003]" 
    2 #define SHORTVN "PennMUSH 1.7.7p17
    3 #define NUMVERSION 001007007017 
     1#define VERSION "PennMUSH version 1.7.7 patchlevel 18 [08/19/2003]" 
     2#define SHORTVN "PennMUSH 1.7.7p18
     3#define NUMVERSION 001007007018 
  • 1.7.7/src/access.c

    r431 r435  
    115115 
    116116static struct access *access_top; 
    117 extern int reserved;        /**< reserved file descriptor */ 
    118117static int add_access_node 
    119118  (const char *host, const dbref who, const int can, const int cant, 
     
    178177  access_top = NULL; 
    179178  /* Be sure we have a file descriptor */ 
    180 #ifndef WIN32 
    181   close(reserved); 
    182 #endif 
     179  release_fd(); 
    183180#ifdef macintosh 
    184181  fp = fopen(ACCESS_FILE, "rb"); 
     
    228225    fclose(fp); 
    229226  } 
    230 #ifndef WIN32 
    231   reserved = open("/dev/null", O_RDWR); 
    232 #endif 
     227  reserve_fd(); 
    233228  return retval; 
    234229} 
     
    247242  sprintf(tmpf, "%s.tmp", ACCESS_FILE); 
    248243  /* Be sure we have a file descriptor */ 
    249 #ifndef WIN32 
    250   close(reserved); 
    251 #endif 
     244  release_fd(); 
    252245#ifdef macintosh 
    253246  fp = fopen(tmpf, "wb"); 
     
    297290    rename(tmpf, ACCESS_FILE); 
    298291  } 
    299 #ifndef WIN32 
    300   reserved = open("/dev/null", O_RDWR); 
    301 #endif 
     292  reserve_fd(); 
    302293  return; 
    303294} 
  • 1.7.7/src/attrib.c

    r433 r435  
    595595  if (!wildcard(name)) { 
    596596    ptr = atr_get_noparent(thing, strupper(name)); 
    597     if (ptr && (object_visual || Is_Visible_Attr(thing, ptr))) 
     597    if (ptr && (object_visual ? Can_Read_Attr(player, thing, ptr) 
     598        : Is_Visible_Attr(thing, ptr))) 
    598599      result = func(player, thing, name, ptr, args); 
    599600  } else { 
    600601    for (ptr = List(thing); ptr; ptr = next) { 
    601602      next = AL_NEXT(ptr); 
    602       if ((object_visual || Is_Visible_Attr(thing, ptr)) 
     603      if ((object_visual ? Can_Read_Attr(player, thing, ptr) 
     604       : Is_Visible_Attr(thing, ptr)) 
    603605      && local_wild_match(name, AL_NAME(ptr))) 
    604606    result += func(player, thing, name, ptr, args); 
  • 1.7.7/src/bsd.c

    r433 r435  
    166166#endif 
    167167#endif 
    168 extern int reserved;        /**< A reserved file descriptor */ 
    169168static int extrafd; 
    170169int shutdown_flag = 0;      /**< Is it time to shut down? */ 
     
    269268  "Registration successful! You will receive your password by email."; 
    270269static const char *shutdown_message = "Going down - Bye"; 
     270#ifdef HAS_OPENSSL 
    271271static const char *ssl_shutdown_message = 
    272272  "GAME: SSL connections must be dropped, sorry."; 
     273#endif 
    273274static const char *asterisk_line = 
    274275  "**********************************************************************"; 
     
    297298DESC *descriptor_list = NULL;   /**< The linked list of descriptors */ 
    298299 
    299 static int sock, sslsock = 0
     300static int sock
    300301#ifdef HAS_OPENSSL 
     302static int sslsock = 0; 
    301303SSL *ssl_master_socket = NULL; 
    302304#endif 
     
    641643 
    642644  /* save a file descriptor */ 
     645  reserve_fd(); 
    643646#ifndef macintosh 
    644647#ifndef WIN32 
    645   reserved = open("/dev/null", O_RDWR); 
    646648  extrafd = open("/dev/null", O_RDWR); 
    647649#endif 
     
    14121414    struct stat sb; 
    14131415 
    1414 #ifndef macintosh 
    1415     close(reserved); 
    1416 #endif 
     1416    release_fd(); 
    14171417    if ((fd = open(filename, O_RDONLY, 0)) < 0) { 
    14181418      do_log(LT_ERR, 0, 0, T("Couldn't open cached text file '%s'"), filename); 
    1419 #ifndef macintosh 
    1420       reserved = open("/dev/null", O_RDWR); 
    1421 #endif 
     1419      reserve_fd(); 
    14221420      return -1; 
    14231421    } 
     
    14271425         filename); 
    14281426      close(fd); 
    1429 #ifndef macintosh 
    1430       reserved = open("/dev/null", O_RDWR); 
    1431 #endif 
     1427      reserve_fd(); 
    14321428      return -1; 
    14331429    } 
     
    14381434         (int) sb.st_size, filename); 
    14391435      close(fd); 
    1440 #ifndef macintosh 
    1441       reserved = open("/dev/null", O_RDWR); 
    1442 #endif 
     1436      reserve_fd(); 
    14431437      return -1; 
    14441438    } 
     
    14491443      mush_free(fb->buff, "fcache_data"); 
    14501444      fb->buff = NULL; 
    1451 #ifndef macintosh 
    1452       reserved = open("/dev/null", O_RDWR); 
    1453 #endif 
     1445      reserve_fd(); 
    14541446      return -1; 
    14551447    } 
    14561448 
    14571449    close(fd); 
    1458 #ifndef macintosh 
    1459     reserved = open("/dev/null", O_RDWR); 
    1460 #endif 
     1450    reserve_fd(); 
    14611451    fb->len = sb.st_size; 
    14621452 
     
    16701660} 
    16711661 
     1662/* ARGSUSED */ 
    16721663static DESC * 
    16731664initializesock(int s, char *addr, char *ip, int use_ssl) 
     
    25332524} 
    25342525 
     2526/* ARGSUSED */ 
    25352527static int 
    25362528process_input(DESC *d, int output_ready) 
  • 1.7.7/src/cmds.c

    r433 r435  
    291291    do_flag_enable(player, arg_left); 
    292292  else 
    293     do_flag_info(player, arg_left); 
     293    do_flag_info("FLAG", player, arg_left); 
    294294} 
    295295 
  • 1.7.7/src/command.c

    r433 r435  
    451451 
    452452  if (flagstr) 
    453     flagmask = string_to_bits(flagstr); 
     453    flagmask = string_to_bits("FLAG", flagstr); 
    454454  ptab_start_inserts(&ptab_command); 
    455455  ptab_insert(&ptab_command, name, 
     
    601601  for (cmd = commands; cmd->name; cmd++) { 
    602602    ptab_insert(&ptab_command, cmd->name, 
    603         make_command(cmd->name, cmd->type, string_to_bits(cmd->flagstr), 
    604                  cmd->powers, switchmask(cmd->switches)
    605                  cmd->func)); 
     603        make_command(cmd->name, cmd->type, 
     604                 string_to_bits("FLAG", cmd->flagstr), cmd->powers
     605                 switchmask(cmd->switches), cmd->func)); 
    606606  } 
    607607  ptab_end_inserts(&ptab_command); 
     
    11421142      } else { 
    11431143    if (!command->flagmask) 
    1144       command->flagmask = new_flag_bitmask(); 
     1144      command->flagmask = new_flag_bitmask("FLAG"); 
    11451145    set_flag_bitmask(command->flagmask, roy->bitpos); 
    11461146    set_flag_bitmask(command->flagmask, wiz->bitpos); 
     
    11561156      else { 
    11571157    if (!command->flagmask) 
    1158       command->flagmask = new_flag_bitmask(); 
     1158      command->flagmask = new_flag_bitmask("FLAG"); 
    11591159    set_flag_bitmask(command->flagmask, mask->bitpos); 
    11601160      } 
     
    13891389   */ 
    13901390  ok = 1; 
    1391   check_flags = cmd->flagmask && !null_flagmask(cmd->flagmask); 
     1391  check_flags = cmd->flagmask && !null_flagmask("FLAG", cmd->flagmask); 
    13921392 
    13931393  if (!((!cmd->powers && !check_flags) || 
  • 1.7.7/src/create.c

    r427 r435  
    123123    Source(new_exit) = loc; 
    124124    Type(new_exit) = TYPE_EXIT; 
    125     Flags(new_exit) = string_to_bits(options.exit_flags); 
     125    Flags(new_exit) = string_to_bits("FLAG", options.exit_flags); 
    126126 
    127127    /* link it in */ 
     
    390390    Zone(room) = Zone(player); 
    391391    Type(room) = TYPE_ROOM; 
    392     Flags(room) = string_to_bits(options.room_flags); 
     392    Flags(room) = string_to_bits("FLAG", options.room_flags); 
    393393 
    394394    notify_format(player, T("%s created with room number %d."), name, room); 
     
    453453    s_Pennies(thing, cost); 
    454454    Type(thing) = TYPE_THING; 
    455     Flags(thing) = string_to_bits(options.thing_flags); 
     455    Flags(thing) = string_to_bits("FLAG", options.thing_flags); 
    456456 
    457457    /* home is here (if we can link to it) or player's home */ 
     
    499499  Zone(clone) = Zone(thing); 
    500500  Parent(clone) = Parent(thing); 
    501   Flags(clone) = clone_flag_bitmask(Flags(thing)); 
     501  Flags(clone) = clone_flag_bitmask("FLAG", Flags(thing)); 
    502502  if (!preserve) { 
    503503    clear_flag_internal(clone, "WIZARD"); 
     
    622622      Zone(clone) = Zone(thing); 
    623623      Parent(clone) = Parent(thing); 
    624       Flags(clone) = clone_flag_bitmask(Flags(thing)); 
     624      Flags(clone) = clone_flag_bitmask("FLAG", Flags(thing)); 
    625625      if (!preserve) { 
    626626    clear_flag_internal(clone, "WIZARD"); 
  • 1.7.7/src/db.c

    r433 r435  
    217217  o->penn = 0; 
    218218  o->type = TYPE_GARBAGE; 
    219   o->flags = new_flag_bitmask(); 
     219  o->flags = new_flag_bitmask("FLAG"); 
    220220  o->powers = 0; 
    221221  o->warnings = 0; 
     
    456456  putref(f, Pennies(i)); 
    457457  putref(f, Typeof(i)); 
    458   putstring(f, bits_to_string(o->flags, GOD, NOTHING)); 
     458  putstring(f, bits_to_string("FLAG", o->flags, GOD, NOTHING)); 
    459459  putref(f, o->powers); 
    460460  /* Original chat system wrote chat channels to the db here.  
     
    557557{ 
    558558  OUTPUT(fprintf(f, "+FLAGS LIST\n")); 
    559   flag_write_all(f); 
     559  flag_write_all(f, "FLAG"); 
    560560} 
    561561 
     
    10561056      } else if (c == 'F') { 
    10571057    (void) getstring_noalloc(f); 
    1058     flag_read_all(f); 
     1058    flag_read_all(f, "FLAG"); 
    10591059      } else { 
    10601060    do_rawlog(LT_ERR, T("Unrecognized database format!")); 
     
    10881088      if (indb_flags & DBF_NEW_FLAGS) { 
    10891089    o->type = getref(f); 
    1090     o->flags = string_to_bits(getstring_noalloc(f)); 
     1090    o->flags = string_to_bits("FLAG", getstring_noalloc(f)); 
    10911091      } else { 
    10921092    int old_flags, old_toggles; 
  • 1.7.7/src/flags.c

    r433 r435  
    3636#include "match.h" 
    3737#include "ptab.h" 
     38#include "htab.h" 
    3839#include "privtab.h" 
    3940#include "game.h" 
     
    4748 
    4849static int can_set_flag(dbref player, dbref thing, FLAG *flagp, int negate); 
    49 static FLAG *letter_to_flagptr(char c, int type); 
    50 static void flag_add(const char *name, FLAG *f); 
     50static FLAG *letter_to_flagptr(FLAGSPACE * n, char c, int type); 
     51static void flag_add(FLAGSPACE * n, const char *name, FLAG *f); 
    5152static int has_flag(dbref thing, FLAG *f); 
    5253 
     
    5556static FLAG *flag_read(FILE * in); 
    5657static void flag_write(FILE * out, FLAG *f, const char *name); 
     58static FLAG *flag_hash_lookup(FLAGSPACE * n, const char *name, int type); 
    5759static FLAG *clone_flag(FLAG *f); 
    5860static FLAG *new_flag(void); 
    5961static void flag_add_additional(void); 
    60 static char *list_aliases(FLAG *given); 
     62static char *list_aliases(FLAGSPACE * n, FLAG *given); 
    6163static void realloc_object_flag_bitmasks(int numbytes); 
     64static FLAG *match_flag_ns(FLAGSPACE * n, const char *name); 
    6265 
    6366PTAB ptab_flag;         /**< Table of flags by name, inc. aliases */ 
    64 FLAG **flags = NULL;        /**< A variable-length array of pointers,  
    65                                  * to canonical flags, indexed by bit  
    66                                  * position. Aliases not inclued. */ 
    67 static int flagbits = 0;    /* The current length of the flags array */ 
     67HASHTAB htab_flagspaces;        /**< Hash of flagspaces */ 
    6868 
    6969extern PTAB ptab_command;   /* Uses flag bitmasks */ 
    7070 
     71#define Flagspace_Lookup(n,ns)  if (!(n = (FLAGSPACE *)hashfind(ns,&htab_flagspaces))) panic("Unable to locate flagspace"); 
    7172 
    7273/** This is the old default flag table. We still use it when we have to 
     
    284285match_flag(const char *name) 
    285286{ 
    286   return (FLAG *) ptab_find(&ptab_flag, name); 
     287  return (FLAG *) match_flag_ns(hashfind("FLAG", &htab_flagspaces), name); 
     288
     289 
     290/** Convenience function to return a pointer to a flag struct 
     291 * given the name. 
     292 * \param name name of flag to find. 
     293 * \return poiner to flag structure, or NULL. 
     294 */ 
     295static FLAG * 
     296match_flag_ns(FLAGSPACE * n, const char *name) 
     297
     298  return (FLAG *) ptab_find(n->tab, name); 
    287299} 
    288300 
     
    292304 * name is a single character. If all else fails, it tries to match 
    293305 * against an object type name. 
     306 * \param n pointer to flagspace to search. 
    294307 * \param name name of flag to find. 
    295308 * \param type mask of desired flag object types. 
    296309 * \return pointer to flag structure, or NULL. 
    297310 */ 
    298 FLAG * 
    299 flag_hash_lookup(const char *name, int type) 
    300 { 
    301   FLAG *f; 
    302  
    303   f = match_flag(name); 
     311static FLAG * 
     312flag_hash_lookup(FLAGSPACE * n, const char *name, int type) 
     313{ 
     314  FLAG *f; 
     315 
     316  f = match_flag_ns(n, name); 
    304317  if (f && !(f->perms & F_DISABLED)) { 
    305318    if (f->type & type) 
     
    310323  /* If the name is a single character, search the flag characters */ 
    311324  if (name && *name && !*(name + 1)) { 
    312     if ((f = letter_to_flagptr(*name, type))) 
     325    if ((f = letter_to_flagptr(n, *name, type))) 
    313326      return f; 
    314327  } 
    315328 
    316329  /* provided for backwards compatibility: type flag checking */ 
    317   for (f = type_table; f->name != NULL; f++) 
    318     if (string_prefix(name, f->name)) 
    319       return f; 
     330  if (n->flag_table == flag_table) { 
     331    for (f = type_table; f->name != NULL; f++) 
     332      if (string_prefix(name, f->name)) 
     333    return f; 
     334  } 
     335 
    320336  return NULL; 
    321337} 
     
    336352/* Deallocate all flag-related memory */ 
    337353static void 
    338 clear_all_flags(void
    339 { 
    340   ptab_free(&ptab_flag); 
     354clear_all_flags(FLAGSPACE * n
     355{ 
     356  ptab_free(n->tab); 
    341357  /* Finally, the flags array */ 
    342   if (flags) 
    343     free(flags); 
    344   flags = NULL; 
    345   flagbits = 0; 
     358  if (n->flags) 
     359    free(n->flags); 
     360  n->flags = NULL; 
     361  n->flagbits = 0; 
    346362} 
    347363 
     
    366382 */ 
    367383static void 
    368 flag_add(const char *name, FLAG *f) 
     384flag_add(FLAGSPACE * n, const char *name, FLAG *f) 
    369385{ 
    370386  /* If this flag has no bitpos assigned, assign it the next one. 
     
    373389   */ 
    374390  if (f->bitpos < 0) 
    375     f->bitpos = flagbits; 
     391    f->bitpos = n->flagbits; 
    376392 
    377393  /* Insert the flag in the ptab by the given name (maybe an alias) */ 
    378   ptab_start_inserts(&ptab_flag); 
    379   ptab_insert(&ptab_flag, name, f); 
    380   ptab_end_inserts(&ptab_flag); 
     394  ptab_start_inserts(n->tab); 
     395  ptab_insert(n->tab, name, f); 
     396  ptab_end_inserts(n->tab); 
    381397 
    382398  /* Is this a canonical flag (as opposed to an alias?) 
     
    387403   * indexing a flag in the flags array) 
    388404   */ 
    389   if ((f->bitpos >= flagbits) || (flags[f->bitpos] == NULL)) { 
     405  if ((f->bitpos >= n->flagbits) || (n->flags[f->bitpos] == NULL)) { 
    390406    /* It's a canonical flag */ 
    391407    int i; 
    392     if (f->bitpos >= flagbits) { 
     408    if (f->bitpos >= n->flagbits) { 
    393409      /* Oops, we need a bigger array */ 
    394       if (flagbits == 0) 
    395     flags = (FLAG **) malloc(sizeof(FLAG *)); 
     410      if (n->flagbits == 0) 
     411    n->flags = (FLAG **) malloc(sizeof(FLAG *)); 
    396412      else { 
    397     flags = (FLAG **) realloc(flags, (f->bitpos + 1) * sizeof(FLAG *)); 
    398     if (!flags) 
     413    n->flags = 
     414      (FLAG **) realloc(n->flags, (f->bitpos + 1) * sizeof(FLAG *)); 
     415    if (!n->flags) 
    399416      panic("Unable to reallocate flags array!\n"); 
    400417      } 
    401418      /* Make sure the new space is full of NULLs */ 
    402       for (i = flagbits; i <= f->bitpos; i++) 
    403     flags[i] = NULL; 
     419      for (i = n->flagbits; i <= f->bitpos; i++) 
     420    n->flags[i] = NULL; 
    404421    } 
    405422    /* Put the canonical flag in the flags array */ 
    406     flags[f->bitpos] = f; 
    407     flagbits = f->bitpos + 1; 
    408     if (flagbits % 8 == 1) { 
     423    n->flags[f->bitpos] = f; 
     424    n->flagbits = f->bitpos + 1; 
     425    if (n->flagbits % 8 == 1) { 
    409426      /* We've crossed over a byte boundary, so we need to realloc 
    410427       * all the flags on all our objects to get them an additional 
    411428       * byte. 
    412429       */ 
    413       realloc_object_flag_bitmasks((flagbits + 7) / 8); 
    414     } 
    415   } 
    416 
    417  
     430      realloc_object_flag_bitmasks((n->flagbits + 7) / 8); 
     431    } 
     432  } 
     433
     434 
     435/* Eventually, this need to compute numbytes itself from the 
     436 * total bytes required for flags + powers 
     437 */ 
    418438static void 
    419439realloc_object_flag_bitmasks(int numbytes) 
     
    505525 */ 
    506526void 
    507 flag_read_all(FILE * in) 
    508 
    509   FLAG *f; 
     527flag_read_all(FILE * in, const char *ns) 
     528
     529  FLAG *f; 
     530  FLAGSPACE *n; 
    510531  char alias[BUFFER_LEN]; 
     532 
     533  if (!(n = (FLAGSPACE *) hashfind(ns, &htab_flagspaces))) { 
     534    do_rawlog(LT_ERR, T("FLAG READ: Unable to locate flagspace %s."), ns); 
     535    return; 
     536  } 
    511537  /* If we are reading flags from the db, they are definitive. */ 
    512   clear_all_flags(); 
     538  clear_all_flags(n); 
    513539  while ((f = flag_read(in))) { 
    514     flag_add(f->name, f); 
     540    flag_add(n, f->name, f); 
    515541  } 
    516542  /* Assumes we'll always have at least one alias */ 
    517543  while ((f = flag_alias_read(in, alias))) { 
    518     flag_add(alias, f); 
     544    flag_add(n, alias, f); 
    519545  } 
    520546  flag_add_additional(); 
     
    548574 */ 
    549575void 
    550 flag_write_all(FILE * out
     576flag_write_all(FILE * out, const char *ns
    551577{ 
    552578  int i; 
    553579  FLAG *f; 
     580  FLAGSPACE *n; 
    554581  char flagname[BUFFER_LEN]; 
     582 
     583  if (!(n = (FLAGSPACE *) hashfind(ns, &htab_flagspaces))) { 
     584    do_rawlog(LT_ERR, T("FLAG WRITE: Unable to locate flagspace %s."), ns); 
     585    return; 
     586  } 
    555587  /* Write out canonical flags first */ 
    556   for (i = 0; i < flagbits; i++) { 
    557     if (flags[i]) 
    558       flag_write(out, flags[i], flags[i]->name); 
     588  for (i = 0; i < n->flagbits; i++) { 
     589    if (n->flags[i]) 
     590      flag_write(out, n->flags[i], n->flags[i]->name); 
    559591  } 
    560592  putstring(out, "FLAG ALIASES"); 
     
    563595   * bit position 
    564596   */ 
    565   f = ptab_firstentry_new(&ptab_flag, flagname); 
     597  f = ptab_firstentry_new(n->tab, flagname); 
    566598  while (f) { 
    567     if (strcmp(flags[f->bitpos]->name, flagname)) { 
     599    if (strcmp(n->flags[f->bitpos]->name, flagname)) { 
    568600      /* This is an alias! */ 
    569601      flag_alias_write(out, f, flagname); 
    570602    } 
    571     f = ptab_nextentry_new(&ptab_flag, flagname); 
     603    f = ptab_nextentry_new(n->tab, flagname); 
    572604  } 
    573605  putstring(out, "END OF FLAGS"); 
    574606} 
    575607 
    576  
    577 /** Initialize the flag table with defaults. 
     608/** Initialize the flagspaces. 
     609 */ 
     610void 
     611init_flagspaces(void) 
     612
     613  FLAGSPACE *flags; 
     614 
     615  hashinit(&htab_flagspaces, 4, sizeof(FLAGSPACE)); 
     616  flags = (FLAGSPACE *) mush_malloc(sizeof(FLAGSPACE), "flagspace"); 
     617  flags->tab = &ptab_flag; 
     618  flags->flagbits = 0; 
     619  flags->flags = NULL; 
     620  flags->flag_table = flag_table; 
     621  flags->flag_alias_table = flag_alias_tab; 
     622  hashadd("FLAG", (void *) flags, &htab_flagspaces); 
     623
     624 
     625 
     626/** Initialize a flag table with defaults. 
    578627 * This function loads the standard flags as a baseline  
    579628 * (and for dbs that haven't yet converted). 
     629 * \param ns name of flagspace to initialize. 
    580630 */ 
    581631void 
    582 init_flag_table(void
     632init_flag_table(const char *ns
    583633{ 
    584634  FLAG *f, *cf; 
    585635  FLAG_ALIAS *a; 
    586   ptab_init(&ptab_flag); 
     636  FLAGSPACE *n; 
     637 
     638  if (!(n = (FLAGSPACE *) hashfind(ns, &htab_flagspaces))) { 
     639    do_rawlog(LT_ERR, T("FLAG INIT: Unable to locate flagspace %s."), ns); 
     640    return; 
     641  } 
     642 
     643  ptab_init(n->tab); 
    587644  /* do regular flags first */ 
    588   for (f = flag_table; f->name; f++) { 
     645  for (f = n->flag_table; f->name; f++) { 
    589646    cf = clone_flag(f); 
    590647    cf->bitpos = -1; 
    591     flag_add(cf->name, cf); 
     648    flag_add(n, cf->name, cf); 
    592649  } 
    593650  /* now add in the aliases */ 
    594   for (a = flag_alias_tab; a->alias; a++) { 
    595     if ((f = match_flag(a->realname))) 
    596       flag_add(a->alias, f); 
     651  for (a = n->flag_alias_table; a->alias; a++) { 
     652    if ((f = match_flag_ns(n, a->realname))) 
     653      flag_add(n, a->alias, f); 
    597654    else 
    598655      do_rawlog(LT_ERR, 
     
    658715{ 
    659716  FLAG *f, *newf; 
    660   object_flag_type bitmask = new_flag_bitmask(); 
     717  object_flag_type bitmask = new_flag_bitmask("FLAG"); 
     718 
    661719  for (f = flag_table; f->name; f++) { 
    662720    if (f->type == NOTYPE) { 
     
    686744/* Given a single character, return the matching flag definition */ 
    687745static FLAG * 
    688 letter_to_flagptr(char c, int type) 
     746letter_to_flagptr(FLAGSPACE * n, char c, int type) 
    689747{ 
    690748  FLAG *f; 
    691749  int i; 
    692   for (i = 0; i < flagbits; i++) 
    693     if ((f = flags[i])) { 
     750  for (i = 0; i < n->flagbits; i++) 
     751    if ((f = n->flags[i])) { 
    694752      /* Doh! Kludge-city. We'll ignore the CHOWN_OK flag on players, because 
    695753       * it's more useful to check 'C' as COLOR. Argle. 
     
    713771#define FlagBit(x) (7 - (x % 8)) 
    714772/** How many bytes do we need for a flag bitmask? */ 
    715 #define FlagBytes  ((size_t)((flagbits + 7) / 8)) 
     773#define FlagBytes(n)  ((size_t)((n->flagbits + 7) / 8)) 
     774 
    716775 
    717776/** Allocate a new flag bitmask. 
     
    722781 */ 
    723782object_flag_type 
    724 new_flag_bitmask(void
     783new_flag_bitmask(const char *ns
    725784{ 
    726785  object_flag_type bitmask; 
    727   bitmask = (object_flag_type) mush_malloc(FlagBytes, "flag_bitmask"); 
     786  FLAGSPACE *n; 
     787  Flagspace_Lookup(n, ns); 
     788  bitmask = (object_flag_type) mush_malloc(FlagBytes(n), "flag_bitmask"); 
    728789  if (!bitmask) 
    729790    panic("Unable to allocate memory for flag bitmask"); 
    730   memset(bitmask, 0, FlagBytes); 
     791  memset(bitmask, 0, FlagBytes(n)); 
    731792  return bitmask; 
    732793} 
     
    740801 */ 
    741802object_flag_type 
    742 clone_flag_bitmask(object_flag_type given) 
     803clone_flag_bitmask(const char *ns, object_flag_type given) 
    743804{ 
    744805  object_flag_type bitmask; 
    745   bitmask = (object_flag_type) mush_malloc(FlagBytes, "flag_bitmask"); 
     806  FLAGSPACE *n; 
     807  Flagspace_Lookup(n, ns); 
     808  bitmask = (object_flag_type) mush_malloc(FlagBytes(n), "flag_bitmask"); 
    746809  if (!bitmask) 
    747810    panic("Unable to allocate memory for flag bitmask"); 
    748   memcpy(bitmask, given, FlagBytes); 
     811  memcpy(bitmask, given, FlagBytes(n)); 
    749812  return bitmask; 
    750813} 
     
    757820/* Copy a given bitmask to an already-allocated destination bitmask */ 
    758821void 
    759 copy_flag_bitmask(object_flag_type dest, object_flag_type given) 
    760 
    761   memcpy((void *) dest, (void *) given, FlagBytes); 
     822copy_flag_bitmask(const char *ns, object_flag_type dest, object_flag_type given) 
     823
     824  FLAGSPACE *n; 
     825  Flagspace_Lookup(n, ns); 
     826  memcpy((void *) dest, (void *) given, FlagBytes(n)); 
    762827} 
    763828 
     
    835900 */ 
    836901int 
    837 has_all_bits(object_flag_type source, object_flag_type bitmask) 
     902has_all_bits(const char *ns, object_flag_type source, object_flag_type bitmask) 
    838903{ 
    839904  unsigned int i; 
    840905  int ok = 1; 
    841   for (i = 0; i < FlagBytes; i++) 
     906  FLAGSPACE *n; 
     907  Flagspace_Lookup(n, ns); 
     908  for (i = 0; i < FlagBytes(n); i++) 
    842909    ok &= ((*(bitmask + i) & *(source + i)) == *(bitmask + i)); 
    843910  return ok; 
     
    850917 */ 
    851918int 
    852 null_flagmask(object_flag_type source) 
     919null_flagmask(const char *ns, object_flag_type source) 
    853920{ 
    854921  unsigned int i; 
    855922  int bad = 0; 
    856   for (i = 0; i < FlagBytes; i++) 
     923  FLAGSPACE *n; 
     924  Flagspace_Lookup(n, ns); 
     925  for (i = 0; i < FlagBytes(n); i++) 
    857926    bad |= *(source + i); 
    858927  return (!bad); 
     
    868937 */ 
    869938int 
    870 has_any_bits(object_flag_type source, object_flag_type bitmask) 
     939has_any_bits(const char *ns, object_flag_type source, object_flag_type bitmask) 
    871940{ 
    872941  unsigned int i; 
    873942  int ok = 0; 
    874   for (i = 0; i < FlagBytes; i++) 
     943  FLAGSPACE *n; 
     944  Flagspace_Lookup(n, ns); 
     945  for (i = 0; i < FlagBytes(n); i++) 
    875946    ok |= (*(bitmask + i) & *(source + i)); 
    876947  return ok; 
     
    885956 */ 
    886957const char * 
    887 bits_to_string(object_flag_type bitmask, dbref privs, dbref thing) 
    888 
    889   FLAG *f; 
     958bits_to_string(const char *ns, object_flag_type bitmask, dbref privs, 
     959           dbref thing) 
     960
     961  FLAG *f; 
     962  FLAGSPACE *n; 
    890963  int i; 
    891964  int first = 1; 
    892965  static char buf[BUFFER_LEN]; 
    893966  char *bp; 
     967 
     968  Flagspace_Lookup(n, ns); 
    894969  bp = buf; 
    895   for (i = 0; i < flagbits; i++) { 
    896     if ((f = flags[i])) { 
     970  for (i = 0; i < n->flagbits; i++) { 
     971    if ((f = n->flags[i])) { 
    897972      if (has_bit(bitmask, f->bitpos) && 
    898973      (!GoodObject(thing) || Can_See_Flag(privs, thing, f))) { 
     
    915990 */ 
    916991object_flag_type 
    917 string_to_bits(const char *str) 
     992string_to_bits(const char *ns, const char *str) 
    918993{ 
    919994  object_flag_type bitmask; 
    920995  char *copy, *s, *sp; 
    921996  FLAG *f; 
    922   bitmask = new_flag_bitmask(); 
     997  FLAGSPACE *n; 
     998 
     999  bitmask = new_flag_bitmask(ns); 
     1000  if (!(n = (FLAGSPACE *) hashfind(ns,