ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/weather.C
Revision: 1.18
Committed: Mon May 28 21:28:36 2007 UTC (16 years, 11 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.17: +17 -17 lines
Log Message:
update copyrights in server/*.C

File Contents

# Content
1 /*
2 * This file is part of Crossfire TRT, the Roguelike Realtime MORPG.
3 *
4 * 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 *
9 * 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 *
14 * 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 *
23 * The authors can be reached via e-mail to <crossfire@schmorp.de>
24 */
25
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 # include <sproto.h>
33 #endif
34
35 static const int season_timechange[5][HOURS_PER_DAY] = {
36 /* 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 };
43
44 void
45 maptile::set_darkness_map ()
46 {
47 timeofday_t tod;
48
49 if (!outdoor)
50 return;
51
52 get_tod (&tod);
53 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 }
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 static void
68 dawn_to_dusk (const timeofday_t * tod)
69 {
70 /* 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 maptile::change_all_map_light (season_timechange[tod->season][tod->hour]);
77 }
78
79 void
80 adjust_daylight ()
81 {
82 timeofday_t tod;
83
84 get_tod (&tod);
85 dawn_to_dusk (&tod);
86 }
87