1
0
forked from 0ad/0ad
Commit Graph

394 Commits

Author SHA1 Message Date
8519eb9b86
Reduce time needed for STUN
In my tests this reduced the time necessary for starting to host a game
or joining a hosted game by ~180ms.
2024-08-23 21:00:15 +02:00
38e3f5cec0 Fix build with miniupnpc 2.2.8
See
https://github.com/miniupnp/miniupnp/blob/miniupnpc_2_2_8/miniupnpc/Changelog.txt.
And https://github.com/0ad/0ad/pull/45

Patch by: @emily
Accepted: by @Stan
Comments by: @phosit, @sera
Differential Revision: https://code.wildfiregames.com/D5307
This was SVN commit r28167.
2024-07-30 18:44:38 +00:00
a16a3f82a1 Delete FSM.cpp forgotten in 3a5ad160f7
This was SVN commit r28075.
2024-05-05 06:04:22 +00:00
3a5ad160f7 Make CFsm a template
The context doesn't have to be converted to `void*` and back.


Differential Revision: https://code.wildfiregames.com/D5253
This was SVN commit r28074.
2024-05-04 16:13:02 +00:00
a4f91e43ae Default many of CFsm's special functions and remove virtual specifires
Differential Revision: https://code.wildfiregames.com/D5249
This was SVN commit r28053.
2024-03-21 17:43:34 +00:00
78652aa92c Use std::function instead of inhereting from CNetFileReceiveTask
The user doesn't have to fiddle with `std::shared_ptr`.
And two (more unrelated) things: use `std::unordered_map`, use a
`std::find_if` in the callback.

Comments By: @vladislavbelov, @Stan
Differential Revision: https://code.wildfiregames.com/D5239
This was SVN commit r28048.
2024-03-09 14:31:43 +00:00
1eb11b39bf Remove the StateSet from FSM
The `StateSet` is only used to check if a state is valid. That's useless
since it wouldn't be found in the `TransitionMap` - With the same
outcome.

Accepted By: @vladislavbelov
Differential Revision: https://code.wildfiregames.com/D5236
This was SVN commit r28039.
2024-02-25 14:05:23 +00:00
483da49759 More generic hash function for FSM
The hash function introduced in 6faf704731 doesn't work on 32 bit
systems. This one should.

Accepted By: @vladislavbelov
Differential Revision: https://code.wildfiregames.com/D5237
This was SVN commit r28033.
2024-02-16 17:31:40 +00:00
6faf704731 Split the FSM-transitions and put them in an unordered_map
Comments By: @vladislavbelov
Differential Revision: https://code.wildfiregames.com/D5225
This was SVN commit r28020.
2024-01-29 18:44:14 +00:00
05356bb9fc Remove the FSM EventMap
Comments By: @vladislavbelov
Differential Revision: https://code.wildfiregames.com/D5089
This was SVN commit r27987.
2023-12-20 20:44:06 +00:00
ffc4a56b9f Revert non-ASCII characters from source and configuration files introduced in 157c6af18e.
Fixes #6846

Differential Revision: https://code.wildfiregames.com/D5185
This was SVN commit r27965.
2023-12-03 00:30:12 +00:00
1bccfef6fb Don't use std::shared_ptr in ScriptInterface
Differential Revision: https://code.wildfiregames.com/D5159
This was SVN commit r27945.
2023-11-19 20:13:19 +00:00
bb
157c6af18e Make the space in 0 A.D. non-breaking throughout the codebase.
Avoid cases of filenames
Update years in terms and other legal(ish) documents
Don't update years in license headers, since change is not meaningful

Will add linter rule in seperate commit

Happy recompiling everyone!

Original Patch By: Nescio
Comment By: Gallaecio
Differential Revision: D2620
This was SVN commit r27786.
2023-07-27 20:54:46 +00:00
80bcf944bc Don't convert actions to void*
Accepted By: @vladislavbelov
Differential Revision: https://code.wildfiregames.com/D5044
This was SVN commit r27783.
2023-07-25 07:50:33 +00:00
909a81bc87 Correct syntax mistakes made in b7d776175b
Accepted By: @vladislavbelov
Differential Revision: https://code.wildfiregames.com/D5068
This was SVN commit r27781.
2023-07-24 08:19:19 +00:00
8b761fec29 Constrain the FSM-transition to have at most one action.
Accepted By: @vladislavbelov
Differential Revision: https://code.wildfiregames.com/D5059
This was SVN commit r27768.
2023-07-19 12:23:53 +00:00
b7d776175b Add a test for the FSM
Accepted By: @wraitii
Differential Revision: https://code.wildfiregames.com/D4902
This was SVN commit r27742.
2023-06-27 19:20:41 +00:00
8480cfc35f Remove FSM conditions.
FSM conditions aren't used. So this removes dead code.

