Crossfire Server, Trunk
weather.cpp
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 1999-2014 Mark Wedel and the Crossfire Development Team
5  * Copyright (c) 1992 Frank Tore Johansen
6  *
7  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
8  * welcome to redistribute it under certain conditions. For details, please
9  * see COPYING and LICENSE.
10  *
11  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
12  */
13 
19 #include <global.h>
20 #include <tod.h>
21 #include <map.h>
22 #ifndef __CEXTRACT__
23 #include <sproto.h>
24 #endif
25 #include <assert.h>
26 
27 static void dawn_to_dusk(const timeofday_t *tod);
29 static const int season_timechange[5][HOURS_PER_DAY] = {
30 /* 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 */
31  { 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 },
32  { 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 },
33  { 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 },
34  { 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 },
35  { 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 }
36 };
37 
45  int i;
46  timeofday_t tod;
47 
48  if (!m->outdoor) {
49  return;
50  }
51 
52  get_tod(&tod);
53  m->darkness = 0;
54  for (i = HOURS_PER_DAY/2; i < HOURS_PER_DAY; i++) {
56  }
57  for (i = 0; i <= tod.hour; i++) {
59  }
60 }
61 
68 static void dawn_to_dusk(const timeofday_t *tod) {
69  mapstruct *m;
70 
71  /* If the light level isn't changing, no reason to do all
72  * the work below.
73  */
74  if (season_timechange[tod->season][tod->hour] == 0) {
75  return;
76  }
77 
78  for (m = first_map; m != NULL; m = m->next) {
79  if (!m->outdoor) {
80  continue;
81  }
82 
84  }
85 }
86 
94 void tick_the_clock(void) {
95  timeofday_t tod;
96 
97  todtick++;
98  if (todtick%20 == 0) {
100  }
101  get_tod(&tod);
102  dawn_to_dusk(&tod);
103 }
season_timechange
static const int season_timechange[5][HOURS_PER_DAY]
Definition: weather.cpp:29
global.h
todtick
unsigned long todtick
Definition: time.cpp:38
HOURS_PER_DAY
#define HOURS_PER_DAY
Definition: tod.h:15
timeofday_t
Definition: tod.h:38
tick_the_clock
void tick_the_clock(void)
Definition: weather.cpp:94
get_tod
void get_tod(timeofday_t *tod)
Definition: time.cpp:219
m
static event_registration m
Definition: citylife.cpp:425
write_todclock
void write_todclock(void)
Definition: init.cpp:519
first_map
mapstruct * first_map
Definition: init.cpp:107
change_map_light
int change_map_light(mapstruct *m, int change)
Definition: map.cpp:1986
sproto.h
timeofday_t::season
int season
Definition: tod.h:46
map.h
set_darkness_map
void set_darkness_map(mapstruct *m)
Definition: weather.cpp:44
mapstruct
Definition: map.h:313
timeofday_t::hour
int hour
Definition: tod.h:43
tod.h
dawn_to_dusk
static void dawn_to_dusk(const timeofday_t *tod)
Definition: weather.cpp:68