Commit graph

54 commits

Author SHA1 Message Date
Dunedan
93ce94655d
Use @stylistic/brace-style for eslint
Up to now `eslint-plugin-brace-rules` was used to enforce a common brace
style for JavaScript code. This plugin was however updated the last time
over 9 years ago and will be incompatible with ESLint v10, as that
[removes `context.getSourceCode()`][1], the plugin relies on.

To keep the eslint config working with ESLint v10, this replaces
`eslint-plugin-brace-rules` with the [`@stylistic/brace-style`][2] rule
from `@stylistic/eslint-plugin`, a package we already use.

While `@stylistic/brace-style` doesn't offer an option to format braces
in exactly the same way as before, the "allman" style seems to be the
one closest to the existing code.

[1]: https://eslint.org/blog/2025/11/eslint-v10.0.0-alpha.0-released/#removed-deprecated-rule-context-members
[2]: https://eslint.style/rules/brace-style
2026-01-12 21:33:52 +01:00
trompetin17
b42a2b9adb
Apply correct use of TextSize APIs in GUI
Updates GUI code to apply the correct usage of `guiObject.getTextSize()`
and `guiObject.GetPreferedTextSize()`.

- `guiObject.getPreferedTextSize()` is now used when the goal is to compute the
  bounding box of a text string to dynamically resize or layout a GUI
  object accordingly. It simulates how the text would be rendered,
  accounting for markup and layout rules.

- `guiObject.getTextSize()` remains in use when text is being measured
  within a fixed-size GUI element (e.g., a button or label). It respects
  internal constraints like buffer zone and maxWidth, and is typically
  used to align other elements based on its visual appearance.

These changes ensure more accurate text sizing and consistent layout
behavior across GUI components.
2025-06-26 17:11:24 -05:00
Ralph Sennhauser
0ce889ca6d
Use stylistic for deprecated eslint rules
During the eslint 8 cycle the formatting rules were split out [1],
deprecating the corresponding rules in core.

This replaces all rules that where moved to @stylistic/eslint-plugin [2]
and accounts for the difference in the indenting rule behaviour.

To allow the pre-commit import hack to continue to work with the
stylisitc plugin for a recent nodejs version to be used.

[1] https://eslint.org/blog/2023/10/deprecating-formatting-rules/
[2] https://eslint.style/packages/default

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-06-10 21:23:23 +02:00
Ralph Sennhauser
406d0c90ca
Fix eslint rule 'operator-linebreak'
eslint --no-config-lookup --fix --rule '"operator-linebreak": ["warn", "after"]'

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-13 16:06:50 +02:00
Ralph Sennhauser
519a215e1c
Fix eslint rule 'prefer-const' in gui/common
eslint --no-config-lookup --fix --rule '"prefer-const": 1' \
    binaries/data/mods/public/gui/common

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-09 19:32:43 +02:00
Ralph Sennhauser
b6df170303
Fix eslint indent rule
eslint --no-config-lookup --fix --rule 'indent:  ["warn", "tab", { "outerIIFEBody": 0, }]'

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-03 09:39:58 +02:00
Dunedan
8482f25800
Fix a bunch of spelling mistakes
This fixes a bunch of spelling mistakes found in user facing strings.

Fixes #7716
2025-04-11 06:24:32 +02:00
Vantha
78900842b1 Improve the "UDP port 20595" connection error dialog
Add a unique disconnect reason for timeouts of connection attempts.
Rewrite the displayed error message and provide a link directly to the FAQ entry.
(The old message was very misleading and only brought players on the
wrong track during troubleshooting)
2025-03-13 15:34:20 +01:00
scuti
e87d3e4137 Check if online before calling engine command. 2025-02-09 18:50:15 +01:00
Paul Robinson
5b98a647dc Adding Engine Version and Mod name/version checks to multiplayer handshake.
Incrementing protocol version as handshake messages have changed.
2025-01-25 07:39:32 +01:00
wraitii
bdda96a2e7 Prevent using privileged ports on *nix from the GUI
Ports 1-1023 are privileged and shouldn't be accepted by the GUI.

