Thought I’d actually try the techniques I talked about earlier with testers, which ended up being a wise choice! Things did not work out as intended and both techniques created more or less chaos! The interpolation was slow and reacted with a 20ish second delay, while the extrapolation was jerking and kicking around in far too many ways to be comprehended sanely.
The clients were still rendered correctly at the host, and the effect on the interpolation gave a clue as to the issue. After discussing a bit with my tester he synchronized his system clock to within a few seconds of my own. Voila! He could nearly play the game! This made it perfectly clear that it was my usage of time that was the culprit, and I realized I had to create a form of game time. However, since the current time function is in use pretty much everywhere and I do not want to create more time-classes (since I think it just adds to the confusion), I added a time adjustment variable, so that it is possible to change the perception of current time. Not wanting to completely remove the availability of system time, though, it is still possible to fetch it simply by passing a ‘true’ argument to the same function.
I haven’t really posted any code in this blog yet, so I guess I can show you the declaration of said function at least:
// Returns the current time. If true, returns unmodified machine time, if false will return synchronized time as set with SetAdjustment.
static time_t GetCurrentTimeMs(bool machineTime = false);
Milestone 2 is here, and in addition to the above I tried tidying up a few other issues (audio, thread deadlocks, etc.) before preparing the new build. A zipped archive of the prototype is now available in the MS2 repository. Unfortunately I have not prioritized documentation nor usability, which means that it might crash or behave strangely.
To try the game, simply click on Network, then either Host Game or Join Game. By default the target IP is my computer, which I will try and run throughout the day for anyone that wants to test connecting (assuming it doesn’t crash). I’ve tested it a bit, so hopefully it’ll survive! If you want to play the game you or your friends might have to host it, since my server will probably only facilitate test-connections throughout the day.
I’ll also mention some command-line arguments that I’ve added:
- ‘mute’, will disable all audio-playback. I opted to include some of my music which I intend to include with the game later on, but this is useful for sparing ears no matter what reason.
- ‘networkTest’ or ‘testNetwork’, which tries to either host a new game, or if that fails tries to join a game. This is similar to running the below two command-line arguments.
- ‘host_game’, which automatically hosts a game.
- ‘join_game’, which automatically tries to connect to a predefined host. By default this host will be my computer since I’ve got everything set up.
Running it on Windows via Git Bash for example could look something like the following:
$ SpaceRace.exe mute join_game
If there are any uncertainties or you need help testing it, go ahead and contact me!
Below some new screenshots just to try and make it a tradition.
… talking about discovering issues, I just tested and realized that the chat does not work between clients. Will have to enable chat-packet re-transmission so that everyone gets them and not just the host.