Restoring files to original state

Jul 18, 2011 at 8:46pm
I have a problem. I'm working on a game comparable to Final Fantasy. On my maps, there will be "objects" (literally objects, as in pick-up-able items) that get loaded along with the map itself. Once the player picks up an object, I don't want that same object to re-appear next time the map is loaded. Simply overwriting the file the object is in won't do, because if the player starts a new game, the object still won't come back.

I was thinking that I should make a way to "restore" the game object files to their original state upon a new game being started, but the amount of files will be VAST.

Any suggestions would be greatly appreciated...
Jul 18, 2011 at 9:16pm
Typically you have static things that cannot change (maps, objects, NPCs for example) separate from the location/state of the objects and NPCs. When the user picks "New Game" the static data and the default object locations are loaded. When the user picks "Load Saved Game" the static data and the saved object locations are loaded. So, when saving a game, all of the state information is saved into the same format that the "new game" state information is stored in.
Jul 18, 2011 at 9:49pm
So I would simply include the states of my objects in the saved game? How can I be sure that object states are associated with right object?

Object data stored is: x, y, type.

As of right now, objects have no unique identifier, and hopefully, won't ever.
Jul 18, 2011 at 11:43pm
If there is no way to uniquely identify an object, then you don't need to worry whether states are associated with the right object. The object of type T with state x is T(x). As long as any T can take state x, and your program will treat it as T(x), you are OK.

Is there a specific case you are worried about?
Jul 19, 2011 at 12:15am
The only state I was worried about was bool pickedUp; It would need to be associated with the right Object (literally, class Object{ };). Everything else (x, y and type [as in item, weapon, armor and further classification in those areas]) is constant.

So, if object at (100, 123) is picked up, I need the pickedUp variable to be set to true next time the object at (100,123) is loaded, not any random object at (whateverX, whateverY).
Jul 19, 2011 at 1:12am
I don't see how that boolean would need to be associated with the 'right' object anymore than the location and the type would be. Keep the boolean with the other data; the same way you associate some x-coord with some y-coord, also put that type and boolean with that.
Jul 19, 2011 at 2:27am
The x/y are constant, thats what I'm getting at. The only external value is the boolean. If I were to store x/y/type/pickedUp all separately, then I might as well have 2 copies of the file. Those are everything an object has.
Jul 19, 2011 at 10:50pm
Is x/y (or type/x/y) an object's unique identifier?
Jul 19, 2011 at 10:59pm
I suppose it could be... I think I see what your getting at ;)

Load all the objects for a map, indiscriminately. Then, load a file of x/y pairs of picked up objects. Once its loaded, compare all the x/y's to the x/y's of the loaded objects. If they match, delete the object from memory.

Is that what you had in mind?
Topic archived. No new replies allowed.