Patch by: DynamoFox
Differential Revision: https://code.wildfiregames.com/D3574
This was SVN commit r24949.
2021-02-27 16:40:42 +00:00
Angen
1a8de6d2b8 Hide ip and port from users until they want to join, add optional password
Current issue with the lobby, is that we make ips of hosts public for
anyone to read. This patch consists of 3 parts.
1.) Removing ips and ports from lobby javascript
2.) Removing need of script on the server to attach public ips to game
stanza by asking the host using xmppclient as proxy.
3.) Implementing password protected matches, to deny this information to
not trusted players.

Further description:
Do not send ports and stunip to the bots.

Removed from stanza.
Do not send ip to the lobby.

Removed from mapping gamelist from backend to gui (still on the backend
side, because it is done by script on 0ad server).
Get ip and ports on request when trying to connect.

On the host side, ask stun server what is host's public ip and remember
it.
On the client side, send iq through xmppclient to the hosting player and
ask for ip, port and if Stun is used, then if answer is success,
continue
   with connecting, else fail.
Add optional password for matches.

Add password required identifier to the stanza.
Allow host to setup password for the match. Hash it on the host side and
store inside Netserver. If no password is given, matches will behave
as it is not required.
On the client side, if password for the match is required, show
additional window before trying to connect and ask for password, then
hash it
and send with iq request for ip, port and stun.
Server will answer with ip, port and stun only if passwords matches,
else will asnwer with error string.
Some security:
Passwords are hashed before sending, so it is not easy to guess what
users typed. (per wraitii)
Hashes are using different salt as lobby hashing and not using usernames
as salt (as that is not doable), so they are different even typing the
same password as for the lobby account.
Client remembers which user was asked for connection data and iq's id of
request. If answer doesn't match these things, it is ignored. (thnx
user1)
Every request for connection data is logged with hostname of the
requester to the mainlog file (no ips).
If user gets iq to send connection data and is not hosting the match,
will respond with error string "not_server".
If server gets iq::result with connection data, request is ignored.

Differential revision: D3184
Reviewed by: @wraitii
Comments by: @Stan, @bb, @Imarok, @vladislavbelov
Tested in lobby

This was SVN commit r24728.
2021-01-20 18:31:39 +00:00
bb
87849f4fe9 Fix some translatable strings
Patch By: Nescio
Comments By: Freagarach
Differential Revision: D3134
This was SVN commit r24445.
2020-12-24 16:25:32 +00:00
bb
0a26c55513 Fix more JsDocs numbers/bools/strings
This was SVN commit r23992.
2020-08-24 11:50:31 +00:00
elexis
0817d5d715 Always inform clients why the server chose to disconnect them, i.e. stop using NDR_UNKNOWN as a disconnect reason when the reason is known and add a LOGWARNING for future authors.
Differential Revision: https://code.wildfiregames.com/D1561
Tested on: clang 8.0.1, Jenkins

This was SVN commit r22996.
2019-09-26 11:36:03 +00:00
Imarok
839f281c98 Don't add the period outside a translated string
Previoues version reviewed by: bb
Comments by: elexis
Differential Revision: https://code.wildfiregames.com/D1366
This was SVN commit r22234.
2019-04-28 15:26:41 +00:00
Imarok
0fd8aa2a77 Secure lobby authentication - prevent joins as a different player
Reviewed by: Dunedan, elexis, Itms
Fixes #3549
Differential Revision: https://code.wildfiregames.com/D897
This was SVN commit r21520.
2018-03-12 00:23:40 +00:00
Imarok
66a357f286 The server should choose the guid
Reviewed by: elexis
Differential Revision: https://code.wildfiregames.com/D943
This was SVN commit r20341.
2017-10-24 22:05:24 +00:00
elexis
3c73b329f2 JS cleanup.
Mark global consts as variable if mods can legitimately modify them.
Keep global objects const if mods should insert their modifications at a
different place, refs D829.
Mark the few consts inside function scope as let or var for consistency.
Don't touch the AI, simulation test and rmgen folder.
Change some var to let.
Remove an unused variable in the mainmenu and summary screen.
Inline few variables.

