Atrinik Server  4.0
weather.c
Go to the documentation of this file.
1 /*************************************************************************
2  * Atrinik, a Multiplayer Online Role Playing Game *
3  * *
4  * Copyright (C) 2009-2014 Alex Tokar and Atrinik Development Team *
5  * *
6  * Fork from Crossfire (Multiplayer game for X-windows). *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the Free Software *
20  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
21  * *
22  * The author can be reached at admin@atrinik.org *
23  ************************************************************************/
24 
31 #include <global.h>
32 
33 const int season_timechange[SEASONS_PER_YEAR][HOURS_PER_DAY] = {
34  {0, 0, 0, 0, -1, -1, -1, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 1, 1, 0},
35  {0, 0, 0, 0, 0, -1, -1, -1, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 1, 1, 0, 0},
36  {0, 0, 0, 0, 0, -1, -1, -1, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 1, 1, 0},
37  {0, 0, 0, 0, 0, -1, -1, -1, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 1, 1, 0}
38 };
39 
44 {
45  int i;
46  timeofday_t tod;
47 
49  get_tod(&tod);
50 
51  for (i = HOURS_PER_DAY / 2; i < HOURS_PER_DAY; i++) {
52  world_darkness -= season_timechange[tod.season][i];
53  }
54 
55  for (i = 0; i < tod.hour + 1; i++) {
56  world_darkness -= season_timechange[tod.season][i];
57  }
58 }
59 
67 void tick_the_clock(void)
68 {
69  timeofday_t tod;
70 
71  todtick++;
72 
73  if (todtick % 20 == 0) {
75  }
76 
77  get_tod(&tod);
78  world_darkness -= season_timechange[tod.season][tod.hour];
79 }
void get_tod(timeofday_t *tod)
Definition: time.c:279
void write_todclock(void)
Definition: init.c:1158
unsigned long todtick
Definition: init.c:64
void tick_the_clock(void)
Definition: weather.c:67
int world_darkness
Definition: init.c:61
#define HOURS_PER_DAY
Definition: tod.h:37
void init_world_darkness(void)
Definition: weather.c:43
Definition: tod.h:65
int hour
Definition: tod.h:79
#define MAX_DARKNESS
Definition: map.h:37
#define SEASONS_PER_YEAR
Definition: tod.h:45
int season
Definition: tod.h:88