--- deliantra/server/common/region.C 2007/07/11 16:55:18 1.34 +++ deliantra/server/common/region.C 2007/07/13 15:54:40 1.35 @@ -116,12 +116,21 @@ return default_region (); } +void +region::do_destroy () +{ + regions.erase (this); + + attachable::do_destroy (); + + refcnt_dec (); +} + /* * returns 1 if the player is in the region reg, or a child region thereof * otherwise returns 0 * if passed a NULL region returns -1 */ - static int region_is_child_of_region (const region * child, const region * r) { @@ -186,6 +195,8 @@ assert (f.kw == KW_region); region *rgn = new region; + rgn->refcnt_inc (); + f.get (rgn->name); f.next (); @@ -215,15 +226,12 @@ case KW_end: f.next (); + // cannot use find as that will request the default region for_all_regions (old) if (old->name == rgn->name) { - // replace, copy new values (ugly) - rgn->index = old->index; - *old = *rgn; - delete rgn; - - return old; + old->destroy (); + break; } // just append @@ -238,7 +246,7 @@ default: if (!f.parse_error ("region", rgn->name)) { - delete rgn; + rgn->destroy (); return 0; } break;