MovingBlocks / Terasology

Terasology - open source voxel world
http://terasology.org
Apache License 2.0
3.69k stars 1.34k forks source link

Document Game Start Process Order #5151

Open jdrueckert opened 1 year ago

jdrueckert commented 1 year ago

Documentation Topic

In StateLoading.java I noticed some discrepancies in the process loading order between client and host. I don't think this topic is well-documented yet or at least I'm not aware of any such documentation.

Major question for me also is: is the difference in order intentional or a bug?

Documentation Type

With this being architectural documentation of sorts but heavily coupled with the code (despite probably being not modified too often), I would recommend this being documented in the Terasology Engine wiki or in-repo docsify to allow for documentation update as part of related code changes.

If these differences in order of loading are indeed intentional, then this should potentially also be documented in a code comment to avoid future confusion.

Additional notes

The order of process loading for client and host is generally equal (+/- some host only processes and processes that come in dedicated client or host flavours) save for

Step Client Host
1 JoinServer (clients only) RegisterMods (host only)
2 InitialiseRendering* InitialiseRendering*
3 InitialiseEntitySystem InitialiseEntitySystem
4 RegisterBlocks RegisterBlocks
5 InitialiseGraphics* InitialiseGraphics*
6 LoadPrefabs LoadPrefabs
7 ProcessBlockPrefabs ProcessBlockPrefabs
8 LoadExtraBlockData -
9 InitialiseComponentSystemManager InitialiseComponentSystemManager
10 RegisterInputSystem* RegisterInputSystem*
11 RegisterSystems RegisterSystems
12 InitialiseCommandSystem InitialiseCommandSystem
13 - LoadExtraBlockData
14 InitialiseRemoteWorld (clients variant) InitialiseWorld (host variant)
15 - RegisterBlockFamilies
16 - EnsureSaveGameConsistency (host only)
17 InitialisePhysics InitialisePhysics
18 InitialiseSystems InitialiseSystems
19 PreBeginSystems PreBeginSystems
20 - LoadEntities (host only)
21 - InitialiseBlockTypeEntities (host only)
22 CreateRemoteWorldEntity (client variant) CreateWorldEntity (host variant)
23 - InitialiseWorldGenerator (host only)
24 - InitialiseRecordAndReplay (host only)
25 - Start Server (server only)
26 PostBeginSystems PostBeginSystems
27 SetupRemotePlayer (client variant) SetupLocalPlayer (host variant if local player)
28 AwaitCharacterSpawn AwaitCharacterSpawn
29 RegisterBlockFamilies -
30 PrepareWorld PrepareWorld

* only if not in headless mode

While we're at it we might also want to document the different execution modes (client only, host but not server, host and server, host with local player, etc.) E.g., a singleplayer game is actually a host, as is a server game. only clients in a multiplayer setup are actually clients (see logic in stateloading.java and newgamescreen.java)