Commit Graph

24872 Commits

Author SHA1 Message Date
Charles Pigott 80fb1c74f0 Change: Make pathfinder account for maximum order speed, if set 2021-02-22 00:25:47 +00:00
milek7 b749d6f1cb Fix: Allow building with Allegro and without SDL on Linux 2021-02-21 23:05:50 +00:00
translators e74069e4c2 Update: Translations from eints
estonian: 19 changes by siimsoni
french: 3 changes by glx22
2021-02-21 19:00:19 +00:00
Charles Pigott 8157af6d68 Fix #8276: Crash when a NewGRF object's size was not set 2021-02-21 18:16:09 +00:00
Charles Pigott 3af407340e Fix #8349: Close depot vehicle list windows when closing the depot window 2021-02-21 17:58:19 +00:00
Patric Stout 88959f5595
Codechange: [OSX] remove final bits of old debugging code (#8714) 2021-02-21 15:58:26 +01:00
Charles Pigott 1d6a0c7b52 Fix: [YAPF] Road pathfinder did not account for length of tunnel/bridge in path cost
Copy calculations from the rail pathfinder
2021-02-21 10:53:25 +00:00
Charles Pigott c461999b2b Fix #8594: [NRT] Road pathfinder did not account for roadtype speed limits 2021-02-21 10:53:25 +00:00
Patric Stout e1b1608dc6
Fix ec1dd0bf: missing override causing compiler warnings (#8708) 2021-02-20 22:14:26 +01:00
Michael Lutz d16dc22fdf Codechange: Use C++-ism for zeroing. 2021-02-20 21:14:44 +01:00
Michael Lutz 5ca979b1e2 Fix: [OSX] Don't wait on the event loop for drawing. 2021-02-20 21:14:44 +01:00
Michael Lutz f3c192c63d Codechange: [OSX] Only keep a total dirty rect for drawing.
When drawing an 8bpp screen buffer, palette resolving was done for each
dirty rectangle. In areas with high activity, this would mean a pixel might
have been resolved multiple times. Also, if too many individual updates
were queued, the whole screen would be refreshed, even if unnecessary.

All other drivers only keep one overall dirty rect, so do it here as well.
2021-02-20 21:14:44 +01:00
translators 61275df7da Update: Translations from eints
estonian: 62 changes by siimsoni
korean: 1 change by telk5093
russian: 2 changes by Ln-Wolf
finnish: 2 changes by hpiirai
2021-02-20 19:00:44 +00:00
frosch d9b4413bc9
Codechange: rename sound ids to make more sense. (#8701) 2021-02-20 19:01:04 +01:00
SamuXarick cb95b1d2e7 Codechange: Apply coding style 2021-02-20 17:59:04 +00:00
Patric Stout 058f13bdf9 Remove: [SDL] SDL 1.3 never happened, so remove all the special code for it 2021-02-20 17:08:44 +01:00
Patric Stout 0e76d965f1 Codechange: deduplicate tick-handlers of all video drivers
They were all identical, so better put this in a single place
hoping it is less likely to break.
2021-02-20 17:08:44 +01:00
Patric Stout 7996fadb91 Change: [Win32] Remove force_full_redraw and display_hz settings
These were special settings only for the win32-drivers, and
introduced in the very first version we track.

Time kinda had caught up with those variables, so it is time to
say farewell.

force_full_redraw was most likely a debug functionality "in case
our dirty-rect fails". This should no longer be needed.

display_hz was cute, as it had a max of 120. That is kinda
out-dated information, but I also doubt anyone was really using
this.
2021-02-20 17:08:44 +01:00
Patric Stout 23d6f4eac9 Codechange: [Win32] simplify when/where GdiFlush() is called 2021-02-20 17:08:44 +01:00
Patric Stout ec1dd0bf61 Codechange: be consistent in what CheckPaletteAnim() does and when it is called
Additionally, make sure this is a class method. Later commits
will make use of this.
2021-02-20 17:08:44 +01:00
Patric Stout 790fa7102e Codechange: be consistent in naming the paint function Paint()
Also move this function to be a class member. This to allow
further deduplicating of code in a later commit.
2021-02-20 17:08:44 +01:00
Patric Stout 761efbb457 Codechange: use (Un)LockVideoBuffer() to manage video buffer 2021-02-20 17:08:44 +01:00
Patric Stout 661eb39ecc Codechange: move all input-handling of video-drivers into InputLoop 2021-02-20 17:08:44 +01:00
Patric Stout 38b4ae1c0e Codechange: [Win32] make fast-forward check the same as with other drivers
It was of all the drivers the only one doing this slightly different.
When trying to unify more code, that was rather annoying.
2021-02-20 17:08:44 +01:00
Joe Stringer d21442941c Fix: [Cygwin] Fix missing uint definition
In file included from src/settingsgen/../string_func.h:30,
                 from src/settingsgen/settingsgen.cpp:11:
src/settingsgen/../core/bitmath_func.hpp:34:15: error: 'uint' does not name a type; did you mean 'uint8'?
   34 | static inline uint GB(const T x, const uint8 s, const uint8 n)
      |               ^~~~
      |               uint8
2021-02-20 14:54:57 +00:00
Patric Stout 08821f82b6 Fix: [Win32] run InteractiveRandom() once every tick, not once every message
Win32 was the only video driver doing this. It is just a bit too
much random.
2021-02-20 14:25:56 +01:00
Patric Stout 19fdbac287 Fix: [Win32] now we are drawing on a tick, no longer use WM_PAINT
WM_PAINT hits when-ever Windows feels like, but always after we
marked the screen as dirty. In result, it was lagging behind,
giving a sub-60fps experience.

With the new draw-tick there is no longer a need to be driven by
WM_PAINT, so it is better anyway to drive the drawing ourself. As
an added bonus this makes the win32 driver more like the others.
2021-02-20 14:25:56 +01:00
translators 5fc983a1bb Update: Translations from eints
german: 1 change by Wuzzy2
russian: 11 changes by Ln-Wolf
catalan: 2 changes by J0anJosep
spanish: 14 changes by perezdidac
2021-02-19 19:01:10 +00:00
Patric Stout b124c49ea4 Fix: [Actions] Also run CI against libsdl1.2 for every pull request 2021-02-19 19:56:40 +01:00
Patric Stout 8bf8c0f251 Fix d437445c: also use std::chrono for the GRFFileScanner modal window
For some reason I only converted one of the two modal windows we
have, and completely forgot the other.

While at it, synchronize the way those two modal windows work
in terms of "next_update".
2021-02-19 19:56:40 +01:00
Patric Stout cb8e1706b2 Fix: [Actions] if SDL2 is installed, it is always picked over SDL1
So no need to install both SDL1 and SDL2, that gives a false idea
of reality.
2021-02-19 11:34:00 +01:00
Patric Stout d3df4674f9 Fix: [Actions] build our allegro driver too in our CI
This prevents us breaking it without realising.
2021-02-19 11:34:00 +01:00
Patric Stout 932abe6d5c Fix fa170b9: [SDL2] forgot to use GetGameInterval where needed 2021-02-19 11:34:00 +01:00
Patric Stout 15a0ac2735 Fix cd4f0f95: [Allegro] driver failed to build because of missing include 2021-02-19 11:34:00 +01:00
Patric Stout c4df0f95ae Fix: during switching of game-mode, drawing could show closed windows that shouldn't be closed yet
The higher your refresh-rate, the more likely this is. Mostly you
notice this when creating a new game or when abandoning a game.

This is a bit of a hack to keep the old behaviour, as before this
patch the game was already freezing your mouse while it was changing
game-mode, and it does this too after this patch. Just now it
freezes too a few frames earlier, to prevent not drawing windows
people still expect to see.
2021-02-19 10:43:15 +01:00
Patric Stout fa170b9ace Feature: configurable refresh-rate and change default to 60fps
Most modern games run on 60 fps, and for good reason. This gives
a much smoother experiences.

As some people have monitors that can do 144Hz or even 240Hz, allow
people to configure the refresh rate. Of course, the higher you
set the value, the more time the game spends on drawing pixels
instead of simulating the game, which has an effect on simulation
speed.

The simulation will still always run at 33.33 fps, and is not
influences by this setting.
2021-02-19 10:43:15 +01:00
Patric Stout eb9b1ad68d Change: sleep till the next tick in the main loop
Sleep for 1ms (which is always (a lot) more than 1ms) is just
randomly guessing and hoping you hit your deadline, give or take.

But given we can calculate when our next frame is happening, we
can just sleep for that exact amount. As these values are often
a bit larger, it is also more likely the OS can schedule us back
in close to our requested target. This means it is more likely we
hit our deadlines, which makes the FPS a lot more stable.
2021-02-19 10:43:15 +01:00
Patric Stout ae7a2b9f02 Change: allow video-drivers to miss deadlines slightly
Before, every next frame was calculated from the current time.
If for some reason the current frame was drifting a bit, the
next would too, and the next more, etc etc. This meant we rarely
hit the targets we would like, like 33.33fps.

Instead, allow video-drivers to drift slightly, and schedule the
next frame based on the time the last should have happened. Only
if the drift gets too much, that deadlines are missed for longer
period of times, schedule the next frame based on the current
time.

This makes the FPS a lot smoother, as sleeps aren't as exact as
you might think.
2021-02-19 10:43:15 +01:00
Patric Stout c81c6e5eb7 Add: draw the screen at a steady pace, also during fast-forward
During fast-forward, the game was drawing as fast as it could. This
means that the fast-forward was limited also by how fast we could
draw, something that people in general don't expect.

To give an extreme case, if you are fully zoomed out on a busy
map, fast-forward would be mostly limited because of the time it
takes to draw the screen.

By decoupling the draw-tick and game-tick, we can keep the pace
of the draw-tick the same while speeding up the game-tick. To use
the extreme case as example again, if you are fully zoomed out
now, the screen only redraws 33.33 times per second, fast-forwarding
or not. This means fast-forward is much more likely to go at the
same speed, no matter what you are looking at.
2021-02-19 10:43:15 +01:00
Patric Stout 5bfa014505 Codechange: track _realtime_tick more accurate
_realtime_tick was reset every time the diff was calculated. This
means if it would trigger, say, every N.9 milliseconds, it would
after two iterations already drift a millisecond. This adds up
pretty quick.
2021-02-19 10:43:15 +01:00
Patric Stout 25f6851ca1 Codechange: switch all video drivers to std::chrono for keeping time
On all OSes we tested the std::chrono::steady_clock is of a high
enough resolution to do millisecond measurements, which is all we
need.

By accident, this fixes a Win32 driver bug, where we would never
hit our targets, as the resolution of the clock was too low to
do accurate millisecond measurements with (it was ~16ms resolution
instead).
2021-02-19 10:43:15 +01:00
Patric Stout d437445c67 Codechange: use std::chrono to track time in modal windows
Adding to _realtime_ticks in a random place is a bit of a hack,
and by using modern C++, we can avoid this hack.
2021-02-19 10:43:15 +01:00
Tegas Aziz 1f6fb8c290
Add: Indonesia Rupiah as in-game currency (#8616)
The exchange rate is actually more like 19,000, but OpenTTD
doesn't handle such high exchange rates kindly.
2021-02-19 10:27:41 +01:00
Didac Perez Parera 96990b2ea7
Feature: Object class selection string filtering (#8603) 2021-02-19 10:26:54 +01:00
SamuXarick 7577dfa575 Codechange: Apply coding style 2021-02-19 00:14:30 +00:00
translators 259c04f41c Update: Translations from eints
russian: 1 change by Ln-Wolf
polish: 2 changes by yazalo
2021-02-18 19:01:52 +00:00
Tyler Trahan fa88cb62e1
Fix cc39fa9: New orders are non-stop by default (#8689) 2021-02-18 18:42:28 +01:00
Jonathan G Rennison 15b99f2e7a
Fix: Whole status bar instead of money widget refreshed on money change (#8692)
This could result in the rest of the status bar being
redrawn unnecessarily frequently
2021-02-18 12:29:30 +01:00
Jonathan G Rennison 55ed7d16f7
Fix: Unnecessary status bar redraws when there is no news to show (#8691)
InvalidateWindowData with mode SBI_NEWS_DELETED was called on the
status bar when checking for a new item of news to be shown in the
ticker, even if there is no news queued and no change occurs.
2021-02-18 12:17:51 +01:00
Jonathan G Rennison e059a88533
Fix: Autorenew failure advice due to bad refit being shown to all companies (#8681) 2021-02-18 10:50:33 +01:00