/*
* This file is part of Deliantra, the Roguelike Realtime MMORPG.
*
* Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
* Copyright (©) 2002,2007 Tim Rightnour
* Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
* Copyright (©) 1992,2007 Frank Tore Johansen
*
* Deliantra is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* The authors can be reached via e-mail to
*/
/* This weather system was written for crossfire by Tim Rightnour */
#include
#include
#include
#ifndef __CEXTRACT__
# include
#endif
static const int season_timechange[5][HOURS_PER_DAY] = {
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4 5 6 7 8 9 10 11 12 13 */
{ 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1},
{ 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0},
{ 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0},
{ 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0},
{ 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0}
};
void
maptile::set_darkness_map ()
{
timeofday_t tod;
if (!outdoor)
return;
get_tod (&tod);
darkness = 0;
for (int i = HOURS_PER_DAY / 2; i < HOURS_PER_DAY; i++)
change_map_light (season_timechange[tod.season][i]);
for (int i = 0; i <= tod.hour; i++)
change_map_light (season_timechange[tod.season][i]);
}
/*
* Compute the darkness level for all maps in the game. Requires the
* time of day as an argument.
*/
static void
dawn_to_dusk (const timeofday_t * tod)
{
/* If the light level isn't changing, no reason to do all
* the work below.
*/
if (season_timechange[tod->season][tod->hour] == 0)
return;
maptile::change_all_map_light (season_timechange[tod->season][tod->hour]);
}
void
adjust_daylight ()
{
timeofday_t tod;
get_tod (&tod);
dawn_to_dusk (&tod);
}