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

Comparing cf.schmorp.de/server/common/region.C (file contents):
Revision 1.4 by root, Sun Sep 10 16:00:23 2006 UTC vs.
Revision 1.10 by root, Wed Dec 13 02:55:50 2006 UTC

1
2/*
3 * static char *rcsid_map_c =
4 * "$Id: region.C,v 1.4 2006/09/10 16:00:23 root Exp $";
5 */
6
7/* 1/*
8 CrossFire, A Multiplayer game for X-windows 2 CrossFire, A Multiplayer game for X-windows
9 3
10 Copyright (C) 2001-2003 Mark Wedel & Crossfire Development Team 4 Copyright (C) 2001-2003 Mark Wedel & Crossfire Development Team
11 Copyright (C) 1992 Frank Tore Johansen 5 Copyright (C) 1992 Frank Tore Johansen
22 16
23 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
25 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 20
27 The authors can be reached via e-mail at crossfire-devel@real-time.com 21 The authors can be reached via e-mail at <crossfire@schmorp.de>
28*/ 22*/
29 23
30 24
31#include <global.h> 25#include <global.h>
32
33#ifndef WIN32 /* ---win32 exclude header */
34# include <unistd.h> 26#include <unistd.h>
35#endif /* win32 */
36 27
37/* 28/*
38 * Pass a char array, returns a pointer to the region of the same name. 29 * Pass a char array, returns a pointer to the region of the same name.
39 * if it can't find a region of the same name it returns the first region 30 * if it can't find a region of the same name it returns the first region
40 * with the 'fallback' property set. 31 * with the 'fallback' property set.
66 return NULL; 57 return NULL;
67} 58}
68 59
69/* This might need optimising at some point. */ 60/* This might need optimising at some point. */
70region * 61region *
71get_region_by_map (mapstruct *m) 62get_region_by_map (maptile *m)
72{ 63{
73 return get_region_by_name (get_name_of_region_for_map (m)); 64 return get_region_by_name (get_name_of_region_for_map (m));
74} 65}
75 66
76/* 67/*
78 * explicit check that it is, this is much nicer here than scattered throughout 69 * explicit check that it is, this is much nicer here than scattered throughout
79 * the map code. 70 * the map code.
80 */ 71 */
81 72
82const char * 73const char *
83get_name_of_region_for_map (const mapstruct *m) 74get_name_of_region_for_map (const maptile *m)
84{ 75{
85 region *reg; 76 region *reg;
86 77
87 if (m->region != NULL) 78 if (m->region != NULL)
88 return m->region->name; 79 return m->region->name;
243 reg = get_region_by_map (op->map); 234 reg = get_region_by_map (op->map);
244 while (reg != NULL) 235 while (reg != NULL)
245 { 236 {
246 if (reg->jailmap) 237 if (reg->jailmap)
247 { 238 {
248 exit = get_object (); 239 exit = object::create ();
249 EXIT_PATH (exit) = reg->jailmap; 240 EXIT_PATH (exit) = reg->jailmap;
250 /* damned exits reset savebed and remove teleports, so the prisoner can't escape */ 241 /* damned exits reset savebed and remove teleports, so the prisoner can't escape */
251 SET_FLAG (exit, FLAG_DAMNED); 242 SET_FLAG (exit, FLAG_DAMNED);
252 EXIT_X (exit) = reg->jailx; 243 EXIT_X (exit) = reg->jailx;
253 EXIT_Y (exit) = reg->jaily; 244 EXIT_Y (exit) = reg->jaily;
297 */ 288 */
298 289
299region * 290region *
300get_region_struct (void) 291get_region_struct (void)
301{ 292{
302
303 region *reg;
304
305 reg = (region *) CALLOC (1, sizeof (region));
306 if (reg == NULL)
307 fatal (OUT_OF_MEMORY);
308
309 memset (reg, '\0', sizeof (region));
310
311 return reg; 293 return new region;
312} 294}
313 295
314/* 296/*
315 * Reads/parses the region file, and copies into a linked list 297 * Reads/parses the region file, and copies into a linked list
316 * of region structs. 298 * of region structs.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines