1 | |
|
|
2 | /* |
|
|
3 | * static char *rcsid_weather_c = |
|
|
4 | * "$Id: weather.C,v 1.6 2006/09/14 21:16:13 root Exp $"; |
|
|
5 | */ |
|
|
6 | |
|
|
7 | /* |
1 | /* |
8 | CrossFire, A Multiplayer game for X-windows |
2 | CrossFire, A Multiplayer game for X-windows |
9 | |
3 | |
10 | Copyright (C) 2002 Tim Rightnour |
4 | Copyright (C) 2002 Tim Rightnour |
11 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
… | |
… | |
23 | |
17 | |
24 | You should have received a copy of the GNU General Public License |
18 | You should have received a copy of the GNU General Public License |
25 | along with this program; if not, write to the Free Software |
19 | along with this program; if not, write to the Free Software |
26 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
27 | |
21 | |
28 | The authors can be reached via e-mail to crossfire-devel@real-time.com |
22 | The authors can be reached via e-mail to <crossfire@schmorp.de> |
29 | */ |
23 | */ |
30 | |
24 | |
31 | /* This weather system was written for crossfire by Tim Rightnour */ |
25 | /* This weather system was written for crossfire by Tim Rightnour */ |
32 | |
26 | |
33 | #include <global.h> |
27 | #include <global.h> |
… | |
… | |
66 | static void write_rainfallmap (void); |
60 | static void write_rainfallmap (void); |
67 | static void read_rainfallmap (void); |
61 | static void read_rainfallmap (void); |
68 | static void init_rainfall (void); |
62 | static void init_rainfall (void); |
69 | static void init_weatheravoid (weather_avoids_t wa[]); |
63 | static void init_weatheravoid (weather_avoids_t wa[]); |
70 | static void perform_weather (void); |
64 | static void perform_weather (void); |
71 | static object *avoid_weather (int *av, mapstruct *m, int x, int y, int *gs, int grow); |
65 | static object *avoid_weather (int *av, maptile *m, int x, int y, int *gs, int grow); |
72 | static void calculate_temperature (mapstruct *m, int wx, int wy); |
66 | static void calculate_temperature (maptile *m, int wx, int wy); |
73 | static void let_it_snow (mapstruct *m, int wx, int wy); |
67 | static void let_it_snow (maptile *m, int wx, int wy); |
74 | static void singing_in_the_rain (mapstruct *m, int wx, int wy); |
68 | static void singing_in_the_rain (maptile *m, int wx, int wy); |
75 | static void plant_a_garden (mapstruct *m, int wx, int wy); |
69 | static void plant_a_garden (maptile *m, int wx, int wy); |
76 | static void change_the_world (mapstruct *m, int wx, int wy); |
70 | static void change_the_world (maptile *m, int wx, int wy); |
77 | |
71 | |
78 | //static void feather_map(mapstruct *m, int wx, int wy); |
72 | //static void feather_map(maptile *m, int wx, int wy); |
79 | static const char *weathermap_to_worldmap_corner (int wx, int wy, int *x, int *y, int dir); |
73 | static const char *weathermap_to_worldmap_corner (int wx, int wy, int *x, int *y, int dir); |
80 | static int polar_distance (int x, int y, int equator); |
74 | static int polar_distance (int x, int y, int equator); |
81 | static void update_humid (void); |
75 | static void update_humid (void); |
82 | static int humid_tile (int x, int y); |
76 | static int humid_tile (int x, int y); |
83 | static void temperature_calc (int x, int y, const timeofday_t * tod); |
77 | static void temperature_calc (int x, int y, const timeofday_t * tod); |
… | |
… | |
348 | /* |
342 | /* |
349 | * Set the darkness level for a map. Requires the map pointer. |
343 | * Set the darkness level for a map. Requires the map pointer. |
350 | */ |
344 | */ |
351 | |
345 | |
352 | void |
346 | void |
353 | set_darkness_map (mapstruct *m) |
347 | set_darkness_map (maptile *m) |
354 | { |
348 | { |
355 | int i; |
349 | int i; |
356 | timeofday_t tod; |
350 | timeofday_t tod; |
357 | |
351 | |
358 | if (!m->outdoor) |
352 | if (!m->outdoor) |
… | |
… | |
372 | */ |
366 | */ |
373 | |
367 | |
374 | static void |
368 | static void |
375 | dawn_to_dusk (const timeofday_t * tod) |
369 | dawn_to_dusk (const timeofday_t * tod) |
376 | { |
370 | { |
377 | mapstruct *m; |
371 | maptile *m; |
378 | |
372 | |
379 | /* If the light level isn't changing, no reason to do all |
373 | /* If the light level isn't changing, no reason to do all |
380 | * the work below. |
374 | * the work below. |
381 | */ |
375 | */ |
382 | if (season_timechange[tod->season][tod->hour] == 0) |
376 | if (season_timechange[tod->season][tod->hour] == 0) |
… | |
… | |
1083 | int x, y, tx, ty, nx, ny, ax, ay, j; |
1077 | int x, y, tx, ty, nx, ny, ax, ay, j; |
1084 | int spwtx, spwty; |
1078 | int spwtx, spwty; |
1085 | const char *mapname; |
1079 | const char *mapname; |
1086 | long int elev; |
1080 | long int elev; |
1087 | int water, space; |
1081 | int water, space; |
1088 | mapstruct *m; |
1082 | maptile *m; |
1089 | |
1083 | |
1090 | /* handling of this is kinda nasty. For that reason, |
1084 | /* handling of this is kinda nasty. For that reason, |
1091 | * we do the elevation here too. Not because it makes the |
1085 | * we do the elevation here too. Not because it makes the |
1092 | * code cleaner, or makes handling easier, but because I do *not* |
1086 | * code cleaner, or makes handling easier, but because I do *not* |
1093 | * want to maintain two of these nightmares. |
1087 | * want to maintain two of these nightmares. |
… | |
… | |
1470 | */ |
1464 | */ |
1471 | |
1465 | |
1472 | static void |
1466 | static void |
1473 | perform_weather (void) |
1467 | perform_weather (void) |
1474 | { |
1468 | { |
1475 | mapstruct *m; |
1469 | maptile *m; |
1476 | char filename[MAX_BUF]; |
1470 | char filename[MAX_BUF]; |
1477 | FILE *fp; |
1471 | FILE *fp; |
1478 | |
1472 | |
1479 | if (!settings.dynamiclevel) |
1473 | if (!settings.dynamiclevel) |
1480 | return; |
1474 | return; |
… | |
… | |
1527 | */ |
1521 | */ |
1528 | |
1522 | |
1529 | void |
1523 | void |
1530 | weather_effect (const char *filename) |
1524 | weather_effect (const char *filename) |
1531 | { |
1525 | { |
1532 | mapstruct *m; |
1526 | maptile *m; |
1533 | int wx, wy, x, y; |
1527 | int wx, wy, x, y; |
1534 | |
1528 | |
1535 | /* if the dm shut off weather, go home */ |
1529 | /* if the dm shut off weather, go home */ |
1536 | if (settings.dynamiclevel < 1) |
1530 | if (settings.dynamiclevel < 1) |
1537 | return; |
1531 | return; |
… | |
… | |
1577 | * Returns the object pointer for any snow item it found, so you can |
1571 | * Returns the object pointer for any snow item it found, so you can |
1578 | * destroy/melt it. |
1572 | * destroy/melt it. |
1579 | */ |
1573 | */ |
1580 | |
1574 | |
1581 | static object * |
1575 | static object * |
1582 | avoid_weather (int *av, mapstruct *m, int x, int y, int *gs, int grow) |
1576 | avoid_weather (int *av, maptile *m, int x, int y, int *gs, int grow) |
1583 | { |
1577 | { |
1584 | int avoid, gotsnow, i, n; |
1578 | int avoid, gotsnow, i, n; |
1585 | |
1579 | |
1586 | object *tmp; |
1580 | object *tmp; |
1587 | |
1581 | |
… | |
… | |
1640 | |
1634 | |
1641 | /* Temperature is used in a lot of weather function. |
1635 | /* Temperature is used in a lot of weather function. |
1642 | * This need to be precalculated before used. |
1636 | * This need to be precalculated before used. |
1643 | */ |
1637 | */ |
1644 | static void |
1638 | static void |
1645 | calculate_temperature (mapstruct *m, int wx, int wy) |
1639 | calculate_temperature (maptile *m, int wx, int wy) |
1646 | { |
1640 | { |
1647 | uint32 x, y; |
1641 | uint32 x, y; |
1648 | |
1642 | |
1649 | for (x = 0; x < settings.worldmaptilesizex; x++) |
1643 | for (x = 0; x < settings.worldmaptilesizex; x++) |
1650 | { |
1644 | { |
… | |
… | |
1661 | * filename is the pathname for the current map. This should be called from |
1655 | * filename is the pathname for the current map. This should be called from |
1662 | * weather_effect() |
1656 | * weather_effect() |
1663 | */ |
1657 | */ |
1664 | |
1658 | |
1665 | static void |
1659 | static void |
1666 | let_it_snow (mapstruct *m, int wx, int wy) |
1660 | let_it_snow (maptile *m, int wx, int wy) |
1667 | { |
1661 | { |
1668 | int x, y, i; |
1662 | int x, y, i; |
1669 | uint32 nx, ny, j, d; |
1663 | uint32 nx, ny, j, d; |
1670 | int avoid, two, temp, sky, gotsnow, found, nodstk; |
1664 | int avoid, two, temp, sky, gotsnow, found, nodstk; |
1671 | const char *doublestack, *doublestack2; |
1665 | const char *doublestack, *doublestack2; |
… | |
… | |
1765 | { |
1759 | { |
1766 | if (!strcmp (oldsnow->arch->name, at->name)) |
1760 | if (!strcmp (oldsnow->arch->name, at->name)) |
1767 | at = NULL; |
1761 | at = NULL; |
1768 | else |
1762 | else |
1769 | { |
1763 | { |
1770 | remove_ob (oldsnow); |
1764 | oldsnow->destroy (); |
1771 | free_object (oldsnow); |
1765 | |
1772 | tmp = GET_MAP_OB (m, x, y); |
1766 | tmp = GET_MAP_OB (m, x, y); |
1773 | /* clean up the trees we put over the snow */ |
1767 | /* clean up the trees we put over the snow */ |
1774 | found = 0; |
1768 | found = 0; |
1775 | doublestack2 = NULL; |
1769 | doublestack2 = NULL; |
1776 | if (tmp) |
1770 | if (tmp) |
1777 | for (i = 0; weather_replace[i].tile != NULL; i++) |
1771 | for (i = 0; weather_replace[i].tile != NULL; i++) |
1778 | { |
1772 | { |
1779 | if (weather_replace[i].doublestack_arch == NULL) |
1773 | if (weather_replace[i].doublestack_arch == NULL) |
1780 | continue; |
1774 | continue; |
|
|
1775 | |
1781 | if (weather_replace[i].arch_or_name == 1) |
1776 | if (weather_replace[i].arch_or_name == 1) |
1782 | { |
1777 | { |
1783 | if (!strcmp (tmp->arch->name, weather_replace[i].tile)) |
1778 | if (!strcmp (tmp->arch->name, weather_replace[i].tile)) |
1784 | found++; |
1779 | found++; |
1785 | } |
1780 | } |
1786 | else |
|
|
1787 | { |
|
|
1788 | if (!strcmp (tmp->name, weather_replace[i].tile)) |
1781 | else if (!strcmp (tmp->name, weather_replace[i].tile)) |
1789 | found++; |
1782 | found++; |
1790 | } |
1783 | |
1791 | if (found) |
1784 | if (found) |
1792 | { |
1785 | { |
1793 | tmp = tmp->above; |
1786 | tmp = tmp->above; |
1794 | doublestack2 = weather_replace[i].doublestack_arch; |
1787 | doublestack2 = weather_replace[i].doublestack_arch; |
1795 | break; |
1788 | break; |
1796 | } |
1789 | } |
1797 | } |
1790 | } |
|
|
1791 | |
1798 | if (tmp != NULL && doublestack2 != NULL) |
1792 | if (tmp != NULL && doublestack2 != NULL) |
1799 | if (strcmp (tmp->arch->name, doublestack2) == 0) |
1793 | if (strcmp (tmp->arch->name, doublestack2) == 0) |
1800 | { |
1794 | tmp->destroy (); |
1801 | remove_ob (tmp); |
|
|
1802 | free_object (tmp); |
|
|
1803 | } |
|
|
1804 | } |
1795 | } |
1805 | } |
1796 | } |
1806 | if (at != NULL) |
1797 | if (at != NULL) |
1807 | { |
1798 | { |
1808 | ob = arch_to_object (at); |
1799 | ob = arch_to_object (at); |
… | |
… | |
1842 | break; |
1833 | break; |
1843 | } |
1834 | } |
1844 | if (avoid) |
1835 | if (avoid) |
1845 | { |
1836 | { |
1846 | /* replace snow with a big puddle */ |
1837 | /* replace snow with a big puddle */ |
1847 | remove_ob (tmp); |
1838 | tmp->destroy (); |
1848 | free_object (tmp); |
|
|
1849 | tmp = GET_MAP_OB (m, x, y); |
1839 | tmp = GET_MAP_OB (m, x, y); |
|
|
1840 | |
1850 | if (tmp && (!strcmp (tmp->arch->name, "mountain"))) |
1841 | if (tmp && (!strcmp (tmp->arch->name, "mountain"))) |
1851 | { |
|
|
1852 | at = archetype::find ("mountain1_rivlets"); |
1842 | at = archetype::find ("mountain1_rivlets"); |
1853 | } |
|
|
1854 | else if (tmp && (!strcmp (tmp->arch->name, "mountain2"))) |
1843 | else if (tmp && (!strcmp (tmp->arch->name, "mountain2"))) |
1855 | { |
|
|
1856 | at = archetype::find ("mountain2_rivlets"); |
1844 | at = archetype::find ("mountain2_rivlets"); |
1857 | } |
|
|
1858 | else if (tmp && (!strcmp (tmp->arch->name, "mountain4"))) |
1845 | else if (tmp && (!strcmp (tmp->arch->name, "mountain4"))) |
1859 | { |
|
|
1860 | at = archetype::find ("mountain2_rivlets"); |
1846 | at = archetype::find ("mountain2_rivlets"); |
1861 | } |
|
|
1862 | else |
1847 | else |
1863 | { |
|
|
1864 | at = archetype::find ("rain5"); |
1848 | at = archetype::find ("rain5"); |
1865 | } |
1849 | |
1866 | if (at != NULL) |
1850 | if (at != NULL) |
1867 | { |
1851 | { |
1868 | ob = arch_to_object (at); |
1852 | ob = arch_to_object (at); |
1869 | ob->x = x; |
1853 | ob->x = x; |
1870 | ob->y = y; |
1854 | ob->y = y; |
… | |
… | |
1912 | * filename is the pathname for the current map. This should be called from |
1896 | * filename is the pathname for the current map. This should be called from |
1913 | * weather_effect() |
1897 | * weather_effect() |
1914 | */ |
1898 | */ |
1915 | |
1899 | |
1916 | static void |
1900 | static void |
1917 | singing_in_the_rain (mapstruct *m, int wx, int wy) |
1901 | singing_in_the_rain (maptile *m, int wx, int wy) |
1918 | { |
1902 | { |
1919 | int x, y, i; |
1903 | int x, y, i; |
1920 | uint32 nx, ny, d, j; |
1904 | uint32 nx, ny, d, j; |
1921 | int avoid, two, temp, sky, gotsnow, found, nodstk; |
1905 | int avoid, two, temp, sky, gotsnow, found, nodstk; |
1922 | object *ob, *tmp, *oldsnow, *topfloor; |
1906 | object *ob, *tmp, *oldsnow, *topfloor; |
… | |
… | |
2055 | if (!strcmp (oldsnow->arch->name, at->name)) |
2039 | if (!strcmp (oldsnow->arch->name, at->name)) |
2056 | at = NULL; |
2040 | at = NULL; |
2057 | else |
2041 | else |
2058 | { |
2042 | { |
2059 | tmp = GET_MAP_OB (m, x, y); |
2043 | tmp = GET_MAP_OB (m, x, y); |
2060 | remove_ob (oldsnow); |
2044 | oldsnow->remove (); |
2061 | /* clean up the trees we put over the snow */ |
2045 | /* clean up the trees we put over the snow */ |
2062 | found = 0; |
2046 | found = 0; |
2063 | doublestack2 = NULL; |
2047 | doublestack2 = NULL; |
2064 | for (i = 0; weather_replace[i].tile != NULL; i++) |
2048 | for (i = 0; weather_replace[i].tile != NULL; i++) |
2065 | { |
2049 | { |
… | |
… | |
2080 | tmp = tmp->above; |
2064 | tmp = tmp->above; |
2081 | doublestack2 = weather_replace[i].doublestack_arch; |
2065 | doublestack2 = weather_replace[i].doublestack_arch; |
2082 | break; |
2066 | break; |
2083 | } |
2067 | } |
2084 | } |
2068 | } |
2085 | free_object (oldsnow); |
2069 | |
|
|
2070 | oldsnow->destroy (); |
|
|
2071 | |
2086 | if (tmp != NULL && doublestack2 != NULL) |
2072 | if (tmp != NULL && doublestack2 != NULL) |
2087 | if (strcmp (tmp->arch->name, doublestack2) == 0) |
2073 | if (strcmp (tmp->arch->name, doublestack2) == 0) |
2088 | { |
2074 | tmp->destroy (); |
2089 | remove_ob (tmp); |
|
|
2090 | free_object (tmp); |
|
|
2091 | } |
|
|
2092 | } |
2075 | } |
2093 | } |
2076 | } |
|
|
2077 | |
2094 | if (at != NULL) |
2078 | if (at != NULL) |
2095 | { |
2079 | { |
2096 | ob = arch_to_object (at); |
2080 | ob = arch_to_object (at); |
2097 | ob->x = x; |
2081 | ob->x = x; |
2098 | ob->y = y; |
2082 | ob->y = y; |
… | |
… | |
2133 | avoid++; |
2117 | avoid++; |
2134 | else if (!strcmp (tmp->arch->name, "mountain2_rivlets")) |
2118 | else if (!strcmp (tmp->arch->name, "mountain2_rivlets")) |
2135 | avoid++; |
2119 | avoid++; |
2136 | if (avoid) |
2120 | if (avoid) |
2137 | { |
2121 | { |
2138 | remove_ob (tmp); |
2122 | tmp->destroy (); |
2139 | free_object (tmp); |
2123 | |
2140 | if (weathermap[wx][wy].humid < 100 && rndm (0, 50) == 0) |
2124 | if (weathermap[wx][wy].humid < 100 && rndm (0, 50) == 0) |
2141 | weathermap[wx][wy].humid++; |
2125 | weathermap[wx][wy].humid++; |
|
|
2126 | |
2142 | tmp = GET_MAP_OB (m, x, y); |
2127 | tmp = GET_MAP_OB (m, x, y); |
2143 | /* clean up the trees we put over the rain */ |
2128 | /* clean up the trees we put over the rain */ |
2144 | found = 0; |
2129 | found = 0; |
2145 | doublestack2 = NULL; |
2130 | doublestack2 = NULL; |
2146 | for (i = 0; weather_replace[i].tile != NULL; i++) |
2131 | for (i = 0; weather_replace[i].tile != NULL; i++) |
… | |
… | |
2150 | if (weather_replace[i].arch_or_name == 1) |
2135 | if (weather_replace[i].arch_or_name == 1) |
2151 | { |
2136 | { |
2152 | if (!strcmp (tmp->arch->name, weather_replace[i].tile)) |
2137 | if (!strcmp (tmp->arch->name, weather_replace[i].tile)) |
2153 | found++; |
2138 | found++; |
2154 | } |
2139 | } |
2155 | else |
|
|
2156 | { |
|
|
2157 | if (!strcmp (tmp->name, weather_replace[i].tile)) |
2140 | else if (!strcmp (tmp->name, weather_replace[i].tile)) |
2158 | found++; |
2141 | found++; |
2159 | } |
2142 | |
2160 | if (found) |
2143 | if (found) |
2161 | { |
2144 | { |
2162 | tmp = tmp->above; |
2145 | tmp = tmp->above; |
2163 | doublestack2 = weather_replace[i].doublestack_arch; |
2146 | doublestack2 = weather_replace[i].doublestack_arch; |
2164 | break; |
2147 | break; |
2165 | } |
2148 | } |
2166 | } |
2149 | } |
|
|
2150 | |
2167 | if (tmp != NULL && doublestack2 != NULL) |
2151 | if (tmp != NULL && doublestack2 != NULL) |
2168 | if (strcmp (tmp->arch->name, doublestack2) == 0) |
2152 | if (strcmp (tmp->arch->name, doublestack2) == 0) |
2169 | { |
2153 | tmp->destroy (); |
2170 | remove_ob (tmp); |
2154 | |
2171 | free_object (tmp); |
|
|
2172 | } |
|
|
2173 | break; |
2155 | break; |
2174 | } |
2156 | } |
2175 | } |
2157 | } |
2176 | } |
2158 | } |
2177 | } |
2159 | } |
… | |
… | |
2184 | * filename is the pathname for the current map. This should be called from |
2166 | * filename is the pathname for the current map. This should be called from |
2185 | * weather_effect() |
2167 | * weather_effect() |
2186 | */ |
2168 | */ |
2187 | |
2169 | |
2188 | static void |
2170 | static void |
2189 | plant_a_garden (mapstruct *m, int wx, int wy) |
2171 | plant_a_garden (maptile *m, int wx, int wy) |
2190 | { |
2172 | { |
2191 | uint32 x, y, i; |
2173 | uint32 x, y, i; |
2192 | int avoid, two, temp, sky, gotsnow, found, days; |
2174 | int avoid, two, temp, sky, gotsnow, found, days; |
2193 | object *ob, *tmp; |
2175 | object *ob, *tmp; |
2194 | archetype *at; |
2176 | archetype *at; |
… | |
… | |
2226 | temp < weather_grow[i].tempmin || |
2208 | temp < weather_grow[i].tempmin || |
2227 | temp > weather_grow[i].tempmax || rndm (0, MIN (weather_grow[i].random / 2, 1)) == 0) |
2209 | temp > weather_grow[i].tempmax || rndm (0, MIN (weather_grow[i].random / 2, 1)) == 0) |
2228 | { |
2210 | { |
2229 | /* the herb does not belong, randomly delete |
2211 | /* the herb does not belong, randomly delete |
2230 | herbs to prevent overgrowth. */ |
2212 | herbs to prevent overgrowth. */ |
2231 | remove_ob (tmp); |
2213 | tmp->destroy (); |
2232 | free_object (tmp); |
|
|
2233 | break; |
2214 | break; |
2234 | } |
2215 | } |
2235 | } |
2216 | } |
2236 | /* don't doublestack herbs */ |
2217 | /* don't doublestack herbs */ |
2237 | if (found) |
2218 | if (found) |
… | |
… | |
2288 | * the weathermap coordinates for the weathermap square we want to work on. |
2269 | * the weathermap coordinates for the weathermap square we want to work on. |
2289 | * This should be called from weather_effect() |
2270 | * This should be called from weather_effect() |
2290 | */ |
2271 | */ |
2291 | |
2272 | |
2292 | static void |
2273 | static void |
2293 | change_the_world (mapstruct *m, int wx, int wy) |
2274 | change_the_world (maptile *m, int wx, int wy) |
2294 | { |
2275 | { |
2295 | int x, y, i; |
2276 | int x, y, i; |
2296 | uint32 nx, ny, j, d; |
2277 | uint32 nx, ny, j, d; |
2297 | int avoid, two, temp, sky, gotsnow, found, days; |
2278 | int avoid, two, temp, sky, gotsnow, found, days; |
2298 | object *ob, *tmp, *doublestack; |
2279 | object *ob, *tmp, *doublestack; |
… | |
… | |
2358 | (float) weathermap[wx][wy].rainfall / days > weather_tile[i].rfmax || |
2339 | (float) weathermap[wx][wy].rainfall / days > weather_tile[i].rfmax || |
2359 | weathermap[wx][wy].humid < weather_tile[i].humin || |
2340 | weathermap[wx][wy].humid < weather_tile[i].humin || |
2360 | weathermap[wx][wy].humid > weather_tile[i].humax || |
2341 | weathermap[wx][wy].humid > weather_tile[i].humax || |
2361 | temp < weather_tile[i].tempmin || temp > weather_tile[i].tempmax) |
2342 | temp < weather_tile[i].tempmin || temp > weather_tile[i].tempmax) |
2362 | { |
2343 | { |
2363 | remove_ob (tmp); |
2344 | tmp->destroy (); |
2364 | free_object (tmp); |
2345 | |
2365 | if (doublestack) |
2346 | if (doublestack) |
2366 | { |
|
|
2367 | remove_ob (doublestack); |
2347 | doublestack->destroy (); |
2368 | free_object (doublestack); |
2348 | |
2369 | } |
|
|
2370 | break; |
2349 | break; |
2371 | } |
2350 | } |
2372 | else |
2351 | else |
2373 | { |
2352 | { |
2374 | found++; /* there is one here allready. leave it */ |
2353 | found++; /* there is one here allready. leave it */ |
… | |
… | |
2432 | * the weathermap coordinates for the weathermap square we want to work on. |
2411 | * the weathermap coordinates for the weathermap square we want to work on. |
2433 | * This should be called from weather_effect() |
2412 | * This should be called from weather_effect() |
2434 | */ |
2413 | */ |
2435 | #if 0 |
2414 | #if 0 |
2436 | static void |
2415 | static void |
2437 | feather_map (mapstruct *m, int wx, int wy) |
2416 | feather_map (maptile *m, int wx, int wy) |
2438 | { |
2417 | { |
2439 | uint32 x, y, i, nx, ny, j; |
2418 | uint32 x, y, i, nx, ny, j; |
2440 | int avoid, two, gotsnow, nodstk; |
2419 | int avoid, two, gotsnow, nodstk; |
2441 | object *ob, *tmp, *oldsnow, *topfloor, *ntmp, *ntopfloor; |
2420 | object *ob, *tmp, *oldsnow, *topfloor, *ntmp, *ntopfloor; |
2442 | archetype *at; |
2421 | archetype *at; |
… | |
… | |
2488 | if (!QUERY_FLAG (ntmp, FLAG_IS_FLOOR) && !QUERY_FLAG (ntmp, FLAG_OVERLAY_FLOOR)) |
2467 | if (!QUERY_FLAG (ntmp, FLAG_IS_FLOOR) && !QUERY_FLAG (ntmp, FLAG_OVERLAY_FLOOR)) |
2489 | break; |
2468 | break; |
2490 | } |
2469 | } |
2491 | if (ntopfloor != NULL && QUERY_FLAG (ntopfloor, FLAG_IS_FLOOR)) |
2470 | if (ntopfloor != NULL && QUERY_FLAG (ntopfloor, FLAG_IS_FLOOR)) |
2492 | { |
2471 | { |
2493 | remove_ob (topfloor); |
2472 | topfloor->destroy (); |
2494 | free_object (topfloor); |
|
|
2495 | if (tmp != NULL) |
2473 | if (tmp != NULL) |
2496 | { |
2474 | { |
2497 | for (i = 0; weather_tile[i].herb != NULL; i++) |
2475 | for (i = 0; weather_tile[i].herb != NULL; i++) |
2498 | { |
2476 | { |
2499 | if (strcmp (tmp->arch->name, weather_tile[i].herb) == 0) |
2477 | if (strcmp (tmp->arch->name, weather_tile[i].herb) == 0) |
2500 | { |
2478 | { |
2501 | remove_ob (tmp); |
2479 | tmp->destroy (); |
2502 | free_object (tmp); |
|
|
2503 | break; |
2480 | break; |
2504 | } |
2481 | } |
2505 | } |
2482 | } |
2506 | } |
2483 | } |
2507 | } |
2484 | } |
… | |
… | |
2536 | the current mapname (must be a worldmap), and your coordinates on the |
2513 | the current mapname (must be a worldmap), and your coordinates on the |
2537 | map. returns -1 if you give it something it can't figure out. 0 normally. |
2514 | map. returns -1 if you give it something it can't figure out. 0 normally. |
2538 | */ |
2515 | */ |
2539 | |
2516 | |
2540 | int |
2517 | int |
2541 | worldmap_to_weathermap (int x, int y, int *wx, int *wy, mapstruct *m) |
2518 | worldmap_to_weathermap (int x, int y, int *wx, int *wy, maptile *m) |
2542 | { |
2519 | { |
2543 | int spwtx, spwty; |
2520 | int spwtx, spwty; |
2544 | uint32 fx, fy; |
2521 | uint32 fx, fy; |
2545 | uint32 nx, ny; |
2522 | uint32 nx, ny; |
2546 | char *filename = m->path; |
2523 | char *filename = m->path; |
… | |
… | |
2549 | spwty = (settings.worldmaptilesy * settings.worldmaptilesizey) / WEATHERMAPTILESY; |
2526 | spwty = (settings.worldmaptilesy * settings.worldmaptilesizey) / WEATHERMAPTILESY; |
2550 | |
2527 | |
2551 | while (*filename == '/') |
2528 | while (*filename == '/') |
2552 | *filename++; |
2529 | *filename++; |
2553 | |
2530 | |
2554 | fx = MAP_WORLDPARTX (m); |
2531 | fx = m->worldpartx; |
2555 | fy = MAP_WORLDPARTY (m); |
2532 | fy = m->worldparty; |
2556 | if (fx > settings.worldmapstartx + settings.worldmaptilesx || |
2533 | if (fx > settings.worldmapstartx + settings.worldmaptilesx || |
2557 | fx < settings.worldmapstartx || fy > settings.worldmapstarty + settings.worldmaptilesy || fy < settings.worldmapstarty) |
2534 | fx < settings.worldmapstartx || fy > settings.worldmapstarty + settings.worldmaptilesy || fy < settings.worldmapstarty) |
2558 | { |
2535 | { |
2559 | LOG (llevDebug, "worldmap_to_weathermap(%s)\n", filename); |
2536 | LOG (llevDebug, "worldmap_to_weathermap(%s)\n", filename); |
2560 | sscanf (filename, "world/world_%d_%d", &fx, &fy); |
2537 | sscanf (filename, "world/world_%d_%d", &fx, &fy); |
2561 | MAP_WORLDPARTX (m) = fx; |
2538 | m->worldpartx = fx; |
2562 | MAP_WORLDPARTY (m) = fy; |
2539 | m->worldparty = fy; |
2563 | } |
2540 | } |
2564 | if (fx > settings.worldmapstartx + settings.worldmaptilesx || fx < settings.worldmapstartx) |
2541 | if (fx > settings.worldmapstartx + settings.worldmaptilesx || fx < settings.worldmapstartx) |
2565 | return -1; |
2542 | return -1; |
2566 | if (fy > settings.worldmapstarty + settings.worldmaptilesy || fy < settings.worldmapstarty) |
2543 | if (fy > settings.worldmapstarty + settings.worldmaptilesy || fy < settings.worldmapstarty) |
2567 | return -1; |
2544 | return -1; |
… | |
… | |
2789 | /* Given a worldmap name, and x and y on that map, compute the temperature |
2766 | /* Given a worldmap name, and x and y on that map, compute the temperature |
2790 | for a specific square. Used to normalize elevation. |
2767 | for a specific square. Used to normalize elevation. |
2791 | */ |
2768 | */ |
2792 | |
2769 | |
2793 | int |
2770 | int |
2794 | real_world_temperature (int x, int y, mapstruct *m) |
2771 | real_world_temperature (int x, int y, maptile *m) |
2795 | { |
2772 | { |
2796 | int wx, wy, temp, eleva, elevb; |
2773 | int wx, wy, temp, eleva, elevb; |
2797 | object *op; |
2774 | object *op; |
2798 | |
2775 | |
2799 | /*LOG(llevDebug, "real_world_temperature: worldmaptoweathermap : %s\n",m->path); */ |
2776 | /*LOG(llevDebug, "real_world_temperature: worldmaptoweathermap : %s\n",m->path); */ |