Loading

Paste #pguuzosgd

  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,79 @@
  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.  /**
  70.   * Draw rain to the screen.
  71.   * @note Magic numbers taken from RCT.
  72.   */
  73.  void Weather::DrawRain()
  74.  {
  75.     if (this->rain.opacity == 0) return;
  76.  
  77.     const uint32 col = MakeRGBA(127, 127, 127, this->rain.opacity); /// \todo Work out the colour more accurately
  78.  
  79.     for (int x = -this->rain.X_GAP; x < _video.GetXSize(); x  = this->rain.X_GAP) {
  80.         for (int y = -this->rain.Y_GAP; y < _video.GetYSize(); y  = (this->rain.opacity < 50 ? 2 : 1) * this->rain.Y_GAP) {
  81.             _video.FillSurface(col, {x   this->rain.x_off,      y   this->rain.y_off1, 1, 1});
  82.             _video.FillSurface(col, {x   this->rain.x_off   16, y   this->rain.y_off2, 1, 1});
  83.  
  84.             /* Thunderstorms get 2 extra streams of water */
  85.             if (this->GetWeatherType() == WTP_THUNDERSTORM) {
  86.                 _video.FillSurface(col, {x   this->rain.x_off    8, y   this->rain.y_off3, 1, 1});
  87.                 _video.FillSurface(col, {x   this->rain.x_off   24, y   this->rain.y_off4, 1, 1});
  88.             }
  89.         }
  90.     }
  91.  }
  92.  
  93.  /**
  94.   * Set the rain drawing positions.
  95.   * @note Magic numbers taken from RCT.
  96.   */
  97.  void Weather::OnTick()
  98.  {
  99.  // static int count = 0;
  100.  // if (count > 10) {
  101.  // count = 0;
  102.     if (!this->IsRaining()) {
  103.         this->rain.opacity = std::max(this->rain.opacity - 1, 0);
  104.     } else {
  105.         this->rain.opacity = std::min(this->rain.opacity   1, 192);
  106.     }
  107.  // }
  108.  // count  ;
  109.  
  110.     /* If it's not raining (at all), reset the raindrop positions. */
  111.     if (this->rain.opacity == 0) {
  112.         this->rain.x_off  =  0;
  113.         this->rain.y_off1 =  0;
  114.         this->rain.y_off2 =  5;
  115.         this->rain.y_off3 =  7;
  116.         this->rain.y_off4 = 14;
  117.         return;
  118.     }
  119.  
  120.     this->rain.x_off  ;
  121.     if (this->rain.x_off  >= this->rain.X_GAP) this->rain.x_off  -= this->rain.X_GAP;
  122.  
  123.     this->rain.y_off1  = 5;
  124.     if (this->rain.y_off1 >= this->rain.Y_GAP) this->rain.y_off1 -= this->rain.Y_GAP;
  125.     this->rain.y_off2  = 6;
  126.     if (this->rain.y_off2 >= this->rain.Y_GAP) this->rain.y_off2 -= this->rain.Y_GAP;
  127.     this->rain.y_off3  = 3;
  128.     if (this->rain.y_off3 >= this->rain.Y_GAP) this->rain.y_off3 -= this->rain.Y_GAP;
  129.     this->rain.y_off4  = 4;
  130.     if (this->rain.y_off4 >= this->rain.Y_GAP) this->rain.y_off4 -= this->rain.Y_GAP;
  131.  
  132.     _video.MarkDisplayDirty();
  133.  }
  134.  
  135.  /**
  136.   * Get the current type of weather.
  137.   * @return The type of weather of today.
  138.   */
  139. Index: src/weather.h
  140. ===================================================================
  141. --- src/weather.h   (revision 1307)
  142.     src/weather.h   (working copy)
  143. @@ -33,10  33,28 @@
  144.  
  145.     int current; ///< Current weather.
  146.     int next;    ///< Next weather type.
  147. -   int change;  ///< speed of change in the weather.
  148.     int change;  ///< Speed of change in the weather.
  149.  
  150.     /** Helpful storage object for rain related variables. */
  151.     struct rain_t {
  152.         static const int X_GAP = 32; ///< X-distance between each rain drop.
  153.         static const int Y_GAP = 48; ///< Y-distance between each rain drop.
  154.  
  155.         int opacity; ///< Opacity of the rain drops (when fading in or out).
  156.         int x_off;   ///< x-position of a rain drop.
  157.         int y_off1;  ///< 1st y-position of a rain drop.
  158.         int y_off2;  ///< 2nd y-position of a rain drop.
  159.         int y_off3;  ///< 3rd y-position of a rain drop. (Thunderstorm only).
  160.         int y_off4;  ///< 4th y-position of a rain drop. (Thunderstorm only).
  161.     };
  162.     rain_t rain; ///< Rain object.
  163.  
  164.     bool IsRaining();
  165.     void DrawRain();
  166.  
  167.     void Initialize();
  168.     void OnNewDay();
  169.     void OnTick();
  170.  
  171.     WeatherType GetWeatherType() const;
  172.  

Comments