Commit Graph

697 Commits (090616b4c9e1b554f1c8e33f108f668ed526d172)

Author SHA1 Message Date
Patric Stout 47e11fa3f2
Codechange: only run InteractiveRandom() from the draw-thread (#8831)
Otherwise both the draw-thread and game-thread can do it both
at the same time, which gives rather unwanted side-effects.

Calling it from the draw-thread alone is sufficient, as we just
want to create some unpredictable randomness for the player. The
draw-thread is a lot more active (normally) than the game-thread,
so it is the best place of the two to do this.
Additionally, InteractiveRandom() mostly has to do with visuals
that are client-side-only, so more related to drawing than to
game.
3 years ago
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.
3 years ago
Michael Lutz 22f5aeab07 Feature: Automatic UI and font zoom levels when supported by the OS. 3 years ago
glx22 6b8ad5a9b1 Change: Apply some consistency to singleplayer related comments 3 years ago
Michael Lutz fa60c1f8b9
Feature: Choose a sensible window size on a fresh OTTD config file. (#8536) 3 years ago
Patric Stout 760b0cdc11 Change: change console command "restart" and add "reload"
The current "restart" command is now called "reload", as that is
what it does.
The old "restart" command is now called "restart", as that is what
it did.

As this has not been in any official release yet, this shouldn't
harm any kitten.
3 years ago
Patric Stout ff89f5f4c6 Fix 8f3d1ec: "restart" did not always restart your current game
In the sequence:
- Load a game
- Start a newgame (via console)
- Restart a game (via console)
Gave you the loaded game back, not the new game.
3 years ago
Charles Pigott 9b800a96ed
Codechange: Remove min/max functions in favour of STL variants (#8502) 3 years ago
Michael Lutz b408fe77f7 Codechange: Use std::string in file scanners. 4 years ago
Michael Lutz 5cbb2da794 Codechange: Even more std::string usage in file IO. 4 years ago
Michael Lutz 65f65ad2ad Codechange: Convert some more FIO functions to take std::string. 4 years ago
Michael Lutz dd138fc460 Codechange: Stringify config file paths. 4 years ago
Charles Pigott 860c270c73 Codechange: Replace assert_compile macro with static_assert 4 years ago
Jonathan G Rennison 5cf28be742 Codechange: Add support for verbose asserts 4 years ago
Jonathan G Rennison 0c5dc5d41e Change: [Linkgraph] Pause the game when linkgraph jobs lag (#6470)
Check if the job is still running two date fract ticks before it is due
to join, and if so pause the game until its done.
When loading a game, check if the game would block immediately due to
a job which is scheduled to be joined within two date fract ticks,
and if so pause the game until its done.
This avoids the main thread being blocked on a thread join, which appears
to the user as if the game is unresponsive, as the UI does not repaint
and cannot be interacted with.
Show if pause is due to link graph job in status bar, update network
messages.
This does not apply for network clients.
4 years ago
Patric Stout d15dc9f40f Add: support for emscripten (play-OpenTTD-in-the-browser)
Emscripten compiles to WASM, which can be loaded via
HTML / JavaScript. This allows you to play OpenTTD inside a
browser.

Co-authored-by: milek7 <me@milek7.pl>
4 years ago
Patric Stout 5d0331ecdc
Fix 8bef06a2: don't use "extern" when you want to implement a global (#8373) 4 years ago
Patric Stout c66bd18a10
Add: save openttd.cfg immediately on changing a setting (#8358)
Formally it was only done on exit. This means that if it crashes
changes in settings were not stored. This is often rather
frustrating. Additionally, targets (like emscripten) where people
are unlike to use "Exit Game", will never see their configuration
stored.

The drawback is that on every setting change there is some minor
I/O of writing the ini file to disk again.
4 years ago
Patric Stout 2864d019f0
Fix: useless warning with -snull and no BaseSounds available (#8361)
If I explicitly tell the system I do not want sound, I still get
presented a nice message I do not have any BaseSounds available
on my system, and that I should download one to enjoy sound. Well,
let me tell you, with "-snull" that is really really not going to
help. So please, be quiet, and let me enjoy the game without
"boooooo" and "DING DING DING".

Thank you.
4 years ago
Berbe 8f3d1ec970 Feature: Improve restart command
When the restart command is issued, a normal map is always spawned.

This improvement takes into account the current state of _file_to_saveload to check if a savegame/scenario/heightmap was previously loaded, and loads the same resource again.
4 years ago
Michael Lutz c972a63c8c Codechange: Store info about the dedicated server log file in globals with automatic destruction to simplify control flow in openttd_main. 4 years ago
Michael Lutz 37bc2f8064 Codechange: Use std::string in the driver and blitter selection code. 4 years ago
Michael Lutz a49fdb7ebb Codechange: Store base set related texts in std::strings. 4 years ago
glx22 d15c7dbdeb
Add: stations_near and industries_near cache check (#8139) 4 years ago
glx22 86e9326b7f
Add: docking tiles cache check (#8120) 4 years ago
Niels Martin Hansen 0e78393774 Fix: Reference correct section in README file for baseset info 5 years ago
glx ee7a8eebca Codechange: Replace FOR_ALL_TOWNS with range-based for loops 5 years ago
glx b91abd3af9 Codechange: Replace FOR_ALL_ROADSTOPS with range-based for loops 5 years ago
glx d8a1be48cd Codechange: Replace vehicle related FOR_ALL with range-based for loops 5 years ago
glx ddabfed1cd Codechange: Replace station related FOR_ALL with range-based for loops 5 years ago
glx 3a14cea068 Codechange: Replace FOR_ALL_COMPANIES with range-based for loops 5 years ago
S. D. Cloudt 13cc8a0cee Cleanup: Removed SVN headers 5 years ago
peter1138 c02ef3e456 Feature: Add NotRoadTypes (NRT) 5 years ago
Charles Pigott 5b34c8019f Codechange: Remove Company/OwnerByte types 5 years ago
Niels Martin Hansen 37daf43037 Change: Zoom title game by UI zoom level 5 years ago
Henry Wilson 7c8e7c6b6e Codechange: Use null pointer literal instead of the NULL macro 5 years ago
Michael Lutz e804173595 Codechange: If something is a vector of strings, use a vector of strings instead of an AutoFreeSmallVector. 5 years ago
Michael Lutz 05bc2ed7cb Codechange: Replace custom thread code with C++11 thread objects.
We assume a conforming C++11 compiler environment that has a valid <thread>-header.
Failure to run a real thread is handled gracefully.
5 years ago
Michael Lutz 05f4e73608 Codechange: Replace custom mutex code with C++11 mutex'es.
A conforming compiler with a valid <mutex>-header is expected.
Most parts of the code assume that locking a mutex will never fail unexpectedly,
which is generally true on all common platforms that don't just pretend to
be C++11. The use of condition variables in driver code is checked.
5 years ago
Henry Wilson c01a2e2a81 Codechange: Removed SmallVector completely 5 years ago
Henry Wilson a0f36a50e6 Codechange: Replaced SmallVector::Append() with std::vector::[push|emplace]_back() 5 years ago
Henry Wilson 097328c3d7 Codechange: Replaced SmallVector::Get() const with std alternatives 5 years ago
Patric Stout e3c639a09f Remove: ENABLE_NETWORK switch
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.
5 years ago
Charles Pigott fe448a2616 Remove: OPF 5 years ago
Patric Stout 7784d77713 Remove: MorphOS / AmigaOS support
In 10 years there is no commit to change how MorphOS 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), MorphOS is no longer
support. There is an SDL2 port for MorphOS, but it is not maintained
by upstream SDL2, and nobody can currently test it out.

If anyone wants to re-add MorphOS, please do (revert this patch,
fix the problems, and create a Pull Request). If you need any help
doing so, let us know! It is not that we don't like MorphOS, it is
that we don't have anyone fixing the problems :(
5 years ago
Niels Martin Hansen 7e1e2756d4 Add: Show performance of AI and GS in framerate window 5 years ago
Peter Nelson 0f37a683a2 Codechange: Additional type safety for saveload version variables. 5 years ago
glx ba38a7ca65 Fix: don't show OS error box for non GUI video drivers 5 years ago
nikolas d8ccad91f9 Fix: Some code and comment typos
Found with codespell
5 years ago
Peter Nelson 59fe4f28c8 Change: Animate text effects by real time instead of game ticks. 6 years ago
Peter Nelson ead9c9eab5 Change: Switch various window timers to real time instead of game ticks. 6 years ago
Peter Nelson 2a8fa5fef9 Change: Split up Window::OnTick into OnGameTick and OnRealtimeTick. Adjust timers to work with milliseconds instead of ticks. 6 years ago
Gabda87 a0293d313d Add #4115: default company colour setting (#6998)
Works only in single player.
6 years ago
glx c540d72445 Fix: [Win32] WIN32 may not be defined, always prefer the compiler predefined macro _WIN32 6 years ago
SamuXarick 4703cd433d Fix #6460: [AI] Add start_date parameter for Random AIs on new game 6 years ago
Charles Pigott f5b1115039 Doc: Lots and lots of doxymentation fixes 6 years ago
Niels Martin Hansen 50efaa2372 Fix e00908f: Visual C++ 2015 compile error
Microsoft Visual C++ 2015 Update 3 (and possibly other versions) consider a struct member undefined in a
static_assert in the struct body. Moving the static_assert to a member function solves the issue.
6 years ago
Miguel Horta e00908f5e9 Fix #6898: Replace atoi() with strtoul()
Normalize type and parsing of generation_seed across all files
Add assert_compile() to ensure correct type
6 years ago
Niels Martin Hansen 2a868b9f3b Feature: Framerate display window (#6822)
Frame rate and various game loop/graphics timing measurements and graphs. Accessible via the Help menu, and can print some stats in the console via the fps command.
6 years ago
Niels Martin Hansen 6298b96571 Change: Modernise music control logic implementation (#6839)
Rewrite of almost the entire music control logic to a more modern style, hopefully also easier to understand. The old playlist handling made it look like arcane magic, which it doesn't have to be.

- Playlists are now stored in std::vector of objects instead of arrays of bytes with magic sentinel values, that need to be rotated around all the time. Position in playlist is stored as a simple index.
- The theme song is now reserved for the title screen, it doesn't play on any of the standard playlists, but is still available for use on custom playlists.
- When the player enters/leaves the game from the main menu, the music always restarts.
- Playback state (playing or not) is kept even if music becomes unavailable due to an empty playlist (or an empty music set), so it can restart immediately if music becomes available again.
- The shuffle algorithm was changed to a standard Fisher-Yates.
- Possibly better behavior when editing a custom playlist while it's playing.
- Custom playlists should be compatible.
- Framework for supporting custom playlists with songs from multiple music sets.
6 years ago
Patric Stout aef69443e7 Remove: WinCE support 6 years ago
Patric Stout 85adde7485 Remove: PSP support 6 years ago
Ricardo N Feliciano e8de33a61f Cleanup: Use new filename for README file. (#6738) 6 years ago
frosch 7b553d255e (svn r27732) -Change: Turn the message about 'missing baseset sprites' from a popup into a static message that only shows in non-release versions, just like the 'missing translations' message. 8 years ago
alberth 0adfb1ac6f (svn r27653) -Fix(r27647): Rename FileOperation enum and values to SaveLoadOperation to avoid nameclash with windows compiler toolkit. 8 years ago
alberth 6f201ce4a8 (svn r27651) -Codechange: Introduce methods for setting the name and title of _file_to_saveload. 8 years ago
alberth 597380e099 (svn r27650) -Codechange: Replace SaveOrLoadMode by FileOperation and DetailedFileType. 8 years ago
alberth 75ad6d0100 (svn r27647) -Codechange: Introduce file operations, and use it to replace most of SaveLoadDialogMode 8 years ago
alberth 0bf3372882 (svn r27640) -Codechange: Remove another use of _saveload_mode in the loading code. 8 years ago
alberth 2fa0fdb176 (svn r27638) -Codechange: Move FiosType enum, move and rename SetFiosType function. 8 years ago
rubidium 2485b40cdd (svn r26828) -Fix: memory leak when passing -c multiple times 10 years ago
alberth 87dd209784 (svn r26729) -Feature: Warn about missing industries after generating a map. 10 years ago
rubidium b476086c39 (svn r26538) -Codechange: remove double accounting of the drivers 10 years ago
frosch 631e8b45fd (svn r26522) -Add: A config-file-only setting to disable usage of 8bpp video modes.
-Remove: [win32] fullscreen_bpp setting, which is replaced by above setting.
-Change: Disable usage of 8bpp blitters and video modes by default. Many modern OS and hardware cause issues with those.
10 years ago
rubidium 9ed12b0f07 (svn r26509) -Codechange: replace strdup with stredup (the latter ensures the return is not NULL) 10 years ago
rubidium e61fe21237 (svn r26506) -Codechange: replace most of vsnprintf with vseprintf 10 years ago
rubidium 5b82822c12 (svn r26486) -Codechange: replace a number of snprintfs with seprintf 10 years ago
rubidium 0463dbdc9e (svn r26482) -Codechange: add an include that allows us to undefine/redefine "unsafe" functions to prevent them from being used, and thus having to care about certain aspects of their return values 10 years ago
frosch a32d18cbb9 (svn r26371) -Fix [FS#5831]: Calling DoCommandP during the gameloop cleared pending persistent storage changes. 10 years ago
frosch e9f7103ad7 (svn r26369) -Fix-ish: Do not run scripts during command replay. 10 years ago
rubidium a4941e759c (svn r26326) -Fix [FS#5871]: when autosaving the message about a save already happening could be shown, even though the code's intention was to not show it (MJP) 11 years ago
frosch 41b7a04a68 (svn r26317) -Fix [FS#5897]: Check whether NewGRF change vehicle capacity when they are not supposed to, and truncate cargo appropiately if they are allowed to. 11 years ago
rubidium 2618d960e3 (svn r26209) -Codechange: remove some template magic and simplify some code 11 years ago
rubidium 3c94485ba0 (svn r26205) -Feature: SSE 4.1 sprite sorter, improving the sorting performance significantly (MJP)
For example with GCC 4.8, x86_64 Linux, Intel i5-3337U this patch improves the performance of Pile, Treham and Hamac test save games by about 10% in over-all run time at fast forward at 1920x1080 when zoomed out and when trees are not disabled.
11 years ago
frosch eca86d1baf (svn r26174) -Codechange: Rename BaseStorageArray to BasePersistentStorageArray 11 years ago
rubidium 6996b441d9 (svn r26107) -Codechange/cleanup: remove some coding bloat and simplify the driver factory instatiations 11 years ago
rubidium 2009da4f7d (svn r26099) -Codechange: make NewGRF scanner management slightly easier 11 years ago
rubidium 43edd2409e (svn r26098) -Fix: close the log file when OpenTTD was forked and finally closed 11 years ago
rubidium ee0aa389a8 (svn r26097) -Fix: another minor memory leak (when pressing cancel in the bootstrap window) 11 years ago
rubidium 4de2871fc0 (svn r26091) -Fix (r26089): double frees... woospie 11 years ago
rubidium 0ac9ed0b6b (svn r26089) -Fix: a number of minor memory leaks 11 years ago
frosch d0eff986be (svn r25570) -Add: cache for ParagraphLayouts. 11 years ago
rubidium 1efc64fa7d (svn r25553) -Fix [FS#5530]: provide a warning when no vehicles are available, and tell what to do in that case 11 years ago
rubidium 5b2a5ac790 (svn r25506) -Document: a function, and name it slightly better 11 years ago
fonsinchen c32eea02dd (svn r25354) -Add: link graph schedule and typedefs for LinkGraph and related classes 11 years ago
frosch 23ba42b66c (svn r25291) -Add: WindowDesc ability to load and store information in a config file. 11 years ago
peter1138 5bffc704f9 (svn r24974) -Fix [FS#5279]: Honour pause_on_newgame setting when running as a dedicated server. 12 years ago
planetmaker c24374f99c (svn r24900) -Fix [FS#5389]: Comments with typos (most fixes supplied by Eagle_rainbow) 12 years ago
frosch d1ab0f03bc (svn r24790) -Remove: Classic difficulty profiles. 12 years ago
frosch 4471f6bca8 (svn r24716) -Feature(ette): Reset engine pool when starting a scenario. 12 years ago
planetmaker e83cab150b (svn r24485) -Fix: Clarify description of command line option -n 12 years ago
frosch b11b0bb0e2 (svn r24482) -Fix [FS#5232] (r24180): Do not call RebuildSubsidisedSourceAndDestinationCache() before subsidy savegame conversion is finished. 12 years ago
frosch 73706925d1 (svn r24388) -Fix [FS#5233]: Do not consider not finding a particular base set critical; just load a different one and display an in-game error later on. 12 years ago
rubidium b926277caf (svn r24180) -Codechange/feature-ish: add cache checker for the town's cache 12 years ago
rubidium 27d9808f45 (svn r24155) -Fix: the music volume was set too early during startup; at a moment the configuration file wasn't read yet 12 years ago
alberth b57bef91a1 (svn r24099) -Add: Output list of -d option facilities with in the help text. 12 years ago
rubidium e185c2f609 (svn r23963) -Fix [FS#5072]: do not look for missing sprites twice during startup 13 years ago
frosch 428e5d3103 (svn r23839) -Feature: Allow command line options -e and -g to be combined to load saves/scenarios directly into SE. 13 years ago
rubidium 531e501b5a (svn r23751) -Codechange: rename NetworkUDPGameLoop to a more descriptive name, and move the UDP specific bits to network_udp 13 years ago
rubidium 6d6be50ae0 (svn r23740) -Codechange: remove some 300 unneeded includes from the .cpp files 13 years ago
truebrain c99950c215 (svn r23606) -Add: GameScanner, to auto-detect game scripts, and wire it in the console 13 years ago
truebrain 12aa5b6a58 (svn r23604) -Add: initial support for GameScripts 13 years ago
rubidium d0e7b0fd9d (svn r23580) -Codechange: put the infrastructure maintenance cache testing behind the desync debug level guard, improving the game's speed significantly 13 years ago
yexo b4fdba2fb3 (svn r23490) -Add [FS#2750]: OpenBrowser function to open a browser on major OSes 13 years ago
rubidium 2bf0fc3c5c (svn r23476) -Codechange: use the error queue to replace switch mode error strings, again making it possible to return multiple errors 13 years ago
rubidium 58423b26d1 (svn r23474) -Codechange: move the declaration error related functions to error.h 13 years ago
rubidium 5891099f24 (svn r23422) -Fix [FS#4863] (r22797): the default palette setting wasn't applied correctly anymore as the configuration file is loaded after the first NewGRF scan 13 years ago
rubidium a37e8ebe43 (svn r23417) -Fix: wrong argument to printf 13 years ago
michi_cc d30fcd4e35 (svn r23411) -Add: Company infrastructure counts for rail. 13 years ago
truebrain cc12942d70 (svn r23384) -Remove: no longer allow a binary to be without AI support; the parts some compilers failed at, are integrated in other parts of the code now too 13 years ago
rubidium 9512838a5e (svn r23275) -Codechange: allow loading of the monospace (freetype) font at another moment than the other fonts 13 years ago
rubidium 0a4a75b0af (svn r23273) -Codechange: allow passing a MissingGlyphSearcher to CheckForMissingGlyphs (default to the language pack strings) 13 years ago
rubidium 542c61397c (svn r23271) -Codechange: don't repeatedly initialise and free the freetype library 13 years ago
rubidium ea54c38e2c (svn r23246) -Codechange: move searching/loading music/sound sets/drivers to later in the process so we could get rid of errors related to that being dumped onto the console 13 years ago
rubidium 02b884d923 (svn r23244) -Feature: if the installation is ananas, try to get the b without b installed 13 years ago
rubidium 6e31c2f068 (svn r23241) -Codechange: make the decision when to go to the custom drawn cursor more prominently during the initialisation of OpenTTD 13 years ago
rubidium 834eac49fd (svn r23224) -Codechange: first load the config file partially so we can push scanning AIs to later in the process (when the GUI is showing the progress bar) 13 years ago
rubidium 4ae8bbea07 (svn r23222) -Codechange: reduce tar scanning calls to the bare minimum 13 years ago
rubidium 6d991b3b10 (svn r23217) -Codechange: introduce the concept of scanning only in a limited set of sub directories 13 years ago
rubidium 7fd1e1df81 (svn r23198) -Codechange: introduce a free that takes const pointers so we don't need to cast to void/non-const before being able to free 13 years ago
rubidium 1f823f89a1 (svn r23123) -Fix [FS#4790] (r22792): variable was initialised at the wrong moment making things with the cursor go wrong 13 years ago
yexo 433f74edd9 (svn r23065) -Add: -q option to read a savegame, write some general info and exit 13 years ago
michi_cc c575b5bbd7 (svn r23000) -Feature: Base graphics sets can now specify a preferred blitter which OpenTTD uses to decide which blitter to load. 13 years ago
michi_cc 65637d8941 (svn r22874) -Fix [FS#4747]: Check size of various buffers before allocation. (monoid) 13 years ago
rubidium 432b1a4aff (svn r22830) -Codechange: move more logic to after the scanning of NewGRFs 13 years ago
rubidium 0061b5f184 (svn r22822) -Codechange: make a distinction between base sets and newgrfs for their directory 13 years ago
rubidium 9fe4b959ac (svn r22818) -Fix [FS#4742] (r22796, rlongago): don't spawn threads for world generation and NewGRF scanning when using the dedicated or null video driver regardless of the used blitter 13 years ago
rubidium 23e5720392 (svn r22799) -Fix (r22792): compile failure when there is no networking support 13 years ago
rubidium 5ea6064fab (svn r22795) -Codechange: load the intro game the first time without NewGRFs 13 years ago
rubidium 5e7abe58f9 (svn r22792) -Codechange: use scan callback for initial NewGRF scanning 13 years ago
rubidium 421053a694 (svn r22788) -Codechange: move modal progress related functions and variables to progress.cpp/h 13 years ago
rubidium 7b7869fba7 (svn r22786) -Codechange: rename genworld mutices to model_progress mutices 13 years ago
rubidium 37415b9cf7 (svn r22785) -Codechange: rename IsGeneratingWorld to HasModalProgress 13 years ago
frosch c9e920f1eb (svn r22693) -Fix [FS#4691]: The override managers were not reset in some cases like creating a new scenario. 13 years ago
frosch d29def43b0 (svn r22626) -Fix [FS#4622]: Also initialise _old_vds with newgame settings; TTD savegames do not contain these settings. 13 years ago
alberth f1cae9960f (svn r22512) -Add: Save heightmap. 13 years ago
rubidium 944a5cb7aa (svn r22423) -Document: some network stuff 13 years ago
frosch bbcd2bab5d (svn r22419) -Change: Always use the DOS palette for drawing.
-Remove: the '-i' option for palette selection.
13 years ago
rubidium f90044d343 (svn r22202) -Codechange: make MusicFileSettings a proper citizen of the client settings 13 years ago
alberth 31386c42a7 (svn r22145) -Codechange: Do explicit test for non-bool values. 14 years ago