Hello,
For the future it would be handy if multiplayer support was present in box 2d.
I can imagine the following scenerio for a p2p multiplayer game with for example 6 players, perhaps a 7th joining or so.
All players/computers are synchronized and have the same state.
The 7th computer needs to get the entire state from the box 2d engine, this includes data structures as well like which objects to create and how to link them etc.
Also in practice computers/processors might execute floating point a bit differently, how much of a problem this in practice is I don't know... an idea could be to calculate a hash on the entire state each step and transmit and compare the hashes... if they are all the same it's good, if not then the game is "out of sync".
The least ammount of computer(s) with out of sync data are re-synced with data from the majority... if it's even then the group with the computer with the lowest ip address "wins" and syncs the other ones.
So what's needed for such a feature is the following:
1. Box2D needs to be able to save it's entire state to a "stream" this could also be a big chunk of memory.
2. Box2D needs to be able to load it's entire state from a "stream" this could also be a big chuck of memory.
So it seems box2d needs some binary format which can also encode it's "types/classes" like some runtime information.
I guess TypeOf(vSomeObject) could be used... (I am not sure if c++ has a TypeOf).
In case no type information is available then hard coded types/enums/constants could be used a well...
Also perhaps an identifier to identify all objects/instances.
The binary format could be something like:
packed structure
mType
mIdentifier
mObjectData
end
And so forth...
I hope this feature is included in some next version of Box2D so I don't have to modify the source code all the time 😉
Bye,
Skybuck 🙂
For the future it would be handy if multiplayer support was present in box 2d.
I can imagine the following scenerio for a p2p multiplayer game with for example 6 players, perhaps a 7th joining or so.
All players/computers are synchronized and have the same state.
The 7th computer needs to get the entire state from the box 2d engine, this includes data structures as well like which objects to create and how to link them etc.
Also in practice computers/processors might execute floating point a bit differently, how much of a problem this in practice is I don't know... an idea could be to calculate a hash on the entire state each step and transmit and compare the hashes... if they are all the same it's good, if not then the game is "out of sync".
The least ammount of computer(s) with out of sync data are re-synced with data from the majority... if it's even then the group with the computer with the lowest ip address "wins" and syncs the other ones.
So what's needed for such a feature is the following:
1. Box2D needs to be able to save it's entire state to a "stream" this could also be a big chunk of memory.
2. Box2D needs to be able to load it's entire state from a "stream" this could also be a big chuck of memory.
So it seems box2d needs some binary format which can also encode it's "types/classes" like some runtime information.
I guess TypeOf(vSomeObject) could be used... (I am not sure if c++ has a TypeOf).
In case no type information is available then hard coded types/enums/constants could be used a well...
Also perhaps an identifier to identify all objects/instances.
The binary format could be something like:
packed structure
mType
mIdentifier
mObjectData
end
And so forth...
I hope this feature is included in some next version of Box2D so I don't have to modify the source code all the time 😉
Bye,
Skybuck 🙂