--- deliantra/server/common/region.C 2009/01/01 20:49:48 1.42 +++ deliantra/server/common/region.C 2012/01/03 11:25:31 1.54 @@ -1,22 +1,23 @@ /* * This file is part of Deliantra, the Roguelike Realtime MMORPG. * - * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team - * Copyright (©) 2001-2003,2007 Mark Wedel & Crossfire Development Team - * Copyright (©) 1992,2007 Frank Tore Johansen + * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team + * Copyright (©) 2001-2003 Mark Wedel & Crossfire Development Team + * Copyright (©) 1992 Frank Tore Johansen * - * Deliantra is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * Deliantra is free software: you can redistribute it and/or modify it under + * the terms of the Affero GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * You should have received a copy of the Affero GNU General Public License + * and the GNU General Public License along with this program. If not, see + * . * * The authors can be reached via e-mail to */ @@ -36,14 +37,6 @@ return regions [0]; } -/* - * Pass a char array, returns a pointer to the region of the same name. - * if it can't find a region of the same name it returns the first region - * with the 'fallback' property set. - * if it can't find a matching name /or/ a fallback region it logs an info message - * message and returns NULL - * used by the map parsing code. - */ region * region::find (shstr_cmp name) { @@ -51,12 +44,27 @@ if (rgn->name == name) return rgn; - LOG (llevError, "region called %s requested, but not found, using fallback.\n", &name); - return default_region (); } void +object_thawer::get (region_ptr &r) const +{ + shstr_cmp name = get_str (); + + for_all_regions (rgn) + if (rgn->name == name) + { + r = rgn; + return; + } + + parse_error (format ("region called %s requested, but not found, using fallback.\n", get_str ())); + + r = region::default_region (); +} + +void region::do_destroy () { regions.erase (this); @@ -66,6 +74,8 @@ refcnt_dec (); } +//+GPL + /* * returns 1 if the player is in the region reg, or a child region thereof * otherwise returns 0 @@ -111,7 +121,7 @@ object *exit = object::create (); EXIT_PATH (exit) = reg->jailmap; /* damned exits reset savebed and remove teleports, so the prisoner can't escape */ - SET_FLAG (exit, FLAG_DAMNED); + exit->set_flag (FLAG_DAMNED); EXIT_X (exit) = reg->jailx; EXIT_Y (exit) = reg->jaily; return exit; @@ -125,6 +135,8 @@ return 0; } +//-GPL + region * region::read (object_thawer &f) { @@ -141,7 +153,7 @@ switch (f.kw) { case KW_parent: - rgn->parent = region::find (f.get_str ()); + f.get (rgn->parent); break; case KW_msg: f.get_ml (KW_endmsg, rgn->msg); break; @@ -150,8 +162,6 @@ case KW_jail_x: f.get (rgn->jailx); break; case KW_jail_y: f.get (rgn->jaily); break; case KW_portal_map: f.get (rgn->portalmap);break; - case KW_portal_x: f.get (rgn->portalx); break; - case KW_portal_y: f.get (rgn->portaly); break; case KW_fallback: f.get (rgn->fallback); break; case KW_chance: f.get (rgn->treasure_density); break; @@ -192,21 +202,3 @@ } } -/* - * First initialises the archtype hash-table (init_archetable()). - * Reads and parses the archetype file (with the first and second-pass - * functions). - */ -void -init_regions (void) -{ - if (!regions.size ()) - { - // make sure one region is always available - region *rgn = new region; - rgn->name = ""; - rgn->longname = "Built-in Region"; - regions.push_back (rgn); - } -} -