tjheldna Posted August 28, 2012 Share Posted August 28, 2012 Hi All, I'm looking at serializing the current game state for saving and loading. My first question is... Do entity's that are added/removed from the world editor have some sort of unique id assigned to them that I can access? I noticed that the entity "name" field is unique and increments as you drag them in the world, however this could easily be trouble with duplicate names due to copy/paste and user error. That dosen't seem like a robust solution to use the name for its unique identifier. So what I plan to do is loop through all objects in the world match the id's; if its of a certain type then call its load/save function as required. Maybe is there a better way of doing this task? Cheers! Quote Link to comment Share on other sites More sharing options...
Pixel Perfect Posted August 28, 2012 Share Posted August 28, 2012 Nothing to stop you assigning your own unique IDs as you can simply loop through the level objects children assigning them to a new key value. You probably already loop through them in order to create internal game objects so there is no additional overhead really. As these are static then this should always be repeatable. With a base class that all dynamic object classes are derived from containing the ID and a set of virtual functions for loading and saving; each derived class can have its own save load functions which can save/overwrite key data for the restored level. Quote Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++ Link to comment Share on other sites More sharing options...
Josh Posted August 28, 2012 Share Posted August 28, 2012 I would use the pointer to the object as the ID. That's guaranteed to be unique. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
tjheldna Posted August 28, 2012 Author Share Posted August 28, 2012 Thats awesome guys Thanks!! 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.
Note: Your post will require moderator approval before it will be visible.