ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/region.C
(Generate patch)

Comparing deliantra/server/common/region.C (file contents):
Revision 1.10 by root, Wed Dec 13 02:55:50 2006 UTC vs.
Revision 1.17 by root, Thu Jan 25 03:54:44 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 * CrossFire, A Multiplayer game for X-windows
3 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
4 Copyright (C) 2001-2003 Mark Wedel & Crossfire Development Team 5 * Copyright (C) 2001-2003 Mark Wedel & Crossfire Development Team
5 Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (C) 1992 Frank Tore Johansen
6 7 *
7 This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 11 * (at your option) any later version.
11 12 *
12 This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 16 * GNU General Public License for more details.
16 17 *
17 You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 21 *
21 The authors can be reached via e-mail at <crossfire@schmorp.de> 22 * The authors can be reached via e-mail at <crossfire@schmorp.de>
22*/ 23 */
23 24
24 25
25#include <global.h> 26#include <global.h>
26#include <unistd.h> 27#include <unistd.h>
27 28
73const char * 74const char *
74get_name_of_region_for_map (const maptile *m) 75get_name_of_region_for_map (const maptile *m)
75{ 76{
76 region *reg; 77 region *reg;
77 78
78 if (m->region != NULL) 79 if (m->default_region)
79 return m->region->name; 80 return m->default_region->name;
81
80 for (reg = first_region; reg != NULL; reg = reg->next) 82 for (reg = first_region; reg; reg = reg->next)
81 { 83 {
82 if (reg->fallback) 84 if (reg->fallback)
83 return reg->name; 85 return reg->name;
84 } 86 }
87
85 LOG (llevInfo, "map %s had no region and I couldn't find a fallback to use.\n", m->name); 88 LOG (llevInfo, "map %s had no region and I couldn't find a fallback to use.\n", &m->name);
86 return "unknown"; 89 return "unknown";
87} 90}
88 91
89/* 92/*
90 * Tries to find a region that 'name' corresponds to. 93 * Tries to find a region that 'name' corresponds to.
345 */ 348 */
346 if (!strcmp (key, "region")) 349 if (!strcmp (key, "region"))
347 { 350 {
348 *end = 0; 351 *end = 0;
349 newreg = get_region_struct (); 352 newreg = get_region_struct ();
350 newreg->name = strdup_local (value); 353 newreg->name = strdup (value);
351 } 354 }
352 else if (!strcmp (key, "parent")) 355 else if (!strcmp (key, "parent"))
353 { 356 {
354 /* 357 /*
355 * Note that this is in the initialisation code, so we don't actually 358 * Note that this is in the initialisation code, so we don't actually
356 * assign the pointer to the parent yet, because it might not have been 359 * assign the pointer to the parent yet, because it might not have been
357 * parsed. 360 * parsed.
358 */ 361 */
359 *end = 0; 362 *end = 0;
360 newreg->parent_name = strdup_local (value); 363 newreg->parent_name = strdup (value);
361 } 364 }
362 else if (!strcmp (key, "longname")) 365 else if (!strcmp (key, "longname"))
363 { 366 {
364 *end = 0; 367 *end = 0;
365 newreg->longname = strdup_local (value); 368 newreg->longname = strdup (value);
366 } 369 }
367 else if (!strcmp (key, "jail")) 370 else if (!strcmp (key, "jail"))
368 { 371 {
369 /* jail entries are of the form: /path/to/map x y */ 372 /* jail entries are of the form: /path/to/map x y */
370 char path[MAX_BUF]; 373 char path[MAX_BUF];
373 if (sscanf (value, "%[^ ] %d %d\n", path, &x, &y) != 3) 376 if (sscanf (value, "%[^ ] %d %d\n", path, &x, &y) != 3)
374 { 377 {
375 LOG (llevError, "region.c: malformated regions entry: jail %s\n", value); 378 LOG (llevError, "region.c: malformated regions entry: jail %s\n", value);
376 continue; 379 continue;
377 } 380 }
378 newreg->jailmap = strdup_local (path); 381 newreg->jailmap = strdup (path);
379 newreg->jailx = x; 382 newreg->jailx = x;
380 newreg->jaily = y; 383 newreg->jaily = y;
381 } 384 }
382 else if (!strcmp (key, "msg")) 385 else if (!strcmp (key, "msg"))
383 { 386 {
395 * There may be regions with empty messages (eg, msg/endmsg 398 * There may be regions with empty messages (eg, msg/endmsg
396 * with nothing between). When maps are loaded, this is done 399 * with nothing between). When maps are loaded, this is done
397 * so better do it here too... 400 * so better do it here too...
398 */ 401 */
399 if (msgpos != 0) 402 if (msgpos != 0)
400 newreg->msg = strdup_local (msgbuf); 403 newreg->msg = strdup (msgbuf);
401 404
402 /* we have to reset msgpos, or the next region will store both msg blocks. */ 405 /* we have to reset msgpos, or the next region will store both msg blocks. */
403 msgpos = 0; 406 msgpos = 0;
404 } 407 }
405 else if (!strcmp (key, "fallback")) 408 else if (!strcmp (key, "fallback"))
447 reg->parent = get_region_by_name (reg->parent_name); 450 reg->parent = get_region_by_name (reg->parent_name);
448 parent_count++; 451 parent_count++;
449 } 452 }
450 region_count++; 453 region_count++;
451 } 454 }
452 LOG (llevDebug, "Assigned %u regions with %u parents.", region_count, parent_count); 455 LOG (llevDebug, "Assigned %u regions with %u parents.\n", region_count, parent_count);
453} 456}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines