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.7 by root, Sat Sep 16 22:24:12 2006 UTC vs.
Revision 1.11 by root, Thu Dec 14 22:45:40 2006 UTC

21 The authors can be reached via e-mail at <crossfire@schmorp.de> 21 The authors can be reached via e-mail at <crossfire@schmorp.de>
22*/ 22*/
23 23
24 24
25#include <global.h> 25#include <global.h>
26
27#ifndef WIN32 /* ---win32 exclude header */
28# include <unistd.h> 26#include <unistd.h>
29#endif /* win32 */
30 27
31/* 28/*
32 * 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.
33 * 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
34 * with the 'fallback' property set. 31 * with the 'fallback' property set.
237 reg = get_region_by_map (op->map); 234 reg = get_region_by_map (op->map);
238 while (reg != NULL) 235 while (reg != NULL)
239 { 236 {
240 if (reg->jailmap) 237 if (reg->jailmap)
241 { 238 {
242 exit = get_object (); 239 exit = object::create ();
243 EXIT_PATH (exit) = reg->jailmap; 240 EXIT_PATH (exit) = reg->jailmap;
244 /* 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 */
245 SET_FLAG (exit, FLAG_DAMNED); 242 SET_FLAG (exit, FLAG_DAMNED);
246 EXIT_X (exit) = reg->jailx; 243 EXIT_X (exit) = reg->jailx;
247 EXIT_Y (exit) = reg->jaily; 244 EXIT_Y (exit) = reg->jaily;
291 */ 288 */
292 289
293region * 290region *
294get_region_struct (void) 291get_region_struct (void)
295{ 292{
296
297 region *reg;
298
299 reg = (region *) CALLOC (1, sizeof (region));
300 if (reg == NULL)
301 fatal (OUT_OF_MEMORY);
302
303 memset (reg, '\0', sizeof (region));
304
305 return reg; 293 return new region;
306} 294}
307 295
308/* 296/*
309 * Reads/parses the region file, and copies into a linked list 297 * Reads/parses the region file, and copies into a linked list
310 * of region structs. 298 * of region structs.
357 */ 345 */
358 if (!strcmp (key, "region")) 346 if (!strcmp (key, "region"))
359 { 347 {
360 *end = 0; 348 *end = 0;
361 newreg = get_region_struct (); 349 newreg = get_region_struct ();
362 newreg->name = strdup_local (value); 350 newreg->name = strdup (value);
363 } 351 }
364 else if (!strcmp (key, "parent")) 352 else if (!strcmp (key, "parent"))
365 { 353 {
366 /* 354 /*
367 * Note that this is in the initialisation code, so we don't actually 355 * Note that this is in the initialisation code, so we don't actually
368 * assign the pointer to the parent yet, because it might not have been 356 * assign the pointer to the parent yet, because it might not have been
369 * parsed. 357 * parsed.
370 */ 358 */
371 *end = 0; 359 *end = 0;
372 newreg->parent_name = strdup_local (value); 360 newreg->parent_name = strdup (value);
373 } 361 }
374 else if (!strcmp (key, "longname")) 362 else if (!strcmp (key, "longname"))
375 { 363 {
376 *end = 0; 364 *end = 0;
377 newreg->longname = strdup_local (value); 365 newreg->longname = strdup (value);
378 } 366 }
379 else if (!strcmp (key, "jail")) 367 else if (!strcmp (key, "jail"))
380 { 368 {
381 /* jail entries are of the form: /path/to/map x y */ 369 /* jail entries are of the form: /path/to/map x y */
382 char path[MAX_BUF]; 370 char path[MAX_BUF];
385 if (sscanf (value, "%[^ ] %d %d\n", path, &x, &y) != 3) 373 if (sscanf (value, "%[^ ] %d %d\n", path, &x, &y) != 3)
386 { 374 {
387 LOG (llevError, "region.c: malformated regions entry: jail %s\n", value); 375 LOG (llevError, "region.c: malformated regions entry: jail %s\n", value);
388 continue; 376 continue;
389 } 377 }
390 newreg->jailmap = strdup_local (path); 378 newreg->jailmap = strdup (path);
391 newreg->jailx = x; 379 newreg->jailx = x;
392 newreg->jaily = y; 380 newreg->jaily = y;
393 } 381 }
394 else if (!strcmp (key, "msg")) 382 else if (!strcmp (key, "msg"))
395 { 383 {
407 * There may be regions with empty messages (eg, msg/endmsg 395 * There may be regions with empty messages (eg, msg/endmsg
408 * with nothing between). When maps are loaded, this is done 396 * with nothing between). When maps are loaded, this is done
409 * so better do it here too... 397 * so better do it here too...
410 */ 398 */
411 if (msgpos != 0) 399 if (msgpos != 0)
412 newreg->msg = strdup_local (msgbuf); 400 newreg->msg = strdup (msgbuf);
413 401
414 /* we have to reset msgpos, or the next region will store both msg blocks. */ 402 /* we have to reset msgpos, or the next region will store both msg blocks. */
415 msgpos = 0; 403 msgpos = 0;
416 } 404 }
417 else if (!strcmp (key, "fallback")) 405 else if (!strcmp (key, "fallback"))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines