Planeshift
weathermanager.h
Go to the documentation of this file.
1 /*
2  * weathermanager.h
3  *
4  * Copyright (C) 2002 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 #ifndef __WEATHERMANAGER_H__
20 #define __WEATHERMANAGER_H__
21 
22 //=============================================================================
23 // Crystal Space Includes
24 //=============================================================================
25 #include <iengine/sector.h>
26 #include <csutil/randomgen.h>
27 #include <csutil/sysfunc.h>
28 
29 //=============================================================================
30 // Project Includes
31 //=============================================================================
32 #include "util/gameevent.h"
33 
34 //=============================================================================
35 // Local Includes
36 //=============================================================================
37 
38 
39 
40 class psWeatherGameEvent;
41 class psSectorInfo;
42 class CacheManager;
43 
49 {
50 public:
51  WeatherManager(CacheManager* cachemanager);
53 
54  void Initialize();
55 
56  void QueueNextEvent(int delayticks,
57  int eventtype,
58  int eventvalue,
59  int duration,
60  int fade,
61  const char* sector,
63  uint clientnum = 0,
64  int r = 0,
65  int g = 0,
66  int b = 0);
67 
68 
74  void StartWeather(psSectorInfo* si, unsigned int type = 0);
75 
83  void StopWeather(psSectorInfo* si, unsigned int type = 0);
85  void SendClientGameTime(int cnum);
86  void BroadcastGameTime();
88  void UpdateClient(uint32_t cnum);
90  {
91  return gameTimeMinute;
92  }
94  {
95  return gameTimeHour;
96  }
98  {
99  return gameTimeDay;
100  }
102  {
103  return gameTimeMonth;
104  }
106  {
107  return gameTimeYear;
108  }
109 
113  void StartGameTime();
114  void SaveGameTime();
115  void SetGameTime(int hour,int minute);
116 
117 
118 protected:
119  csRandomGen* randomgen;
125 
126  csArray<psWeatherGameEvent*> ignored;
127 
128  CS::Threading::Mutex eventsMutex;
129  csArray<psWeatherGameEvent*> events; // Ugly, but we need a copy of our events
130 
132 };
133 
138 {
139 public:
141  int delayticks,
142  int eventtype,
143  int eventvalue,
144  int duration,
145  int fade,
146  const char* sector,
147  psSectorInfo* si,
148  uint client,
149  int r = 0,
150  int g = 0,
151  int b = 0);
152 
153  virtual void Trigger();
154 
155  const char* GetType();
156 
157  int cr,cg,cb;
158  int type, value, duration,fade;
159  csString sector;
161  uint clientnum;
162 
163 
164 protected:
166 
167 
168 };
169 
170 #endif
171 
csArray< psWeatherGameEvent * > events
void BroadcastGameTime()
void SetGameTime(int hour, int minute)
psSectorInfo * si
void StartWeather(psSectorInfo *si, unsigned int type=0)
Starts automatic weather in a sector Allocates new events for snow, rain and fog. ...
WeatherManager * weathermanager
csArray< psWeatherGameEvent * > ignored
Used for overriding commands like /rain.
int GetGameTODMinute()
void QueueNextEvent(int delayticks, int eventtype, int eventvalue, int duration, int fade, const char *sector, psSectorInfo *si, uint clientnum=0, int r=0, int g=0, int b=0)
CS::Threading::Mutex eventsMutex
WeatherManager(CacheManager *cachemanager)
void UpdateClient(uint32_t cnum)
Definition: wn.h:215
When a weather event is created, it goes here.
void SaveGameTime()
void HandleWeatherEvent(psWeatherGameEvent *event)
void StartGameTime()
Look into the database for the saved time.
void BroadcastGameTimeSuperclients()
This class manages the caching of data that is unchanging during server operation.
Definition: cachemanager.h:234
CacheManager * cacheManager
csRandomGen * randomgen
This class handles generation of any and all weather events in the game, including rain...
void StopWeather(psSectorInfo *si, unsigned int type=0)
Stops automatic weather in a sector Puts all events from the automatic weather (rain and snow for now...
Contains information about sectors from the server perspective.
Definition: pssectorinfo.h:46
void SendClientGameTime(int cnum)
All scheduled events must inherit from this class.
Definition: gameevent.h:36