38 #include "../noble/noble.h"
42 #include "..\noble\noble.h"
79 n_int map_dimensions2;
82 NA_ASSERT(local_land,
"local_weather NULL");
87 if (map_bits2 < 0)
return 0;
89 while (lx < map_dimensions2)
92 while (ly < map_dimensions2)
99 average = average >> map_bits2;
106 static void weather_wrap(
n_c_int * section)
108 const n_int bits_neg = (-131072 * 254) / 256;
109 const n_int bits_pos = ( 131071 * 254) / 256;
110 n_int max = bits_neg;
111 n_int min = bits_pos;
116 n_c_int value = section[placement++];
127 if ((min < bits_neg) || (max > bits_pos))
132 n_c_int value = section[placement];
133 section[placement++] = (value * 253) / 256;
144 n_int map_dimensions2;
147 NA_ASSERT(local_land,
"local_land NULL");
151 if (map_bits2 < 0)
return;
153 local_delta = weather_delta(local_land);
157 NA_ASSERT(atmosphere,
"atmosphere NULL");
158 NA_ASSERT(delta_pressure,
"delta_pressure NULL");
160 if (atmosphere == 0L)
return;
161 if (delta_pressure == 0L)
return;
163 while ( ly < map_dimensions2 )
165 n_int ly_min = ((ly + (map_dimensions2-1) ) & ((map_dimensions2)-1)) * map_dimensions2;
166 n_int ly_plu = ((ly + 1 ) & (map_dimensions2-1)) * map_dimensions2;
167 n_int ly_neu = ly * map_dimensions2;
169 while ( lx < map_dimensions2 )
172 ((
n_int)delta_pressure[ lx | ly_neu ] << map_bits2)
174 - atmosphere[ ((lx + 1 ) & (map_dimensions2-1)) | ly_neu ]
175 + atmosphere[ ((lx + (map_dimensions2-1) ) & ((map_dimensions2)-1)) | ly_neu ]
176 - atmosphere[ lx | ly_plu ]
177 + atmosphere[ lx | ly_min ];
179 atmosphere[ lx | ly_neu ] += (local_atm - local_delta) >> map_bits2;
185 weather_wrap(atmosphere);
194 n_int map_dimension2;
197 NA_ASSERT(local_land,
"local_land NULL");
199 if (local_land == 0L)
return;
205 if (map_bits2 < 0)
return;
207 NA_ASSERT(atmosphere,
"atmosphere NULL");
208 NA_ASSERT(delta_pressure,
"delta_pressure NULL");
212 while ( ly < map_dimension2 )
216 while ( lx < map_dimension2 )
225 atmosphere[ (map_dimension2 * ly) + lx ] = (
n_c_int)total_land;
231 while ( ly < (map_dimension2) )
234 n_uint ly_plu = ((ly + 1 ) & ((map_dimension2)-1)) * map_dimension2;
235 n_uint ly_min = ((ly + (map_dimension2-1)) & (map_dimension2-1)) * map_dimension2;
236 n_uint ly_neu = (ly * map_dimension2);
237 while ( lx < (map_dimension2) )
239 delta_pressure[ ly_neu + lx ]
240 = (
n_byte2)(atmosphere[ (( lx + 1 ) & ((map_dimension2)-1)) + ly_neu]
241 - atmosphere[(( lx + ((map_dimension2)-1) ) & ((map_dimension2)-1)) + ly_neu]
242 + atmosphere[ lx + ly_plu ]
243 - atmosphere[ lx + ly_min ]
251 while( ly < (map_dimension2 * map_dimension2))
253 atmosphere[ ly ] = 0;
257 while( ly < (map_dimension2 * 2))
268 n_int tpx = ((px/2) + dimension2) % dimension2;
269 n_int tpy = ((py/2) + dimension2) % dimension2;
271 return land->
atmosphere[(dimension2 * tpy) + tpx];
276 n_int local_pressure;
277 NA_ASSERT(local_land,
"local_land NULL");
281 if (pos == 0L)
return;
282 if (wind == 0L)
return;
297 NA_ASSERT(local_land,
"local_land NULL");
299 local_time = local_land->
time;
354 NA_ASSERT(local_land,
"local_land NULL");
356 time_of_day = local_land->
time;
368 NA_ASSERT((((
WATER_MAP + lunar + solar) > -1) && ((
WATER_MAP + lunar + solar) < 256)),
"(WATER_MAP + lunar + solar) outside byte boundaries");
376 NA_ASSERT(local_land,
"local_land NULL");
378 if (local_land == 0L)
return;
383 local_land->
time = 0;
391 #define OPERATOR_AREA(fg, dfg, fdg) ((((dfg) * (dfg)) + ((fdg) * (fdg))) >> 6)
392 #define OPERATOR_HEIGHT(fg, dfg, fdg) (((WATER_MAP + fg) * (WATER_MAP + fg)) >> 8 )
393 #define OPERATOR_WATER(fg, dfg, fdg) (((WATER_MAP - fg) * (WATER_MAP - fg)) >> 8 )
394 #define OPERATOR_SUN(fg, dfg, fdg, ct, st) (((((ct) * (fg)) + ((st) * (dfg))) >> 4) + WATER_MAP)
395 #define OPERATOR_SALT(fg, dfg, fdg, fs) (((fs*fs)+(dfg*fdg))>>4)
397 #define WATER_MAP2 (WATER_MAP * 2)
401 n_int temp = 0, temp_add;
402 n_int number_sum = 0;
408 NA_ASSERT(local_land,
"local_land NULL");
409 NA_ASSERT(specific_kind,
"specific_kind NULL");
415 dfg = (dfg - fg) * 8;
416 fdg = (fdg - fg) * 8;
420 if(specific_kind[0] !=
'.')
424 if(specific_kind[0] ==
'+')
429 if(specific_kind[1] !=
'.')
433 if(specific_kind[1] ==
'+')
438 if(specific_kind[2] !=
'.')
442 if(specific_kind[2] ==
'+')
447 if(specific_kind[3] !=
'.')
452 n_int hr = ((((local_land->
time << 6) / 180) + 32) & 255);
456 n_int weather_divide = (105 + ((weather % 3) * 30));
460 vect2_offset(&time_weather, 840/ weather_divide, 840/ weather_divide);
463 temp_add =
OPERATOR_SUN(fg, dfg, fdg, time_weather.
x, time_weather.
y);
464 if(specific_kind[3] ==
'+')
470 if(specific_kind[4] !=
'.')
474 if(specific_kind[4] ==
'+')
479 if(specific_kind[5] !=
'.')
484 if(specific_kind[5] ==
'+') temp=0;
489 if(specific_kind[5] ==
'+')
493 NA_ASSERT(number_sum,
"number_sum is ZERO");
496 temp = temp / number_sum;
503 NA_ASSERT(local_land,
"local_land NULL");
514 land_operator(local_land, (map_x+1)&(map_dimension-1), map_y, kind)*(locx-
MAPSPACE_TO_APESPACE(map_x)));
516 land_operator(local_land, (map_x-1)&(map_dimension-1), map_y, kind)*(
MAPSPACE_TO_APESPACE(map_x+1)-locx));
518 land_operator(local_land, map_x, (map_y+1)&(map_dimension-1), kind)*(locy-
MAPSPACE_TO_APESPACE(map_y)));
520 land_operator(local_land, map_x, (map_y-1)&(map_dimension-1), kind)*(
MAPSPACE_TO_APESPACE(map_y+1)-locy));
521 return interpolated >> 1;
528 if (local == 0L)
return;
534 if (local_map == 0L)
return;
538 local_map[loop] = 128;
554 local_random[0] = local_land->
genetics[0];
555 local_random[1] = local_land->
genetics[1];
578 n_byte val = local_hires[lp<<1];
579 if ((val > 105) && (val < 151))
581 value_setting |= 1 << (lp & 31);
586 local_hires_tides[lp>>5] = value_setting;
606 if (output == 0L)
return;
607 if (local == 0L)
return;
608 if (location == 0L)
return;
667 set->location[0] = location[0];
668 set->location[1] = location[1];
669 set->time = local->
time;
670 set->date = local->
date;