Hopson97 / open-builder

Open "Minecraft-like" game with multiplayer support and Lua scripting support for the both client and server
https://github.com/Hopson97/open-builder/projects/3
GNU General Public License v3.0
700 stars 80 forks source link

Make the client not launch until server is ready #77

Closed Hopson97 closed 4 years ago

Hopson97 commented 4 years ago

Suggestion Title

Make client not launch until server has finished starting

Describe your suggestion

Right now there is a 500ms dselay in the launchBoth function in main.cpp, but sometimes this means the server has not finished setting up before the client has launched, meaning the client doesn't connect

Work Arounds

There are 3 work around for the time being:

Build and run in release modd

This will make the world generation faster, meaning the server will actually be ready before the client starts.

sh scripts/build.sh release
sh scripts/run.sh release

Run the server and the client separately

sh scripts/run.sh -server 4

#wait a few secs, then on another terminal

sh scripts/run.sh -client x

Edit the code a bit to increase the delay

In main.cpp there is a function called launchBoth

This is the function that will launch the server on one thread, wait about 500ms, and then launch the client.

You can increase the number in the sleep_for function call to mitigate the issue.

Hopson97 commented 4 years ago

Solved by PR #79