… | |
… | |
34 | |
34 | |
35 | |
35 | |
36 | extern int nrofallocobjects, nroffreeobjects; |
36 | extern int nrofallocobjects, nroffreeobjects; |
37 | |
37 | |
38 | /* |
38 | /* |
39 | * Returns the mapstruct which has a name matching the given argument. |
39 | * Returns the maptile which has a name matching the given argument. |
40 | * return NULL if no match is found. |
40 | * return NULL if no match is found. |
41 | */ |
41 | */ |
42 | |
42 | |
43 | mapstruct * |
43 | maptile * |
44 | has_been_loaded (const char *name) |
44 | has_been_loaded (const char *name) |
45 | { |
45 | { |
46 | mapstruct *map; |
46 | maptile *map; |
47 | |
47 | |
48 | if (!name || !*name) |
48 | if (!name || !*name) |
49 | return 0; |
49 | return 0; |
50 | for (map = first_map; map; map = map->next) |
50 | for (map = first_map; map; map = map->next) |
51 | if (!strcmp (name, map->path)) |
51 | if (!strcmp (name, map->path)) |
… | |
… | |
204 | * Dumping these at llevError doesn't seem right, but is |
204 | * Dumping these at llevError doesn't seem right, but is |
205 | * necessary to make sure the information is in fact logged. |
205 | * necessary to make sure the information is in fact logged. |
206 | */ |
206 | */ |
207 | |
207 | |
208 | void |
208 | void |
209 | dump_map (const mapstruct *m) |
209 | dump_map (const maptile *m) |
210 | { |
210 | { |
211 | LOG (llevError, "Map %s status: %d.\n", m->path, m->in_memory); |
211 | LOG (llevError, "Map %s status: %d.\n", m->path, m->in_memory); |
212 | LOG (llevError, "Size: %dx%d Start: %d,%d\n", MAP_WIDTH (m), MAP_HEIGHT (m), MAP_ENTER_X (m), MAP_ENTER_Y (m)); |
212 | LOG (llevError, "Size: %dx%d Start: %d,%d\n", MAP_WIDTH (m), MAP_HEIGHT (m), MAP_ENTER_X (m), MAP_ENTER_Y (m)); |
213 | |
213 | |
214 | if (m->msg != NULL) |
214 | if (m->msg != NULL) |
… | |
… | |
231 | */ |
231 | */ |
232 | |
232 | |
233 | void |
233 | void |
234 | dump_all_maps (void) |
234 | dump_all_maps (void) |
235 | { |
235 | { |
236 | mapstruct *m; |
236 | maptile *m; |
237 | |
237 | |
238 | for (m = first_map; m != NULL; m = m->next) |
238 | for (m = first_map; m != NULL; m = m->next) |
239 | { |
239 | { |
240 | dump_map (m); |
240 | dump_map (m); |
241 | } |
241 | } |
… | |
… | |
250 | * is needed. The case of not passing values is if we're just |
250 | * is needed. The case of not passing values is if we're just |
251 | * checking for the existence of something on those spaces, but |
251 | * checking for the existence of something on those spaces, but |
252 | * don't expect to insert/remove anything from those spaces. |
252 | * don't expect to insert/remove anything from those spaces. |
253 | */ |
253 | */ |
254 | int |
254 | int |
255 | get_map_flags (mapstruct *oldmap, mapstruct **newmap, sint16 x, sint16 y, sint16 * nx, sint16 * ny) |
255 | get_map_flags (maptile *oldmap, maptile **newmap, sint16 x, sint16 y, sint16 * nx, sint16 * ny) |
256 | { |
256 | { |
257 | sint16 newx, newy; |
257 | sint16 newx, newy; |
258 | int retval = 0; |
258 | int retval = 0; |
259 | mapstruct *mp; |
259 | maptile *mp; |
260 | |
260 | |
261 | if (out_of_map (oldmap, x, y)) |
261 | if (out_of_map (oldmap, x, y)) |
262 | return P_OUT_OF_MAP; |
262 | return P_OUT_OF_MAP; |
263 | newx = x; |
263 | newx = x; |
264 | newy = y; |
264 | newy = y; |
… | |
… | |
290 | * the coordinates & map passed in should have been updated for tiling |
290 | * the coordinates & map passed in should have been updated for tiling |
291 | * by the caller. |
291 | * by the caller. |
292 | */ |
292 | */ |
293 | |
293 | |
294 | int |
294 | int |
295 | blocked_link (object *ob, mapstruct *m, int sx, int sy) |
295 | blocked_link (object *ob, maptile *m, int sx, int sy) |
296 | { |
296 | { |
297 | object *tmp; |
297 | object *tmp; |
298 | int mflags, blocked; |
298 | int mflags, blocked; |
299 | |
299 | |
300 | /* Make sure the coordinates are valid - they should be, as caller should |
300 | /* Make sure the coordinates are valid - they should be, as caller should |
… | |
… | |
412 | * code, we need to have actual object to check its move_type |
412 | * code, we need to have actual object to check its move_type |
413 | * against the move_block values. |
413 | * against the move_block values. |
414 | */ |
414 | */ |
415 | |
415 | |
416 | int |
416 | int |
417 | ob_blocked (const object *ob, mapstruct *m, sint16 x, sint16 y) |
417 | ob_blocked (const object *ob, maptile *m, sint16 x, sint16 y) |
418 | { |
418 | { |
419 | archetype *tmp; |
419 | archetype *tmp; |
420 | int flag; |
420 | int flag; |
421 | mapstruct *m1; |
421 | maptile *m1; |
422 | sint16 sx, sy; |
422 | sint16 sx, sy; |
423 | |
423 | |
424 | if (ob == NULL) |
424 | if (ob == NULL) |
425 | { |
425 | { |
426 | flag = get_map_flags (m, &m1, x, y, &sx, &sy); |
426 | flag = get_map_flags (m, &m1, x, y, &sx, &sy); |
… | |
… | |
491 | * they are saved). We do have to look for the old maps that did save |
491 | * they are saved). We do have to look for the old maps that did save |
492 | * the more sections and not re-add sections for them. |
492 | * the more sections and not re-add sections for them. |
493 | */ |
493 | */ |
494 | |
494 | |
495 | static void |
495 | static void |
496 | link_multipart_objects (mapstruct *m) |
496 | link_multipart_objects (maptile *m) |
497 | { |
497 | { |
498 | int x, y; |
498 | int x, y; |
499 | object *tmp, *op, *last, *above; |
499 | object *tmp, *op, *last, *above; |
500 | archetype *at; |
500 | archetype *at; |
501 | |
501 | |
… | |
… | |
538 | * Loads (ands parses) the objects into a given map from the specified |
538 | * Loads (ands parses) the objects into a given map from the specified |
539 | * file pointer. |
539 | * file pointer. |
540 | * mapflags is the same as we get with load_original_map |
540 | * mapflags is the same as we get with load_original_map |
541 | */ |
541 | */ |
542 | void |
542 | void |
543 | load_objects (mapstruct *m, object_thawer & fp, int mapflags) |
543 | load_objects (maptile *m, object_thawer & fp, int mapflags) |
544 | { |
544 | { |
545 | int i, j; |
545 | int i, j; |
546 | int unique; |
546 | int unique; |
547 | object *op, *prev = NULL, *last_more = NULL, *otmp; |
547 | object *op, *prev = NULL, *last_more = NULL, *otmp; |
548 | |
548 | |
… | |
… | |
614 | * Modified by MSW 2001-07-01 to do in a single pass - reduces code, |
614 | * Modified by MSW 2001-07-01 to do in a single pass - reduces code, |
615 | * and we only save the head of multi part objects - this is needed |
615 | * and we only save the head of multi part objects - this is needed |
616 | * in order to do map tiling properly. |
616 | * in order to do map tiling properly. |
617 | */ |
617 | */ |
618 | void |
618 | void |
619 | save_objects (mapstruct *m, object_freezer & fp, object_freezer & fp2, int flag) |
619 | save_objects (maptile *m, object_freezer & fp, object_freezer & fp2, int flag) |
620 | { |
620 | { |
621 | int i, j = 0, unique = 0; |
621 | int i, j = 0, unique = 0; |
622 | object *op; |
622 | object *op; |
623 | |
623 | |
624 | /* first pass - save one-part objects */ |
624 | /* first pass - save one-part objects */ |
… | |
… | |
648 | } /* for this space */ |
648 | } /* for this space */ |
649 | } /* for this j */ |
649 | } /* for this j */ |
650 | } |
650 | } |
651 | |
651 | |
652 | /* |
652 | /* |
653 | * Allocates, initialises, and returns a pointer to a mapstruct. |
653 | * Allocates, initialises, and returns a pointer to a maptile. |
654 | * Modified to no longer take a path option which was not being |
654 | * Modified to no longer take a path option which was not being |
655 | * used anyways. MSW 2001-07-01 |
655 | * used anyways. MSW 2001-07-01 |
656 | */ |
656 | */ |
657 | |
657 | |
658 | mapstruct * |
658 | maptile * |
659 | get_linked_map (void) |
659 | get_linked_map (void) |
660 | { |
660 | { |
661 | mapstruct *map = new mapstruct; |
661 | maptile *map = new maptile; |
662 | mapstruct *mp; |
662 | maptile *mp; |
663 | |
663 | |
664 | for (mp = first_map; mp != NULL && mp->next != NULL; mp = mp->next); |
664 | for (mp = first_map; mp != NULL && mp->next != NULL; mp = mp->next); |
665 | if (mp == NULL) |
665 | if (mp == NULL) |
666 | first_map = map; |
666 | first_map = map; |
667 | else |
667 | else |
… | |
… | |
682 | MAP_WORLDPARTY (map) = -1; |
682 | MAP_WORLDPARTY (map) = -1; |
683 | return map; |
683 | return map; |
684 | } |
684 | } |
685 | |
685 | |
686 | /* |
686 | /* |
687 | * Allocates the arrays contained in a mapstruct. |
687 | * Allocates the arrays contained in a maptile. |
688 | * This basically allocates the dynamic array of spaces for the |
688 | * This basically allocates the dynamic array of spaces for the |
689 | * map. |
689 | * map. |
690 | */ |
690 | */ |
691 | |
691 | |
692 | void |
692 | void |
693 | allocate_map (mapstruct *m) |
693 | allocate_map (maptile *m) |
694 | { |
694 | { |
695 | m->in_memory = MAP_IN_MEMORY; |
695 | m->in_memory = MAP_IN_MEMORY; |
696 | /* Log this condition and free the storage. We could I suppose |
696 | /* Log this condition and free the storage. We could I suppose |
697 | * realloc, but if the caller is presuming the data will be intact, |
697 | * realloc, but if the caller is presuming the data will be intact, |
698 | * that is their poor assumption. |
698 | * that is their poor assumption. |
… | |
… | |
710 | } |
710 | } |
711 | |
711 | |
712 | /* Create and returns a map of the specific size. Used |
712 | /* Create and returns a map of the specific size. Used |
713 | * in random map code and the editor. |
713 | * in random map code and the editor. |
714 | */ |
714 | */ |
715 | mapstruct * |
715 | maptile * |
716 | get_empty_map (int sizex, int sizey) |
716 | get_empty_map (int sizex, int sizey) |
717 | { |
717 | { |
718 | mapstruct *m = get_linked_map (); |
718 | maptile *m = get_linked_map (); |
719 | |
719 | |
720 | m->width = sizex; |
720 | m->width = sizex; |
721 | m->height = sizey; |
721 | m->height = sizey; |
722 | m->in_memory = MAP_SWAPPED; |
722 | m->in_memory = MAP_SWAPPED; |
723 | allocate_map (m); |
723 | allocate_map (m); |
… | |
… | |
805 | } |
805 | } |
806 | |
806 | |
807 | /* opposite of parse string, this puts the string that was originally fed in to |
807 | /* opposite of parse string, this puts the string that was originally fed in to |
808 | * the map (or something equivilent) into output_string. */ |
808 | * the map (or something equivilent) into output_string. */ |
809 | static void |
809 | static void |
810 | print_shop_string (mapstruct *m, char *output_string) |
810 | print_shop_string (maptile *m, char *output_string) |
811 | { |
811 | { |
812 | int i; |
812 | int i; |
813 | char tmp[MAX_BUF]; |
813 | char tmp[MAX_BUF]; |
814 | |
814 | |
815 | strcpy (output_string, ""); |
815 | strcpy (output_string, ""); |
… | |
… | |
849 | * MSW 2001-07-01 |
849 | * MSW 2001-07-01 |
850 | * return 0 on success, 1 on failure. |
850 | * return 0 on success, 1 on failure. |
851 | */ |
851 | */ |
852 | |
852 | |
853 | static int |
853 | static int |
854 | load_map_header (object_thawer & fp, mapstruct *m) |
854 | load_map_header (object_thawer & fp, maptile *m) |
855 | { |
855 | { |
856 | char buf[HUGE_BUF], msgbuf[HUGE_BUF], maplorebuf[HUGE_BUF], *key = NULL, *value, *end; |
856 | char buf[HUGE_BUF], msgbuf[HUGE_BUF], maplorebuf[HUGE_BUF], *key = NULL, *value, *end; |
857 | int msgpos = 0; |
857 | int msgpos = 0; |
858 | int maplorepos = 0; |
858 | int maplorepos = 0; |
859 | |
859 | |
… | |
… | |
1147 | } |
1147 | } |
1148 | |
1148 | |
1149 | /* |
1149 | /* |
1150 | * Opens the file "filename" and reads information about the map |
1150 | * Opens the file "filename" and reads information about the map |
1151 | * from the given file, and stores it in a newly allocated |
1151 | * from the given file, and stores it in a newly allocated |
1152 | * mapstruct. A pointer to this structure is returned, or NULL on failure. |
1152 | * maptile. A pointer to this structure is returned, or NULL on failure. |
1153 | * flags correspond to those in map.h. Main ones used are |
1153 | * flags correspond to those in map.h. Main ones used are |
1154 | * MAP_PLAYER_UNIQUE, in which case we don't do any name changes, and |
1154 | * MAP_PLAYER_UNIQUE, in which case we don't do any name changes, and |
1155 | * MAP_BLOCK, in which case we block on this load. This happens in all |
1155 | * MAP_BLOCK, in which case we block on this load. This happens in all |
1156 | * cases, no matter if this flag is set or not. |
1156 | * cases, no matter if this flag is set or not. |
1157 | * MAP_STYLE: style map - don't add active objects, don't add to server |
1157 | * MAP_STYLE: style map - don't add active objects, don't add to server |
1158 | * managed map list. |
1158 | * managed map list. |
1159 | */ |
1159 | */ |
1160 | |
1160 | |
1161 | mapstruct * |
1161 | maptile * |
1162 | load_original_map (const char *filename, int flags) |
1162 | load_original_map (const char *filename, int flags) |
1163 | { |
1163 | { |
1164 | mapstruct *m; |
1164 | maptile *m; |
1165 | char pathname[MAX_BUF]; |
1165 | char pathname[MAX_BUF]; |
1166 | |
1166 | |
1167 | if (flags & MAP_PLAYER_UNIQUE) |
1167 | if (flags & MAP_PLAYER_UNIQUE) |
1168 | strcpy (pathname, filename); |
1168 | strcpy (pathname, filename); |
1169 | else if (flags & MAP_OVERLAY) |
1169 | else if (flags & MAP_OVERLAY) |
… | |
… | |
1205 | * Loads a map, which has been loaded earlier, from file. |
1205 | * Loads a map, which has been loaded earlier, from file. |
1206 | * Return the map object we load into (this can change from the passed |
1206 | * Return the map object we load into (this can change from the passed |
1207 | * option if we can't find the original map) |
1207 | * option if we can't find the original map) |
1208 | */ |
1208 | */ |
1209 | |
1209 | |
1210 | static mapstruct * |
1210 | static maptile * |
1211 | load_temporary_map (mapstruct *m) |
1211 | load_temporary_map (maptile *m) |
1212 | { |
1212 | { |
1213 | char buf[MAX_BUF]; |
1213 | char buf[MAX_BUF]; |
1214 | |
1214 | |
1215 | if (!m->tmpname) |
1215 | if (!m->tmpname) |
1216 | { |
1216 | { |
… | |
… | |
1258 | * Loads a map, which has been loaded earlier, from file. |
1258 | * Loads a map, which has been loaded earlier, from file. |
1259 | * Return the map object we load into (this can change from the passed |
1259 | * Return the map object we load into (this can change from the passed |
1260 | * option if we can't find the original map) |
1260 | * option if we can't find the original map) |
1261 | */ |
1261 | */ |
1262 | |
1262 | |
1263 | mapstruct * |
1263 | maptile * |
1264 | load_overlay_map (const char *filename, mapstruct *m) |
1264 | load_overlay_map (const char *filename, maptile *m) |
1265 | { |
1265 | { |
1266 | char pathname[MAX_BUF]; |
1266 | char pathname[MAX_BUF]; |
1267 | |
1267 | |
1268 | strcpy (pathname, create_overlay_pathname (filename)); |
1268 | strcpy (pathname, create_overlay_pathname (filename)); |
1269 | |
1269 | |
… | |
… | |
1292 | * This is the start of unique map handling code |
1292 | * This is the start of unique map handling code |
1293 | *****************************************************************************/ |
1293 | *****************************************************************************/ |
1294 | |
1294 | |
1295 | /* This goes through map 'm' and removed any unique items on the map. */ |
1295 | /* This goes through map 'm' and removed any unique items on the map. */ |
1296 | static void |
1296 | static void |
1297 | delete_unique_items (mapstruct *m) |
1297 | delete_unique_items (maptile *m) |
1298 | { |
1298 | { |
1299 | int i, j, unique; |
1299 | int i, j, unique; |
1300 | object *op, *next; |
1300 | object *op, *next; |
1301 | |
1301 | |
1302 | for (i = 0; i < MAP_WIDTH (m); i++) |
1302 | for (i = 0; i < MAP_WIDTH (m); i++) |
… | |
… | |
1324 | /* |
1324 | /* |
1325 | * Loads unique objects from file(s) into the map which is in memory |
1325 | * Loads unique objects from file(s) into the map which is in memory |
1326 | * m is the map to load unique items into. |
1326 | * m is the map to load unique items into. |
1327 | */ |
1327 | */ |
1328 | static void |
1328 | static void |
1329 | load_unique_objects (mapstruct *m) |
1329 | load_unique_objects (maptile *m) |
1330 | { |
1330 | { |
1331 | int count; |
1331 | int count; |
1332 | char firstname[MAX_BUF]; |
1332 | char firstname[MAX_BUF]; |
1333 | |
1333 | |
1334 | for (count = 0; count < 10; count++) |
1334 | for (count = 0; count < 10; count++) |
… | |
… | |
1357 | |
1357 | |
1358 | /* |
1358 | /* |
1359 | * Saves a map to file. If flag is set, it is saved into the same |
1359 | * Saves a map to file. If flag is set, it is saved into the same |
1360 | * file it was (originally) loaded from. Otherwise a temporary |
1360 | * file it was (originally) loaded from. Otherwise a temporary |
1361 | * filename will be genarated, and the file will be stored there. |
1361 | * filename will be genarated, and the file will be stored there. |
1362 | * The temporary filename will be stored in the mapstructure. |
1362 | * The temporary filename will be stored in the maptileure. |
1363 | * If the map is unique, we also save to the filename in the map |
1363 | * If the map is unique, we also save to the filename in the map |
1364 | * (this should have been updated when first loaded) |
1364 | * (this should have been updated when first loaded) |
1365 | */ |
1365 | */ |
1366 | |
1366 | |
1367 | int |
1367 | int |
1368 | new_save_map (mapstruct *m, int flag) |
1368 | new_save_map (maptile *m, int flag) |
1369 | { |
1369 | { |
1370 | char filename[MAX_BUF], buf[MAX_BUF], shop[MAX_BUF]; |
1370 | char filename[MAX_BUF], buf[MAX_BUF], shop[MAX_BUF]; |
1371 | int i; |
1371 | int i; |
1372 | |
1372 | |
1373 | if (flag && !*m->path) |
1373 | if (flag && !*m->path) |
… | |
… | |
1537 | /* |
1537 | /* |
1538 | * Remove and free all objects in the given map. |
1538 | * Remove and free all objects in the given map. |
1539 | */ |
1539 | */ |
1540 | |
1540 | |
1541 | void |
1541 | void |
1542 | free_all_objects (mapstruct *m) |
1542 | free_all_objects (maptile *m) |
1543 | { |
1543 | { |
1544 | int i, j; |
1544 | int i, j; |
1545 | object *op; |
1545 | object *op; |
1546 | |
1546 | |
1547 | for (i = 0; i < MAP_WIDTH (m); i++) |
1547 | for (i = 0; i < MAP_WIDTH (m); i++) |
… | |
… | |
1570 | } |
1570 | } |
1571 | } |
1571 | } |
1572 | } |
1572 | } |
1573 | |
1573 | |
1574 | /* |
1574 | /* |
1575 | * Frees everything allocated by the given mapstructure. |
1575 | * Frees everything allocated by the given maptileure. |
1576 | * don't free tmpname - our caller is left to do that |
1576 | * don't free tmpname - our caller is left to do that |
1577 | */ |
1577 | */ |
1578 | |
1578 | |
1579 | void |
1579 | void |
1580 | free_map (mapstruct *m, int flag) |
1580 | free_map (maptile *m, int flag) |
1581 | { |
1581 | { |
1582 | int i; |
1582 | int i; |
1583 | |
1583 | |
1584 | if (!m->in_memory) |
1584 | if (!m->in_memory) |
1585 | { |
1585 | { |
… | |
… | |
1612 | } |
1612 | } |
1613 | m->in_memory = MAP_SWAPPED; |
1613 | m->in_memory = MAP_SWAPPED; |
1614 | } |
1614 | } |
1615 | |
1615 | |
1616 | /* |
1616 | /* |
1617 | * function: vanish mapstruct |
1617 | * function: vanish maptile |
1618 | * m : pointer to mapstruct, if NULL no action |
1618 | * m : pointer to maptile, if NULL no action |
1619 | * this deletes all the data on the map (freeing pointers) |
1619 | * this deletes all the data on the map (freeing pointers) |
1620 | * and then removes this map from the global linked list of maps. |
1620 | * and then removes this map from the global linked list of maps. |
1621 | */ |
1621 | */ |
1622 | |
1622 | |
1623 | void |
1623 | void |
1624 | delete_map (mapstruct *m) |
1624 | delete_map (maptile *m) |
1625 | { |
1625 | { |
1626 | mapstruct *tmp, *last; |
1626 | maptile *tmp, *last; |
1627 | int i; |
1627 | int i; |
1628 | |
1628 | |
1629 | if (!m) |
1629 | if (!m) |
1630 | return; |
1630 | return; |
1631 | |
1631 | |
… | |
… | |
1693 | * dont do any more name translation on it. |
1693 | * dont do any more name translation on it. |
1694 | * |
1694 | * |
1695 | * Returns a pointer to the given map. |
1695 | * Returns a pointer to the given map. |
1696 | */ |
1696 | */ |
1697 | |
1697 | |
1698 | mapstruct * |
1698 | maptile * |
1699 | ready_map_name (const char *name, int flags) |
1699 | ready_map_name (const char *name, int flags) |
1700 | { |
1700 | { |
1701 | mapstruct *m; |
1701 | maptile *m; |
1702 | |
1702 | |
1703 | if (!name) |
1703 | if (!name) |
1704 | return (NULL); |
1704 | return (NULL); |
1705 | |
1705 | |
1706 | /* Have we been at this level before? */ |
1706 | /* Have we been at this level before? */ |
… | |
… | |
1808 | * have a difficulty set than using this function - human calculation |
1808 | * have a difficulty set than using this function - human calculation |
1809 | * is much better than this functions guesswork. |
1809 | * is much better than this functions guesswork. |
1810 | */ |
1810 | */ |
1811 | |
1811 | |
1812 | int |
1812 | int |
1813 | calculate_difficulty (mapstruct *m) |
1813 | calculate_difficulty (maptile *m) |
1814 | { |
1814 | { |
1815 | object *op; |
1815 | object *op; |
1816 | archetype *at; |
1816 | archetype *at; |
1817 | int x, y, i; |
1817 | int x, y, i; |
1818 | long monster_cnt = 0; |
1818 | long monster_cnt = 0; |
… | |
… | |
1860 | |
1860 | |
1861 | return 1; |
1861 | return 1; |
1862 | } |
1862 | } |
1863 | |
1863 | |
1864 | void |
1864 | void |
1865 | clean_tmp_map (mapstruct *m) |
1865 | clean_tmp_map (maptile *m) |
1866 | { |
1866 | { |
1867 | if (m->tmpname == NULL) |
1867 | if (m->tmpname == NULL) |
1868 | return; |
1868 | return; |
1869 | INVOKE_MAP (CLEAN, m); |
1869 | INVOKE_MAP (CLEAN, m); |
1870 | (void) unlink (m->tmpname); |
1870 | (void) unlink (m->tmpname); |
… | |
… | |
1895 | * to maps than los. |
1895 | * to maps than los. |
1896 | * postive values make it darker, negative make it brighter |
1896 | * postive values make it darker, negative make it brighter |
1897 | */ |
1897 | */ |
1898 | |
1898 | |
1899 | int |
1899 | int |
1900 | change_map_light (mapstruct *m, int change) |
1900 | change_map_light (maptile *m, int change) |
1901 | { |
1901 | { |
1902 | int new_level = m->darkness + change; |
1902 | int new_level = m->darkness + change; |
1903 | |
1903 | |
1904 | /* Nothing to do */ |
1904 | /* Nothing to do */ |
1905 | if (!change || (new_level <= 0 && m->darkness == 0) || (new_level >= MAX_DARKNESS && m->darkness >= MAX_DARKNESS)) |
1905 | if (!change || (new_level <= 0 && m->darkness == 0) || (new_level >= MAX_DARKNESS && m->darkness >= MAX_DARKNESS)) |
… | |
… | |
1936 | * on the map (what it looks like, whether it blocks magic, |
1936 | * on the map (what it looks like, whether it blocks magic, |
1937 | * has a living creatures, prevents people from passing |
1937 | * has a living creatures, prevents people from passing |
1938 | * through, etc) |
1938 | * through, etc) |
1939 | */ |
1939 | */ |
1940 | void |
1940 | void |
1941 | update_position (mapstruct *m, int x, int y) |
1941 | update_position (maptile *m, int x, int y) |
1942 | { |
1942 | { |
1943 | object *tmp, *last = NULL; |
1943 | object *tmp, *last = NULL; |
1944 | uint8 flags = 0, oldflags, light = 0, anywhere = 0; |
1944 | uint8 flags = 0, oldflags, light = 0, anywhere = 0; |
1945 | New_Face *top, *floor, *middle; |
1945 | New_Face *top, *floor, *middle; |
1946 | object *top_obj, *floor_obj, *middle_obj; |
1946 | object *top_obj, *floor_obj, *middle_obj; |
… | |
… | |
2139 | SET_MAP_LIGHT (m, x, y, light); |
2139 | SET_MAP_LIGHT (m, x, y, light); |
2140 | } |
2140 | } |
2141 | |
2141 | |
2142 | |
2142 | |
2143 | void |
2143 | void |
2144 | set_map_reset_time (mapstruct *map) |
2144 | set_map_reset_time (maptile *map) |
2145 | { |
2145 | { |
2146 | int timeout; |
2146 | int timeout; |
2147 | |
2147 | |
2148 | timeout = MAP_RESET_TIMEOUT (map); |
2148 | timeout = MAP_RESET_TIMEOUT (map); |
2149 | if (timeout <= 0) |
2149 | if (timeout <= 0) |
… | |
… | |
2158 | * maps tile_map values if it tiles back to this one. It returns |
2158 | * maps tile_map values if it tiles back to this one. It returns |
2159 | * the value of orig_map->tile_map[tile_num]. It really only does this |
2159 | * the value of orig_map->tile_map[tile_num]. It really only does this |
2160 | * so that it is easier for calling functions to verify success. |
2160 | * so that it is easier for calling functions to verify success. |
2161 | */ |
2161 | */ |
2162 | |
2162 | |
2163 | static mapstruct * |
2163 | static maptile * |
2164 | load_and_link_tiled_map (mapstruct *orig_map, int tile_num) |
2164 | load_and_link_tiled_map (maptile *orig_map, int tile_num) |
2165 | { |
2165 | { |
2166 | int dest_tile = (tile_num + 2) % 4; |
2166 | int dest_tile = (tile_num + 2) % 4; |
2167 | char *path = path_combine_and_normalize (orig_map->path, orig_map->tile_path[tile_num]); |
2167 | char *path = path_combine_and_normalize (orig_map->path, orig_map->tile_path[tile_num]); |
2168 | |
2168 | |
2169 | orig_map->tile_map[tile_num] = ready_map_name (path, 0); |
2169 | orig_map->tile_map[tile_num] = ready_map_name (path, 0); |
… | |
… | |
2184 | * tiled maps. |
2184 | * tiled maps. |
2185 | * |
2185 | * |
2186 | * |
2186 | * |
2187 | */ |
2187 | */ |
2188 | int |
2188 | int |
2189 | out_of_map (mapstruct *m, int x, int y) |
2189 | out_of_map (maptile *m, int x, int y) |
2190 | { |
2190 | { |
2191 | |
2191 | |
2192 | /* If we get passed a null map, this is obviously the |
2192 | /* If we get passed a null map, this is obviously the |
2193 | * case. This generally shouldn't happen, but if the |
2193 | * case. This generally shouldn't happen, but if the |
2194 | * map loads fail below, it could happen. |
2194 | * map loads fail below, it could happen. |
… | |
… | |
2249 | * the map as that the coordinates are really on, and |
2249 | * the map as that the coordinates are really on, and |
2250 | * updates x and y to be the localized coordinates. |
2250 | * updates x and y to be the localized coordinates. |
2251 | * Using this is more efficient of calling out_of_map |
2251 | * Using this is more efficient of calling out_of_map |
2252 | * and then figuring out what the real map is |
2252 | * and then figuring out what the real map is |
2253 | */ |
2253 | */ |
2254 | mapstruct * |
2254 | maptile * |
2255 | get_map_from_coord (mapstruct *m, sint16 * x, sint16 * y) |
2255 | get_map_from_coord (maptile *m, sint16 * x, sint16 * y) |
2256 | { |
2256 | { |
2257 | |
2257 | |
2258 | if (*x < 0) |
2258 | if (*x < 0) |
2259 | { |
2259 | { |
2260 | if (!m->tile_path[3]) |
2260 | if (!m->tile_path[3]) |
… | |
… | |
2306 | /** |
2306 | /** |
2307 | * Return whether map2 is adjacent to map1. If so, store the distance from |
2307 | * Return whether map2 is adjacent to map1. If so, store the distance from |
2308 | * map1 to map2 in dx/dy. |
2308 | * map1 to map2 in dx/dy. |
2309 | */ |
2309 | */ |
2310 | static int |
2310 | static int |
2311 | adjacent_map (const mapstruct *map1, const mapstruct *map2, int *dx, int *dy) |
2311 | adjacent_map (const maptile *map1, const maptile *map2, int *dx, int *dy) |
2312 | { |
2312 | { |
2313 | if (!map1 || !map2) |
2313 | if (!map1 || !map2) |
2314 | return 0; |
2314 | return 0; |
2315 | |
2315 | |
2316 | if (map1 == map2) |
2316 | if (map1 == map2) |
… | |
… | |
2474 | * for something in the future. Also, since no object is pasted, the best |
2474 | * for something in the future. Also, since no object is pasted, the best |
2475 | * field of the rv_vector is set to NULL. |
2475 | * field of the rv_vector is set to NULL. |
2476 | */ |
2476 | */ |
2477 | |
2477 | |
2478 | void |
2478 | void |
2479 | get_rangevector_from_mapcoord (const mapstruct *m, int x, int y, const object *op2, rv_vector * retval, int flags) |
2479 | get_rangevector_from_mapcoord (const maptile *m, int x, int y, const object *op2, rv_vector * retval, int flags) |
2480 | { |
2480 | { |
2481 | if (!adjacent_map (m, op2->map, &retval->distance_x, &retval->distance_y)) |
2481 | if (!adjacent_map (m, op2->map, &retval->distance_x, &retval->distance_y)) |
2482 | { |
2482 | { |
2483 | /* be conservative and fill in _some_ data */ |
2483 | /* be conservative and fill in _some_ data */ |
2484 | retval->distance = 100000; |
2484 | retval->distance = 100000; |