Accepted By: @wraitii
Differential Revision: https://code.wildfiregames.com/D4959
This was SVN commit r27702.
2023-06-14 14:58:37 +00:00
7c07083724 Fix the removal of implicit conversions in libfmt 10 by using explicit casts.
Patch by: @phosit
Accepted by: @vladislavbelov
Comments by: @sera
Differential Revision: https://code.wildfiregames.com/D4998
This was SVN commit r27657.
2023-05-31 12:03:04 +00:00
ef71533d70 Use a lower default MTU for ENet hosts, and make it configurable.
This fixes packet loss issues on some VPN solutions.

Patch By: sera
Differential Revision: https://code.wildfiregames.com/D4967
This was SVN commit r27599.
2023-04-10 08:21:07 +00:00
b31e698f12 Use override in classes derived from AbstractProfileTable.
Patch By: phosit
Differential Revision: https://code.wildfiregames.com/D4825
This was SVN commit r27414.
2023-01-10 22:32:08 +00:00
fc392a4367 FSM cleanup:
- Use reinterpret_cast.
- Use using instead of typedef.
- Use PascalCase for CONDITION and ACTION.
- Use constexpr instead of #define.

Patch by: @phosit
Differential Revision: https://code.wildfiregames.com/D4868
This was SVN commit r27385.
2023-01-07 21:41:30 +00:00
f1edbb9049 Make comments in FSM detectable by doxygen
- Move the comments to the header file
 - Add a dot at the end of a comment
 - Remove some trivial comments
 - Improve spelling.

Patch by: @phosit
Differential Revision: https://code.wildfiregames.com/D4861
This was SVN commit r27376.
2023-01-06 19:16:11 +00:00
c729444787 replace NULL by nullptr
remove nullptr check before delete. They are redundant.
remove nullptr check after new. They will never be null.
two whitespaces changes forgotten in
https://code.wildfiregames.com/D4800.

Patch by: @phosit
Differential Revision: https://code.wildfiregames.com/D4853
This was SVN commit r27351.
2023-01-05 12:09:02 +00:00
8e0e40d489 Fix whitespaces, identation and remove (void).
Patch by: @phosit
Differential Revision: https://code.wildfiregames.com/D4800
This was SVN commit r27337.
2023-01-04 17:10:05 +00:00
3dad53a7ee Fixes without PCH build in StunClient missing include for std::byte added in 895e4e6aa6.
Differential Revision: https://code.wildfiregames.com/D4814
This was SVN commit r27174.
2022-10-26 00:15:27 +00:00
dfa8176007 Allow 0.0.0.0 IP in StunClient tests added in 2034136560.
Patch By: kalev
Differential Revision: https://code.wildfiregames.com/D4792
This was SVN commit r27164.
2022-10-22 19:22:38 +00:00
b59e798ef4 Moves network/fsm.* to network/FSM.*.
Patch By: phosit
Differential Revision: https://code.wildfiregames.com/D4797
This was SVN commit r27150.
2022-10-12 18:16:27 +00:00
Angen
8cec96270b Don't create thread on failed connection
Differential revision: D4545
Fixes: #6442

This was SVN commit r26649.
2022-03-14 17:19:42 +00:00
bb
8eecc39e71 Let the Gamesetup.cpp Autostart (starting from cl) use the gamesettings via the autostart gui page.
Comments and testing By: Langbart
Fixes #6433
Differential Revision: D4492
Includes/Obsoletes D4287

This was SVN commit r26584.
2022-03-06 21:12:16 +00:00
410d2e883a Remove leftover terrain-based movement cost code.
6581796103 removed the ability for terrain to affect movement speed. The
JPS pathfinder cannot support it, and the approach was poor anyways,
coupling rendering data with simulation data.
This lets us remove the dependency on CTerrainTextureManager everywhere.

Tested by: langbart
Differential Revision: https://code.wildfiregames.com/D4459
This was SVN commit r26269.
2022-01-29 08:22:28 +00:00
b6012ec606 Fix false positive; undefined variable in NetworkClient.cpp
refs #6321 for further cleanups.
Discussed with: @wraitii
Differential Revision: https://code.wildfiregames.com/D4258
This was SVN commit r25908.
2021-09-09 18:00:17 +00:00
96708cc6a5 Adds header for forward declarations of CStr.
This was SVN commit r25905.
2021-09-09 17:39:08 +00:00
a5c82a4ef6 Removes unused forward declarations of class and struct.
This was SVN commit r25903.
2021-09-08 19:43:01 +00:00
8af0689b5f Fix gamesetup player assignment issue when joining
Switch some logic from C++ to JS in PREGAME for player assignments. Refs
#3049

