Index: src/freerct.cpp =================================================================== --- src/freerct.cpp (revision 1307) +++ src/freerct.cpp (working copy) @@ -111,12 +111,8 @@ const char *font_path = cfg_file.GetValue("font", "medium-path"); int font_size = cfg_file.GetNum("font", "medium-size"); if (font_path == nullptr || *font_path == '\0' || font_size == -1) { - fprintf(stderr, "Failed to find font settings. Did you make a 'freerct.cfg' file next to the 'freerct' program?\n"); - fprintf(stderr, "Example content (you may need to change the path and.or the size):\n" - "[font]\n" - "medium-size = 12\n" - "medium-path = /usr/share/fonts/gnu-free/FreeSans.ttf\n"); - return 1; + font_path = "RCT1.ttf"; + font_size = 16; } /* Initialize video. */ Index: src/gamecontrol.cpp =================================================================== --- src/gamecontrol.cpp (revision 1307) +++ src/gamecontrol.cpp (working copy) @@ -90,6 +90,7 @@ { _manager.Tick(); _guests.DoTick(); + _weather.OnTick(); DateOnTick(); _guests.OnAnimate(frame_delay); _rides_manager.OnAnimate(frame_delay); Index: src/viewport.cpp =================================================================== --- src/viewport.cpp (revision 1307) +++ src/viewport.cpp (working copy) @@ -1418,6 +1418,8 @@ _video.BlitImage(dd.base, dd.sprite, rec, gs); } + _weather.DrawRain(); + _video.SetClippedRectangle(cr); } Index: src/weather.cpp =================================================================== --- src/weather.cpp (revision 1307) +++ src/weather.cpp (working copy) @@ -12,7 +12,9 @@ #include "stdafx.h" #include "weather.h" #include "dates.h" +#include "palette.h" #include "random.h" +#include "video.h" Weather _weather; ///< Weather in the park. @@ -151,7 +153,71 @@ if (this->change == 0) this->change = (this->next - this->current > 0) ? 1 : -1; } +/** Helper method to determine if water is falling from the sky. */ +bool Weather::IsRaining() +{ + return this->GetWeatherType() == WTP_RAINING || this->GetWeatherType() == WTP_THUNDERSTORM; +} + +/** Draw rain to the screen. */ +void Weather::DrawRain() +{ + if (this->rain.opacity == 0) return; + + const uint32 col = MakeRGBA(127, 127, 127, this->rain.opacity); /// \todo Work out the colour more accurately + + for (int x = -this->rain.X_GAP; x < _video.GetXSize(); x += this->rain.X_GAP) { + for (int y = -this->rain.Y_GAP; y < _video.GetYSize(); y += (this->rain.opacity < 50 ? 2 : 1) * this->rain.Y_GAP) { + _video.FillSurface(col, {x + this->rain.x_off, y + this->rain.y_off1, 1, 1}); + _video.FillSurface(col, {x + this->rain.x_off + 16, y + this->rain.y_off2, 1, 1}); + + /* Thunderstorms get 2 extra streams of water */ + if (this->GetWeatherType() == WTP_THUNDERSTORM) { + _video.FillSurface(col, {x + this->rain.x_off + 8, y + this->rain.y_off3, 1, 1}); + _video.FillSurface(col, {x + this->rain.x_off + 24, y + this->rain.y_off4, 1, 1}); + } + } + } +} + /** + * Set the rain drawing positions. + * @note Magic numbers taken from RCT. + */ +void Weather::OnTick() +{ + if (!this->IsRaining()) { + this->rain.opacity = std::max(this->rain.opacity - 1, 0); + } else { + this->rain.opacity = std::min(this->rain.opacity + 1, 192); + } + + /* If it's not raining (at all), reset the raindrop positions. */ + if (this->rain.opacity == 0) { + this->rain.x_off = 0; + this->rain.y_off1 = 0; + this->rain.y_off2 = 5; + this->rain.y_off3 = 7; + this->rain.y_off4 = 14; + return; + } + + this->rain.x_off++; + if (this->rain.x_off >= this->rain.X_GAP) this->rain.x_off -= this->rain.X_GAP; + + this->rain.y_off1 += 5; + if (this->rain.y_off1 >= this->rain.Y_GAP) this->rain.y_off1 -= this->rain.Y_GAP; + this->rain.y_off2 += 6; + if (this->rain.y_off2 >= this->rain.Y_GAP) this->rain.y_off2 -= this->rain.Y_GAP; + this->rain.y_off3 += 3; + if (this->rain.y_off3 >= this->rain.Y_GAP) this->rain.y_off3 -= this->rain.Y_GAP; + this->rain.y_off4 += 4; + if (this->rain.y_off4 >= this->rain.Y_GAP) this->rain.y_off4 -= this->rain.Y_GAP; + + _video.MarkDisplayDirty(); +} + +/** * Get the current type of weather. * @return The type of weather of today. */ Index: src/weather.h =================================================================== --- src/weather.h (revision 1307) +++ src/weather.h (working copy) @@ -33,10 +33,28 @@ int current; ///< Current weather. int next; ///< Next weather type. - int change; ///< speed of change in the weather. + int change; ///< Speed of change in the weather. + /** Helpful storage object for rain related variables. */ + struct rain_t { + static const int X_GAP = 32; ///< X-distance between each rain drop. + static const int Y_GAP = 48; ///< Y-distance between each rain drop. + + int opacity; ///< Opacity of the rain drops (when fading in or out). + int x_off; ///< x-position of a rain drop. + int y_off1; ///< 1st y-position of a rain drop. + int y_off2; ///< 2nd y-position of a rain drop. + int y_off3; ///< 3rd y-position of a rain drop. (Thunderstorm only). + int y_off4; ///< 4th y-position of a rain drop. (Thunderstorm only). + }; + rain_t rain; ///< Rain object. + + bool IsRaining(); + void DrawRain(); + void Initialize(); void OnNewDay(); + void OnTick(); WeatherType GetWeatherType() const;