Restricted access to data

Started by
1 comment, last by JohnBolton 19 years, 5 months ago
Im currently writing a RTS game that uses syncronized simulation on all machines and just sending user input over the network. The problem is that some parts of the programs are unsyncronized (everything having to do with drawing etc) and some syncronized (all the stuff that actually change the gameworld). Now to keep the simulation syncronized I need to restrict how data is accessed. Syncronized code can read/write syncronized data and write unsyncronized data while unsynced code can read/write unsyncronized data but only read syncronized data. As long as I was the only coder in the project this was somewhat easy to uphold but now that a few more people has started coding on the project the risk of mistakes increase. Is there some way to uphold the above access patterns by some features in C++ ?
Advertisement
If you're worried about the data being corrupted, I'd say push everything into some source control (CVS, for one) - look around at other source control options too - most have some sort of user-level security where you can specify read/write permissions...

In general, make your synchronized data private and control access to it. Any code within the scope of the data can change it, and any code outside of the scope can't.

I suspect that much of the problem is the result of the data comprising the synchronized game state being scattered all over. Some reorganization with a stronger distinction between synchronized and non-synchronized might help solve the problem.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!

This topic is closed to new replies.

Advertisement