[FND] Network implementation

Content and general development discussion for Source of Mana.


Post Reply
User avatar
Reid
Lead Developer (SoM)
Lead Developer (SoM)
Posts: 1551
Joined: 15 May 2010, 21:39
Location: Artis
Contact:

[FND] Network implementation

Post by Reid »

So this is it, the big task for the 0.0.4 milestone is currently in progress!

We have a basic client/server interaction using Godot's network API all under the same godot project to reduce the amount of work needed.
You can run the build with --server and/or --client to run the game as a host server, a game client or an hybrid game/server for an offline game experience.
All of this is possible with the services architecture implemented in SoM that let anyone to disable any internal service (camera, tilemaps, audio, entities, etc...)

Now, to go a bit deeper in the implementation, we are using Godot's "new" rpc system that was reworked for Godot 4: https://godotengine.org/article/multipl ... -report-2/

Godot 4 introduced a bunch of other nice features for their network API like the scene replication and a low-level ENet support but these features do not fit into our agenda due to some design limitation on their side.
So to resume, we will go with the simple solution and use rpc commands to do all of the update on our clients/server.

"Time is an illusion. Lunchtime doubly so."
-- Ford Prefect
User avatar
Reid
Lead Developer (SoM)
Lead Developer (SoM)
Posts: 1551
Joined: 15 May 2010, 21:39
Location: Artis
Contact:

Re: [WIP] Network implementation

Post by Reid »

One of the big work needed before to continue this implementation is to split our entity management (mobs, npcs and players) into client-side and server-side entities.

To prevent any naming issue we will call a server-side entity an "agent" and keep the "entity" name for the client/visible part.
Both our entities and agents will be created with the available data from the data/db/entities.json to keep all data in sync.

This work is underway, it might be a bit long as we have to split all of our code to use the agent system for our World service and the entity for our map, camera and debug services.

Now, here come a blocking issue on my side, there was a design flaw when first implementing the entity system for the milestone 0.0.3 as we loaded all of them as nodes through the World service. The world service can't update them on their own as they have to be within the scene tree to be updated.
This issue was hidden by the fact that only one player was present during the test and this player loaded all other entities within the current map, so at this time, they were in a scene tree and they could be updated.
Sadly this is not possible anymore as our agent will remain on the world service and just send position/direction/path information to our connected clients.

The server and the world service is not yet using a scene tree to prevent some performance issue, although it seems we are now forced to use the node architecture for our server which complexify a bit the world service.
I'm looking at it right now but I have to run some tests, if anyone has some idea on a third way to do this it would be more than welcome! On the meantime, I will continue to work on the entity split and testing the node system for our world service.

"Time is an illusion. Lunchtime doubly so."
-- Ford Prefect
User avatar
Reid
Lead Developer (SoM)
Lead Developer (SoM)
Posts: 1551
Joined: 15 May 2010, 21:39
Location: Artis
Contact:

Re: [WIP] Network implementation

Post by Reid »

I have a bit less time these last days so my commits are a bit more messy on the network branch but everything is going well!

We have an offline mode running well with a fake client/server and I'm implementing every calls between our client and server services into the network service which is/should/need_to_be the central service for all network related calls.

"Time is an illusion. Lunchtime doubly so."
-- Ford Prefect
User avatar
Reid
Lead Developer (SoM)
Lead Developer (SoM)
Posts: 1551
Joined: 15 May 2010, 21:39
Location: Artis
Contact:

Re: [FND] Network implementation

Post by Reid »

We now have a working client/server!

I merged the basic_network branch into the master branch to continue the work in there, some basic features are still missing (can't see a newly connected player, can't reconnect, can't sit, etc...) but it is possible to wander into our maps without any big issues!

"Time is an illusion. Lunchtime doubly so."
-- Ford Prefect
Post Reply