Loading
#openttdcoop - Paste
Archives
Trending
Docs
Login
ABAP
ActionScript
ActionScript 3
Ada
AIMMS3
ALGOL 68
Apache configuration
AppleScript
Apt sources
ARM ASSEMBLER
ASM
ASP
asymptote
Autoconf
Autohotkey
AutoIt
AviSynth
awk
BASCOM AVR
Bash
Basic4GL
BibTeX
BlitzBasic
bnf
Boo
Brainfuck
C
C#
C (LoadRunner)
C (Mac)
C (WinAPI)
C++
C++ (Qt)
C++ (WinAPI)
CAD DCL
CAD Lisp
CFDG
ChaiScript
Chapel
CIL
Clojure
CMake
COBOL
CoffeeScript
ColdFusion
CSS
Cuesheet
D
Dart
DCL
DCPU-16 Assembly
DCS
Delphi
Diff
DIV
DOS
dot
E
ECMAScript
Eiffel
eMail (mbox)
EPC
Erlang
Euphoria
EZT
F#
Falcon
FO (abas-ERP)
Formula One
Fortran
FreeBasic
FreeSWITCH
GADV 4CS
GAMBAS
GDB
genero
Genie
glSlang
GML
GNU/Octave
GNU Gettext
GNU make
Gnuplot
Go
Groovy
GwBasic
Haskell
Haxe
HicEst
HQ9+
HTML
HTML5
Icon
INI
Inno
INTERCAL
Io
ISPF Panel
J
Java
Java(TM) 2 Platform Standard Edition 5.0
Javascript
JCL
jQuery
KiXtart
KLone C
KLone C++
LaTeX
LDIF
Liberty BASIC
Lisp
LLVM Intermediate Representation
Locomotive Basic
Logtalk
LOLcode
Lotus Notes @Formulas
LotusScript
LScript
LSL2
Lua
MagikSF
MapBasic
Matlab M
Microchip Assembler
Microsoft Registry
mIRC Scripting
MMIX
Modula-2
Modula-3
MOS 6502 (6510) ACME Cross Assembler format
MOS 6502 (6510) Kick Assembler format
MOS 6502 (6510) TASM/64TASS 1.46 Assembler format
Motorola 68000 - HiSoft Devpac ST 2 Assembler format
Motorola 68000 Assembler
MXML
MySQL
Nagios
NetRexx
newlisp
nginx
Nimrod
NML NewGRF Meta Language
NSIS
Oberon-2
Objeck Programming Language
Objective-C
OCaml
OCaml (brief)
ooRexx
OpenBSD Packet Filter
OpenOffice.org Basic
Oracle 8 SQL
Oracle 11 SQL
Oxygene
OZ
ParaSail
PARI/GP
Pascal
PCRE
per
Perl
Perl 6
PHP
PHP (brief)
PIC16
Pike
Pixel Bender 1.0
PL/I
PL/SQL
PostgreSQL
PostScript
POVRAY
PowerBuilder
PowerShell
ProFTPd configuration
Progress
Prolog
PROPERTIES
ProvideX
Puppet
PureBasic
Python
Python for S60
q/kdb+
QBasic/QuickBASIC
QML
R / S+
Racket
Rails
RBScript
REBOL
rexx
robots.txt
RPM Specification File
Ruby
Rust
SAS
Scala
Scheme
SciLab
SCL
sdlBasic
Smalltalk
Smarty
SPARK
SPARQL
SQL
Squirrel Script
Squirrel Script with OpenTTD AI/GS
StandardML
StoneScript
SystemVerilog
T-SQL
TCL
Tera Term Macro
Text
thinBasic
TypoScript
Unicon (Unified Extended Dialect of Icon)
Uno Idl
Unreal Script
UPC
Urbi
Vala
vb.net
VBScript
Vedit macro language
Verilog
VHDL
Vim Script
Visual Basic
Visual Fox Pro
Visual Prolog
Whitespace
Whois (RPSL format)
Winbatch
X++
XBasic
XML
Xorg configuration
YAML
ZiLOG Z80 Assembler
ZXBasic
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;
Mark as private
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
forever