--- deliantra/server/common/arch.C 2006/09/07 09:37:11 1.13 +++ deliantra/server/common/arch.C 2006/09/08 17:14:07 1.14 @@ -1,6 +1,6 @@ /* * static char *rcsid_arch_c = - * "$Id: arch.C,v 1.13 2006/09/07 09:37:11 pippijn Exp $"; + * "$Id: arch.C,v 1.14 2006/09/08 17:14:07 root Exp $"; */ /* @@ -421,23 +421,15 @@ LOG (llevDebug, "Freed %d archetypes, %d faces\n", i, f); } -/* - * Allocates, initialises and returns the pointer to an archetype structure. - */ -// TODO: should become constructor -archetype * -get_archetype_struct (void) +archetype::archetype () { - archetype * - arch; - - arch = new archetype; - - clear_object (&arch->clone); /* to initial state other also */ - CLEAR_FLAG (&arch->clone, FLAG_FREED); /* This shouldn't matter, since copy_object() */ - SET_FLAG (&arch->clone, FLAG_REMOVED); /* doesn't copy these flags... */ + clear_object (&clone); /* to initial state other also */ + CLEAR_FLAG (&clone, FLAG_FREED); /* This shouldn't matter, since copy_object() */ + SET_FLAG (&clone, FLAG_REMOVED); /* doesn't copy these flags... */ +} - return arch; +archetype::~archetype () +{ } /* @@ -447,20 +439,12 @@ void first_arch_pass (object_thawer & fp) { - object * - op; - archetype * - at, * - head = NULL, *last_more = NULL; - int - i; + archetype *at, *head = NULL, *last_more = NULL; - op = get_object (); - op->arch = first_archetype = at = get_archetype_struct (); + at->clone.arch = first_archetype = at = new archetype; - while ((i = load_object (fp, op, 0))) + while (int i = load_object (fp, &at->clone, 0)) { - copy_object (op, &at->clone); at->clone.speed_left = (float) (-0.1); /* copy the body_info to the body_used - this is only really * need for monsters, but doesn't hurt to do it for everything. @@ -468,7 +452,7 @@ * values for the body_used info, so when items are created * for it, they can be properly equipped. */ - memcpy (&at->clone.body_used, &op->body_info, sizeof (op->body_info)); + memcpy (&at->clone.body_used, &at->clone.body_info, sizeof (at->clone.body_info)); switch (i) { @@ -518,14 +502,11 @@ } - at = get_archetype_struct (); - clear_object (op); - op->arch = at; + at = new archetype; + at->clone.arch = at; } - delete - at; - free_object (op); + delete at; } /* @@ -536,11 +517,8 @@ void second_arch_pass (object_thawer & thawer) { - char - buf[MAX_BUF], * - variable = buf, *argument, *cp; - archetype * - at = NULL, *other; + char buf[MAX_BUF], *variable = buf, *argument, *cp; + archetype *at = NULL, *other; while (fgets (buf, MAX_BUF, thawer) != NULL) { @@ -681,10 +659,8 @@ object * create_singularity (const char *name) { - object * - op; - char - buf[MAX_BUF]; + object *op; + char buf[MAX_BUF]; sprintf (buf, "%s (%s)", ARCH_SINGULARITY, name); op = get_object (); op->name = op->name_pl = buf; @@ -700,8 +676,7 @@ object * get_archetype (const char *name) { - archetype * - at; + archetype *at; at = find_archetype (name); if (at == NULL) return create_singularity (name); @@ -715,12 +690,9 @@ unsigned long hasharch (const char *str, int tablesize) { - unsigned long - hash = 0; - unsigned int - i = 0; - const char * - p; + unsigned long hash = 0; + unsigned int i = 0; + const char *p; /* use the one-at-a-time hash function, which supposedly is * better than the djb2-like one used by perl5.005, but