Changeset 435
- Timestamp:
- 08/12/06 18:55:36 (2 years ago)
- Files:
-
- 1.7.7/CHANGES.177 (modified) (1 diff)
- 1.7.7/Patchlevel (modified) (1 diff)
- 1.7.7/game/txt/hlp/pennv177.hlp (modified) (2 diffs)
- 1.7.7/game/txt/hlp/pennvOLD.hlp (modified) (1 diff)
- 1.7.7/hdrs/csrimalloc.h (modified) (1 diff)
- 1.7.7/hdrs/externs.h (modified) (1 diff)
- 1.7.7/hdrs/flags.h (modified) (5 diffs)
- 1.7.7/hdrs/game.h (modified) (1 diff)
- 1.7.7/hdrs/version.h (modified) (1 diff)
- 1.7.7/src/access.c (modified) (5 diffs)
- 1.7.7/src/attrib.c (modified) (1 diff)
- 1.7.7/src/bsd.c (modified) (10 diffs)
- 1.7.7/src/cmds.c (modified) (1 diff)
- 1.7.7/src/command.c (modified) (5 diffs)
- 1.7.7/src/create.c (modified) (5 diffs)
- 1.7.7/src/db.c (modified) (5 diffs)
- 1.7.7/src/flags.c (modified) (64 diffs)
- 1.7.7/src/fundb.c (modified) (7 diffs)
- 1.7.7/src/game.c (modified) (4 diffs)
- 1.7.7/src/myssl.c (modified) (7 diffs)
- 1.7.7/src/player.c (modified) (5 diffs)
- 1.7.7/src/timer.c (modified) (5 diffs)
- 1.7.7/src/wiz.c (modified) (7 diffs)
- 1.7.7/win32/cmds.h (modified) (1 diff)
- 1.7.7/win32/funs.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
1.7.7/CHANGES.177
r433 r435 18 18 19 19 ========================================================================== 20 21 Version 1.7.7 patchlevel 18 August 19, 2003 22 23 Major 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. 27 Minor 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] 30 Fixes: 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 20 37 21 38 Version 1.7.7 patchlevel 17 August 11, 2003 1.7.7/Patchlevel
r433 r435 1 1 Do not edit this file. It is maintained by the official PennMUSH patches. 2 This is PennMUSH 1.7.7p1 72 This is PennMUSH 1.7.7p18 1.7.7/game/txt/hlp/pennv177.hlp
r433 r435 1 & 1.7.7p1 71 & 1.7.7p18 2 2 & changes 3 3 This is a list of changes in this patchlevel which are probably of … … 12 12 be read in 'help patchlevels'. 13 13 14 Version 1.7.7 patchlevel 18 August 19, 2003 15 16 Major 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. 20 Minor 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] 23 Fixes: 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 14 32 Version 1.7.7 patchlevel 17 August 11, 2003 15 33 1.7.7/game/txt/hlp/pennvOLD.hlp
r433 r435 4418 4418 type 'help <version>p<patchlevel>'. For example, 'help 1.7.2p3' 4419 4419 4420 1.7.7: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 4420 1.7.7: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 4421 4421 1.7.6: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 4422 4422 1.7.5: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 1.7.7/hdrs/csrimalloc.h
r427 r435 91 91 */ 92 92 #ifdef __GNUC__ 93 #ifndef alloca 93 94 #define alloca(n) __builtin_alloca(n) 95 #endif 94 96 #endif /* __GNUC__ */ 95 97 #ifdef sparc 1.7.7/hdrs/externs.h
r433 r435 182 182 int parse_chat(dbref player, char *command); 183 183 extern void fork_and_dump(int forking); 184 void reserve_fd(void); 185 void release_fd(void); 186 184 187 185 188 /* From look.c */ 1.7.7/hdrs/flags.h
r423 r435 7 7 8 8 #include "conf.h" 9 #include "ptab.h" 10 9 11 typedef struct flag_info FLAG; 10 12 … … 53 55 }; 54 56 57 typedef 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 */ 63 struct 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 55 72 /* From flags.c */ 56 extern FLAG *flag_hash_lookup(const char *name, int type);57 73 extern int has_flag_by_name(dbref thing, const char *flag, int type); 58 74 extern const char *unparse_flags(dbref thing, dbref player); … … 63 79 extern const char *power_description(dbref thing); 64 80 extern 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); 81 extern int flaglist_check(const char *ns, dbref player, dbref it, 82 const char *fstr, int type); 83 extern int flaglist_check_long(const char *ns, dbref player, dbref it, 84 const char *fstr, int type); 68 85 extern FLAG *match_flag(const char *name); 69 86 extern int match_power(const char *name); 70 87 extern 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); 88 extern void twiddle_flag_internal(const char *ns, dbref thing, const char *flag, 89 int negate); 90 extern object_flag_type new_flag_bitmask(const char *ns); 91 extern object_flag_type clone_flag_bitmask(const char *ns, 92 object_flag_type given); 93 extern void copy_flag_bitmask(const char *ns, object_flag_type dest, 94 object_flag_type given); 75 95 extern void destroy_flag_bitmask(object_flag_type bitmask); 76 96 extern void set_flag_bitmask(object_flag_type bitmask, int bit); 77 97 extern void clear_flag_bitmask(object_flag_type bitmask, int bit); 78 98 extern 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 *); 99 extern int has_all_bits(const char *ns, object_flag_type source, 100 object_flag_type bitmask); 101 extern int null_flagmask(const char *ns, object_flag_type source); 102 extern int has_any_bits(const char *ns, object_flag_type source, 103 object_flag_type bitmask); 104 extern object_flag_type string_to_bits(const char *ns, const char *str); 105 extern const char *bits_to_string(const char *ns, object_flag_type bitmask, 106 dbref privs, dbref thing); 107 extern void flag_write_all(FILE *, const char *); 108 extern void flag_read_all(FILE *, const char *); 87 109 extern int type_from_old_flags(long old_flags); 88 110 extern object_flag_type flags_from_old_flags(long old_flags, long old_toggles, … … 91 113 int perms, int negate_perms); 92 114 extern 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); 115 extern char *list_all_flags(const char *ns, const char *name, dbref privs, 116 int which); 117 extern void do_flag_info(const char *ns, dbref player, const char *name); 95 118 extern void do_flag_delete(dbref player, const char *name); 96 119 extern void do_flag_disable(dbref player, const char *name); … … 104 127 #define twiddle_flag_bitmask(bm,b,neg) (neg ? clear_flag_bitmask(bm,b) : \ 105 128 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) 108 131 #define twiddle_flag(thing,f,negate) \ 109 132 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) 112 135 113 136 /*--------------------------------------------------------------------- 1.7.7/hdrs/game.h
r417 r435 17 17 extern void init_math_hashtab(void); /* funmath.c */ 18 18 extern void init_aname_table(void); /* atr_tab.c */ 19 extern void init_flag_table(void); /* flags.c */ 19 extern void init_flagspaces(void); /* flags.c */ 20 extern void init_flag_table(const char *ns); /* flags.c */ 20 21 extern void init_tag_hashtab(void); /* funstr.c */ 21 22 extern void init_pronouns(void); /* funstr.c */ 1.7.7/hdrs/version.h
r433 r435 1 #define VERSION "PennMUSH version 1.7.7 patchlevel 1 7 [08/11/2003]"2 #define SHORTVN "PennMUSH 1.7.7p1 7"3 #define NUMVERSION 00100700701 71 #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 115 115 116 116 static struct access *access_top; 117 extern int reserved; /**< reserved file descriptor */118 117 static int add_access_node 119 118 (const char *host, const dbref who, const int can, const int cant, … … 178 177 access_top = NULL; 179 178 /* Be sure we have a file descriptor */ 180 #ifndef WIN32 181 close(reserved); 182 #endif 179 release_fd(); 183 180 #ifdef macintosh 184 181 fp = fopen(ACCESS_FILE, "rb"); … … 228 225 fclose(fp); 229 226 } 230 #ifndef WIN32 231 reserved = open("/dev/null", O_RDWR); 232 #endif 227 reserve_fd(); 233 228 return retval; 234 229 } … … 247 242 sprintf(tmpf, "%s.tmp", ACCESS_FILE); 248 243 /* Be sure we have a file descriptor */ 249 #ifndef WIN32 250 close(reserved); 251 #endif 244 release_fd(); 252 245 #ifdef macintosh 253 246 fp = fopen(tmpf, "wb"); … … 297 290 rename(tmpf, ACCESS_FILE); 298 291 } 299 #ifndef WIN32 300 reserved = open("/dev/null", O_RDWR); 301 #endif 292 reserve_fd(); 302 293 return; 303 294 } 1.7.7/src/attrib.c
r433 r435 595 595 if (!wildcard(name)) { 596 596 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))) 598 599 result = func(player, thing, name, ptr, args); 599 600 } else { 600 601 for (ptr = List(thing); ptr; ptr = next) { 601 602 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)) 603 605 && local_wild_match(name, AL_NAME(ptr))) 604 606 result += func(player, thing, name, ptr, args); 1.7.7/src/bsd.c
r433 r435 166 166 #endif 167 167 #endif 168 extern int reserved; /**< A reserved file descriptor */169 168 static int extrafd; 170 169 int shutdown_flag = 0; /**< Is it time to shut down? */ … … 269 268 "Registration successful! You will receive your password by email."; 270 269 static const char *shutdown_message = "Going down - Bye"; 270 #ifdef HAS_OPENSSL 271 271 static const char *ssl_shutdown_message = 272 272 "GAME: SSL connections must be dropped, sorry."; 273 #endif 273 274 static const char *asterisk_line = 274 275 "**********************************************************************"; … … 297 298 DESC *descriptor_list = NULL; /**< The linked list of descriptors */ 298 299 299 static int sock , sslsock = 0;300 static int sock; 300 301 #ifdef HAS_OPENSSL 302 static int sslsock = 0; 301 303 SSL *ssl_master_socket = NULL; 302 304 #endif … … 641 643 642 644 /* save a file descriptor */ 645 reserve_fd(); 643 646 #ifndef macintosh 644 647 #ifndef WIN32 645 reserved = open("/dev/null", O_RDWR);646 648 extrafd = open("/dev/null", O_RDWR); 647 649 #endif … … 1412 1414 struct stat sb; 1413 1415 1414 #ifndef macintosh 1415 close(reserved); 1416 #endif 1416 release_fd(); 1417 1417 if ((fd = open(filename, O_RDONLY, 0)) < 0) { 1418 1418 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(); 1422 1420 return -1; 1423 1421 } … … 1427 1425 filename); 1428 1426 close(fd); 1429 #ifndef macintosh 1430 reserved = open("/dev/null", O_RDWR); 1431 #endif 1427 reserve_fd(); 1432 1428 return -1; 1433 1429 } … … 1438 1434 (int) sb.st_size, filename); 1439 1435 close(fd); 1440 #ifndef macintosh 1441 reserved = open("/dev/null", O_RDWR); 1442 #endif 1436 reserve_fd(); 1443 1437 return -1; 1444 1438 } … … 1449 1443 mush_free(fb->buff, "fcache_data"); 1450 1444 fb->buff = NULL; 1451 #ifndef macintosh 1452 reserved = open("/dev/null", O_RDWR); 1453 #endif 1445 reserve_fd(); 1454 1446 return -1; 1455 1447 } 1456 1448 1457 1449 close(fd); 1458 #ifndef macintosh 1459 reserved = open("/dev/null", O_RDWR); 1460 #endif 1450 reserve_fd(); 1461 1451 fb->len = sb.st_size; 1462 1452 … … 1670 1660 } 1671 1661 1662 /* ARGSUSED */ 1672 1663 static DESC * 1673 1664 initializesock(int s, char *addr, char *ip, int use_ssl) … … 2533 2524 } 2534 2525 2526 /* ARGSUSED */ 2535 2527 static int 2536 2528 process_input(DESC *d, int output_ready) 1.7.7/src/cmds.c
r433 r435 291 291 do_flag_enable(player, arg_left); 292 292 else 293 do_flag_info( player, arg_left);293 do_flag_info("FLAG", player, arg_left); 294 294 } 295 295 1.7.7/src/command.c
r433 r435 451 451 452 452 if (flagstr) 453 flagmask = string_to_bits( flagstr);453 flagmask = string_to_bits("FLAG", flagstr); 454 454 ptab_start_inserts(&ptab_command); 455 455 ptab_insert(&ptab_command, name, … … 601 601 for (cmd = commands; cmd->name; cmd++) { 602 602 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)); 606 606 } 607 607 ptab_end_inserts(&ptab_command); … … 1142 1142 } else { 1143 1143 if (!command->flagmask) 1144 command->flagmask = new_flag_bitmask( );1144 command->flagmask = new_flag_bitmask("FLAG"); 1145 1145 set_flag_bitmask(command->flagmask, roy->bitpos); 1146 1146 set_flag_bitmask(command->flagmask, wiz->bitpos); … … 1156 1156 else { 1157 1157 if (!command->flagmask) 1158 command->flagmask = new_flag_bitmask( );1158 command->flagmask = new_flag_bitmask("FLAG"); 1159 1159 set_flag_bitmask(command->flagmask, mask->bitpos); 1160 1160 } … … 1389 1389 */ 1390 1390 ok = 1; 1391 check_flags = cmd->flagmask && !null_flagmask( cmd->flagmask);1391 check_flags = cmd->flagmask && !null_flagmask("FLAG", cmd->flagmask); 1392 1392 1393 1393 if (!((!cmd->powers && !check_flags) || 1.7.7/src/create.c
r427 r435 123 123 Source(new_exit) = loc; 124 124 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); 126 126 127 127 /* link it in */ … … 390 390 Zone(room) = Zone(player); 391 391 Type(room) = TYPE_ROOM; 392 Flags(room) = string_to_bits( options.room_flags);392 Flags(room) = string_to_bits("FLAG", options.room_flags); 393 393 394 394 notify_format(player, T("%s created with room number %d."), name, room); … … 453 453 s_Pennies(thing, cost); 454 454 Type(thing) = TYPE_THING; 455 Flags(thing) = string_to_bits( options.thing_flags);455 Flags(thing) = string_to_bits("FLAG", options.thing_flags); 456 456 457 457 /* home is here (if we can link to it) or player's home */ … … 499 499 Zone(clone) = Zone(thing); 500 500 Parent(clone) = Parent(thing); 501 Flags(clone) = clone_flag_bitmask( Flags(thing));501 Flags(clone) = clone_flag_bitmask("FLAG", Flags(thing)); 502 502 if (!preserve) { 503 503 clear_flag_internal(clone, "WIZARD"); … … 622 622 Zone(clone) = Zone(thing); 623 623 Parent(clone) = Parent(thing); 624 Flags(clone) = clone_flag_bitmask( Flags(thing));624 Flags(clone) = clone_flag_bitmask("FLAG", Flags(thing)); 625 625 if (!preserve) { 626 626 clear_flag_internal(clone, "WIZARD"); 1.7.7/src/db.c
r433 r435 217 217 o->penn = 0; 218 218 o->type = TYPE_GARBAGE; 219 o->flags = new_flag_bitmask( );219 o->flags = new_flag_bitmask("FLAG"); 220 220 o->powers = 0; 221 221 o->warnings = 0; … … 456 456 putref(f, Pennies(i)); 457 457 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)); 459 459 putref(f, o->powers); 460 460 /* Original chat system wrote chat channels to the db here. … … 557 557 { 558 558 OUTPUT(fprintf(f, "+FLAGS LIST\n")); 559 flag_write_all(f );559 flag_write_all(f, "FLAG"); 560 560 } 561 561 … … 1056 1056 } else if (c == 'F') { 1057 1057 (void) getstring_noalloc(f); 1058 flag_read_all(f );1058 flag_read_all(f, "FLAG"); 1059 1059 } else { 1060 1060 do_rawlog(LT_ERR, T("Unrecognized database format!")); … … 1088 1088 if (indb_flags & DBF_NEW_FLAGS) { 1089 1089 o->type = getref(f); 1090 o->flags = string_to_bits( getstring_noalloc(f));1090 o->flags = string_to_bits("FLAG", getstring_noalloc(f)); 1091 1091 } else { 1092 1092 int old_flags, old_toggles; 1.7.7/src/flags.c
r433 r435 36 36 #include "match.h" 37 37 #include "ptab.h" 38 #include "htab.h" 38 39 #include "privtab.h" 39 40 #include "game.h" … … 47 48 48 49 static 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);50 static FLAG *letter_to_flagptr(FLAGSPACE * n, char c, int type); 51 static void flag_add(FLAGSPACE * n, const char *name, FLAG *f); 51 52 static int has_flag(dbref thing, FLAG *f); 52 53 … … 55 56 static FLAG *flag_read(FILE * in); 56 57 static void flag_write(FILE * out, FLAG *f, const char *name); 58 static FLAG *flag_hash_lookup(FLAGSPACE * n, const char *name, int type); 57 59 static FLAG *clone_flag(FLAG *f); 58 60 static FLAG *new_flag(void); 59 61 static void flag_add_additional(void); 60 static char *list_aliases(FLAG *given);62 static char *list_aliases(FLAGSPACE * n, FLAG *given); 61 63 static void realloc_object_flag_bitmasks(int numbytes); 64 static FLAG *match_flag_ns(FLAGSPACE * n, const char *name); 62 65 63 66 PTAB 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 */ 67 HASHTAB htab_flagspaces; /**< Hash of flagspaces */ 68 68 69 69 extern PTAB ptab_command; /* Uses flag bitmasks */ 70 70 71 #define Flagspace_Lookup(n,ns) if (!(n = (FLAGSPACE *)hashfind(ns,&htab_flagspaces))) panic("Unable to locate flagspace"); 71 72 72 73 /** This is the old default flag table. We still use it when we have to … … 284 285 match_flag(const char *name) 285 286 { 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 */ 295 static FLAG * 296 match_flag_ns(FLAGSPACE * n, const char *name) 297 { 298 return (FLAG *) ptab_find(n->tab, name); 287 299 } 288 300 … … 292 304 * name is a single character. If all else fails, it tries to match 293 305 * against an object type name. 306 * \param n pointer to flagspace to search. 294 307 * \param name name of flag to find. 295 308 * \param type mask of desired flag object types. 296 309 * \return pointer to flag structure, or NULL. 297 310 */ 298 FLAG *299 flag_hash_lookup( const char *name, int type)300 { 301 FLAG *f; 302 303 f = match_flag (name);311 static FLAG * 312 flag_hash_lookup(FLAGSPACE * n, const char *name, int type) 313 { 314 FLAG *f; 315 316 f = match_flag_ns(n, name); 304 317 if (f && !(f->perms & F_DISABLED)) { 305 318 if (f->type & type) … … 310 323 /* If the name is a single character, search the flag characters */ 311 324 if (name && *name && !*(name + 1)) { 312 if ((f = letter_to_flagptr( *name, type)))325 if ((f = letter_to_flagptr(n, *name, type))) 313 326 return f; 314 327 } 315 328 316 329 /* 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 320 336 return NULL; 321 337 } … … 336 352 /* Deallocate all flag-related memory */ 337 353 static void 338 clear_all_flags( void)339 { 340 ptab_free( &ptab_flag);354 clear_all_flags(FLAGSPACE * n) 355 { 356 ptab_free(n->tab); 341 357 /* 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; 346 362 } 347 363 … … 366 382 */ 367 383 static void 368 flag_add( const char *name, FLAG *f)384 flag_add(FLAGSPACE * n, const char *name, FLAG *f) 369 385 { 370 386 /* If this flag has no bitpos assigned, assign it the next one. … … 373 389 */ 374 390 if (f->bitpos < 0) 375 f->bitpos = flagbits;391 f->bitpos = n->flagbits; 376 392 377 393 /* 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); 381 397 382 398 /* Is this a canonical flag (as opposed to an alias?) … … 387 403 * indexing a flag in the flags array) 388 404 */ 389 if ((f->bitpos >= flagbits) || (flags[f->bitpos] == NULL)) {405 if ((f->bitpos >= n->flagbits) || (n->flags[f->bitpos] == NULL)) { 390 406 /* It's a canonical flag */ 391 407 int i; 392 if (f->bitpos >= flagbits) {408 if (f->bitpos >= n->flagbits) { 393 409 /* 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 *)); 396 412 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) 399 416 panic("Unable to reallocate flags array!\n"); 400 417 } 401 418 /* 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; 404 421 } 405 422 /* 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) { 409 426 /* We've crossed over a byte boundary, so we need to realloc 410 427 * all the flags on all our objects to get them an additional 411 428 * byte. 412 429 */ 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 */ 418 438 static void 419 439 realloc_object_flag_bitmasks(int numbytes) … … 505 525 */ 506 526 void 507 flag_read_all(FILE * in) 508 { 509 FLAG *f; 527 flag_read_all(FILE * in, const char *ns) 528 { 529 FLAG *f; 530 FLAGSPACE *n; 510 531 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 } 511 537 /* If we are reading flags from the db, they are definitive. */ 512 clear_all_flags( );538 clear_all_flags(n); 513 539 while ((f = flag_read(in))) { 514 flag_add( f->name, f);540 flag_add(n, f->name, f); 515 541 } 516 542 /* Assumes we'll always have at least one alias */ 517 543 while ((f = flag_alias_read(in, alias))) { 518 flag_add( alias, f);544 flag_add(n, alias, f); 519 545 } 520 546 flag_add_additional(); … … 548 574 */ 549 575 void 550 flag_write_all(FILE * out )576 flag_write_all(FILE * out, const char *ns) 551 577 { 552 578 int i; 553 579 FLAG *f; 580 FLAGSPACE *n; 554 581 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 } 555 587 /* 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); 559 591 } 560 592 putstring(out, "FLAG ALIASES"); … … 563 595 * bit position 564 596 */ 565 f = ptab_firstentry_new( &ptab_flag, flagname);597 f = ptab_firstentry_new(n->tab, flagname); 566 598 while (f) { 567 if (strcmp( flags[f->bitpos]->name, flagname)) {599 if (strcmp(n->flags[f->bitpos]->name, flagname)) { 568 600 /* This is an alias! */ 569 601 flag_alias_write(out, f, flagname); 570 602 } 571 f = ptab_nextentry_new( &ptab_flag, flagname);603 f = ptab_nextentry_new(n->tab, flagname); 572 604 } 573 605 putstring(out, "END OF FLAGS"); 574 606 } 575 607 576 577 /** Initialize the flag table with defaults. 608 /** Initialize the flagspaces. 609 */ 610 void 611 init_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. 578 627 * This function loads the standard flags as a baseline 579 628 * (and for dbs that haven't yet converted). 629 * \param ns name of flagspace to initialize. 580 630 */ 581 631 void 582 init_flag_table( void)632 init_flag_table(const char *ns) 583 633 { 584 634 FLAG *f, *cf; 585 635 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); 587 644 /* do regular flags first */ 588 for (f = flag_table; f->name; f++) {645 for (f = n->flag_table; f->name; f++) { 589 646 cf = clone_flag(f); 590 647 cf->bitpos = -1; 591 flag_add( cf->name, cf);648 flag_add(n, cf->name, cf); 592 649 } 593 650 /* 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); 597 654 else 598 655 do_rawlog(LT_ERR, … … 658 715 { 659 716 FLAG *f, *newf; 660 object_flag_type bitmask = new_flag_bitmask(); 717 object_flag_type bitmask = new_flag_bitmask("FLAG"); 718 661 719 for (f = flag_table; f->name; f++) { 662 720 if (f->type == NOTYPE) { … … 686 744 /* Given a single character, return the matching flag definition */ 687 745 static FLAG * 688 letter_to_flagptr( char c, int type)746 letter_to_flagptr(FLAGSPACE * n, char c, int type) 689 747 { 690 748 FLAG *f; 691 749 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])) { 694 752 /* Doh! Kludge-city. We'll ignore the CHOWN_OK flag on players, because 695 753 * it's more useful to check 'C' as COLOR. Argle. … … 713 771 #define FlagBit(x) (7 - (x % 8)) 714 772 /** 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 716 775 717 776 /** Allocate a new flag bitmask. … … 722 781 */ 723 782 object_flag_type 724 new_flag_bitmask( void)783 new_flag_bitmask(const char *ns) 725 784 { 726 785 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"); 728 789 if (!bitmask) 729 790 panic("Unable to allocate memory for flag bitmask"); 730 memset(bitmask, 0, FlagBytes );791 memset(bitmask, 0, FlagBytes(n)); 731 792 return bitmask; 732 793 } … … 740 801 */ 741 802 object_flag_type 742 clone_flag_bitmask( object_flag_type given)803 clone_flag_bitmask(const char *ns, object_flag_type given) 743 804 { 744 805 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"); 746 809 if (!bitmask) 747 810 panic("Unable to allocate memory for flag bitmask"); 748 memcpy(bitmask, given, FlagBytes );811 memcpy(bitmask, given, FlagBytes(n)); 749 812 return bitmask; 750 813 } … … 757 820 /* Copy a given bitmask to an already-allocated destination bitmask */ 758 821 void 759 copy_flag_bitmask(object_flag_type dest, object_flag_type given) 760 { 761 memcpy((void *) dest, (void *) given, FlagBytes); 822 copy_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)); 762 827 } 763 828 … … 835 900 */ 836 901 int 837 has_all_bits( object_flag_type source, object_flag_type bitmask)902 has_all_bits(const char *ns, object_flag_type source, object_flag_type bitmask) 838 903 { 839 904 unsigned int i; 840 905 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++) 842 909 ok &= ((*(bitmask + i) & *(source + i)) == *(bitmask + i)); 843 910 return ok; … … 850 917 */ 851 918 int 852 null_flagmask( object_flag_type source)919 null_flagmask(const char *ns, object_flag_type source) 853 920 { 854 921 unsigned int i; 855 922 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++) 857 926 bad |= *(source + i); 858 927 return (!bad); … … 868 937 */ 869 938 int 870 has_any_bits( object_flag_type source, object_flag_type bitmask)939 has_any_bits(const char *ns, object_flag_type source, object_flag_type bitmask) 871 940 { 872 941 unsigned int i; 873 942 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++) 875 946 ok |= (*(bitmask + i) & *(source + i)); 876 947 return ok; … … 885 956 */ 886 957 const char * 887 bits_to_string(object_flag_type bitmask, dbref privs, dbref thing) 888 { 889 FLAG *f; 958 bits_to_string(const char *ns, object_flag_type bitmask, dbref privs, 959 dbref thing) 960 { 961 FLAG *f; 962 FLAGSPACE *n; 890 963 int i; 891 964 int first = 1; 892 965 static char buf[BUFFER_LEN]; 893 966 char *bp; 967 968 Flagspace_Lookup(n, ns); 894 969 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])) { 897 972 if (has_bit(bitmask, f->bitpos) && 898 973 (!GoodObject(thing) || Can_See_Flag(privs, thing, f))) { … … 915 990 */ 916 991 object_flag_type 917 string_to_bits(const char * str)992 string_to_bits(const char *ns, const char *str) 918 993 { 919 994 object_flag_type bitmask; 920 995 char *copy, *s, *sp; 921 996 FLAG *f; 922 bitmask = new_flag_bitmask(); 997 FLAGSPACE *n; 998 999 bitmask = new_flag_bitmask(ns); 1000 if (!(n = (FLAGSPACE *) hashfind(ns,
