… | |
… | |
288 | */ |
288 | */ |
289 | |
289 | |
290 | region * |
290 | region * |
291 | get_region_struct (void) |
291 | get_region_struct (void) |
292 | { |
292 | { |
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; |
293 | return new region; |
303 | } |
294 | } |
304 | |
295 | |
305 | /* |
296 | /* |
306 | * Reads/parses the region file, and copies into a linked list |
297 | * Reads/parses the region file, and copies into a linked list |
307 | * of region structs. |
298 | * of region structs. |
… | |
… | |
354 | */ |
345 | */ |
355 | if (!strcmp (key, "region")) |
346 | if (!strcmp (key, "region")) |
356 | { |
347 | { |
357 | *end = 0; |
348 | *end = 0; |
358 | newreg = get_region_struct (); |
349 | newreg = get_region_struct (); |
359 | newreg->name = strdup_local (value); |
350 | newreg->name = strdup (value); |
360 | } |
351 | } |
361 | else if (!strcmp (key, "parent")) |
352 | else if (!strcmp (key, "parent")) |
362 | { |
353 | { |
363 | /* |
354 | /* |
364 | * 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 |
365 | * 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 |
366 | * parsed. |
357 | * parsed. |
367 | */ |
358 | */ |
368 | *end = 0; |
359 | *end = 0; |
369 | newreg->parent_name = strdup_local (value); |
360 | newreg->parent_name = strdup (value); |
370 | } |
361 | } |
371 | else if (!strcmp (key, "longname")) |
362 | else if (!strcmp (key, "longname")) |
372 | { |
363 | { |
373 | *end = 0; |
364 | *end = 0; |
374 | newreg->longname = strdup_local (value); |
365 | newreg->longname = strdup (value); |
375 | } |
366 | } |
376 | else if (!strcmp (key, "jail")) |
367 | else if (!strcmp (key, "jail")) |
377 | { |
368 | { |
378 | /* jail entries are of the form: /path/to/map x y */ |
369 | /* jail entries are of the form: /path/to/map x y */ |
379 | char path[MAX_BUF]; |
370 | char path[MAX_BUF]; |
… | |
… | |
382 | if (sscanf (value, "%[^ ] %d %d\n", path, &x, &y) != 3) |
373 | if (sscanf (value, "%[^ ] %d %d\n", path, &x, &y) != 3) |
383 | { |
374 | { |
384 | LOG (llevError, "region.c: malformated regions entry: jail %s\n", value); |
375 | LOG (llevError, "region.c: malformated regions entry: jail %s\n", value); |
385 | continue; |
376 | continue; |
386 | } |
377 | } |
387 | newreg->jailmap = strdup_local (path); |
378 | newreg->jailmap = strdup (path); |
388 | newreg->jailx = x; |
379 | newreg->jailx = x; |
389 | newreg->jaily = y; |
380 | newreg->jaily = y; |
390 | } |
381 | } |
391 | else if (!strcmp (key, "msg")) |
382 | else if (!strcmp (key, "msg")) |
392 | { |
383 | { |
… | |
… | |
404 | * There may be regions with empty messages (eg, msg/endmsg |
395 | * There may be regions with empty messages (eg, msg/endmsg |
405 | * with nothing between). When maps are loaded, this is done |
396 | * with nothing between). When maps are loaded, this is done |
406 | * so better do it here too... |
397 | * so better do it here too... |
407 | */ |
398 | */ |
408 | if (msgpos != 0) |
399 | if (msgpos != 0) |
409 | newreg->msg = strdup_local (msgbuf); |
400 | newreg->msg = strdup (msgbuf); |
410 | |
401 | |
411 | /* 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. */ |
412 | msgpos = 0; |
403 | msgpos = 0; |
413 | } |
404 | } |
414 | else if (!strcmp (key, "fallback")) |
405 | else if (!strcmp (key, "fallback")) |