Loading

Paste #pdvmw2nxr

  1. Index: src/freerct.cpp
  2. ===================================================================
  3. --- src/freerct.cpp (revision 1307)
  4. +++ src/freerct.cpp (working copy)
  5. @@ -111,12 +111,8 @@
  6.     const char *font_path = cfg_file.GetValue("font", "medium-path");
  7.     int font_size = cfg_file.GetNum("font", "medium-size");
  8.     if (font_path == nullptr || *font_path == '\0' || font_size == -1) {
  9. -       fprintf(stderr, "Failed to find font settings. Did you make a 'freerct.cfg' file next to the 'freerct' program?\n");
  10. -       fprintf(stderr, "Example content (you may need to change the path and.or the size):\n"
  11. -                       "[font]\n"
  12. -                       "medium-size = 12\n"
  13. -                       "medium-path = /usr/share/fonts/gnu-free/FreeSans.ttf\n");
  14. -       return 1;
  15. +       font_path = "RCT1.ttf";
  16. +       font_size = 16;
  17.     }
  18.  
  19.     /* Initialize video. */
  20. Index: src/gamecontrol.cpp
  21. ===================================================================
  22. --- src/gamecontrol.cpp (revision 1307)
  23. +++ src/gamecontrol.cpp (working copy)
  24. @@ -90,6 +90,7 @@
  25.  {
  26.     _manager.Tick();
  27.     _guests.DoTick();
  28. +   _weather.OnTick();
  29.     DateOnTick();
  30.     _guests.OnAnimate(frame_delay);
  31.     _rides_manager.OnAnimate(frame_delay);
  32. Index: src/viewport.cpp
  33. ===================================================================
  34. --- src/viewport.cpp    (revision 1307)
  35. +++ src/viewport.cpp    (working copy)
  36. @@ -1418,6 +1418,8 @@
  37.         _video.BlitImage(dd.base, dd.sprite, rec, gs);
  38.     }
  39.  
  40. +   _weather.DrawRain();
  41. +
  42.     _video.SetClippedRectangle(cr);
  43.  }
  44.  
  45. Index: src/weather.cpp
  46. ===================================================================
  47. --- src/weather.cpp (revision 1307)
  48. +++ src/weather.cpp (working copy)
  49. @@ -12,7 +12,9 @@
  50.  #include "stdafx.h"
  51.  #include "weather.h"
  52.  #include "dates.h"
  53. +#include "palette.h"
  54.  #include "random.h"
  55. +#include "video.h"
  56.  
  57.  Weather _weather; ///< Weather in the park.
  58.  
  59. @@ -151,7 +153,71 @@
  60.     if (this->change == 0) this->change = (this->next - this->current > 0) ? 1 : -1;
  61.  }
  62.  
  63. +/** Helper method to determine if water is falling from the sky. */
  64. +bool Weather::IsRaining()
  65. +{
  66. +   return this->GetWeatherType() == WTP_RAINING || this->GetWeatherType() == WTP_THUNDERSTORM;
  67. +}
  68. +
  69. +/** Draw rain to the screen. */
  70. +void Weather::DrawRain()
  71. +{
  72. +   if (this->rain.opacity == 0) return;
  73. +
  74. +   const uint32 col = MakeRGBA(127, 127, 127, this->rain.opacity); /// \todo Work out the colour more accurately
  75. +
  76. +   for (int x = -this->rain.X_GAP; x < _video.GetXSize(); x += this->rain.X_GAP) {
  77. +       for (int y = -this->rain.Y_GAP; y < _video.GetYSize(); y += (this->rain.opacity < 50 ? 2 : 1) * this->rain.Y_GAP) {
  78. +           _video.FillSurface(col, {x + this->rain.x_off,      y + this->rain.y_off1, 1, 1});
  79. +           _video.FillSurface(col, {x + this->rain.x_off + 16, y + this->rain.y_off2, 1, 1});
  80. +
  81. +           /* Thunderstorms get 2 extra streams of water */
  82. +           if (this->GetWeatherType() == WTP_THUNDERSTORM) {
  83. +               _video.FillSurface(col, {x + this->rain.x_off +  8, y + this->rain.y_off3, 1, 1});
  84. +               _video.FillSurface(col, {x + this->rain.x_off + 24, y + this->rain.y_off4, 1, 1});
  85. +           }
  86. +       }
  87. +   }
  88. +}
  89. +
  90.  /**
  91. + * Set the rain drawing positions.
  92. + * @note Magic numbers taken from RCT.
  93. + */
  94. +void Weather::OnTick()
  95. +{
  96. +   if (!this->IsRaining()) {
  97. +       this->rain.opacity = std::max(this->rain.opacity - 1, 0);
  98. +   } else {
  99. +       this->rain.opacity = std::min(this->rain.opacity + 1, 192);
  100. +   }
  101. +
  102. +   /* If it's not raining (at all), reset the raindrop positions. */
  103. +   if (this->rain.opacity == 0) {
  104. +       this->rain.x_off  =  0;
  105. +       this->rain.y_off1 =  0;
  106. +       this->rain.y_off2 =  5;
  107. +       this->rain.y_off3 =  7;
  108. +       this->rain.y_off4 = 14;
  109. +       return;
  110. +   }
  111. +
  112. +   this->rain.x_off++;
  113. +   if (this->rain.x_off  >= this->rain.X_GAP) this->rain.x_off  -= this->rain.X_GAP;
  114. +
  115. +   this->rain.y_off1 += 5;
  116. +   if (this->rain.y_off1 >= this->rain.Y_GAP) this->rain.y_off1 -= this->rain.Y_GAP;
  117. +   this->rain.y_off2 += 6;
  118. +   if (this->rain.y_off2 >= this->rain.Y_GAP) this->rain.y_off2 -= this->rain.Y_GAP;
  119. +   this->rain.y_off3 += 3;
  120. +   if (this->rain.y_off3 >= this->rain.Y_GAP) this->rain.y_off3 -= this->rain.Y_GAP;
  121. +   this->rain.y_off4 += 4;
  122. +   if (this->rain.y_off4 >= this->rain.Y_GAP) this->rain.y_off4 -= this->rain.Y_GAP;
  123. +
  124. +   _video.MarkDisplayDirty();
  125. +}
  126. +
  127. +/**
  128.   * Get the current type of weather.
  129.   * @return The type of weather of today.
  130.   */
  131. Index: src/weather.h
  132. ===================================================================
  133. --- src/weather.h   (revision 1307)
  134. +++ src/weather.h   (working copy)
  135. @@ -33,10 +33,28 @@
  136.  
  137.     int current; ///< Current weather.
  138.     int next;    ///< Next weather type.
  139. -   int change;  ///< speed of change in the weather.
  140. +   int change;  ///< Speed of change in the weather.
  141.  
  142. +   /** Helpful storage object for rain related variables. */
  143. +   struct rain_t {
  144. +       static const int X_GAP = 32; ///< X-distance between each rain drop.
  145. +       static const int Y_GAP = 48; ///< Y-distance between each rain drop.
  146. +
  147. +       int opacity; ///< Opacity of the rain drops (when fading in or out).
  148. +       int x_off;   ///< x-position of a rain drop.
  149. +       int y_off1;  ///< 1st y-position of a rain drop.
  150. +       int y_off2;  ///< 2nd y-position of a rain drop.
  151. +       int y_off3;  ///< 3rd y-position of a rain drop. (Thunderstorm only).
  152. +       int y_off4;  ///< 4th y-position of a rain drop. (Thunderstorm only).
  153. +   };
  154. +   rain_t rain; ///< Rain object.
  155. +
  156. +   bool IsRaining();
  157. +   void DrawRain();
  158. +
  159.     void Initialize();
  160.     void OnNewDay();
  161. +   void OnTick();
  162.  
  163.     WeatherType GetWeatherType() const;
  164.  
  165.  

Comments