… | |
… | |
222 | void |
222 | void |
223 | dump_all_maps (void) |
223 | dump_all_maps (void) |
224 | { |
224 | { |
225 | maptile *m; |
225 | maptile *m; |
226 | |
226 | |
227 | for (m = first_map; m != NULL; m = m->next) |
227 | for (m = first_map; m; m = m->next) |
228 | { |
|
|
229 | dump_map (m); |
228 | dump_map (m); |
230 | } |
|
|
231 | } |
229 | } |
232 | |
230 | |
233 | /* This rolls up wall, blocks_magic, blocks_view, etc, all into |
231 | /* This rolls up wall, blocks_magic, blocks_view, etc, all into |
234 | * one function that just returns a P_.. value (see map.h) |
232 | * one function that just returns a P_.. value (see map.h) |
235 | * it will also do map translation for tiled maps, returning |
233 | * it will also do map translation for tiled maps, returning |
… | |
… | |
239 | * is needed. The case of not passing values is if we're just |
237 | * is needed. The case of not passing values is if we're just |
240 | * checking for the existence of something on those spaces, but |
238 | * checking for the existence of something on those spaces, but |
241 | * don't expect to insert/remove anything from those spaces. |
239 | * don't expect to insert/remove anything from those spaces. |
242 | */ |
240 | */ |
243 | int |
241 | int |
244 | get_map_flags (maptile *oldmap, maptile **newmap, sint16 x, sint16 y, sint16 * nx, sint16 * ny) |
242 | get_map_flags (maptile *oldmap, maptile **newmap, sint16 x, sint16 y, sint16 *nx, sint16 *ny) |
245 | { |
243 | { |
246 | sint16 newx, newy; |
244 | sint16 newx, newy; |
247 | int retval = 0; |
245 | int retval = 0; |
248 | maptile *mp; |
246 | maptile *mp; |
249 | |
247 | |
250 | if (out_of_map (oldmap, x, y)) |
|
|
251 | return P_OUT_OF_MAP; |
|
|
252 | newx = x; |
248 | newx = x; |
253 | newy = y; |
249 | newy = y; |
|
|
250 | |
254 | mp = get_map_from_coord (oldmap, &newx, &newy); |
251 | mp = get_map_from_coord (oldmap, &newx, &newy); |
|
|
252 | |
|
|
253 | if (!mp) |
|
|
254 | return P_OUT_OF_MAP; |
|
|
255 | |
255 | if (mp != oldmap) |
256 | if (mp != oldmap) |
256 | retval |= P_NEW_MAP; |
257 | retval |= P_NEW_MAP; |
257 | if (newmap) |
|
|
258 | *newmap = mp; |
|
|
259 | if (nx) |
|
|
260 | *nx = newx; |
|
|
261 | if (ny) |
|
|
262 | *ny = newy; |
|
|
263 | |
258 | |
264 | retval |= mp->spaces[newx + mp->width * newy].flags; |
259 | if (newmap) *newmap = mp; |
|
|
260 | if (nx) *nx = newx; |
|
|
261 | if (ny) *ny = newy; |
265 | |
262 | |
266 | return retval; |
263 | return retval | mp->at (newx, newy).flags (); |
267 | } |
264 | } |
268 | |
265 | |
269 | /* |
266 | /* |
270 | * Returns true if the given coordinate is blocked except by the |
267 | * Returns true if the given coordinate is blocked except by the |
271 | * object passed is not blocking. This is used with |
268 | * object passed is not blocking. This is used with |
… | |
… | |
294 | } |
291 | } |
295 | |
292 | |
296 | /* Save some cycles - instead of calling get_map_flags(), just get the value |
293 | /* Save some cycles - instead of calling get_map_flags(), just get the value |
297 | * directly. |
294 | * directly. |
298 | */ |
295 | */ |
299 | mflags = m->spaces[sx + m->width * sy].flags; |
296 | mflags = m->at (sx, sy).flags (); |
300 | |
297 | |
301 | blocked = GET_MAP_MOVE_BLOCK (m, sx, sy); |
298 | blocked = GET_MAP_MOVE_BLOCK (m, sx, sy); |
302 | |
299 | |
303 | /* If space is currently not blocked by anything, no need to |
300 | /* If space is currently not blocked by anything, no need to |
304 | * go further. Not true for players - all sorts of special |
301 | * go further. Not true for players - all sorts of special |
… | |
… | |
323 | /* We basically go through the stack of objects, and if there is |
320 | /* We basically go through the stack of objects, and if there is |
324 | * some other object that has NO_PASS or FLAG_ALIVE set, return |
321 | * some other object that has NO_PASS or FLAG_ALIVE set, return |
325 | * true. If we get through the entire stack, that must mean |
322 | * true. If we get through the entire stack, that must mean |
326 | * ob is blocking it, so return 0. |
323 | * ob is blocking it, so return 0. |
327 | */ |
324 | */ |
328 | for (tmp = GET_MAP_OB (m, sx, sy); tmp != NULL; tmp = tmp->above) |
325 | for (tmp = GET_MAP_OB (m, sx, sy); tmp; tmp = tmp->above) |
329 | { |
326 | { |
330 | |
327 | |
331 | /* This must be before the checks below. Code for inventory checkers. */ |
328 | /* This must be before the checks below. Code for inventory checkers. */ |
332 | if (tmp->type == CHECK_INV && OB_MOVE_BLOCK (ob, tmp)) |
329 | if (tmp->type == CHECK_INV && OB_MOVE_BLOCK (ob, tmp)) |
333 | { |
330 | { |
… | |
… | |
397 | * |
394 | * |
398 | * Note this used to be arch_blocked, but with new movement |
395 | * Note this used to be arch_blocked, but with new movement |
399 | * code, we need to have actual object to check its move_type |
396 | * code, we need to have actual object to check its move_type |
400 | * against the move_block values. |
397 | * against the move_block values. |
401 | */ |
398 | */ |
402 | |
|
|
403 | int |
399 | int |
404 | ob_blocked (const object *ob, maptile *m, sint16 x, sint16 y) |
400 | ob_blocked (const object *ob, maptile *m, sint16 x, sint16 y) |
405 | { |
401 | { |
406 | archetype *tmp; |
402 | archetype *tmp; |
407 | int flag; |
403 | int flag; |
… | |
… | |
437 | |
433 | |
438 | /* Note it is intentional that we check ob - the movement type of the |
434 | /* Note it is intentional that we check ob - the movement type of the |
439 | * head of the object should correspond for the entire object. |
435 | * head of the object should correspond for the entire object. |
440 | */ |
436 | */ |
441 | if (OB_TYPE_MOVE_BLOCK (ob, GET_MAP_MOVE_BLOCK (m1, sx, sy))) |
437 | if (OB_TYPE_MOVE_BLOCK (ob, GET_MAP_MOVE_BLOCK (m1, sx, sy))) |
442 | return AB_NO_PASS; |
438 | return P_NO_PASS; |
443 | |
|
|
444 | } |
439 | } |
|
|
440 | |
445 | return 0; |
441 | return 0; |
446 | } |
442 | } |
447 | |
443 | |
448 | /* When the map is loaded, load_object does not actually insert objects |
444 | /* When the map is loaded, load_object does not actually insert objects |
449 | * into inventory, but just links them. What this does is go through |
445 | * into inventory, but just links them. What this does is go through |
… | |
… | |
486 | object *tmp, *op, *last, *above; |
482 | object *tmp, *op, *last, *above; |
487 | archetype *at; |
483 | archetype *at; |
488 | |
484 | |
489 | for (x = 0; x < MAP_WIDTH (m); x++) |
485 | for (x = 0; x < MAP_WIDTH (m); x++) |
490 | for (y = 0; y < MAP_HEIGHT (m); y++) |
486 | for (y = 0; y < MAP_HEIGHT (m); y++) |
491 | for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = above) |
487 | for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = above) |
492 | { |
488 | { |
493 | above = tmp->above; |
489 | above = tmp->above; |
494 | |
490 | |
495 | /* already multipart - don't do anything more */ |
491 | /* already multipart - don't do anything more */ |
496 | if (tmp->head || tmp->more) |
492 | if (tmp->head || tmp->more) |
… | |
… | |
581 | { |
577 | { |
582 | for (j = 0; j < m->height; j++) |
578 | for (j = 0; j < m->height; j++) |
583 | { |
579 | { |
584 | unique = 0; |
580 | unique = 0; |
585 | /* check for unique items, or unique squares */ |
581 | /* check for unique items, or unique squares */ |
586 | for (otmp = get_map_ob (m, i, j); otmp; otmp = otmp->above) |
582 | for (otmp = GET_MAP_OB (m, i, j); otmp; otmp = otmp->above) |
587 | { |
583 | { |
588 | if (QUERY_FLAG (otmp, FLAG_UNIQUE) || QUERY_FLAG (otmp, FLAG_OBJ_SAVE_ON_OVL)) |
584 | if (QUERY_FLAG (otmp, FLAG_UNIQUE) || QUERY_FLAG (otmp, FLAG_OBJ_SAVE_ON_OVL)) |
589 | unique = 1; |
585 | unique = 1; |
590 | |
586 | |
591 | if (!(mapflags & (MAP_OVERLAY | MAP_PLAYER_UNIQUE) || unique)) |
587 | if (!(mapflags & (MAP_OVERLAY | MAP_PLAYER_UNIQUE) || unique)) |
… | |
… | |
612 | /* first pass - save one-part objects */ |
608 | /* first pass - save one-part objects */ |
613 | for (i = 0; i < MAP_WIDTH (m); i++) |
609 | for (i = 0; i < MAP_WIDTH (m); i++) |
614 | for (j = 0; j < MAP_HEIGHT (m); j++) |
610 | for (j = 0; j < MAP_HEIGHT (m); j++) |
615 | { |
611 | { |
616 | unique = 0; |
612 | unique = 0; |
617 | for (op = get_map_ob (m, i, j); op; op = op->above) |
613 | for (op = GET_MAP_OB (m, i, j); op; op = op->above) |
618 | { |
614 | { |
619 | if (QUERY_FLAG (op, FLAG_IS_FLOOR) && QUERY_FLAG (op, FLAG_UNIQUE)) |
615 | if (QUERY_FLAG (op, FLAG_IS_FLOOR) && QUERY_FLAG (op, FLAG_UNIQUE)) |
620 | unique = 1; |
616 | unique = 1; |
621 | |
617 | |
622 | if (op->type == PLAYER) |
618 | if (op->type == PLAYER) |
623 | { |
|
|
624 | LOG (llevDebug, "Player on map that is being saved\n"); |
|
|
625 | continue; |
619 | continue; |
626 | } |
|
|
627 | |
620 | |
628 | if (op->head || op->owner) |
621 | if (op->head || op->owner) |
629 | continue; |
622 | continue; |
630 | |
623 | |
631 | if (unique || QUERY_FLAG (op, FLAG_UNIQUE)) |
624 | if (unique || QUERY_FLAG (op, FLAG_UNIQUE)) |
632 | save_object (fp2, op, 3); |
625 | save_object (fp2, op, 3); |
633 | else if (flag == 0 || (flag == 2 && (!QUERY_FLAG (op, FLAG_OBJ_ORIGINAL) && !QUERY_FLAG (op, FLAG_UNPAID)))) |
626 | else if (flag == 0 || (flag == 2 && (!QUERY_FLAG (op, FLAG_OBJ_ORIGINAL) && !QUERY_FLAG (op, FLAG_UNPAID)))) |
634 | save_object (fp, op, 3); |
627 | save_object (fp, op, 3); |
635 | |
628 | } |
636 | } /* for this space */ |
629 | } |
637 | } /* for this j */ |
|
|
638 | } |
630 | } |
639 | |
631 | |
640 | maptile::maptile () |
632 | maptile::maptile () |
641 | { |
633 | { |
642 | in_memory = MAP_SWAPPED; |
634 | in_memory = MAP_SWAPPED; |
… | |
… | |
692 | { |
684 | { |
693 | LOG (llevError, "allocate_map called with already allocated map (%s)\n", path); |
685 | LOG (llevError, "allocate_map called with already allocated map (%s)\n", path); |
694 | free (spaces); |
686 | free (spaces); |
695 | } |
687 | } |
696 | |
688 | |
697 | spaces = (MapSpace *) |
689 | spaces = (mapspace *) |
698 | calloc (1, width * height * sizeof (MapSpace)); |
690 | calloc (1, width * height * sizeof (mapspace)); |
699 | |
691 | |
700 | if (!spaces) |
692 | if (!spaces) |
701 | fatal (OUT_OF_MEMORY); |
693 | fatal (OUT_OF_MEMORY); |
702 | } |
694 | } |
703 | |
695 | |
… | |
… | |
1249 | for (i = 0; i < MAP_WIDTH (m); i++) |
1241 | for (i = 0; i < MAP_WIDTH (m); i++) |
1250 | for (j = 0; j < MAP_HEIGHT (m); j++) |
1242 | for (j = 0; j < MAP_HEIGHT (m); j++) |
1251 | { |
1243 | { |
1252 | unique = 0; |
1244 | unique = 0; |
1253 | |
1245 | |
1254 | for (op = get_map_ob (m, i, j); op; op = next) |
1246 | for (op = GET_MAP_OB (m, i, j); op; op = next) |
1255 | { |
1247 | { |
1256 | next = op->above; |
1248 | next = op->above; |
1257 | |
1249 | |
1258 | if (QUERY_FLAG (op, FLAG_IS_FLOOR) && QUERY_FLAG (op, FLAG_UNIQUE)) |
1250 | if (QUERY_FLAG (op, FLAG_IS_FLOOR) && QUERY_FLAG (op, FLAG_UNIQUE)) |
1259 | unique = 1; |
1251 | unique = 1; |
… | |
… | |
1781 | return MAP_DIFFICULTY (m); |
1773 | return MAP_DIFFICULTY (m); |
1782 | } |
1774 | } |
1783 | |
1775 | |
1784 | for (x = 0; x < MAP_WIDTH (m); x++) |
1776 | for (x = 0; x < MAP_WIDTH (m); x++) |
1785 | for (y = 0; y < MAP_HEIGHT (m); y++) |
1777 | for (y = 0; y < MAP_HEIGHT (m); y++) |
1786 | for (op = get_map_ob (m, x, y); op != NULL; op = op->above) |
1778 | for (op = GET_MAP_OB (m, x, y); op != NULL; op = op->above) |
1787 | { |
1779 | { |
1788 | if (QUERY_FLAG (op, FLAG_MONSTER)) |
1780 | if (QUERY_FLAG (op, FLAG_MONSTER)) |
1789 | { |
1781 | { |
1790 | total_exp += op->stats.exp; |
1782 | total_exp += op->stats.exp; |
1791 | monster_cnt++; |
1783 | monster_cnt++; |
… | |
… | |
1884 | /* All clients need to get re-updated for the change */ |
1876 | /* All clients need to get re-updated for the change */ |
1885 | update_all_map_los (m); |
1877 | update_all_map_los (m); |
1886 | return 1; |
1878 | return 1; |
1887 | } |
1879 | } |
1888 | |
1880 | |
1889 | |
|
|
1890 | /* |
1881 | /* |
1891 | * This function updates various attributes about a specific space |
1882 | * This function updates various attributes about a specific space |
1892 | * on the map (what it looks like, whether it blocks magic, |
1883 | * on the map (what it looks like, whether it blocks magic, |
1893 | * has a living creatures, prevents people from passing |
1884 | * has a living creatures, prevents people from passing |
1894 | * through, etc) |
1885 | * through, etc) |
1895 | */ |
1886 | */ |
1896 | void |
1887 | void |
1897 | update_position (maptile *m, int x, int y) |
1888 | mapspace::update_ () |
1898 | { |
1889 | { |
1899 | object *tmp, *last = NULL; |
1890 | object *tmp, *last = 0; |
1900 | uint8 flags = 0, oldflags, light = 0, anywhere = 0; |
1891 | uint8 flags = 0, light = 0, anywhere = 0; |
1901 | New_Face *top, *floor, *middle; |
1892 | New_Face *top, *floor, *middle; |
1902 | object *top_obj, *floor_obj, *middle_obj; |
1893 | object *top_obj, *floor_obj, *middle_obj; |
1903 | MoveType move_block = 0, move_slow = 0, move_on = 0, move_off = 0, move_allow = 0; |
1894 | MoveType move_block = 0, move_slow = 0, move_on = 0, move_off = 0, move_allow = 0; |
1904 | |
1895 | |
1905 | oldflags = GET_MAP_FLAGS (m, x, y); |
|
|
1906 | if (!(oldflags & P_NEED_UPDATE)) |
|
|
1907 | { |
|
|
1908 | LOG (llevDebug, "update_position called with P_NEED_UPDATE not set: %s (%d, %d)\n", m->path, x, y); |
|
|
1909 | return; |
|
|
1910 | } |
|
|
1911 | |
|
|
1912 | middle = blank_face; |
1896 | middle = blank_face; |
1913 | top = blank_face; |
1897 | top = blank_face; |
1914 | floor = blank_face; |
1898 | floor = blank_face; |
1915 | |
1899 | |
1916 | middle_obj = NULL; |
1900 | middle_obj = 0; |
1917 | top_obj = NULL; |
1901 | top_obj = 0; |
1918 | floor_obj = NULL; |
1902 | floor_obj = 0; |
1919 | |
1903 | |
1920 | for (tmp = get_map_ob (m, x, y); tmp; last = tmp, tmp = tmp->above) |
1904 | for (tmp = bottom; tmp; last = tmp, tmp = tmp->above) |
1921 | { |
1905 | { |
1922 | |
|
|
1923 | /* This could be made additive I guess (two lights better than |
1906 | /* This could be made additive I guess (two lights better than |
1924 | * one). But if so, it shouldn't be a simple additive - 2 |
1907 | * one). But if so, it shouldn't be a simple additive - 2 |
1925 | * light bulbs do not illuminate twice as far as once since |
1908 | * light bulbs do not illuminate twice as far as once since |
1926 | * it is a disapation factor that is squared (or is it cubed?) |
1909 | * it is a dissapation factor that is cubed. |
1927 | */ |
1910 | */ |
1928 | if (tmp->glow_radius > light) |
1911 | if (tmp->glow_radius > light) |
1929 | light = tmp->glow_radius; |
1912 | light = tmp->glow_radius; |
1930 | |
1913 | |
1931 | /* This call is needed in order to update objects the player |
1914 | /* This call is needed in order to update objects the player |
… | |
… | |
1969 | { |
1952 | { |
1970 | middle = tmp->face; |
1953 | middle = tmp->face; |
1971 | middle_obj = tmp; |
1954 | middle_obj = tmp; |
1972 | } |
1955 | } |
1973 | } |
1956 | } |
|
|
1957 | |
1974 | if (tmp == tmp->above) |
1958 | if (tmp == tmp->above) |
1975 | { |
1959 | { |
1976 | LOG (llevError, "Error in structure of map\n"); |
1960 | LOG (llevError, "Error in structure of map\n"); |
1977 | exit (-1); |
1961 | exit (-1); |
1978 | } |
1962 | } |
1979 | |
1963 | |
1980 | move_slow |= tmp->move_slow; |
1964 | move_slow |= tmp->move_slow; |
1981 | move_block |= tmp->move_block; |
1965 | move_block |= tmp->move_block; |
1982 | move_on |= tmp->move_on; |
1966 | move_on |= tmp->move_on; |
1983 | move_off |= tmp->move_off; |
1967 | move_off |= tmp->move_off; |
1984 | move_allow |= tmp->move_allow; |
1968 | move_allow |= tmp->move_allow; |
1985 | |
1969 | |
1986 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
|
|
1987 | flags |= P_IS_ALIVE; |
|
|
1988 | if (QUERY_FLAG (tmp, FLAG_NO_MAGIC)) |
|
|
1989 | flags |= P_NO_MAGIC; |
|
|
1990 | if (QUERY_FLAG (tmp, FLAG_DAMNED)) |
|
|
1991 | flags |= P_NO_CLERIC; |
|
|
1992 | if (tmp->type == SAFE_GROUND) |
|
|
1993 | flags |= P_SAFE; |
|
|
1994 | |
|
|
1995 | if (QUERY_FLAG (tmp, FLAG_BLOCKSVIEW)) |
1970 | if (QUERY_FLAG (tmp, FLAG_BLOCKSVIEW)) flags |= P_BLOCKSVIEW; |
1996 | flags |= P_BLOCKSVIEW; |
1971 | if (QUERY_FLAG (tmp, FLAG_NO_MAGIC)) flags |= P_NO_MAGIC; |
1997 | } /* for stack of objects */ |
1972 | if (tmp->type == PLAYER) flags |= P_PLAYER; |
1998 | |
1973 | if (tmp->type == SAFE_GROUND) flags |= P_SAFE; |
1999 | /* we don't want to rely on this function to have accurate flags, but |
1974 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) flags |= P_IS_ALIVE; |
2000 | * since we're already doing the work, we calculate them here. |
1975 | if (QUERY_FLAG (tmp, FLAG_DAMNED)) flags |= P_NO_CLERIC; |
2001 | * if they don't match, logic is broken someplace. |
|
|
2002 | */ |
|
|
2003 | if (((oldflags & ~(P_NEED_UPDATE | P_NO_ERROR)) != flags) && (!(oldflags & P_NO_ERROR))) |
|
|
2004 | { |
1976 | } |
2005 | LOG (llevDebug, "update_position: updated flags do not match old flags: %s (old=%d,new=%d) %x != %x\n", |
1977 | |
2006 | m->path, x, y, (oldflags & ~P_NEED_UPDATE), flags); |
1978 | this->light = light; |
2007 | } |
1979 | this->flags_ = flags; |
2008 | SET_MAP_FLAGS (m, x, y, flags); |
1980 | this->move_block = move_block & ~move_allow; |
2009 | SET_MAP_MOVE_BLOCK (m, x, y, move_block & ~move_allow); |
1981 | this->move_on = move_on; |
2010 | SET_MAP_MOVE_ON (m, x, y, move_on); |
1982 | this->move_off = move_off; |
2011 | SET_MAP_MOVE_OFF (m, x, y, move_off); |
1983 | this->move_slow = move_slow; |
2012 | SET_MAP_MOVE_SLOW (m, x, y, move_slow); |
|
|
2013 | |
1984 | |
2014 | /* At this point, we have a floor face (if there is a floor), |
1985 | /* At this point, we have a floor face (if there is a floor), |
2015 | * and the floor is set - we are not going to touch it at |
1986 | * and the floor is set - we are not going to touch it at |
2016 | * this point. |
1987 | * this point. |
2017 | * middle contains the highest visibility face. |
1988 | * middle contains the highest visibility face. |
… | |
… | |
2071 | break; |
2042 | break; |
2072 | } |
2043 | } |
2073 | } |
2044 | } |
2074 | } |
2045 | } |
2075 | } |
2046 | } |
|
|
2047 | |
2076 | if (middle == floor) |
2048 | if (middle == floor) |
2077 | middle = blank_face; |
2049 | middle = blank_face; |
|
|
2050 | |
2078 | if (top == middle) |
2051 | if (top == middle) |
2079 | middle = blank_face; |
2052 | middle = blank_face; |
2080 | SET_MAP_FACE (m, x, y, top, 0); |
|
|
2081 | if (top != blank_face) |
|
|
2082 | SET_MAP_FACE_OBJ (m, x, y, top_obj, 0); |
|
|
2083 | else |
|
|
2084 | SET_MAP_FACE_OBJ (m, x, y, NULL, 0); |
|
|
2085 | SET_MAP_FACE (m, x, y, middle, 1); |
|
|
2086 | if (middle != blank_face) |
|
|
2087 | SET_MAP_FACE_OBJ (m, x, y, middle_obj, 1); |
|
|
2088 | else |
|
|
2089 | SET_MAP_FACE_OBJ (m, x, y, NULL, 1); |
|
|
2090 | SET_MAP_FACE (m, x, y, floor, 2); |
|
|
2091 | if (floor != blank_face) |
|
|
2092 | SET_MAP_FACE_OBJ (m, x, y, floor_obj, 2); |
|
|
2093 | else |
|
|
2094 | SET_MAP_FACE_OBJ (m, x, y, NULL, 2); |
|
|
2095 | SET_MAP_LIGHT (m, x, y, light); |
|
|
2096 | } |
|
|
2097 | |
2053 | |
|
|
2054 | faces [0] = top; faces_obj [0] = top != blank_face ? top_obj : 0; |
|
|
2055 | faces [1] = middle; faces_obj [1] = middle != blank_face ? middle_obj : 0; |
|
|
2056 | faces [2] = floor; faces_obj [2] = floor != blank_face ? floor_obj : 0; |
|
|
2057 | } |
2098 | |
2058 | |
2099 | void |
2059 | void |
2100 | set_map_reset_time (maptile *map) |
2060 | set_map_reset_time (maptile *map) |
2101 | { |
2061 | { |
2102 | int timeout; |
2062 | int timeout; |
… | |
… | |
2142 | * |
2102 | * |
2143 | */ |
2103 | */ |
2144 | int |
2104 | int |
2145 | out_of_map (maptile *m, int x, int y) |
2105 | out_of_map (maptile *m, int x, int y) |
2146 | { |
2106 | { |
2147 | |
|
|
2148 | /* If we get passed a null map, this is obviously the |
2107 | /* If we get passed a null map, this is obviously the |
2149 | * case. This generally shouldn't happen, but if the |
2108 | * case. This generally shouldn't happen, but if the |
2150 | * map loads fail below, it could happen. |
2109 | * map loads fail below, it could happen. |
2151 | */ |
2110 | */ |
2152 | if (!m) |
2111 | if (!m) |
… | |
… | |
2154 | |
2113 | |
2155 | if (x < 0) |
2114 | if (x < 0) |
2156 | { |
2115 | { |
2157 | if (!m->tile_path[3]) |
2116 | if (!m->tile_path[3]) |
2158 | return 1; |
2117 | return 1; |
|
|
2118 | |
2159 | if (!m->tile_map[3] || m->tile_map[3]->in_memory != MAP_IN_MEMORY) |
2119 | if (!m->tile_map[3] || m->tile_map[3]->in_memory != MAP_IN_MEMORY) |
2160 | { |
|
|
2161 | load_and_link_tiled_map (m, 3); |
2120 | load_and_link_tiled_map (m, 3); |
2162 | } |
2121 | |
2163 | return (out_of_map (m->tile_map[3], x + MAP_WIDTH (m->tile_map[3]), y)); |
2122 | return (out_of_map (m->tile_map[3], x + MAP_WIDTH (m->tile_map[3]), y)); |
2164 | } |
2123 | } |
|
|
2124 | |
2165 | if (x >= MAP_WIDTH (m)) |
2125 | if (x >= MAP_WIDTH (m)) |
2166 | { |
2126 | { |
2167 | if (!m->tile_path[1]) |
2127 | if (!m->tile_path[1]) |
2168 | return 1; |
2128 | return 1; |
|
|
2129 | |
2169 | if (!m->tile_map[1] || m->tile_map[1]->in_memory != MAP_IN_MEMORY) |
2130 | if (!m->tile_map[1] || m->tile_map[1]->in_memory != MAP_IN_MEMORY) |
2170 | { |
|
|
2171 | load_and_link_tiled_map (m, 1); |
2131 | load_and_link_tiled_map (m, 1); |
2172 | } |
2132 | |
2173 | return (out_of_map (m->tile_map[1], x - MAP_WIDTH (m), y)); |
2133 | return (out_of_map (m->tile_map[1], x - MAP_WIDTH (m), y)); |
2174 | } |
2134 | } |
|
|
2135 | |
2175 | if (y < 0) |
2136 | if (y < 0) |
2176 | { |
2137 | { |
2177 | if (!m->tile_path[0]) |
2138 | if (!m->tile_path[0]) |
2178 | return 1; |
2139 | return 1; |
|
|
2140 | |
2179 | if (!m->tile_map[0] || m->tile_map[0]->in_memory != MAP_IN_MEMORY) |
2141 | if (!m->tile_map[0] || m->tile_map[0]->in_memory != MAP_IN_MEMORY) |
2180 | { |
|
|
2181 | load_and_link_tiled_map (m, 0); |
2142 | load_and_link_tiled_map (m, 0); |
2182 | } |
2143 | |
2183 | return (out_of_map (m->tile_map[0], x, y + MAP_HEIGHT (m->tile_map[0]))); |
2144 | return (out_of_map (m->tile_map[0], x, y + MAP_HEIGHT (m->tile_map[0]))); |
2184 | } |
2145 | } |
|
|
2146 | |
2185 | if (y >= MAP_HEIGHT (m)) |
2147 | if (y >= MAP_HEIGHT (m)) |
2186 | { |
2148 | { |
2187 | if (!m->tile_path[2]) |
2149 | if (!m->tile_path[2]) |
2188 | return 1; |
2150 | return 1; |
|
|
2151 | |
2189 | if (!m->tile_map[2] || m->tile_map[2]->in_memory != MAP_IN_MEMORY) |
2152 | if (!m->tile_map[2] || m->tile_map[2]->in_memory != MAP_IN_MEMORY) |
2190 | { |
|
|
2191 | load_and_link_tiled_map (m, 2); |
2153 | load_and_link_tiled_map (m, 2); |
2192 | } |
2154 | |
2193 | return (out_of_map (m->tile_map[2], x, y - MAP_HEIGHT (m))); |
2155 | return (out_of_map (m->tile_map[2], x, y - MAP_HEIGHT (m))); |
2194 | } |
2156 | } |
2195 | |
2157 | |
2196 | /* Simple case - coordinates are within this local |
2158 | /* Simple case - coordinates are within this local |
2197 | * map. |
2159 | * map. |
… | |
… | |
2212 | { |
2174 | { |
2213 | |
2175 | |
2214 | if (*x < 0) |
2176 | if (*x < 0) |
2215 | { |
2177 | { |
2216 | if (!m->tile_path[3]) |
2178 | if (!m->tile_path[3]) |
2217 | return NULL; |
2179 | return 0; |
2218 | if (!m->tile_map[3] || m->tile_map[3]->in_memory != MAP_IN_MEMORY) |
2180 | if (!m->tile_map[3] || m->tile_map[3]->in_memory != MAP_IN_MEMORY) |
2219 | load_and_link_tiled_map (m, 3); |
2181 | load_and_link_tiled_map (m, 3); |
2220 | |
2182 | |
2221 | *x += MAP_WIDTH (m->tile_map[3]); |
2183 | *x += MAP_WIDTH (m->tile_map[3]); |
2222 | return (get_map_from_coord (m->tile_map[3], x, y)); |
2184 | return (get_map_from_coord (m->tile_map[3], x, y)); |
2223 | } |
2185 | } |
|
|
2186 | |
2224 | if (*x >= MAP_WIDTH (m)) |
2187 | if (*x >= MAP_WIDTH (m)) |
2225 | { |
2188 | { |
2226 | if (!m->tile_path[1]) |
2189 | if (!m->tile_path[1]) |
2227 | return NULL; |
2190 | return 0; |
|
|
2191 | |
2228 | if (!m->tile_map[1] || m->tile_map[1]->in_memory != MAP_IN_MEMORY) |
2192 | if (!m->tile_map[1] || m->tile_map[1]->in_memory != MAP_IN_MEMORY) |
2229 | load_and_link_tiled_map (m, 1); |
2193 | load_and_link_tiled_map (m, 1); |
2230 | |
2194 | |
2231 | *x -= MAP_WIDTH (m); |
2195 | *x -= MAP_WIDTH (m); |
2232 | return (get_map_from_coord (m->tile_map[1], x, y)); |
2196 | return (get_map_from_coord (m->tile_map[1], x, y)); |
2233 | } |
2197 | } |
|
|
2198 | |
2234 | if (*y < 0) |
2199 | if (*y < 0) |
2235 | { |
2200 | { |
2236 | if (!m->tile_path[0]) |
2201 | if (!m->tile_path[0]) |
2237 | return NULL; |
2202 | return 0; |
|
|
2203 | |
2238 | if (!m->tile_map[0] || m->tile_map[0]->in_memory != MAP_IN_MEMORY) |
2204 | if (!m->tile_map[0] || m->tile_map[0]->in_memory != MAP_IN_MEMORY) |
2239 | load_and_link_tiled_map (m, 0); |
2205 | load_and_link_tiled_map (m, 0); |
2240 | |
2206 | |
2241 | *y += MAP_HEIGHT (m->tile_map[0]); |
2207 | *y += MAP_HEIGHT (m->tile_map[0]); |
2242 | return (get_map_from_coord (m->tile_map[0], x, y)); |
2208 | return (get_map_from_coord (m->tile_map[0], x, y)); |
2243 | } |
2209 | } |
|
|
2210 | |
2244 | if (*y >= MAP_HEIGHT (m)) |
2211 | if (*y >= MAP_HEIGHT (m)) |
2245 | { |
2212 | { |
2246 | if (!m->tile_path[2]) |
2213 | if (!m->tile_path[2]) |
2247 | return NULL; |
2214 | return 0; |
|
|
2215 | |
2248 | if (!m->tile_map[2] || m->tile_map[2]->in_memory != MAP_IN_MEMORY) |
2216 | if (!m->tile_map[2] || m->tile_map[2]->in_memory != MAP_IN_MEMORY) |
2249 | load_and_link_tiled_map (m, 2); |
2217 | load_and_link_tiled_map (m, 2); |
2250 | |
2218 | |
2251 | *y -= MAP_HEIGHT (m); |
2219 | *y -= MAP_HEIGHT (m); |
2252 | return (get_map_from_coord (m->tile_map[2], x, y)); |
2220 | return (get_map_from_coord (m->tile_map[2], x, y)); |