ServerPseudeCode
From MountainfortWiki
Ghoulsblade (Talk | contribs) (Created page with "== network == network send/recv/accept : c++ client->server : player-movement : c++ (distribution of player-sent message) client->server : weapon/targetting/tooluse : handled by...") |
Ghoulsblade (Talk | contribs) |
||
Line 10: | Line 10: | ||
- | == mainloop == | + | == mainloop (draft) == |
* poll network (calls c++) | * poll network (calls c++) | ||
Line 16: | Line 16: | ||
* multi-threaded : execute jobs:simulation (parallel with working threads) (produces messages in thread-message buffers) | * multi-threaded : execute jobs:simulation (parallel with working threads) (produces messages in thread-message buffers) | ||
* backbuffer switch (terrain) | * backbuffer switch (terrain) | ||
- | |||
* situation now : simulation=done, we have messages in thread-message-buffers (spawn/destroy object, awake fluid-block) | * situation now : simulation=done, we have messages in thread-message-buffers (spawn/destroy object, awake fluid-block) | ||
- | * single- | + | * single-threaded : function HandleMessages() : |
- | + | * move messages in thread-message buffers to global message queue | |
- | * single thread : global message queue : | + | ** single thread : global message queue : |
** messages for manager (fluid, light, objectspawn) : handle now (also timed events, e.g. lumberjack tree) | ** messages for manager (fluid, light, objectspawn) : handle now (also timed events, e.g. lumberjack tree) | ||
** messages for objects : create jobs for handling in multithreaded way | ** messages for objects : create jobs for handling in multithreaded way | ||
* multi-threaded : execute jobs:object-messages/think | * multi-threaded : execute jobs:object-messages/think | ||
+ | |||
+ | * call HandleMessages() again (handles object updates that can be sent to client before the maxfps wait) | ||
+ | ** needs to be called twice to (1) start jobs for objmessages and (2) send updates to the clients | ||
* backbuffer switch (object properties) | * backbuffer switch (object properties) |