--- deliantra/server/common/region.C 2007/08/30 07:28:25 1.36
+++ deliantra/server/common/region.C 2009/01/01 11:41:17 1.41
@@ -1,11 +1,11 @@
/*
- * This file is part of Crossfire TRT, the Roguelike Realtime MORPG.
+ * This file is part of Deliantra, the Roguelike Realtime MMORPG.
*
- * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
+ * 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
*
- * Crossfire TRT is free software: you can redistribute it and/or modify
+ * 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.
@@ -18,7 +18,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
- * The authors can be reached via e-mail to
+ * The authors can be reached via e-mail to
*/
#include
@@ -45,13 +45,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);
+ LOG (llevError, "region called %s requested, but not found, using fallback.\n", &name);
return default_region ();
}
@@ -74,44 +74,36 @@
if (!name)
return default_region ();
+ // TODO: bug, changes possibly const string
char *p = strchr (name, '\n');
if (p)
*p = '\0';
for_all_regions (rgn)
- if (!strcasecmp (rgn->name, name))
+ if (rgn->name.eq_nc (name))
return rgn;
for_all_regions (rgn)
- if (rgn->longname)
- if (!strcasecmp (rgn->longname, name))
- return rgn;
+ if (rgn->longname.eq_nc (name))
+ return rgn;
for_all_regions (rgn)
- if (rgn->longname)
- {
- if (strstr (rgn->longname, name))
- return rgn;
- }
+ if (rgn->longname.contains (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;
- }
+ /*
+ * 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 (rgn->longname && rgn->name.contains (name))
+ return rgn;
for_all_regions (rgn)
- {
- if (strstr (rgn->name, name))
- return rgn;
- }
+ if (rgn->name.contains (name))
+ return rgn;
return default_region ();
}
@@ -134,20 +126,19 @@
static int
region_is_child_of_region (const region * child, const region * r)
{
-
- if (r == NULL)
+ if (!r)
return -1;
- if (child == NULL)
+ if (!child)
return 0;
- if (!strcmp (child->name, r->name))
+ if (child->name == r->name)
return 1;
- else if (child->parent != NULL)
+ if (child->parent)
return region_is_child_of_region (child->parent, r);
- else
- return 0;
+
+ return 0;
}
/** Returns an object which is an exit through which the player represented by op should be
@@ -158,21 +149,18 @@
object *
get_jail_exit (object *op)
{
- region *reg;
- object *exit;
-
if (op->type != PLAYER)
{
LOG (llevError, "region.c: get_jail_exit called against non-player object.\n");
return NULL;
}
- reg = op->region ();
+ region *reg = op->region ();
while (reg)
{
if (reg->jailmap)
{
- exit = object::create ();
+ 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);