1 | |
1 | |
2 | /* |
2 | /* |
3 | * static char *rcsid_weather_c = |
3 | * static char *rcsid_weather_c = |
4 | * "$Id: weather.C,v 1.5 2006/09/10 15:59:58 root Exp $"; |
4 | * "$Id: weather.C,v 1.6 2006/09/14 21:16:13 root Exp $"; |
5 | */ |
5 | */ |
6 | |
6 | |
7 | /* |
7 | /* |
8 | CrossFire, A Multiplayer game for X-windows |
8 | CrossFire, A Multiplayer game for X-windows |
9 | |
9 | |
… | |
… | |
1354 | { |
1354 | { |
1355 | int i; |
1355 | int i; |
1356 | |
1356 | |
1357 | for (i = 0; wa[i].name != NULL; i++) |
1357 | for (i = 0; wa[i].name != NULL; i++) |
1358 | { |
1358 | { |
1359 | wa[i].what = find_archetype (wa[i].name); |
1359 | wa[i].what = archetype::find (wa[i].name); |
1360 | } |
1360 | } |
1361 | } |
1361 | } |
1362 | |
1362 | |
1363 | static int wmperformstartx; |
1363 | static int wmperformstartx; |
1364 | static int wmperformstarty; |
1364 | static int wmperformstarty; |
… | |
… | |
1714 | sky += 10; /*let it snow */ |
1714 | sky += 10; /*let it snow */ |
1715 | oldsnow = avoid_weather (&avoid, m, x, y, &gotsnow, 0); |
1715 | oldsnow = avoid_weather (&avoid, m, x, y, &gotsnow, 0); |
1716 | if (!avoid) |
1716 | if (!avoid) |
1717 | { |
1717 | { |
1718 | if (sky >= SKY_LIGHT_SNOW && sky < SKY_HEAVY_SNOW) |
1718 | if (sky >= SKY_LIGHT_SNOW && sky < SKY_HEAVY_SNOW) |
1719 | at = find_archetype (weather_replace[0].special_snow); |
1719 | at = archetype::find (weather_replace[0].special_snow); |
1720 | if (sky >= SKY_HEAVY_SNOW) |
1720 | if (sky >= SKY_HEAVY_SNOW) |
1721 | at = find_archetype (weather_replace[1].special_snow); |
1721 | at = archetype::find (weather_replace[1].special_snow); |
1722 | if (sky >= SKY_LIGHT_SNOW) |
1722 | if (sky >= SKY_LIGHT_SNOW) |
1723 | { |
1723 | { |
1724 | /* the bottom floor of scorn is not IS_FLOOR */ |
1724 | /* the bottom floor of scorn is not IS_FLOOR */ |
1725 | topfloor = NULL; |
1725 | topfloor = NULL; |
1726 | for (tmp = GET_MAP_OB (m, x, y); tmp; topfloor = tmp, tmp = tmp->above) |
1726 | for (tmp = GET_MAP_OB (m, x, y); tmp; topfloor = tmp, tmp = tmp->above) |
… | |
… | |
1749 | found++; |
1749 | found++; |
1750 | } |
1750 | } |
1751 | if (found) |
1751 | if (found) |
1752 | { |
1752 | { |
1753 | if (weather_replace[i].special_snow != NULL) |
1753 | if (weather_replace[i].special_snow != NULL) |
1754 | at = find_archetype (weather_replace[i].special_snow); |
1754 | at = archetype::find (weather_replace[i].special_snow); |
1755 | if (weather_replace[i].doublestack_arch != NULL && !nodstk) |
1755 | if (weather_replace[i].doublestack_arch != NULL && !nodstk) |
1756 | { |
1756 | { |
1757 | two++; |
1757 | two++; |
1758 | doublestack = weather_replace[i].doublestack_arch; |
1758 | doublestack = weather_replace[i].doublestack_arch; |
1759 | } |
1759 | } |
… | |
… | |
1813 | CLEAR_FLAG (ob, FLAG_IS_FLOOR); |
1813 | CLEAR_FLAG (ob, FLAG_IS_FLOOR); |
1814 | insert_ob_in_map (ob, m, ob, INS_NO_MERGE | INS_NO_WALK_ON | INS_ABOVE_FLOOR_ONLY); |
1814 | insert_ob_in_map (ob, m, ob, INS_NO_MERGE | INS_NO_WALK_ON | INS_ABOVE_FLOOR_ONLY); |
1815 | if (two) |
1815 | if (two) |
1816 | { |
1816 | { |
1817 | at = NULL; |
1817 | at = NULL; |
1818 | at = find_archetype (doublestack); |
1818 | at = archetype::find (doublestack); |
1819 | if (at != NULL) |
1819 | if (at != NULL) |
1820 | { |
1820 | { |
1821 | ob = arch_to_object (at); |
1821 | ob = arch_to_object (at); |
1822 | ob->x = x; |
1822 | ob->x = x; |
1823 | ob->y = y; |
1823 | ob->y = y; |
… | |
… | |
1847 | remove_ob (tmp); |
1847 | remove_ob (tmp); |
1848 | free_object (tmp); |
1848 | free_object (tmp); |
1849 | tmp = GET_MAP_OB (m, x, y); |
1849 | tmp = GET_MAP_OB (m, x, y); |
1850 | if (tmp && (!strcmp (tmp->arch->name, "mountain"))) |
1850 | if (tmp && (!strcmp (tmp->arch->name, "mountain"))) |
1851 | { |
1851 | { |
1852 | at = find_archetype ("mountain1_rivlets"); |
1852 | at = archetype::find ("mountain1_rivlets"); |
1853 | } |
1853 | } |
1854 | else if (tmp && (!strcmp (tmp->arch->name, "mountain2"))) |
1854 | else if (tmp && (!strcmp (tmp->arch->name, "mountain2"))) |
1855 | { |
1855 | { |
1856 | at = find_archetype ("mountain2_rivlets"); |
1856 | at = archetype::find ("mountain2_rivlets"); |
1857 | } |
1857 | } |
1858 | else if (tmp && (!strcmp (tmp->arch->name, "mountain4"))) |
1858 | else if (tmp && (!strcmp (tmp->arch->name, "mountain4"))) |
1859 | { |
1859 | { |
1860 | at = find_archetype ("mountain2_rivlets"); |
1860 | at = archetype::find ("mountain2_rivlets"); |
1861 | } |
1861 | } |
1862 | else |
1862 | else |
1863 | { |
1863 | { |
1864 | at = find_archetype ("rain5"); |
1864 | at = archetype::find ("rain5"); |
1865 | } |
1865 | } |
1866 | if (at != NULL) |
1866 | if (at != NULL) |
1867 | { |
1867 | { |
1868 | ob = arch_to_object (at); |
1868 | ob = arch_to_object (at); |
1869 | ob->x = x; |
1869 | ob->x = x; |
… | |
… | |
1893 | avoid++; |
1893 | avoid++; |
1894 | else if (tmp && (!strcasecmp (tmp->name, "shallow_sea"))) |
1894 | else if (tmp && (!strcasecmp (tmp->name, "shallow_sea"))) |
1895 | avoid++; |
1895 | avoid++; |
1896 | if (avoid > 0) |
1896 | if (avoid > 0) |
1897 | { |
1897 | { |
1898 | at = find_archetype ("ice"); |
1898 | at = archetype::find ("ice"); |
1899 | ob = arch_to_object (at); |
1899 | ob = arch_to_object (at); |
1900 | ob->x = x; |
1900 | ob->x = x; |
1901 | ob->y = y; |
1901 | ob->y = y; |
1902 | insert_ob_in_map (ob, m, ob, INS_NO_MERGE | INS_NO_WALK_ON | INS_ABOVE_FLOOR_ONLY); |
1902 | insert_ob_in_map (ob, m, ob, INS_NO_MERGE | INS_NO_WALK_ON | INS_ABOVE_FLOOR_ONLY); |
1903 | } |
1903 | } |
… | |
… | |
1967 | if (!avoid) |
1967 | if (!avoid) |
1968 | { |
1968 | { |
1969 | tmp = GET_MAP_OB (m, x, y); |
1969 | tmp = GET_MAP_OB (m, x, y); |
1970 | if (tmp && (!strcmp (tmp->arch->name, "mountain"))) |
1970 | if (tmp && (!strcmp (tmp->arch->name, "mountain"))) |
1971 | { |
1971 | { |
1972 | at = find_archetype ("mountain1_rivlets"); |
1972 | at = archetype::find ("mountain1_rivlets"); |
1973 | break; |
1973 | break; |
1974 | } |
1974 | } |
1975 | else if (tmp && (!strcmp (tmp->arch->name, "mountain2"))) |
1975 | else if (tmp && (!strcmp (tmp->arch->name, "mountain2"))) |
1976 | { |
1976 | { |
1977 | at = find_archetype ("mountain2_rivlets"); |
1977 | at = archetype::find ("mountain2_rivlets"); |
1978 | break; |
1978 | break; |
1979 | } |
1979 | } |
1980 | else if (tmp && (!strcmp (tmp->arch->name, "mountain4"))) |
1980 | else if (tmp && (!strcmp (tmp->arch->name, "mountain4"))) |
1981 | { |
1981 | { |
1982 | at = find_archetype ("mountain2_rivlets"); |
1982 | at = archetype::find ("mountain2_rivlets"); |
1983 | break; |
1983 | break; |
1984 | } |
1984 | } |
1985 | if (sky == SKY_LIGHT_RAIN || sky == SKY_RAIN) |
1985 | if (sky == SKY_LIGHT_RAIN || sky == SKY_RAIN) |
1986 | { |
1986 | { |
1987 | switch (rndm (0, SKY_HAIL - sky)) |
1987 | switch (rndm (0, SKY_HAIL - sky)) |
1988 | { |
1988 | { |
1989 | case 0: |
1989 | case 0: |
1990 | at = find_archetype ("rain1"); |
1990 | at = archetype::find ("rain1"); |
1991 | break; |
1991 | break; |
1992 | case 1: |
1992 | case 1: |
1993 | at = find_archetype ("rain2"); |
1993 | at = archetype::find ("rain2"); |
1994 | break; |
1994 | break; |
1995 | default: |
1995 | default: |
1996 | at = NULL; |
1996 | at = NULL; |
1997 | } |
1997 | } |
1998 | } |
1998 | } |
1999 | if (sky >= SKY_HEAVY_RAIN && sky <= SKY_HURRICANE) |
1999 | if (sky >= SKY_HEAVY_RAIN && sky <= SKY_HURRICANE) |
2000 | { |
2000 | { |
2001 | switch (rndm (0, SKY_HAIL - sky)) |
2001 | switch (rndm (0, SKY_HAIL - sky)) |
2002 | { |
2002 | { |
2003 | case 0: |
2003 | case 0: |
2004 | at = find_archetype ("rain3"); |
2004 | at = archetype::find ("rain3"); |
2005 | break; |
2005 | break; |
2006 | case 1: |
2006 | case 1: |
2007 | at = find_archetype ("rain4"); |
2007 | at = archetype::find ("rain4"); |
2008 | break; |
2008 | break; |
2009 | case 2: |
2009 | case 2: |
2010 | at = find_archetype ("rain5"); |
2010 | at = archetype::find ("rain5"); |
2011 | break; |
2011 | break; |
2012 | default: |
2012 | default: |
2013 | at = NULL; |
2013 | at = NULL; |
2014 | } |
2014 | } |
2015 | } |
2015 | } |
… | |
… | |
2099 | SET_FLAG (ob, FLAG_OVERLAY_FLOOR); |
2099 | SET_FLAG (ob, FLAG_OVERLAY_FLOOR); |
2100 | ob->material = M_LIQUID; |
2100 | ob->material = M_LIQUID; |
2101 | insert_ob_in_map (ob, m, ob, INS_NO_MERGE | INS_NO_WALK_ON | INS_ABOVE_FLOOR_ONLY); |
2101 | insert_ob_in_map (ob, m, ob, INS_NO_MERGE | INS_NO_WALK_ON | INS_ABOVE_FLOOR_ONLY); |
2102 | if (two) |
2102 | if (two) |
2103 | { |
2103 | { |
2104 | at = find_archetype (doublestack); |
2104 | at = archetype::find (doublestack); |
2105 | if (at != NULL) |
2105 | if (at != NULL) |
2106 | { |
2106 | { |
2107 | ob = arch_to_object (at); |
2107 | ob = arch_to_object (at); |
2108 | ob->x = x; |
2108 | ob->x = x; |
2109 | ob->y = y; |
2109 | ob->y = y; |
… | |
… | |
2263 | if ((!GET_MAP_OB (m, x, y)) || |
2263 | if ((!GET_MAP_OB (m, x, y)) || |
2264 | GET_MAP_OB (m, x, y)->elevation < weather_grow[i].elevmin || |
2264 | GET_MAP_OB (m, x, y)->elevation < weather_grow[i].elevmin || |
2265 | GET_MAP_OB (m, x, y)->elevation > weather_grow[i].elevmax) |
2265 | GET_MAP_OB (m, x, y)->elevation > weather_grow[i].elevmax) |
2266 | continue; |
2266 | continue; |
2267 | /* we got this far.. must be a match */ |
2267 | /* we got this far.. must be a match */ |
2268 | at = find_archetype (weather_grow[i].herb); |
2268 | at = archetype::find (weather_grow[i].herb); |
2269 | break; |
2269 | break; |
2270 | } |
2270 | } |
2271 | if (at != NULL) |
2271 | if (at != NULL) |
2272 | { |
2272 | { |
2273 | ob = arch_to_object (at); |
2273 | ob = arch_to_object (at); |
… | |
… | |
2392 | GET_MAP_OB (m, x, y)->elevation > weather_tile[i].elevmax) |
2392 | GET_MAP_OB (m, x, y)->elevation > weather_tile[i].elevmax) |
2393 | continue; |
2393 | continue; |
2394 | /* we got this far.. must be a match */ |
2394 | /* we got this far.. must be a match */ |
2395 | if (GET_MAP_OB (m, x, y) && strcmp (GET_MAP_OB (m, x, y)->arch->name, weather_tile[i].herb) == 0) |
2395 | if (GET_MAP_OB (m, x, y) && strcmp (GET_MAP_OB (m, x, y)->arch->name, weather_tile[i].herb) == 0) |
2396 | break; /* no sense in doubling up */ |
2396 | break; /* no sense in doubling up */ |
2397 | at = find_archetype (weather_tile[i].herb); |
2397 | at = archetype::find (weather_tile[i].herb); |
2398 | break; |
2398 | break; |
2399 | } |
2399 | } |
2400 | if (at != NULL) |
2400 | if (at != NULL) |
2401 | { |
2401 | { |
2402 | if (weather_tile[i].tile != NULL && GET_MAP_OB (m, x, y) && |
2402 | if (weather_tile[i].tile != NULL && GET_MAP_OB (m, x, y) && |
2403 | strcmp (weather_tile[i].tile, GET_MAP_OB (m, x, y)->arch->name) != 0) |
2403 | strcmp (weather_tile[i].tile, GET_MAP_OB (m, x, y)->arch->name) != 0) |
2404 | dat = find_archetype (weather_tile[i].tile); |
2404 | dat = archetype::find (weather_tile[i].tile); |
2405 | if (dat != NULL) |
2405 | if (dat != NULL) |
2406 | { |
2406 | { |
2407 | ob = arch_to_object (dat); |
2407 | ob = arch_to_object (dat); |
2408 | ob->x = x; |
2408 | ob->x = x; |
2409 | ob->y = y; |
2409 | ob->y = y; |