ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/map.C
(Generate patch)

Comparing deliantra/server/common/map.C (file contents):
Revision 1.30 by root, Thu Sep 14 22:33:59 2006 UTC vs.
Revision 1.32 by root, Thu Oct 5 16:50:06 2006 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines