… | |
… | |
75 | { |
75 | { |
76 | region *reg; |
76 | region *reg; |
77 | |
77 | |
78 | if (m->region != NULL) |
78 | if (m->region != NULL) |
79 | return m->region->name; |
79 | return m->region->name; |
|
|
80 | |
80 | for (reg = first_region; reg != NULL; reg = reg->next) |
81 | for (reg = first_region; reg != NULL; reg = reg->next) |
81 | { |
82 | { |
82 | if (reg->fallback) |
83 | if (reg->fallback) |
83 | return reg->name; |
84 | return reg->name; |
84 | } |
85 | } |
|
|
86 | |
85 | LOG (llevInfo, "map %s had no region and I couldn't find a fallback to use.\n", m->name); |
87 | LOG (llevInfo, "map %s had no region and I couldn't find a fallback to use.\n", &m->name); |
86 | return "unknown"; |
88 | return "unknown"; |
87 | } |
89 | } |
88 | |
90 | |
89 | /* |
91 | /* |
90 | * Tries to find a region that 'name' corresponds to. |
92 | * Tries to find a region that 'name' corresponds to. |
… | |
… | |
234 | reg = get_region_by_map (op->map); |
236 | reg = get_region_by_map (op->map); |
235 | while (reg != NULL) |
237 | while (reg != NULL) |
236 | { |
238 | { |
237 | if (reg->jailmap) |
239 | if (reg->jailmap) |
238 | { |
240 | { |
239 | exit = get_object (); |
241 | exit = object::create (); |
240 | EXIT_PATH (exit) = reg->jailmap; |
242 | EXIT_PATH (exit) = reg->jailmap; |
241 | /* damned exits reset savebed and remove teleports, so the prisoner can't escape */ |
243 | /* damned exits reset savebed and remove teleports, so the prisoner can't escape */ |
242 | SET_FLAG (exit, FLAG_DAMNED); |
244 | SET_FLAG (exit, FLAG_DAMNED); |
243 | EXIT_X (exit) = reg->jailx; |
245 | EXIT_X (exit) = reg->jailx; |
244 | EXIT_Y (exit) = reg->jaily; |
246 | EXIT_Y (exit) = reg->jaily; |
… | |
… | |
288 | */ |
290 | */ |
289 | |
291 | |
290 | region * |
292 | region * |
291 | get_region_struct (void) |
293 | get_region_struct (void) |
292 | { |
294 | { |
293 | |
|
|
294 | region *reg; |
|
|
295 | |
|
|
296 | reg = (region *) CALLOC (1, sizeof (region)); |
|
|
297 | if (reg == NULL) |
|
|
298 | fatal (OUT_OF_MEMORY); |
|
|
299 | |
|
|
300 | memset (reg, '\0', sizeof (region)); |
|
|
301 | |
|
|
302 | return reg; |
295 | return new region; |
303 | } |
296 | } |
304 | |
297 | |
305 | /* |
298 | /* |
306 | * Reads/parses the region file, and copies into a linked list |
299 | * Reads/parses the region file, and copies into a linked list |
307 | * of region structs. |
300 | * of region structs. |
… | |
… | |
354 | */ |
347 | */ |
355 | if (!strcmp (key, "region")) |
348 | if (!strcmp (key, "region")) |
356 | { |
349 | { |
357 | *end = 0; |
350 | *end = 0; |
358 | newreg = get_region_struct (); |
351 | newreg = get_region_struct (); |
359 | newreg->name = strdup_local (value); |
352 | newreg->name = strdup (value); |
360 | } |
353 | } |
361 | else if (!strcmp (key, "parent")) |
354 | else if (!strcmp (key, "parent")) |
362 | { |
355 | { |
363 | /* |
356 | /* |
364 | * Note that this is in the initialisation code, so we don't actually |
357 | * Note that this is in the initialisation code, so we don't actually |
365 | * assign the pointer to the parent yet, because it might not have been |
358 | * assign the pointer to the parent yet, because it might not have been |
366 | * parsed. |
359 | * parsed. |
367 | */ |
360 | */ |
368 | *end = 0; |
361 | *end = 0; |
369 | newreg->parent_name = strdup_local (value); |
362 | newreg->parent_name = strdup (value); |
370 | } |
363 | } |
371 | else if (!strcmp (key, "longname")) |
364 | else if (!strcmp (key, "longname")) |
372 | { |
365 | { |
373 | *end = 0; |
366 | *end = 0; |
374 | newreg->longname = strdup_local (value); |
367 | newreg->longname = strdup (value); |
375 | } |
368 | } |
376 | else if (!strcmp (key, "jail")) |
369 | else if (!strcmp (key, "jail")) |
377 | { |
370 | { |
378 | /* jail entries are of the form: /path/to/map x y */ |
371 | /* jail entries are of the form: /path/to/map x y */ |
379 | char path[MAX_BUF]; |
372 | char path[MAX_BUF]; |
… | |
… | |
382 | if (sscanf (value, "%[^ ] %d %d\n", path, &x, &y) != 3) |
375 | if (sscanf (value, "%[^ ] %d %d\n", path, &x, &y) != 3) |
383 | { |
376 | { |
384 | LOG (llevError, "region.c: malformated regions entry: jail %s\n", value); |
377 | LOG (llevError, "region.c: malformated regions entry: jail %s\n", value); |
385 | continue; |
378 | continue; |
386 | } |
379 | } |
387 | newreg->jailmap = strdup_local (path); |
380 | newreg->jailmap = strdup (path); |
388 | newreg->jailx = x; |
381 | newreg->jailx = x; |
389 | newreg->jaily = y; |
382 | newreg->jaily = y; |
390 | } |
383 | } |
391 | else if (!strcmp (key, "msg")) |
384 | else if (!strcmp (key, "msg")) |
392 | { |
385 | { |
… | |
… | |
404 | * There may be regions with empty messages (eg, msg/endmsg |
397 | * There may be regions with empty messages (eg, msg/endmsg |
405 | * with nothing between). When maps are loaded, this is done |
398 | * with nothing between). When maps are loaded, this is done |
406 | * so better do it here too... |
399 | * so better do it here too... |
407 | */ |
400 | */ |
408 | if (msgpos != 0) |
401 | if (msgpos != 0) |
409 | newreg->msg = strdup_local (msgbuf); |
402 | newreg->msg = strdup (msgbuf); |
410 | |
403 | |
411 | /* we have to reset msgpos, or the next region will store both msg blocks. */ |
404 | /* we have to reset msgpos, or the next region will store both msg blocks. */ |
412 | msgpos = 0; |
405 | msgpos = 0; |
413 | } |
406 | } |
414 | else if (!strcmp (key, "fallback")) |
407 | else if (!strcmp (key, "fallback")) |