ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/weather.C
Revision: 1.20
Committed: Thu Nov 8 19:43:29 2007 UTC (16 years, 6 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: rel-2_4, rel-2_5, rel-2_52, rel-2_53, rel-2_32, rel-2_43, rel-2_42, rel-2_41
Changes since 1.19: +4 -4 lines
Log Message:
update copyrights and other minor stuff to deliantra

File Contents

# User Rev Content
1 elmex 1.1 /*
2 root 1.20 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 pippijn 1.16 *
4 root 1.20 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 root 1.18 * 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.20 * Deliantra is free software: you can redistribute it and/or modify
10 root 1.19 * 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 pippijn 1.16 *
14 root 1.19 * 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 root 1.18 *
19 root 1.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 pippijn 1.16 *
22 root 1.20 * The authors can be reached via e-mail to <support@deliantra.net>
23 pippijn 1.16 */
24 elmex 1.1
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 root 1.5 # include <sproto.h>
32 elmex 1.1 #endif
33    
34     static const int season_timechange[5][HOURS_PER_DAY] = {
35 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 */
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 elmex 1.1 };
42    
43 root 1.5 void
44 root 1.14 maptile::set_darkness_map ()
45 elmex 1.1 {
46 root 1.5 timeofday_t tod;
47 elmex 1.1
48 root 1.14 if (!outdoor)
49 root 1.5 return;
50 elmex 1.1
51 root 1.5 get_tod (&tod);
52 root 1.14 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 elmex 1.1 }
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 root 1.5 static void
67     dawn_to_dusk (const timeofday_t * tod)
68 elmex 1.1 {
69 root 1.5 /* 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 root 1.14 maptile::change_all_map_light (season_timechange[tod->season][tod->hour]);
76 elmex 1.1 }
77    
78 root 1.5 void
79 root 1.17 adjust_daylight ()
80 elmex 1.1 {
81 root 1.5 timeofday_t tod;
82    
83     get_tod (&tod);
84     dawn_to_dusk (&tod);
85 elmex 1.1 }
86 root 1.17