summaryrefslogtreecommitdiff
path: root/src/network
AgeCommit message (Collapse)Author
2021-04-07Fix #8713: Change OTTD2FS and FS2OTTD to return string objects instead of ↵Niels Martin Hansen
static buffers
2021-04-06Fix: [Network] State conditions for sending client info/quit packets (#8959)Jonathan G Rennison
Use status >= STATUS_AUTHORIZED as the state criteria for all cases where updates about other clients are sent. This avoids the case where a client is informed that another client has joined but not informed when it later quits, resulting in stale entries in the client list window.
2021-03-10Add: make modal windows update more smoothPatric Stout
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-03Fix #8799: NGameAllowedSorter() is not imposing strict weak ordering ↵Patric Stout
relation (#8801) In other words, it should only (!) return true if A comes for B. This promise was broken for the situation where two values are identical. It would return true in these cases too. This is of course not possible: if two values are identical, neither come before the other. As such, the sorter was not imposing strict weak ordering relations. libstdc++ handled this scenario just fine, but libc++ crashes badly on this, as it allowed comparing of [begin, end] instead of [begin, end). libc++ considered this not a bug (and by specs, they are correct; just this way of crashing is of course a bit harsh): https://bugs.llvm.org/show_bug.cgi?id=47903
2021-02-28Fix #6266: Ugly lists in network lobby windows on double/quad interface ↵dP
sizes with custom fonts
2021-02-28Fix: [Network] don't show "server doesn't respond" while in queuePatric Stout
Send all clients in the queue every game-day a packet that they are still in the queue.
2021-02-28Fix: [Network] send map to next client if current client disconnectsPatric Stout
Also terminate creating of the savegame, as the client is gone, there really is no need for that anymore.
2021-02-28Fix: [Network] also count the person downloading the map in the queuePatric Stout
Strictly seen, there are "N" people -waiting- in front of you in the queue, but it is nicer to show "N + 1" for the person that is currently downloading the map. Avoids it showing: "0 clients in front of you". That just feels a bit off.
2021-02-27Change: Improve console warnings on invalid network commands (#8753)Pavel Stupnikov
2021-02-27Codechange: [Network] replace _realtime_tick with std::chronoPatric Stout
2021-02-27Fix bddfcaef: don't tell twice that a client left because of a timeout etc ↵Patric Stout
(#8746) SendError() notifies all clients of the disconnect. This calls CloseConnection() at the end, which also notified the clients of the disconnect. Really no need to do it twice. The status NETWORK_RECV_STATUS_SERVER_ERROR is only set by SendError(), so in case that is the status, don't let ClientConnection() send another notification.
2021-02-20Codechange: rename sound ids to make more sense. (#8701)frosch
2021-02-08Fix: mention our websites with https:// (instead of http://) (#8657)Patric Stout
It is 2021. Nobody should advertise http anymore. Not even us.
2021-02-05Codechange: Apply coding style (#8640)SamuXarick
* Fix: Missing or needed spaces * Codechange: Remove space * Codechange: Remove space * Codechange: More missing spaces * Codechange: Missing spaces * Codechange: Remove space * Codechange: Remove space
2021-01-31Fix 2db88953: default Network Server List sorter put compatible servers in ↵Patric Stout
wrong order (#8626) If a server is compatible, it falls back to sorting by clients. This used to be in reverse, so full servers are on top. With the codechange commit, this was removed by accident, and as such empty servers were on top. This is silly.
2021-01-22Change: Apply some consistency to singleplayer related commentsglx22
2021-01-08Fix: Start the inactivity-timeout for the content server only after the ↵frosch
connection has been established. (#8530) When connecting took long due to the first N resolve-addresses timing out, OpenTTD would immediately close the connection, without sending anything.
2021-01-08Codechange: Remove min/max functions in favour of STL variants (#8502)Charles Pigott
2021-01-05Change: move "give money" from client-list to company windowPatric Stout
This is a much better location for this button, as you send money from one company to another company, not from player to player. This is based on work done by JGRPP in: https://github.com/JGRennison/OpenTTD-patches/commit/f82054339124cc6b89c5f4f9dac2d9da62f0108b and surrounding commits, which took the work from estys: https://www.tt-forums.net/viewtopic.php?p=1183311#p1183311 We did modify it to fix several bugs and clean up the code while here anyway. The callback was removed, as it meant a modified client could prevent anyone from seeing money was transfered. The message is now generated in the command itself, making that impossible.
2021-01-02Fix: prevent clients making emergency saves twice if server disconnects (#8477)Patric Stout
This was clearly overlooked during the initial implementation.
2020-12-27Fix b408fe7: Don't try to construct a std::string from nullptrCharles Pigott
2020-12-27Codechange: Even more std::string usage in file IO.Michael Lutz
2020-12-27Codechange: Convert some more FIO functions to take std::string.Michael Lutz
2020-12-27Codechange: Use std::string in FIO search path handling.Michael Lutz
2020-12-27Codechange: Replace assert_compile macro with static_assertCharles Pigott
2020-12-25Codechange: Rename strings to match their usage.frosch
2020-12-25Change: Remove the LAN/Internet combobox from the server list in favour of ↵frosch
adding two separate search buttons.
2020-12-22Change: [Linkgraph] Pause the game when linkgraph jobs lag (#6470)Jonathan G Rennison
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-16Change: send network error to the server before making an emergency save (#8387)Pavel Stupnikov
2020-12-15Fix: Remove unnessary reference to suppress warning (#8337)Byoungchan Lee
Apple Clang version 12 (bundled with Xcode 12) complaints about copying small objects in range loop (-Wrange-loop-analysis introduced by -Wall). This warning can be easily avoided by removing the reference from the const pointer type.
2020-12-15Fix: workarounds for two emscripten bugs in the network stackPatric Stout
2020-12-15Add: support for emscripten (play-OpenTTD-in-the-browser)Patric Stout
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-07-09Fix: Thread unsafe use of SendPacket for PACKET_SERVER_MAP_SIZEJonathan G Rennison
NetworkTCPSocketHandler::SendPacket is not thread safe and may not be used concurrently from multiple threads without suitable locking
2020-06-27Doc: Acknowledge integer type mismatch in certain admin packets using ↵duck
AdminUpdateType (#8238)
2020-06-27Fix: Compiler warnings about memsetting non-trivial classesCharles Pigott
2020-06-21Fix: Thread unsafe use of NetworkAddress::GetAddressAsStringJonathan G Rennison
Remove static buffer form of NetworkAddress::GetAddressAsString. This is used in multiple threads concurrently, and is not thread-safe. Replace it with a form returning std::string.
2020-06-18Fix: Racy use of flags in TCPConnecter::CheckCallbacksJonathan G Rennison
conected and aborted flags are used concurrently from multiple threads.
2020-06-05Add: introduce CMake for project managementPatric Stout
CMake works on all our supported platforms, like MSVC, Mingw, GCC, Clang, and many more. It allows for a single way of doing things, so no longer we need shell scripts and vbs scripts to work on all our supported platforms. Additionally, CMake allows to generate project files for like MSVC, KDevelop, etc. This heavily reduces the lines of code we need to support multiple platforms from a project perspective. Addtiionally, this heavily improves our detection of libraries, etc.
2020-06-01Fix #8024: make online content gui more responsive while loadingYexo
Previously the internal content list was invalidated and sorted for every new item added. Now the sorting is delayed until the GUI is drawn, which means we only sort once per GUI tick. Since the amount of incoming items per GUI tick is not controlled by the GUI but rather by network speed, we were previously doing a lot of duplicate work per tick, causing the mouse cursor to lag while the list was initialized.
2020-05-21Codechange: Replace custom linked list for GRF texts with STL vectors and ↵Michael Lutz
strings.
2020-05-07Fix #8117: Memory leak in admin port (#8122)glx22
2020-04-05Fix #8060, 5880f14: Restore admin network API compatibility.frosch
2020-02-23Codechange: Limit field width to avoid sscanf crashQuipyowert2
2020-02-08Fix #7976: Don't kick the client doing the rconglx
2020-02-04Feature #7756: Allow server to supply a reason to kicked/banned clientsBjarni Thor
This commit adds the missing feature of allowing the server owner to provide a reason for kicking/banning a client, which the client sees in a pop-up window after being kicked. The implementation extends the network protocol by adding a new network action called NETWORK_ACTION_KICKED that is capable of having an error string, unlike the other network error packages. Additionally, the kick function broadcasts a message to all clients about the kicked client and the reason for the kick.
2020-01-12Feature: Auto-restart loads the original resources againBerbe
If the game was started loading a savegame or scenario, auto-restart will load a new random map. This is inconsistent with the case in which a heightmap was loaded, as in that case the heightmap is kept as a basis for a new game. This proposal solves this heterogeneity be considering the originally loaded resource shall be kept, hence savegames & scenarios shall be reloaded
2020-01-07Codechange: Remove std::function from Pool iteration wrapperJonathan G Rennison
Add a separate template wrapper for filtered iteration
2019-12-21Fix: unused variable warningsglx
2019-12-21Codechange: Replace FOR_ALL_TOWNS with range-based for loopsglx
2019-12-21Codechange: Replace vehicle related FOR_ALL with range-based for loopsglx