FWGS / xash3d-fwgs

Xash3D FWGS engine.
1.51k stars 226 forks source link

xash:// URI idea #1591

Open a1batross opened 7 months ago

a1batross commented 7 months ago

xash URI scheme would identify the servers that can be reached using Xash3D's client-server protocol.

The existence of such scheme will make it easier for users to share server links on the Web, messengers etc.

Any thoughts? The scheme isn't really relevant yet, the point is to make it accessible to be able to reach a resource, in this case a multiplayer game.

By querying the server with info packet we can figure out almost everything needed, and ask the user if they wants to join the server, or explain why they cannot (missing gamedir, unsupported protocol, no free slots, etc).

The implementation doesn't seem to be very complex, almost every operating system allows associating URI with an executable. Android as always the "special" kind of kid, but new port must be able to figure out whether the specified game directory needs special DLLs or not.

Discussion on SourceHut: https://todo.sr.ht/~a1batross/xash3d-fwgs/14

a1batross commented 7 months ago

cc @numas13 @mittorn @nekonomicon @SNMetamorph @Velaron

SNMetamorph commented 7 months ago

I think that's pretty good idea in terms of user friendliness

mittorn commented 7 months ago

It's ok to have game scheme, but there are questions about implementation.

Engine do not have generic launcher, so it is not possible to make default options like "-dev", so need way to set options, that should be passed automaticly when it's empty

And what if url opened with running engine? How to implement messages between processes to run connect command in running instance instead of spawning new one?

Should be url browseable (should we allow browser to start engine by triggerring link?)

Which data it should contain? gamedir, server password, team, custom userinfo? maybe some whitelisted setinfo list?

Maybe include protocol in scheme for correct matching?

a1batross commented 7 months ago

it is not possible to make default options like "-dev", In case of "-dev" I would like to have a toggle in menu to allow console and set developer level dynamically. Saving global options is another task. (There was an issue for that) It's fairly simple to do this on the Windows and Android, since it has centralized settings storage. On Linux and BSD, something located in ~/.local/share might be the solution (also according to XDG). For game consoles ports, handling the URI must be optional, due to the absence of a real operating system.

And what if url opened with running engine? I think it should open in current engine. One of the possible signaling methods is to send connectionless packet on localhost. We might be able to always listen on localhost, even in singleplayer game.

Should be url browseable Yes. It's basically what @numas13 did here.

Which data it should contain As you suggested, including password might be pretty useful. But I don't think including gamedir or protocol is useful for anything. A maliciously crafted link might set different gamedir, and after checking whether the server is reachable (i.e. sending info packet and getting a reply) we will have to switch gamedir. So why initialize the engine with one gamedir and switch to another, when sending a message and waiting for reply is basically a few lines?

numas13 commented 7 months ago

@mittorn

The core idea is to be able to connect to a server through a web browser.

Suppose there will be some website with a list of all servers from the master server. The user could click on the "Play" link, and the game would be launched. The game will then try to retrieve information from the server and show a dialog to the user.

Example links:

# connect to host:27010 and detect gamedir from the server
xash3d://host
# connect to host:port and detect gamedir from the server
xash3d://host:port 
# connect with exact gamedir
xash3d://host/valve

Demo.

https://github.com/FWGS/xash3d-fwgs/assets/2345745/a6cde707-6e3e-4148-a6d5-7bde7cd3aa86

mittorn commented 7 months ago

Gamedir in uri will be more user-friendly. It is good to know, which game running this server. And i do not like idea connect to server directly from launcher, it might need many code copy-pasting, error checking, etc. Not too complex for launcher?

 Yes, gamedir value maybe inactual, but servers do not change gamedir very often, it's more possible that server does not exist anymore. I do not see any reason not to include it, but it might be optional. And even it wrong, i very, very do not want engine to switch to unknown gamedir (which may crash engine because incompatible gamelibs on do not have binaries of my architexture) just because did not know gamedir before opening link. Opening cstrike instead of valve might be pain on android devices because even if client installed, it will eat much resources. I do not want this feature without user knowing gamedir before opening link, url should be user-readable. Changing game to some mod, that contains configs for different engine version will break configs. Even if server wants different gamedir, game should not change until user confirmed this, it should not be run automaticly.

Not sure at alll that changegame useful in some point outside x86 windows for now. Even if user have "cstrike" directory, it will be confused by broken/crashing game after clicking someone's server link.

Other case, Android user copied entire Half-Life directory from steam and it contains some mods, but user do not have mods apk installed. Engine just will load game with half-life client. To prevent this case, i not enabled changegame in my port (at least until i cannot detect if gamedir supported correctly)

Even connecting legacy server needs some time to change proto. Connecting goldsrc server might be useful, but will not work without protocol specified at all. So i think, some protocol information, at least xash49/legacy/goldsrc switch will be useful

On 26.01.2024 19:51, Alibek Omarov wrote:

So why initialize the engine with one gamedir and switch to another, when sending a message and waiting for reply is basically a few lines?

a1batross commented 7 months ago

Of course, no action will be done without a user consent. Not changing gamedir, not joining the server. If you got a link to a server on a running one game, while engine runs something else, it should ask whether you want to want to "lose all unsaved data/disconnect from current server", and change game into another gamedir.

If you want to include gamedir into the link, it's not a problem, but it might be ignored by the implementation.

Even if we look into the WON version of Half-Life, it was able to switch current game without an issue.

And, yes, server may change the gamedir. What if it's your private server that you set up for friends, and play different mods?