Fixes #6204

Reported by: Imarok
Tested By: Imarok
Differential Revision: https://code.wildfiregames.com/D4092
This was SVN commit r25699.
2021-06-06 08:02:28 +00:00
d9d19543b5 Adds std namespace to shared_ptr usages in network and engine.
This was SVN commit r25527.
2021-05-22 19:28:40 +00:00
d7a4fb7c20 Try to punch a hole through local firewalls, and fallback to localhost.
Fixes (probably rare) regression in 2034136560.

Differential Revision: https://code.wildfiregames.com/D3999
This was SVN commit r25515.
2021-05-22 08:34:00 +00:00
7bfcd9f78b Additional entropy when hashing match passwords.
The purpose of our client-side hashing for lobby game passwords is to
prevent malicious hosts from getting valuable passwords from clients
(e.g. accidentally typing their lobby password instead of the game, or
even their email password, etc).
However, the hashing was deterministic (and rather simple), making it
possible to compute rainbow tables and recover user passwords anyways.

By adding more variation, including some that cannot so easily be
controlled by the host (the client name), this becomes impractical. The
password hashing function used is rather fast, but given the base low
probability of mistypes, this seems fine.

Differential Revision: https://code.wildfiregames.com/D3459
This was SVN commit r25459.
2021-05-18 14:47:36 +00:00
895e4e6aa6 StunClient code cleanup: use enet functions, endianness
Instead of using platform-specific sockets, use enet_socket* functions
(which ends up doing the same).
Clean up some confusing APIs, removing the distinction between finding
the public IP for the host/join.

Fix endianness support & use simpler code.

Refs D364 / 61261d14fc (and some subsequent fixing diffs).

Differential Revision: https://code.wildfiregames.com/D3970
This was SVN commit r25453.
2021-05-17 15:14:10 +00:00
2034136560 Implement a workaround for routers without NAT loopback.
This allows joining a lobby game hosted on the same network (behind the
same NAT gateway).
This is relatively primitive to keep things simple: if the server and
the client have the same public IP, it is assumed that they are on the
same network and the client instead requests the local IP.

Differential Revision: https://code.wildfiregames.com/D3944
This was SVN commit r25448.
2021-05-16 15:34:38 +00:00
4f972bc623 Split off JSON-related function from ScriptInterface, clean up headers.
Follows 34b1920e7b.

JSON functions and ToString are movec to their own headers.
Also clean out a few PersistentRooted usage to use the 2-phase init to
clean up scriptInterface usage.

With these functions split off, we can finally clean out headers and
remove ScriptInterface.h from most of them, in favour of smaller and
more precise headers.


Take the opportunity to clarify some comments regarding Mutability.

Differential Revision: https://code.wildfiregames.com/D3961
This was SVN commit r25434.
2021-05-14 10:18:03 +00:00
0f60bf3a97 Split off Object-related functions from ScriptInterface
Follows 34b1920e7b.

This splits off the object-related functions, such as
[Set/Get/Has]Property, CreateObject, CreateArray, FreezeObject.

It also puts the definitions in the header itself, which might end up
with faster code here & there, though perhaps slower compilation time
(somewhat doubtful since we already included most things anyways).

Differential Revision: https://code.wildfiregames.com/D3956
This was SVN commit r25430.
2021-05-13 17:23:52 +00:00
4ad78018f9 Fix no-pch build. Potentially fixes bb49fbe793, 0198942a79, 34b1920e7b, 8b08f4ae7a 0dbf417171, 3af1fc64d2, 5fbdbaa3bc, 6fbf036ae4.
Comments by: @vladislavbelov, @wraitii.
Differential Revision: https://code.wildfiregames.com/D3948
This was SVN commit r25423.
2021-05-12 13:48:55 +00:00
6fbf036ae4 Split off StructuredClone from ScriptInterface
Follows 34b1920e7b.

This separates StructuredClone & DeepCopy logic into its own header,
reducing the size of the monolithic ScriptInterface header.

Differential Revision: https://code.wildfiregames.com/D3922
This was SVN commit r25419.
2021-05-10 11:51:32 +00:00
e94faf7827 Don't hardcode the "0ad" resource into lobby XMPP & hosting
XMPP JID has a concept of 'resources', which can be used to
differentiate multiple clients of the same account.