This was SVN commit r20047.
2017-08-26 20:10:39 +00:00
Itms
db0570e71e String changes, based on feedback from translators.
Reviewed By: Phormio
Differential Revision: https://code.wildfiregames.com/D561
This was SVN commit r19726.
2017-06-03 16:30:18 +00:00
elexis
da5463d135 Prevent lobby players from hosting games with empty servernames.
Display a notification instead of using the default port if an invalid
one was specified.

Patch By: Vladislav
Refs #4402

This was SVN commit r19307.
2017-03-17 01:51:54 +00:00
elexis
e0f7578fbe Ensure unique client GUIDs. Patch by sbirmi, fixes #3949.
Two clients chosing the same GUID is highly unlikely, yet possible.
A malicious client chosing an existing GUID would have resulted in
unassigning the player with that GUID.

This was SVN commit r19225.
2017-02-14 16:54:34 +00:00
mimo
f01e932ce3 fixes a few missing semicolon
This was SVN commit r19025.
2016-12-07 18:06:12 +00:00
elexis
9970b433a2 Add chat command to kick or ban all observers, refs #3241.
This is in particular useful as many observers can join in the gamesetup
phase
(since the server doesn't restrict connects then due to not knowing in
advance which client will become an assigned player.)

This was SVN commit r19007.
2016-11-27 23:31:14 +00:00
Itms
c1b28ba1e0 Fix some strings reported by translators.
This was SVN commit r18793.
2016-09-29 20:54:13 +00:00
elexis
7c3c5f6173 Fix some string issues reported on transifex.
This was SVN commit r18786.
2016-09-27 18:29:32 +00:00
elexis
c43654c120 Display the number of clients too when typing the /list chat command.
This was SVN commit r18720.
2016-09-12 02:23:19 +00:00
elexis
62061557db Host on arbitrary UDP ports. Patch in cooperation with Imarok, fixes #3575.
This was SVN commit r18372.
2016-06-13 16:56:14 +00:00
elexis
248a48d88a Major network cleanup. Patch by Imarok.
Access the server from the client only, not from the GUI (except for
autostarted games).
Thereby lay the foundation for clients to setup the game (refs #3806)
and dedicated hosting (refs #3556).
Doesn't transfer nor remove the SetTurnLength showcase from 0ebe3486b6.

This was SVN commit r18322.
2016-06-04 12:08:30 +00:00
elexis
4944d9b83c GUI / messagebox cleanup.
Remove pointless "mode" argument from messageBox and add newlines to its
calls.
Remove unused variable codes, trailing whitespace and useless comments.
Remove redundant button init code by using a loop (forEach to avoid a
closure).
Inline many unneeded variables.
Add missing translate to gamesetup_mp.js.
Quote object keys and capitalize globals correctly.

This was SVN commit r18178.
2016-05-15 04:04:31 +00:00
elexis
f64f1c4ade Show a hint when failed to connect to a game stating that it is likely caused by the host not forwarding the UDP port. Patch by Stan, fixes #3570.
This was SVN commit r18176.
2016-05-15 00:37:58 +00:00
elexis
71c441b092 GUI cleanup.
Remove a wrong translation comment.
Nuke duplicate calls.

This was SVN commit r18151.
2016-05-10 02:35:12 +00:00
elexis
983ef2ed2c Add translation context to the "Unknown" strings, allowing to chose a different translation for every occurance.
This was SVN commit r18112.
2016-04-30 14:01:07 +00:00
Itms
d70062c348 Cleanup of the network code (range-based for, remove spaces between angle brackets, and other little things).
Based on a patch by elexis, fixes #3907

This was SVN commit r18091.
2016-04-24 20:48:53 +00:00
elexis
d61e315f4d Fix few style issues remarked by leper.
Add a unit (seconds) to the network-timeout warning.
Rename isChatAddressee to parseChatAddressee as it changes the message.
Early return for EnableOOSLog to avoid printing duplicate messages.

This was SVN commit r17895.
2016-03-15 04:37:41 +00:00
elexis
042c9a9334 Allow hosting matches with 8 players and up to 16 observers, fixes #3254.
The host can change the number of allowed observers in running games.

Make sure that joining observers won't take the "slot" of disconnected
players, fixes #3671.

Send clients a new disconnect reason "Server full" instead of letting
them timeout.

This was SVN commit r17881.
2016-03-13 16:52:00 +00:00
elexis
f2ed0098ee Make the playername-deduplication ("User" -> "User (2)") optional.
Have it disabled by default to fix #3604.
Prevents players from rejoining as late-observers in case they timed-out
on the client-side but not on the server-side.

This was SVN commit r17851.
2016-03-09 15:02:38 +00:00
elexis
f8b20d181d Add chat-addressee dropdown, refs #1767.
Add observer-only chat and allow private messages from observer to
observer.
Prevent defeated players from using the team-chat, fixes #3441.

This was SVN commit r17771.
2016-02-18 01:09:56 +00:00
elexis
22f5b00fce Implement network-warnings, fixes #3264.
Shows a notification if the local client or other players connections
timeout or have bad latency.

This was SVN commit r17730.
2016-02-04 17:14:46 +00:00
elexis
ab16ddb256 Show a more specific disconnect-message in case the host closed the server. Refs #3264, #3570.
This was SVN commit r17710.
2016-01-25 12:56:30 +00:00
elexis
9f334036ef Do not align object properties.
Do not construct objects if they only contain two atomic elements.
Revert getDisconnectReason so as to have a custom message for the error
case. Add a warning.

This was SVN commit r17601.
2016-01-04 17:59:12 +00:00
elexis
6cdd99474a Fix fail.
This was SVN commit r17570.
2015-12-30 11:17:50 +00:00
elexis
7648b4f482 Gamesetup and session cleanup.
Convert network commands to an object and simplify the formating of
system chat messages.

This was SVN commit r17569.
2015-12-29 15:29:24 +00:00
elexis
46a42c04ef Gamesetup message cleanup.
Transform switch-statements into objects.
Make them more consistent, in particular the kick/ban and
ready-messages.
Also colorizes the playername in disconnect messages.
Fix a wrong comment in the network code and remove a duplicate check
(AIs).

This was SVN commit r17568.
2015-12-29 14:45:53 +00:00
elexis
f8ec158116 Session cleanup.
Transform trivial switch-statements to objects.
Move removeOldChatMessage right below addChatMessage, since it is only
used there.

This was SVN commit r17566.
2015-12-28 23:16:33 +00:00
elexis
a280cb87db Colorize playernames when using the /list command in the gamesetup/session.
Add two missing semicolons and remove an unnecessary one.
Eliminate formatClientList, message, formattedUsername and
formattedUsernamePrefix.
Move four hardcoded colors to globals.

This was SVN commit r17554.
2015-12-25 23:49:28 +00:00
elexis
6e80288d30 Add a chat-command to clear all messages. Works for lobby, gamesetup and session. Patch by ruiRanger, fixes #3396.
This was SVN commit r17465.
2015-12-14 03:12:26 +00:00
leper
32da740f14 Allow kicking/banning players from gamesetup and session. Patch by elexis. Fixes #3241.
This was SVN commit r17217.
2015-11-11 02:05:23 +00:00
Itms
e56dddbefb Optionally allow observers to rejoin a game when they weren't here during the game setup.
Patch by elexis, fixes #3242.

This was SVN commit r16945.
2015-08-28 20:20:10 +00:00
leper
38a007f6fa Properly escape a string.
This was SVN commit r16414.
2015-03-15 04:15:57 +00:00