… | |
… | |
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. |
… | |
… | |
60 | return NULL; |
57 | return NULL; |
61 | } |
58 | } |
62 | |
59 | |
63 | /* This might need optimising at some point. */ |
60 | /* This might need optimising at some point. */ |
64 | region * |
61 | region * |
65 | get_region_by_map (mapstruct *m) |
62 | get_region_by_map (maptile *m) |
66 | { |
63 | { |
67 | 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)); |
68 | } |
65 | } |
69 | |
66 | |
70 | /* |
67 | /* |
… | |
… | |
72 | * 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 |
73 | * the map code. |
70 | * the map code. |
74 | */ |
71 | */ |
75 | |
72 | |
76 | const char * |
73 | const char * |
77 | get_name_of_region_for_map (const mapstruct *m) |
74 | get_name_of_region_for_map (const maptile *m) |
78 | { |
75 | { |
79 | region *reg; |
76 | region *reg; |
80 | |
77 | |
81 | if (m->region != NULL) |
78 | if (m->region != NULL) |
82 | return m->region->name; |
79 | return m->region->name; |
… | |
… | |
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 | |
293 | region * |
290 | region * |
294 | get_region_struct (void) |
291 | get_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. |