summaryrefslogtreecommitdiff
path: root/src/video/dedicated_v.cpp
AgeCommit message (Collapse)Author
2021-02-19Feature: configurable refresh-rate and change default to 60fpsPatric Stout
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-19Change: sleep till the next tick in the main loopPatric Stout
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-19Change: allow video-drivers to miss deadlines slightlyPatric Stout
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-19Add: draw the screen at a steady pace, also during fast-forwardPatric Stout
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-19Codechange: track _realtime_tick more accuratePatric Stout
_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-19Codechange: switch all video drivers to std::chrono for keeping timePatric Stout
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-01-14Feature: Choose a sensible window size on a fresh OTTD config file. (#8536)Michael Lutz
2020-12-27Codechange: Convert some more FIO functions to take std::string.Michael Lutz
2020-12-27Codechange: Replace assert_compile macro with static_assertCharles Pigott
2020-05-21Codechange: Use std::string in the driver and blitter selection code.Michael Lutz
2019-11-10Cleanup: Removed SVN headersS. D. Cloudt
2019-08-06Cleanup: Remove duplicate thread.h include (#7683)nikolas
2019-04-10Codechange: Use null pointer literal instead of the NULL macroHenry Wilson
2019-04-06Codechange: Use platform independent C++11 function for sleeping on a thread.Michael Lutz
2019-04-06Codechange: Replace custom thread code with C++11 thread objects.Michael Lutz
We assume a conforming C++11 compiler environment that has a valid <thread>-header. Failure to run a real thread is handled gracefully.
2019-03-20Remove: ENABLE_NETWORK switchPatric Stout
This switch has been a pain for years. Often disabling broke compilation, as no developer compiles OpenTTD without, neither do any of our official binaries. Additionaly, it has grown so hugely in our codebase, that it clearly shows that the current solution was a poor one. 350+ instances of "#ifdef ENABLE_NETWORK" were in the code, of which only ~30 in the networking code itself. The rest were all around the code to do the right thing, from GUI to NewGRF. A more proper solution would be to stub all the functions, and make sure the rest of the code can simply assume network is available. This was also partially done, and most variables were correct if networking was disabled. Despite that, often the #ifdefs were still used. With the recent removal of DOS, there is also no platform anymore which we support where networking isn't working out-of-the-box. All in all, it is time to remove the ENABLE_NETWORK switch. No replacement is planned, but if you feel we really need this option, we welcome any Pull Request which implements this in a way that doesn't crawl through the code like this diff shows we used to.
2019-03-05Remove: BeOS support (deprecated by Haiku)Patric Stout
In 10 years there is no commit to change how BeOS works, and we have no active maintainer for it. It is unlikely it works in its current state (but not impossible). With the arrival of SDL2 (and removal of SDL), BeOS is no longer support. SDL2 suggests to use Haiku instead of BeOS.
2018-12-27Fix: [Win32] WIN32 may not be defined, always prefer the compiler predefined ↵glx
macro _WIN32
2018-04-29Remove: WinCE supportPatric Stout
2018-04-29Remove: PSP supportPatric Stout
2016-10-30(svn r27673) -Add: [Win32] Thread names for windows debuggers.michi_cc
2016-09-04(svn r27653) -Fix(r27647): Rename FileOperation enum and values to ↵alberth
SaveLoadOperation to avoid nameclash with windows compiler toolkit.
2016-09-04(svn r27650) -Codechange: Replace SaveOrLoadMode by FileOperation and ↵alberth
DetailedFileType.
2014-04-24(svn r26496) -Fix (r1547): Reading console input on dedicated server relied ↵frosch
on unspecified behaviour.
2014-04-23(svn r26482) -Codechange: add an include that allows us to undefine/redefine ↵rubidium
"unsafe" functions to prevent them from being used, and thus having to care about certain aspects of their return values
2014-04-08(svn r26449) -Add: Allow more sound sleep for dedicated servers when there's ↵planetmaker
nothing to do and nobody paying attention
2014-01-02(svn r26209) -Codechange: remove some template magic and simplify some coderubidium
2013-01-08(svn r24900) -Fix [FS#5389]: Comments with typos (most fixes supplied by ↵planetmaker
Eagle_rainbow)
2011-12-10(svn r23470) -Codechange: move declaration of SwitchToMode to a header ↵rubidium
instead of declaring it in 6 other files
2011-11-04(svn r23119) -Fix: [Win32] Don't show a crash/assertion message box for a ↵michi_cc
GUI-less video driver.
2011-05-28(svn r22512) -Add: Save heightmap.alberth
2011-02-25(svn r22144) -Codechange: Unify 'while (true)' to 'for (;;)'alberth
2010-12-05(svn r21396) -Codechange: rename SafeSaveOrLoad to SaveLoad (it only did ↵rubidium
load), and add support for (safe) loading with a LoadFilter
2010-11-19(svn r21252) -Codechange: introduce a constant for the number of ↵rubidium
milliseconds per game tick and use it
2010-09-10(svn r20783) -Change/Fix: do autosave-on-exit as well when using kill/CTRL-C ↵rubidium
to terminate a dedicated OpenTTD
2010-08-01(svn r20286) -Codechange: Unify end of doxygen comments.frosch
2010-07-19(svn r20192) -Cleanup: bye bye variables.h, bye bye VARDEF... you won't be ↵rubidium
missed :)
2010-07-19(svn r20183) -Codechange: make _do_autosave and _dedicated_forks not use ↵rubidium
VARDEF and put them in a more logical location
2010-06-05(svn r19933) -Fix [FS#3804]: Keep _current_company and _local_company in ↵frosch
sync during GUI operation.
2010-04-09(svn r19593) -Codechange: improve loading/executing the desync logsrubidium
2010-01-15(svn r18809) -Codechange/Cleanup: remove unneeded headers from some files, ↵rubidium
if a header require a header make it include that header
2010-01-12(svn r18792) -Fix [FS#3522] (r18709): crash when using the 32bpp blitter ↵rubidium
with a dedicated server
2009-12-19(svn r18545) -Fix [FS#3292]: Assign '_screen.dst_ptr' as soon as it is ↵frosch
allocated.
2009-08-21(svn r17248) -Fix: add GPL license notice where appropriaterubidium
2009-08-20(svn r17228) -Codechange: some coding style fixesrubidium
2009-05-19(svn r16360) -Codechange: don't use _network_playas as a 'second' ↵rubidium
_local_company, but only as a storage location for the company you want to join in MP.
2009-04-10(svn r16024) -Codechange: harden string copying on places where it's possiblerubidium
2009-03-15(svn r15718) -Cleanup: apply some comment coding style on the rest of the ↵rubidium
sources too
2009-03-06(svn r15626) -Fix [FS#2698]: UTF8 string handling could cause buffer overruns.rubidium
2009-02-25(svn r15576) -Codechange: rename SwitchModes to SwitchMode and don't ↵yexo
hardcode the values for that enum.