1 |
/* |
2 |
* This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 |
* |
4 |
* Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 |
* Copyright (©) 2002,2007 Tim Rightnour |
6 |
* Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
7 |
* Copyright (©) 1992,2007 Frank Tore Johansen |
8 |
* |
9 |
* Deliantra is free software: you can redistribute it and/or modify |
10 |
* it under the terms of the GNU General Public License as published by |
11 |
* the Free Software Foundation, either version 3 of the License, or |
12 |
* (at your option) any later version. |
13 |
* |
14 |
* This program is distributed in the hope that it will be useful, |
15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 |
* GNU General Public License for more details. |
18 |
* |
19 |
* You should have received a copy of the GNU General Public License |
20 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
21 |
* |
22 |
* The authors can be reached via e-mail to <support@deliantra.net> |
23 |
*/ |
24 |
|
25 |
/* This weather system was written for crossfire by Tim Rightnour */ |
26 |
|
27 |
#include <global.h> |
28 |
#include <tod.h> |
29 |
#include <map.h> |
30 |
#ifndef __CEXTRACT__ |
31 |
# include <sproto.h> |
32 |
#endif |
33 |
|
34 |
static const int season_timechange[5][HOURS_PER_DAY] = { |
35 |
/* 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 */ |
36 |
{ 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}, |
37 |
{ 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}, |
38 |
{ 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}, |
39 |
{ 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}, |
40 |
{ 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} |
41 |
}; |
42 |
|
43 |
void |
44 |
maptile::set_darkness_map () |
45 |
{ |
46 |
timeofday_t tod; |
47 |
|
48 |
if (!outdoor) |
49 |
return; |
50 |
|
51 |
get_tod (&tod); |
52 |
darkness = 0; |
53 |
|
54 |
for (int i = HOURS_PER_DAY / 2; i < HOURS_PER_DAY; i++) |
55 |
change_map_light (season_timechange[tod.season][i]); |
56 |
|
57 |
for (int i = 0; i <= tod.hour; i++) |
58 |
change_map_light (season_timechange[tod.season][i]); |
59 |
} |
60 |
|
61 |
/* |
62 |
* Compute the darkness level for all maps in the game. Requires the |
63 |
* time of day as an argument. |
64 |
*/ |
65 |
|
66 |
static void |
67 |
dawn_to_dusk (const timeofday_t * tod) |
68 |
{ |
69 |
/* If the light level isn't changing, no reason to do all |
70 |
* the work below. |
71 |
*/ |
72 |
if (season_timechange[tod->season][tod->hour] == 0) |
73 |
return; |
74 |
|
75 |
maptile::change_all_map_light (season_timechange[tod->season][tod->hour]); |
76 |
} |
77 |
|
78 |
void |
79 |
adjust_daylight () |
80 |
{ |
81 |
timeofday_t tod; |
82 |
|
83 |
get_tod (&tod); |
84 |
dawn_to_dusk (&tod); |
85 |
} |
86 |
|