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