--- deliantra/server/common/region.C 2008/12/31 17:35:37 1.40
+++ deliantra/server/common/region.C 2009/11/06 13:03:34 1.45
@@ -5,18 +5,19 @@
* Copyright (©) 2001-2003,2007 Mark Wedel & Crossfire Development Team
* Copyright (©) 1992,2007 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
*/
@@ -45,73 +46,13 @@
* used by the map parsing code.
*/
region *
-region::find (const char *name)
+region::find (shstr_cmp name)
{
for_all_regions (rgn)
- if (!strcmp (rgn->name, name))
+ if (rgn->name == name)
return rgn;
- LOG (llevError, "region called %s requested, but not found, using fallback.\n", name);
-
- return default_region ();
-}
-
-/*
- * Tries to find a region that 'name' corresponds to.
- * It looks, in order, for:
- * an exact match to region name (case insensitive)
- * an exact match to longname (case insensitive)
- * a substring that matches to the longname (eg Kingdom)
- * a substring that matches to the region name (eg nav)
- * if it can find none of these it returns the first parentless region
- * (there should be only one of these - the top level one)
- * If we got a NULL, then just return the top level region
- *
- */
-region *
-region::find_fuzzy (const char *name)
-{
- if (!name)
- return default_region ();
-
- char *p = strchr (name, '\n');
- if (p)
- *p = '\0';
-
- for_all_regions (rgn)
- if (!strcasecmp (rgn->name, name))
- return rgn;
-
- for_all_regions (rgn)
- if (rgn->longname)
- if (!strcasecmp (rgn->longname, name))
- return rgn;
-
- for_all_regions (rgn)
- if (rgn->longname)
- {
- if (strstr (rgn->longname, name))
- return rgn;
- }
-
- for_all_regions (rgn)
- if (rgn->longname)
- {
- /*
- * This is not a bug, we want the region that is most identifiably a discrete
- * area in the game, eg if we have 'scor', we want to return 'scorn' and not
- * 'scornarena', regardless of their order on the list so we only look at those
- * regions with a longname set.
- */
- if (strstr (rgn->name, name))
- return rgn;
- }
-
- for_all_regions (rgn)
- {
- if (strstr (rgn->name, name))
- return rgn;
- }
+ LOG (llevError, "region called %s requested, but not found, using fallback.\n", &name);
return default_region ();
}
@@ -126,6 +67,8 @@
refcnt_dec ();
}
+//+GPL
+
/*
* returns 1 if the player is in the region reg, or a child region thereof
* otherwise returns 0
@@ -185,6 +128,8 @@
return 0;
}
+//-GPL
+
region *
region::read (object_thawer &f)
{
@@ -252,12 +197,7 @@
}
}
-/*
- * First initialises the archtype hash-table (init_archetable()).
- * Reads and parses the archetype file (with the first and second-pass
- * functions).
- */
-void
+static void
init_regions (void)
{
if (!regions.size ())