3 – Maintain Order Always write out the order of the data the same. This one is pretty easy, the only real pitfall is to make sure your data structure and undo/redo system are working correctly. For example, if you happen to store your objects in a list and someone removes and object at the front, but when it's undone, it's inserted at the end of the list (even if the UI doesn't reflect this). This could affect your output order. 4 – Don't Add New Objects At The End When you go to save the entities, don't write them out in the order they were created. This will definitely result in a merge conflict. Because it ensures that if two users edit the file and both add an entity, they'll both show up in the same location and confuse the merge tool. One thing you could do is to sort them based on a GUID that is stored as part of the objects data. Sorting based on GUID ensures a lower probability of collisions occurring when two users both add objects. Alternatively, a sorting based on a string containing the machine name of the original creator of the object is another idea. It would ensure every user touching the file would be inserting to their own section of the file instead of everyone inserting to the tail. [This piece was reprinted from #AltDevBlogADay, a shared blog initiative started by @mike_acton devoted to giving game developers of all disciplines a place to motivate each other to write regularly about their personal game development passions.]
var settings = new XmlWriterSettings() { NewLineOnAttributes = true }; using (XmlWriter writer = XmlWriter.Create(filestream, settings)) { // Write out document... }
Announcements
Making Your Files Merge Friendly
In this reprinted #altdevblogaday piece, Activate3D's Nick Darnell provides a useful checklist for making merging posible and as painless as can be for content creators.