OWEATHER.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. // Filename : OWEATHER.H
  21. // Description : Header file for class Weather
  22. // Ownership : Gilbert
  23. #ifndef __OWEATHER_H
  24. #define __OWEATHER_H
  25. #ifndef __ALL_H
  26. #include <ALL.h>
  27. #endif
  28. //--------- Define constant ----------//
  29. #define MAX_WEATHER_FORECAST 3
  30. //--------- Define WeatherType ----------//
  31. typedef enum _WeatherType
  32. {
  33. WEATHER_SUNNY = 0x00,
  34. WEATHER_CLOUDY = 0x01,
  35. WEATHER_RAIN = 0x02,
  36. WEATHER_LIGHTNING = 0x04,
  37. WEATHER_LIGHTN_RAIN = 0x06,
  38. WEATHER_WINDY = 0x08,
  39. WEATHER_WINDY_STORM = 0x0a,
  40. WEATHER_HOT_WAVE = 0x10,
  41. WEATHER_COLD_WAVE = 0x20,
  42. WEATHER_SNOW = 0x40
  43. } WeatherType;
  44. //--------- Define class Weather ----------//
  45. #pragma pack(1)
  46. class Weather
  47. {
  48. private:
  49. unsigned seed;
  50. short season_phase; // 0 = early spring, 364 = end of winter
  51. short day_to_quake;
  52. short avg_temp;
  53. short temp_amp;
  54. short wind_spd;
  55. // #### begin Gilbert 31/10 #######//
  56. long high_wind_day;
  57. // #### end Gilbert 31/10 #######//
  58. short wind_dir;
  59. short windy_speed;
  60. short tornado_count; // 0=today has tornado, 1... no. of days of last tornado
  61. char cur_cloud_str; // 0 (shine) to 10 (dark)
  62. char cur_cloud_len;
  63. char cur_cloud_type; // type of cloud
  64. int quake_frequency;
  65. public:
  66. short quake_x; // center of quake, generated on the day of quake
  67. short quake_y;
  68. public:
  69. void init_date(short year, short month, short day, short latitude, int quakeFreq);
  70. void next_day(); // called when a day has passed
  71. short cloud(); // return 0 (shine) to 10 (dark)
  72. short temp_c(); // temperature in degree C
  73. short temp_f(); // temperature in degree F
  74. // short humidity(); // relative humidity, 0 to 100
  75. short wind_speed(); // wind speed 0 to 100
  76. short wind_direct(); // 0 to 360
  77. double wind_direct_rad(); // in radian
  78. short rain_scale(); // rain scale, 0 (no rain) to 12 (heavy rain)
  79. short snow_scale(); // snow scale, 0 (no snow) to 8 (heavy snow)
  80. char is_lightning();
  81. char is_quake();
  82. char has_tornado();
  83. short tornado_x_loc(short maxXLoc, short maxYLoc);
  84. short tornado_y_loc(short maxXLoc, short maxYLoc);
  85. WeatherType desc();
  86. short quake_rate(short x, short y); // 0-100
  87. int write_file(File* filePtr);
  88. int read_file(File* filePtr);
  89. private:
  90. short base_temp();
  91. unsigned rand_seed(unsigned);
  92. };
  93. #pragma pack()
  94. // ------- define class MagicWeather -----------//
  95. #pragma pack(1)
  96. class MagicWeather
  97. {
  98. private:
  99. char rain_str;
  100. short wind_spd;
  101. short wind_dir;
  102. public:
  103. short rain_day;
  104. short wind_day;
  105. short lightning_day;
  106. public:
  107. void init();
  108. void next_day();
  109. void cast_rain(short duration, char rainScale);
  110. void cast_wind(short duration, short speed, short direction);
  111. void cast_lightning(short duration);
  112. short wind_speed(); // wind speed 0 to 100
  113. short wind_direct(); // 0 to 360
  114. double wind_direct_rad(); // in radian
  115. short rain_scale(); // rain scale, 0 (no rain) to 12 (heavy rain)
  116. int write_file(File* filePtr);
  117. int read_file(File* filePtr);
  118. friend class Weather;
  119. };
  120. #pragma pack()
  121. extern Weather weather, weather_forecast[MAX_WEATHER_FORECAST];
  122. extern MagicWeather magic_weather;
  123. #endif