… | |
… | |
366 | */ |
366 | */ |
367 | |
367 | |
368 | static void |
368 | static void |
369 | dawn_to_dusk (const timeofday_t * tod) |
369 | dawn_to_dusk (const timeofday_t * tod) |
370 | { |
370 | { |
371 | maptile *m; |
|
|
372 | |
|
|
373 | /* If the light level isn't changing, no reason to do all |
371 | /* If the light level isn't changing, no reason to do all |
374 | * the work below. |
372 | * the work below. |
375 | */ |
373 | */ |
376 | if (season_timechange[tod->season][tod->hour] == 0) |
374 | if (season_timechange[tod->season][tod->hour] == 0) |
377 | return; |
375 | return; |
378 | |
376 | |
379 | for (m = first_map; m != NULL; m = m->next) |
377 | for_all_maps (m) |
380 | { |
|
|
381 | if (!m->outdoor) |
378 | if (m->outdoor) |
382 | continue; |
|
|
383 | change_map_light (m, season_timechange[tod->season][tod->hour]); |
379 | change_map_light (m, season_timechange[tod->season][tod->hour]); |
384 | } |
|
|
385 | } |
380 | } |
386 | |
381 | |
387 | /* |
382 | /* |
388 | * This performs the basic function of advancing the clock one tick |
383 | * This performs the basic function of advancing the clock one tick |
389 | * forward. Every 20 ticks, the clock is saved to disk. It is also |
384 | * forward. Every 20 ticks, the clock is saved to disk. It is also |
390 | * saved on shutdown. Any time dependant functions should be called |
385 | * saved on shutdown. Any time dependant functions should be called |
391 | * from this function, and probably be passed tod as an argument. |
386 | * from this function, and probably be passed tod as an argument. |
392 | * Please don't modify tod in the dependant function. |
387 | * Please don't modify tod in the dependant function. |
393 | */ |
388 | */ |
394 | |
|
|
395 | void |
389 | void |
396 | tick_the_clock (void) |
390 | tick_the_clock (void) |
397 | { |
391 | { |
398 | timeofday_t tod; |
392 | timeofday_t tod; |
399 | |
393 | |
400 | todtick++; |
394 | todtick++; |
401 | if (todtick % 20 == 0) |
395 | if (todtick % 20 == 0) |
402 | write_todclock (); |
396 | write_todclock (); |
|
|
397 | |
403 | if (settings.dynamiclevel > 0) |
398 | if (settings.dynamiclevel > 0) |
404 | { |
399 | { |
405 | if (todtick % 21 == 0) |
400 | if (todtick % 21 == 0) |
406 | write_pressuremap (); |
401 | write_pressuremap (); |
407 | if (todtick % 22 == 0) |
402 | if (todtick % 22 == 0) |
… | |
… | |
420 | if (todtick % 28 == 0) |
415 | if (todtick % 28 == 0) |
421 | write_skymap (); |
416 | write_skymap (); |
422 | if (todtick % 29 == 0) |
417 | if (todtick % 29 == 0) |
423 | write_rainfallmap (); |
418 | write_rainfallmap (); |
424 | } |
419 | } |
|
|
420 | |
425 | get_tod (&tod); |
421 | get_tod (&tod); |
426 | dawn_to_dusk (&tod); |
422 | dawn_to_dusk (&tod); |
427 | /* call the weather calculators, here, in order */ |
423 | /* call the weather calculators, here, in order */ |
428 | if (settings.dynamiclevel > 0) |
424 | if (settings.dynamiclevel > 0) |
429 | { |
425 | { |
… | |
… | |
434 | init_temperature (); |
430 | init_temperature (); |
435 | compute_sky (); |
431 | compute_sky (); |
436 | if (tod.hour == 0) |
432 | if (tod.hour == 0) |
437 | process_rain (); |
433 | process_rain (); |
438 | } |
434 | } |
|
|
435 | |
439 | /* perform_weather must follow calculators */ |
436 | /* perform_weather must follow calculators */ |
440 | perform_weather (); |
437 | perform_weather (); |
441 | if (settings.dynamiclevel > 0) |
438 | if (settings.dynamiclevel > 0) |
442 | { |
439 | { |
443 | write_weather_images (); |
440 | write_weather_images (); |