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.2 by root, Wed Feb 8 03:46:15 2006 UTC vs.
Revision 1.3 by root, Tue Feb 21 11:00:07 2006 UTC

1/* 1/*
2 * static char *rcsid_map_c = 2 * static char *rcsid_map_c =
3 * "$Id: map.c,v 1.2 2006/02/08 03:46:15 root Exp $"; 3 * "$Id: map.c,v 1.3 2006/02/21 11:00:07 root Exp $";
4 */ 4 */
5 5
6/* 6/*
7 CrossFire, A Multiplayer game for X-windows 7 CrossFire, A Multiplayer game for X-windows
8 8
1918 * case. This generally shouldn't happen, but if the 1918 * case. This generally shouldn't happen, but if the
1919 * map loads fail below, it could happen. 1919 * map loads fail below, it could happen.
1920 */ 1920 */
1921 if (!m) return 0; 1921 if (!m) return 0;
1922 1922
1923 /* Simple case - coordinates are within this local
1924 * map.
1925 */
1926 if ( x>=0 && x<MAP_WIDTH(m) && y>=0 && y < MAP_HEIGHT(m))
1927 return 0;
1928
1929 if (x<0) { 1923 if (x<0) {
1930 if (!m->tile_path[3]) return 1; 1924 if (!m->tile_path[3]) return 1;
1931 if (!m->tile_map[3] || m->tile_map[3]->in_memory != MAP_IN_MEMORY) { 1925 if (!m->tile_map[3] || m->tile_map[3]->in_memory != MAP_IN_MEMORY) {
1932 load_and_link_tiled_map(m, 3); 1926 load_and_link_tiled_map(m, 3);
1933 } 1927 }
1952 if (!m->tile_map[2] || m->tile_map[2]->in_memory != MAP_IN_MEMORY) { 1946 if (!m->tile_map[2] || m->tile_map[2]->in_memory != MAP_IN_MEMORY) {
1953 load_and_link_tiled_map(m, 2); 1947 load_and_link_tiled_map(m, 2);
1954 } 1948 }
1955 return (out_of_map(m->tile_map[2], x, y - MAP_HEIGHT(m))); 1949 return (out_of_map(m->tile_map[2], x, y - MAP_HEIGHT(m)));
1956 } 1950 }
1951
1952 /* Simple case - coordinates are within this local
1953 * map.
1954 */
1957 return 1; 1955 return 0;
1958} 1956}
1959 1957
1960/* This is basically the same as out_of_map above, but 1958/* This is basically the same as out_of_map above, but
1961 * instead we return NULL if no map is valid (coordinates 1959 * instead we return NULL if no map is valid (coordinates
1962 * out of bounds and no tiled map), otherwise it returns 1960 * out of bounds and no tiled map), otherwise it returns
1966 * and then figuring out what the real map is 1964 * and then figuring out what the real map is
1967 */ 1965 */
1968mapstruct *get_map_from_coord(mapstruct *m, sint16 *x, sint16 *y) 1966mapstruct *get_map_from_coord(mapstruct *m, sint16 *x, sint16 *y)
1969{ 1967{
1970 1968
1971 /* Simple case - coordinates are within this local
1972 * map.
1973 */
1974
1975 if (*x>=0 && *x<MAP_WIDTH(m) && *y>=0 && *y < MAP_HEIGHT(m))
1976 return m;
1977
1978 if (*x<0) { 1969 if (*x<0) {
1979 if (!m->tile_path[3]) return NULL; 1970 if (!m->tile_path[3]) return NULL;
1980 if (!m->tile_map[3] || m->tile_map[3]->in_memory != MAP_IN_MEMORY) 1971 if (!m->tile_map[3] || m->tile_map[3]->in_memory != MAP_IN_MEMORY)
1981 load_and_link_tiled_map(m, 3); 1972 load_and_link_tiled_map(m, 3);
1982 1973
2005 load_and_link_tiled_map(m, 2); 1996 load_and_link_tiled_map(m, 2);
2006 1997
2007 *y -= MAP_HEIGHT(m); 1998 *y -= MAP_HEIGHT(m);
2008 return (get_map_from_coord(m->tile_map[2], x, y)); 1999 return (get_map_from_coord(m->tile_map[2], x, y));
2009 } 2000 }
2010 return NULL; /* Shouldn't get here */ 2001
2002 /* Simple case - coordinates are within this local
2003 * map.
2004 */
2005
2006 return m;
2011} 2007}
2012 2008
2013// return wether map2 is adjacent to map1 and store their distance 2009// return wether map2 is adjacent to map1 and store their distance
2014// in dx/dy if yes. 2010// in dx/dy if yes.
2015static int adjacent_map (mapstruct *map1, mapstruct *map2, int *dx, int *dy) 2011static int adjacent_map (mapstruct *map1, mapstruct *map2, int *dx, int *dy)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines