1 /* 2 * Seven Kingdoms: Ancient Adversaries 3 * 4 * Copyright 1997,1998 Enlight Software Ltd. 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 * 19 */ 20 21 // Filename : OWEATHER.H 22 // Description : Header file for class Weather 23 // Ownership : Gilbert 24 25 26 #ifndef __OWEATHER_H 27 #define __OWEATHER_H 28 29 #include <stdint.h> 30 31 #include <ALL.h> 32 33 //--------- Define constant ----------// 34 #define MAX_WEATHER_FORECAST 3 35 36 37 //--------- Define WeatherType ----------// 38 typedef enum _WeatherType 39 { 40 WEATHER_SUNNY = 0x00, 41 WEATHER_CLOUDY = 0x01, 42 43 WEATHER_RAIN = 0x02, 44 WEATHER_LIGHTNING = 0x04, 45 WEATHER_LIGHTN_RAIN = 0x06, 46 WEATHER_WINDY = 0x08, 47 WEATHER_WINDY_STORM = 0x0a, 48 WEATHER_HOT_WAVE = 0x10, 49 50 WEATHER_COLD_WAVE = 0x20, 51 WEATHER_SNOW = 0x40 52 } WeatherType; 53 54 55 //--------- Define class Weather ----------// 56 57 #pragma pack(1) 58 class Weather 59 { 60 private: 61 unsigned seed; 62 short season_phase; // 0 = early spring, 364 = end of winter 63 short day_to_quake; 64 short avg_temp; 65 short temp_amp; 66 67 short wind_spd; 68 // #### begin Gilbert 31/10 #######// 69 int32_t high_wind_day; 70 // #### end Gilbert 31/10 #######// 71 short wind_dir; 72 short windy_speed; 73 short tornado_count; // 0=today has tornado, 1... no. of days of last tornado 74 75 char cur_cloud_str; // 0 (shine) to 10 (dark) 76 char cur_cloud_len; 77 char cur_cloud_type; // type of cloud 78 int quake_frequency; 79 80 public: 81 short quake_x; // center of quake, generated on the day of quake 82 short quake_y; 83 84 public: 85 void init_date(short year, short month, short day, short latitude, int quakeFreq); 86 void next_day(); // called when a day has passed 87 88 short cloud(); // return 0 (shine) to 10 (dark) 89 short temp_c(); // temperature in degree C 90 short temp_f(); // temperature in degree F 91 // short humidity(); // relative humidity, 0 to 100 92 short wind_speed(); // wind speed 0 to 100 93 short wind_direct(); // 0 to 360 94 double wind_direct_rad(); // in radian 95 96 short rain_scale(); // rain scale, 0 (no rain) to 12 (heavy rain) 97 short snow_scale(); // snow scale, 0 (no snow) to 8 (heavy snow) 98 char is_lightning(); 99 char is_quake(); 100 char has_tornado(); 101 short tornado_x_loc(short maxXLoc, short maxYLoc); 102 short tornado_y_loc(short maxXLoc, short maxYLoc); 103 104 WeatherType desc(); 105 short quake_rate(short x, short y); // 0-100 106 107 int write_file(File* filePtr); 108 int read_file(File* filePtr); 109 110 private: 111 short base_temp(); 112 unsigned rand_seed(unsigned); 113 }; 114 #pragma pack() 115 116 117 // ------- define class MagicWeather -----------// 118 119 #pragma pack(1) 120 class MagicWeather 121 { 122 private: 123 char rain_str; 124 short wind_spd; 125 short wind_dir; 126 127 public: 128 short rain_day; 129 short wind_day; 130 short lightning_day; 131 132 public: 133 void init(); 134 135 void next_day(); 136 void cast_rain(short duration, char rainScale); 137 void cast_wind(short duration, short speed, short direction); 138 void cast_lightning(short duration); 139 140 short wind_speed(); // wind speed 0 to 100 141 short wind_direct(); // 0 to 360 142 double wind_direct_rad(); // in radian 143 short rain_scale(); // rain scale, 0 (no rain) to 12 (heavy rain) 144 145 int write_file(File* filePtr); 146 int read_file(File* filePtr); 147 148 friend class Weather; 149 }; 150 #pragma pack() 151 152 extern Weather weather, weather_forecast[MAX_WEATHER_FORECAST]; 153 extern MagicWeather magic_weather; 154 155 #endif 156