… | |
… | |
1759 | { |
1759 | { |
1760 | if (!strcmp (oldsnow->arch->name, at->name)) |
1760 | if (!strcmp (oldsnow->arch->name, at->name)) |
1761 | at = NULL; |
1761 | at = NULL; |
1762 | else |
1762 | else |
1763 | { |
1763 | { |
1764 | remove_ob (oldsnow); |
1764 | oldsnow->destroy (); |
1765 | free_object (oldsnow); |
1765 | |
1766 | tmp = GET_MAP_OB (m, x, y); |
1766 | tmp = GET_MAP_OB (m, x, y); |
1767 | /* clean up the trees we put over the snow */ |
1767 | /* clean up the trees we put over the snow */ |
1768 | found = 0; |
1768 | found = 0; |
1769 | doublestack2 = NULL; |
1769 | doublestack2 = NULL; |
1770 | if (tmp) |
1770 | if (tmp) |
1771 | for (i = 0; weather_replace[i].tile != NULL; i++) |
1771 | for (i = 0; weather_replace[i].tile != NULL; i++) |
1772 | { |
1772 | { |
1773 | if (weather_replace[i].doublestack_arch == NULL) |
1773 | if (weather_replace[i].doublestack_arch == NULL) |
1774 | continue; |
1774 | continue; |
|
|
1775 | |
1775 | if (weather_replace[i].arch_or_name == 1) |
1776 | if (weather_replace[i].arch_or_name == 1) |
1776 | { |
1777 | { |
1777 | if (!strcmp (tmp->arch->name, weather_replace[i].tile)) |
1778 | if (!strcmp (tmp->arch->name, weather_replace[i].tile)) |
1778 | found++; |
1779 | found++; |
1779 | } |
1780 | } |
1780 | else |
|
|
1781 | { |
|
|
1782 | if (!strcmp (tmp->name, weather_replace[i].tile)) |
1781 | else if (!strcmp (tmp->name, weather_replace[i].tile)) |
1783 | found++; |
1782 | found++; |
1784 | } |
1783 | |
1785 | if (found) |
1784 | if (found) |
1786 | { |
1785 | { |
1787 | tmp = tmp->above; |
1786 | tmp = tmp->above; |
1788 | doublestack2 = weather_replace[i].doublestack_arch; |
1787 | doublestack2 = weather_replace[i].doublestack_arch; |
1789 | break; |
1788 | break; |
1790 | } |
1789 | } |
1791 | } |
1790 | } |
|
|
1791 | |
1792 | if (tmp != NULL && doublestack2 != NULL) |
1792 | if (tmp != NULL && doublestack2 != NULL) |
1793 | if (strcmp (tmp->arch->name, doublestack2) == 0) |
1793 | if (strcmp (tmp->arch->name, doublestack2) == 0) |
1794 | { |
1794 | tmp->destroy (); |
1795 | remove_ob (tmp); |
|
|
1796 | free_object (tmp); |
|
|
1797 | } |
|
|
1798 | } |
1795 | } |
1799 | } |
1796 | } |
1800 | if (at != NULL) |
1797 | if (at != NULL) |
1801 | { |
1798 | { |
1802 | ob = arch_to_object (at); |
1799 | ob = arch_to_object (at); |
… | |
… | |
1836 | break; |
1833 | break; |
1837 | } |
1834 | } |
1838 | if (avoid) |
1835 | if (avoid) |
1839 | { |
1836 | { |
1840 | /* replace snow with a big puddle */ |
1837 | /* replace snow with a big puddle */ |
1841 | remove_ob (tmp); |
1838 | tmp->destroy (); |
1842 | free_object (tmp); |
|
|
1843 | tmp = GET_MAP_OB (m, x, y); |
1839 | tmp = GET_MAP_OB (m, x, y); |
|
|
1840 | |
1844 | if (tmp && (!strcmp (tmp->arch->name, "mountain"))) |
1841 | if (tmp && (!strcmp (tmp->arch->name, "mountain"))) |
1845 | { |
|
|
1846 | at = archetype::find ("mountain1_rivlets"); |
1842 | at = archetype::find ("mountain1_rivlets"); |
1847 | } |
|
|
1848 | else if (tmp && (!strcmp (tmp->arch->name, "mountain2"))) |
1843 | else if (tmp && (!strcmp (tmp->arch->name, "mountain2"))) |
1849 | { |
|
|
1850 | at = archetype::find ("mountain2_rivlets"); |
1844 | at = archetype::find ("mountain2_rivlets"); |
1851 | } |
|
|
1852 | else if (tmp && (!strcmp (tmp->arch->name, "mountain4"))) |
1845 | else if (tmp && (!strcmp (tmp->arch->name, "mountain4"))) |
1853 | { |
|
|
1854 | at = archetype::find ("mountain2_rivlets"); |
1846 | at = archetype::find ("mountain2_rivlets"); |
1855 | } |
|
|
1856 | else |
1847 | else |
1857 | { |
|
|
1858 | at = archetype::find ("rain5"); |
1848 | at = archetype::find ("rain5"); |
1859 | } |
1849 | |
1860 | if (at != NULL) |
1850 | if (at != NULL) |
1861 | { |
1851 | { |
1862 | ob = arch_to_object (at); |
1852 | ob = arch_to_object (at); |
1863 | ob->x = x; |
1853 | ob->x = x; |
1864 | ob->y = y; |
1854 | ob->y = y; |
… | |
… | |
2049 | if (!strcmp (oldsnow->arch->name, at->name)) |
2039 | if (!strcmp (oldsnow->arch->name, at->name)) |
2050 | at = NULL; |
2040 | at = NULL; |
2051 | else |
2041 | else |
2052 | { |
2042 | { |
2053 | tmp = GET_MAP_OB (m, x, y); |
2043 | tmp = GET_MAP_OB (m, x, y); |
2054 | remove_ob (oldsnow); |
2044 | oldsnow->remove (); |
2055 | /* clean up the trees we put over the snow */ |
2045 | /* clean up the trees we put over the snow */ |
2056 | found = 0; |
2046 | found = 0; |
2057 | doublestack2 = NULL; |
2047 | doublestack2 = NULL; |
2058 | for (i = 0; weather_replace[i].tile != NULL; i++) |
2048 | for (i = 0; weather_replace[i].tile != NULL; i++) |
2059 | { |
2049 | { |
… | |
… | |
2074 | tmp = tmp->above; |
2064 | tmp = tmp->above; |
2075 | doublestack2 = weather_replace[i].doublestack_arch; |
2065 | doublestack2 = weather_replace[i].doublestack_arch; |
2076 | break; |
2066 | break; |
2077 | } |
2067 | } |
2078 | } |
2068 | } |
2079 | free_object (oldsnow); |
2069 | |
|
|
2070 | oldsnow->destroy (); |
|
|
2071 | |
2080 | if (tmp != NULL && doublestack2 != NULL) |
2072 | if (tmp != NULL && doublestack2 != NULL) |
2081 | if (strcmp (tmp->arch->name, doublestack2) == 0) |
2073 | if (strcmp (tmp->arch->name, doublestack2) == 0) |
2082 | { |
2074 | tmp->destroy (); |
2083 | remove_ob (tmp); |
|
|
2084 | free_object (tmp); |
|
|
2085 | } |
|
|
2086 | } |
2075 | } |
2087 | } |
2076 | } |
|
|
2077 | |
2088 | if (at != NULL) |
2078 | if (at != NULL) |
2089 | { |
2079 | { |
2090 | ob = arch_to_object (at); |
2080 | ob = arch_to_object (at); |
2091 | ob->x = x; |
2081 | ob->x = x; |
2092 | ob->y = y; |
2082 | ob->y = y; |
… | |
… | |
2127 | avoid++; |
2117 | avoid++; |
2128 | else if (!strcmp (tmp->arch->name, "mountain2_rivlets")) |
2118 | else if (!strcmp (tmp->arch->name, "mountain2_rivlets")) |
2129 | avoid++; |
2119 | avoid++; |
2130 | if (avoid) |
2120 | if (avoid) |
2131 | { |
2121 | { |
2132 | remove_ob (tmp); |
2122 | tmp->destroy (); |
2133 | free_object (tmp); |
2123 | |
2134 | if (weathermap[wx][wy].humid < 100 && rndm (0, 50) == 0) |
2124 | if (weathermap[wx][wy].humid < 100 && rndm (0, 50) == 0) |
2135 | weathermap[wx][wy].humid++; |
2125 | weathermap[wx][wy].humid++; |
|
|
2126 | |
2136 | tmp = GET_MAP_OB (m, x, y); |
2127 | tmp = GET_MAP_OB (m, x, y); |
2137 | /* clean up the trees we put over the rain */ |
2128 | /* clean up the trees we put over the rain */ |
2138 | found = 0; |
2129 | found = 0; |
2139 | doublestack2 = NULL; |
2130 | doublestack2 = NULL; |
2140 | for (i = 0; weather_replace[i].tile != NULL; i++) |
2131 | for (i = 0; weather_replace[i].tile != NULL; i++) |
… | |
… | |
2144 | if (weather_replace[i].arch_or_name == 1) |
2135 | if (weather_replace[i].arch_or_name == 1) |
2145 | { |
2136 | { |
2146 | if (!strcmp (tmp->arch->name, weather_replace[i].tile)) |
2137 | if (!strcmp (tmp->arch->name, weather_replace[i].tile)) |
2147 | found++; |
2138 | found++; |
2148 | } |
2139 | } |
2149 | else |
|
|
2150 | { |
|
|
2151 | if (!strcmp (tmp->name, weather_replace[i].tile)) |
2140 | else if (!strcmp (tmp->name, weather_replace[i].tile)) |
2152 | found++; |
2141 | found++; |
2153 | } |
2142 | |
2154 | if (found) |
2143 | if (found) |
2155 | { |
2144 | { |
2156 | tmp = tmp->above; |
2145 | tmp = tmp->above; |
2157 | doublestack2 = weather_replace[i].doublestack_arch; |
2146 | doublestack2 = weather_replace[i].doublestack_arch; |
2158 | break; |
2147 | break; |
2159 | } |
2148 | } |
2160 | } |
2149 | } |
|
|
2150 | |
2161 | if (tmp != NULL && doublestack2 != NULL) |
2151 | if (tmp != NULL && doublestack2 != NULL) |
2162 | if (strcmp (tmp->arch->name, doublestack2) == 0) |
2152 | if (strcmp (tmp->arch->name, doublestack2) == 0) |
2163 | { |
2153 | tmp->destroy (); |
2164 | remove_ob (tmp); |
2154 | |
2165 | free_object (tmp); |
|
|
2166 | } |
|
|
2167 | break; |
2155 | break; |
2168 | } |
2156 | } |
2169 | } |
2157 | } |
2170 | } |
2158 | } |
2171 | } |
2159 | } |
… | |
… | |
2220 | temp < weather_grow[i].tempmin || |
2208 | temp < weather_grow[i].tempmin || |
2221 | 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) |
2222 | { |
2210 | { |
2223 | /* the herb does not belong, randomly delete |
2211 | /* the herb does not belong, randomly delete |
2224 | herbs to prevent overgrowth. */ |
2212 | herbs to prevent overgrowth. */ |
2225 | remove_ob (tmp); |
2213 | tmp->destroy (); |
2226 | free_object (tmp); |
|
|
2227 | break; |
2214 | break; |
2228 | } |
2215 | } |
2229 | } |
2216 | } |
2230 | /* don't doublestack herbs */ |
2217 | /* don't doublestack herbs */ |
2231 | if (found) |
2218 | if (found) |
… | |
… | |
2352 | (float) weathermap[wx][wy].rainfall / days > weather_tile[i].rfmax || |
2339 | (float) weathermap[wx][wy].rainfall / days > weather_tile[i].rfmax || |
2353 | weathermap[wx][wy].humid < weather_tile[i].humin || |
2340 | weathermap[wx][wy].humid < weather_tile[i].humin || |
2354 | weathermap[wx][wy].humid > weather_tile[i].humax || |
2341 | weathermap[wx][wy].humid > weather_tile[i].humax || |
2355 | temp < weather_tile[i].tempmin || temp > weather_tile[i].tempmax) |
2342 | temp < weather_tile[i].tempmin || temp > weather_tile[i].tempmax) |
2356 | { |
2343 | { |
2357 | remove_ob (tmp); |
2344 | tmp->destroy (); |
2358 | free_object (tmp); |
2345 | |
2359 | if (doublestack) |
2346 | if (doublestack) |
2360 | { |
|
|
2361 | remove_ob (doublestack); |
2347 | doublestack->destroy (); |
2362 | free_object (doublestack); |
2348 | |
2363 | } |
|
|
2364 | break; |
2349 | break; |
2365 | } |
2350 | } |
2366 | else |
2351 | else |
2367 | { |
2352 | { |
2368 | found++; /* there is one here allready. leave it */ |
2353 | found++; /* there is one here allready. leave it */ |
… | |
… | |
2482 | 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)) |
2483 | break; |
2468 | break; |
2484 | } |
2469 | } |
2485 | if (ntopfloor != NULL && QUERY_FLAG (ntopfloor, FLAG_IS_FLOOR)) |
2470 | if (ntopfloor != NULL && QUERY_FLAG (ntopfloor, FLAG_IS_FLOOR)) |
2486 | { |
2471 | { |
2487 | remove_ob (topfloor); |
2472 | topfloor->destroy (); |
2488 | free_object (topfloor); |
|
|
2489 | if (tmp != NULL) |
2473 | if (tmp != NULL) |
2490 | { |
2474 | { |
2491 | for (i = 0; weather_tile[i].herb != NULL; i++) |
2475 | for (i = 0; weather_tile[i].herb != NULL; i++) |
2492 | { |
2476 | { |
2493 | if (strcmp (tmp->arch->name, weather_tile[i].herb) == 0) |
2477 | if (strcmp (tmp->arch->name, weather_tile[i].herb) == 0) |
2494 | { |
2478 | { |
2495 | remove_ob (tmp); |
2479 | tmp->destroy (); |
2496 | free_object (tmp); |
|
|
2497 | break; |
2480 | break; |
2498 | } |
2481 | } |
2499 | } |
2482 | } |
2500 | } |
2483 | } |
2501 | } |
2484 | } |
… | |
… | |
2543 | spwty = (settings.worldmaptilesy * settings.worldmaptilesizey) / WEATHERMAPTILESY; |
2526 | spwty = (settings.worldmaptilesy * settings.worldmaptilesizey) / WEATHERMAPTILESY; |
2544 | |
2527 | |
2545 | while (*filename == '/') |
2528 | while (*filename == '/') |
2546 | *filename++; |
2529 | *filename++; |
2547 | |
2530 | |
2548 | fx = MAP_WORLDPARTX (m); |
2531 | fx = m->worldpartx; |
2549 | fy = MAP_WORLDPARTY (m); |
2532 | fy = m->worldparty; |
2550 | if (fx > settings.worldmapstartx + settings.worldmaptilesx || |
2533 | if (fx > settings.worldmapstartx + settings.worldmaptilesx || |
2551 | fx < settings.worldmapstartx || fy > settings.worldmapstarty + settings.worldmaptilesy || fy < settings.worldmapstarty) |
2534 | fx < settings.worldmapstartx || fy > settings.worldmapstarty + settings.worldmaptilesy || fy < settings.worldmapstarty) |
2552 | { |
2535 | { |
2553 | LOG (llevDebug, "worldmap_to_weathermap(%s)\n", filename); |
2536 | LOG (llevDebug, "worldmap_to_weathermap(%s)\n", filename); |
2554 | sscanf (filename, "world/world_%d_%d", &fx, &fy); |
2537 | sscanf (filename, "world/world_%d_%d", &fx, &fy); |
2555 | MAP_WORLDPARTX (m) = fx; |
2538 | m->worldpartx = fx; |
2556 | MAP_WORLDPARTY (m) = fy; |
2539 | m->worldparty = fy; |
2557 | } |
2540 | } |
2558 | if (fx > settings.worldmapstartx + settings.worldmaptilesx || fx < settings.worldmapstartx) |
2541 | if (fx > settings.worldmapstartx + settings.worldmaptilesx || fx < settings.worldmapstartx) |
2559 | return -1; |
2542 | return -1; |
2560 | if (fy > settings.worldmapstarty + settings.worldmaptilesy || fy < settings.worldmapstarty) |
2543 | if (fy > settings.worldmapstarty + settings.worldmaptilesy || fy < settings.worldmapstarty) |
2561 | return -1; |
2544 | return -1; |