Permalink
Browse files

Inital attr-arrays checkin: Store attributes on objects in arrays, no…

…t linked lists.
  • Loading branch information...
shawnw committed Feb 2, 2018
1 parent f5e2e39 commit 1b227266a51ffb625a6a1dda4d8a32e066f82cf1
Showing with 720 additions and 651 deletions.
  1. +2 −1 .clang-format
  2. +5 −2 CHANGES.187.md
  3. +214 −217 hdrs/atr_tab.h
  4. +8 −3 hdrs/attrib.h
  5. +4 −1 hdrs/dbdefs.h
  6. +1 −2 src/atr_tab.c
  7. +427 −390 src/attrib.c
  8. +0 −2 src/cmds.c
  9. +1 −0 src/create.c
  10. +46 −24 src/db.c
  11. +2 −1 src/destroy.c
  12. +4 −4 src/game.c
  13. +1 −1 src/set.c
  14. +4 −2 src/timer.c
  15. +1 −1 src/wiz.c
@@ -8,7 +8,8 @@ AlwaysBreakAfterReturnType: AllDefinitions
BreakBeforeBraces: Linux
ColumnLimit: 80
ContinuationIndentWidth: 2
ForEachMacros: ['DESC_ITER_CONN', 'DESC_ITER' ]
ForEachMacros: ['DESC_ITER_CONN', 'DESC_ITER', 'DOLIST', 'DOLIST_VISIBLE',
'ATTR_FOR_EACH' ]
IndentCaseLabels: false
IndentWidth: 2
KeepEmptyLinesAtTheStartOfBlocks: true
@@ -22,8 +22,11 @@ Version 1.8.7 patchlevel 0 ??? ?? 20??
Major Changes
-------------
* Support websocket connections. See <https://github.com/grapenut/websockclient> for a
sample in-browser client. [Grapenut, 1007]
* Support websocket connections. See
<https://github.com/grapenut/websockclient> for a sample in-browser
client. [Grapenut, 1007]
* Change attributes from being stored in sorted linked lists to sorted
arrays; results in faster lookups and less memory usage. [SW]
Softcode
--------

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -19,9 +19,8 @@
struct attr {
char const *name; /**< Name of attribute */
uint32_t flags; /**< Attribute flags */
chunk_reference_t data; /**< The attribute's value, compressed */
dbref creator; /**< The attribute's creator's dbref */
ATTR *next; /**< Pointer to next attribute in list */
chunk_reference_t data; /**< The attribute's value, compressed */
};
/** An alias for an attribute.
@@ -48,6 +47,9 @@ const char *check_attr_value(dbref player, const char *name, const char *value);
int cnf_attribute_access(char *attrname, char *opts);
void add_new_attr(char *name, uint32_t flags);
bool attr_reserve(dbref, int);
void attr_shrink(dbref);
/* From attrib.c */
/** atr_add(), atr_clr() error codes */
@@ -169,9 +171,12 @@ extern ATTR attr[]; /**< external predefined attributes. */
#define AL_STR(alist) (atr_get_compressed_data((alist)))
/** The raw length of the (possibly compressed) attribute text. */
#define AL_STRLEN(alist) ((alist)->data ? chunk_len((alist)->data) : 0)
#define AL_NEXT(alist) ((alist)->next)
#define AL_CREATOR(alist) ((alist)->creator)
#define AL_FLAGS(alist) ((alist)->flags)
#define AL_DEREFS(alist) ((alist)->data ? chunk_derefs((alist)->data) : 0)
#define ATTR_FOR_EACH(obj, var) \
if (List(obj)) \
for (var = List(obj); AL_NAME(var); var++)
#endif /* __ATTRIB_H */
@@ -50,6 +50,7 @@ extern dbref first_free; /* pointer to free list */
#define ModTime(x) (db[(x)].modification_time)
#define AttrCount(x) (db[(x)].attrcount)
#define AttrCap(x) (db[(x)].attrcap)
/* Moved from warnings.c because create.c needs it. */
#define Warnings(x) (db[(x)].warnings)
@@ -189,6 +190,7 @@ extern dbref first_free; /* pointer to free list */
#define AF_Mhear(a) ((a)->flags & AF_MHEAR)
#define AF_Ahear(a) ((a)->flags & AF_AHEAR)
#define AF_Quiet(a) ((a)->flags & AF_QUIET)
#define AF_Root(a) ((a)->flags & AF_ROOT)
/* Non-mortal checks */
#define God(x) ((x) == GOD)
@@ -269,10 +271,11 @@ struct object {
*/
time_t modification_time;
int attrcount; /**< Number of attribs on the object */
int attrcap; /**< Size of the attribute array */
int type; /**< Object's type */
object_flag_type flags; /**< Pointer to flag bit array */
object_flag_type powers; /**< Pointer to power bit array */
ALIST *list; /**< list of attributes on the object */
ALIST *list; /**< Array of attributes on the object */
};
/** A structure to hold database statistics.
@@ -218,7 +218,6 @@ attr_read(PENNFILE *f)
a->data = NULL_CHUNK_REFERENCE;
AL_FLAGS(a) = 0;
AL_CREATOR(a) = GOD;
a->next = NULL;
db_read_this_labeled_string(f, "name", &tmp);
@@ -801,7 +800,7 @@ do_attribute_access(dbref player, char *name, char *perms, int retroactive)
if (retroactive) {
for (i = 0; i < db_top; i++) {
if ((ap2 = atr_get_noparent(i, name))) {
if (AL_FLAGS(ap2) & AF_ROOT)
if (AF_Root(ap2))
AL_FLAGS(ap2) = flags | AF_ROOT;
else
AL_FLAGS(ap2) = flags;
Oops, something went wrong.

0 comments on commit 1b22726

Please sign in to comment.