Keeping sync in multiplayer RTS game that uses floating point arithmetic
Posted
by Calmarius
on Stack Overflow
See other posts from Stack Overflow
or by Calmarius
Published on 2009-12-22T20:29:20Z
Indexed on
2010/06/09
18:42 UTC
Read the original article
Hit count: 261
I'm writing a 2D space RTS game in C#. Single player works. Now I want to add some multiplayer functionality. I googled for it and it seems there is only one way to have thousands of units continuously moving without a powerful net connection: send only the commands through the network while running the same simulation at every player.
And now there is a problem the entire engine uses doubles everywhere. And floating point calculations are depends heavily on compiler optimalizations and cpu architecture so it is very hard to keep things syncronized. And it is not grid based at all, and have a simple phisics engine to move the space-ships (space ships have impulse and angular-momentum...). So recoding the entire stuff to use fixed point would be quite cumbersome (but probably the only solution).
So I have 2 options so far:
- Say bye to the current code and restart from scratch using integers
- Make the game LAN only where there is enough bandwidth to have 8 players with thousands of units and sending the positions and orientation etc in (almost) every frame...
So I looking for better opinions, (or even tips on migrating the code to fixed-point without messing everything up...)
© Stack Overflow or respective owner