Commit Graph

617 Commits

Author SHA1 Message Date
rubidium42 44ca7d9377 Change: Use gender-neutral pronouns 2021-05-15 10:16:48 +02:00
rubidium42 297d6e20bf Codechange: [Network] Pass passwords as std::string to the network code 2021-05-14 23:22:04 +02:00
rubidium42 c73d64adf9 Codechange: move passwords in settings to std::string 2021-05-13 23:13:17 +02:00
glx22 38c97e1492 Codechange: Replace TILE_AREA_LOOP with range-based for loops 2021-05-13 00:13:54 +02:00
Patric Stout b136e65cf9
Change: reworked the debug levels for network facility (#9251)
It now follows very simple rules:
0 - Fatal, user should know about this
1 - Error, but we are recovering
2 - Warning, wrong but okay if you don't know
3 - Info, information you might care about
4 -
5 - Debug #1 - High level debug messages
6 - Debug #2 - Low level debug messages
7 - Trace information
2021-05-12 16:34:02 +02:00
Rubidium fa6abe1646 Cleanup: remove the old FIO slot functions 2021-05-08 12:39:34 +02:00
William Davis 881e1da51d
Change: Use gender-neutral pronouns in console command messages (and comments) (#9203) 2021-05-08 11:02:30 +01:00
rubidium42 3d91eee919 Codechange: [Network] Move connection string parsing away from C-strings 2021-05-06 20:33:26 +02:00
rubidium42 e7581fd42d Change: [Network] Update server's NetworkServerGameInfo only when needed
Split the updating in a "static" version that only needs to be called when a new map is loaded or some settings are changed, and a "dynamic" version that updates everything that changes regularly such as the current game date or the number of spectators.
2021-05-05 21:01:23 +02:00
rubidium42 05394d5216 Fix #6598: Prevent invalid memory accesses when abandoning a join from within a network game
One could join a network game from within an already running network game. This would call a NetworkDisconnect, but keeps the UI alive. If, during that process the join is aborted, e.g. by cancelling on a password dialog, you would still be in your network game but also get shown the server list.
Solve all the underlying problems by falling back to the main UI when (re)connecting to a(nother) server.
2021-05-01 18:30:08 +02:00
rubidium42 a61696d6c5 Change: [Network] Encapsulate logic about the connection string to the network code (#23) 2021-04-29 20:12:11 +02:00
Patric Stout be37a2cab8 Codechange: use NetworkAddress instead of two host/port variables where possible
This also means we no longer need last_host/last_port, but can
just use a single last_joined setting.
2021-04-29 20:12:11 +02:00
rubidium42 cbad518bf3 Codechange: [Network] Do not leak os_abstraction.h via network_func 2021-04-27 18:17:34 +01:00
Patric Stout 31897eaa7d Codechange: split ParseConnectionString into two functions
One also looks for a company, the other doesn't. There were more
uses of the latter than the first, leaving very weird code all
over the place.
2021-04-20 17:34:04 +02:00
Patric Stout f4bd3fff5e Remove: "map_name" from server announcements / listing
The idea back in the days was nice, but it never resulted in
anything useful. Most servers either read "(loaded game)" or
"Random Map", neither being useful. It was meant for heightmaps,
so you could find a server that was using a specific one .. but
there are many things wrong with that idea. Mostly, servers tend
to save and load savegames from time to time, after which the
original heightmap used was lost.

All in all, removing map_name all together is just better.
2021-04-20 17:24:38 +02:00
rubidium42 c4bccd4f70
Fix #8874: show a warning when a NewGRF scan is requested multiple times from the console (#9022) 2021-04-12 20:53:04 +02:00
rubidium42 df045b92ea
Fix #9008: Validate starting year given on the command line. (#9014)
An invalid starting year causes all sorts of weird behaviour and crashes in map generation.

Now just set the appropriate setting via IConsoleSetSetting so the validation
and, if needed, clamping is performed on the starting year value.
2021-04-11 13:52:55 +02:00
Patric Stout 5426cb3baf Fix: abort GRFFileScanner on exiting the game as soon as possible
This prevents the window from "freezing" when you close it during
the scanning of NewGRFs, as it first would continue the action.
2021-03-10 13:41:18 +01:00
Patric Stout b349ef6e71 Fix: don't update framerates when a modal window is open
Otherwise the numbers are all over the place when a modal window
just closed.
2021-03-10 13:41:18 +01:00
Patric Stout 970fedd78c Add: make modal windows update more smooth
Basically, modal windows had their own thread-locking for what
drawing was possible. This is a bit nonsense now we have a
game-thread. And it makes much more sense to do things like
NewGRFScan and GenerateWorld in the game-thread, and not in a
thread next to the game-thread.

This commit changes that: it removes the threads for NewGRFScan
and GenerateWorld, and just runs the code in the game-thread.
On regular intervals it allows the draw-thread to do a tick,
which gives a much smoother look and feel.

It does slow down NewGRFScan and GenerateWorld ever so slightly
as it spends more time on drawing. But the slowdown is not
measureable on my machines (with 700+ NewGRFs / 4kx4k map and
a Debug build).

Running without a game-thread means NewGRFScan and GenerateWorld
are now blocking.
2021-03-10 13:41:18 +01:00
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.
2021-03-09 20:30:37 +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
Michael Lutz 22f5aeab07 Feature: Automatic UI and font zoom levels when supported by the OS. 2021-02-14 14:16:40 +01:00
glx22 6b8ad5a9b1 Change: Apply some consistency to singleplayer related comments 2021-01-22 22:19:55 +01:00
Michael Lutz fa60c1f8b9
Feature: Choose a sensible window size on a fresh OTTD config file. (#8536) 2021-01-14 21:53:06 +01:00
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.
2021-01-11 20:11:08 +01:00
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.
2021-01-11 20:11:08 +01:00
Charles Pigott 9b800a96ed
Codechange: Remove min/max functions in favour of STL variants (#8502) 2021-01-08 11:16:18 +01:00
Michael Lutz b408fe77f7 Codechange: Use std::string in file scanners. 2020-12-27 13:19:25 +01:00
Michael Lutz 5cbb2da794 Codechange: Even more std::string usage in file IO. 2020-12-27 13:19:25 +01:00
Michael Lutz 65f65ad2ad Codechange: Convert some more FIO functions to take std::string. 2020-12-27 13:19:25 +01:00
Michael Lutz dd138fc460 Codechange: Stringify config file paths. 2020-12-27 13:19:25 +01:00
Charles Pigott 860c270c73 Codechange: Replace assert_compile macro with static_assert 2020-12-27 10:55:42 +00:00
Jonathan G Rennison 5cf28be742 Codechange: Add support for verbose asserts 2020-12-27 10:30:55 +00:00
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.
2020-12-22 15:17:57 +01:00
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>
2020-12-15 15:46:39 +01:00
Patric Stout 5d0331ecdc
Fix 8bef06a2: don't use "extern" when you want to implement a global (#8373) 2020-12-13 16:56:33 +01:00
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.
2020-12-13 16:28:06 +01:00
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.
2020-12-08 10:24:59 +01:00
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.
2020-09-24 19:17:18 +02:00
Michael Lutz c972a63c8c Codechange: Store info about the dedicated server log file in globals with automatic destruction to simplify control flow in openttd_main. 2020-05-21 20:02:34 +02:00
Michael Lutz 37bc2f8064 Codechange: Use std::string in the driver and blitter selection code. 2020-05-21 20:02:34 +02:00
Michael Lutz a49fdb7ebb Codechange: Store base set related texts in std::strings. 2020-05-21 20:02:34 +02:00
glx22 d15c7dbdeb
Add: stations_near and industries_near cache check (#8139) 2020-05-12 01:19:52 +02:00
glx22 86e9326b7f
Add: docking tiles cache check (#8120) 2020-05-07 01:14:22 +02:00
Niels Martin Hansen 0e78393774 Fix: Reference correct section in README file for baseset info 2019-12-26 19:50:07 +01:00
glx ee7a8eebca Codechange: Replace FOR_ALL_TOWNS with range-based for loops 2019-12-21 20:13:03 +01:00
glx b91abd3af9 Codechange: Replace FOR_ALL_ROADSTOPS with range-based for loops 2019-12-21 20:13:03 +01:00
glx d8a1be48cd Codechange: Replace vehicle related FOR_ALL with range-based for loops 2019-12-21 20:13:03 +01:00
glx ddabfed1cd Codechange: Replace station related FOR_ALL with range-based for loops 2019-12-21 20:13:03 +01:00