We currently hardcode this 'resource' to '0ad' in two places:
- The 0 A.D. client always uses '0ad'
- The network code expects a host resource to be '0ad' when connecting.

As noted in 0fd8aa2a77#31215, it is less effort to store the JI
D directly. This patch does that. It also makes 0 A.D. use a different
resource each time.
Note that resources ought not contain particular information, as the
XMPP server is free to
 clobber it. I keep '0ad-' here for debug purposes.

This allows:
- multiple 0 A.D. instances to log on the lobby at the same time (not
massively useful, but good for debugging sometimes)
- hosting a game with a custom resource, which will potentially make it
easier to have dedi
cated servers on one account.

Note that hosting multiple games on one account is currently not
supported and will have weird behaviour on the lobbybots side. They
should be upgraded independently of this.

Refs #3556

Differential Revision: https://code.wildfiregames.com/D3500
This was SVN commit r25407.
2021-05-09 12:51:32 +00:00
34b1920e7b Split ScriptRequest in its own header.
We often only need to include ScriptRequest.h and not the full
ScriptInterface.h

Differential Revision: https://code.wildfiregames.com/D3920
This was SVN commit r25366.
2021-05-03 16:07:26 +00:00
b55b236379 Remember OOS on a per-client basis.
Change the OOS notification logic to remember the OOS-ness of each
client. Reset it on client leave.
The server will thus continue checking for OOS if the OOS-client leaves.
This is convenient to ignore observer OOS, or wait for an OOS player
without restarting the game.

Also add the turn number to the OOS dump, to fix #3348: particularly
following d4c2cf4430 the turn is likely to not be the same between
different clients.

Agree by: asterix
Differential Revision: https://code.wildfiregames.com/D3753
This was SVN commit r25170.
2021-03-31 15:55:19 +00:00
5ebf2020b0 Netcode: allow observers to lag behind the live game.
Observers no longer lag the game for players. There is still some time
to serialise the game when sending it to a joining observer, and
depending on the chosen 'max lag' the game may stop while observers
sufficiently catch up, but this impact too is reduced.

- Make the NetServerTurnManager ignore players marked as 'observers' for
the purpose of ending a turn, effectively making it possible for
observers to lag without it affecting the players in any way.
- Add a config option (network.observermaxlag) that specifies how many
turns behind the live game observers are allowed to be. Default to 10
turns, or 2 seconds, to keep them 'largely live'.
- The controller is not treated as an observer.
- Implement a simple UI to show this delay & allow the game to speed up
automatically to try and catch up. This can be deactivated via
network.autocatchup.
- Move network options to the renamed 'Network / Lobby' options page.
- Do not debug_warn/crash when receiving commands from the past -
instead warn and carry on, to avoid DOS and "coop play" issues.

Refs #5903, Refs #4210

Differential Revision: https://code.wildfiregames.com/D3737
This was SVN commit r25156.
2021-03-29 07:53:06 +00:00
87a2c3347f Make real directory paths on the VFS predictable (retry)
This is the same commit as 4bb31f084e, reverted in 5d1899785a. Noted
issues were fixed.

Partial revert/fix of 2f19cf86d3 and 2567fee329.

Before this diff, it was possible for a mod containing a cache/ or a
config/ folder to get written to incorrectly.
The issue is VFS can map multiple directories to one 'virtual' path, for
reading mods. However, writing data is problematic: which path to
choose?
The only viable solution is to use a path relative to the highest
priority directory encountered in the VFS path, or write paths could be
'hijacked' by lower-priority mods.

This fixes these issues by:
- Adding a new lookup mode ('Real-path') that explicitly picks the real
path relative to the highest-priority subdirectory in the VFS Path.
- Preventing overwriting a real directory with a lower priority one in
general.
- Revert c0c8132dd4's GetRealPath change, re-introducing the function as
GetOriginalPath.

This also cleans up some duplication that led to empty mod folders in
the user mod path, and cleans up loading the 'user' mod.
It also makes it explicit that a directory must be passed to Mount().

Note that the new 'realpath' lookup can still be somewhat complex with
many mount points at various hierarchy levels, but it is at least
predictable/deterministic without having to be careful about populating
order.

Fixes #2553

Differential Revision: https://code.wildfiregames.com/D3728
This was SVN commit r25107.
2021-03-23 12:46:59 +00:00
5d1899785a Revert 4bb31f084e
4bb31f084e led to an issue in windows-specific code not detected by the
tests. I'll debug later.

This was SVN commit r25105.
2021-03-22 19:52:07 +00:00