Rishabh Posted June 22, 2017 Report Share Posted June 22, 2017 (edited) Hey all, I was trying to play around with the network protocol. How can I extract the state of the game currently? I couldn't seem to find this part in the source. I want to be able to send my state to the other player without hashing it. Thanks in advance. Edited June 22, 2017 by Rishabh Quote Link to comment Share on other sites More sharing options...
elexis Posted June 22, 2017 Report Share Posted June 22, 2017 What do you want to achieve exactly? Just disable hashing to improve performance? Quote Link to comment Share on other sites More sharing options...
fcxSanya Posted June 22, 2017 Report Share Posted June 22, 2017 3 hours ago, Rishabh said: How can I extract the state of the game currently? I couldn't seem to find this part in the source. I want to be able to send my state to the other player without hashing it. You can check out how the simulation state is serialized for the hashing itself, see CComponentManager::ComputeStateHash , as the code comment says: Quote // Hash serialization: this includes the minimal data necessary to detect // differences in the state, and ignores things like counts and names // If 'quick' is set, this checks even fewer things, so that it will // be fast enough to run every turn but will typically detect any // out-of-syncs fairly soon For the full simulation state serialization / deserialization you can examine the save / load game mechanics, see SavedGame.cpp Quote Link to comment Share on other sites More sharing options...
mapkoc Posted June 22, 2017 Report Share Posted June 22, 2017 Isn't the game state in one of these objects? https://github.com/0ad/0ad/blob/9c792c327af49702eb146d8551235ebc650fd561/binaries/data/mods/public/simulation/ai/common-api/shared.js baseAI uses it like this this.gameState = sharedAI.gameState[this.player]; I think its a pretty elaborate js object with many nested dictionaries and somewhere in the simulation code gets updated each player's turn. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.