• entries
    707
  • comments
    1173
  • views
    434011

Saving and Loading - Check!

Sign in to follow this  
Programmer16

1164 views

Well, no more pretty screenshots today. I spent a little bit too much time on UI Skin earlier, but saving and loading is now completely integrated. It's going to be a day or two before I can show it off as I don't have the in-game menu done (so I can't save, go back to the menu, and then load), but I'll try to once I have that done. I say try because I still need to spring for the paid version of Fraps so I can record more than 30 seconds.

There is still a bit of garbage that needs to be cleaned up and refactoring that needs to be done. My state data isn't set up properly; I'm storing and loading the scene id, so that's displayed as the location instead of the scene's name. I also kind of hacked things together a little bit to get them working, so currently every object that is loaded is saved and when loading it loads the objects, loads the scene (which reloads those characters) and then their state data is restored. I had to do this because currently the character data doesn't store the current animation's name is memory other than in the animation itself, which isn't loaded until the object is loaded (thus, I load the object, load the scene, copy the data over.)

I have to say, even if the coming project turns out to be a huge flop, I'm very content with what I've learned while working on the project. Off to bed for me.

Sign in to follow this  


3 Comments


Recommended Comments

[quote]There is still a bit of garbage that needs to be cleaned up and refactoring that needs to be done. My state data isn't set up properly; I'm storing and loading the scene id, so that's displayed as the location instead of the scene's name. I also kind of hacked things together a little bit to get them working, so currently every object that is loaded is saved and when loading it loads the objects, loads the scene (which reloads those characters) and then their state data is restored. I had to do this because currently the character data doesn't store the current animation's name is memory other than in the animation itself, which isn't loaded until the object is loaded (thus, I load the object, load the scene, copy the data over.)
[/quote]
As far as I understood, you have an issue with resolving (cyclic) references. The trick is, to map your references to unique IDs when saving and resolve this references again after loading them.

Simple example:
[CODE]
character A --friend_of-->character B
character B --knows--> character C
character C --friend_of-->character A

1. give each object unique ID
character A(1) --friend_of-->character B(2)
character B(2) --knows--> character C(3)
character C(3) --friend_of-->character A(1)

2. save objects, but each reference only contains the ID and not the object:
character A(1) --friend_of--> (2)
character B(2) --knows--> (3)
character C(3) --friend_of-->(1)

3. reload the game, use only the ids, but when ever you encounter a object, save it to a map/array
(1) ==maps_to==> character A(1)
(2) ==maps_to==>character B(2)
(3) ==maps_to==>character C(3)

4. in a post processing step reconnect the objects by using the unique ID
character A(1) --friend_of-->character B(2)
character B(2) --knows--> character C(3)
character C(3) --friend_of-->character A(1)
[/CODE]

Done :-)

Share this comment


Link to comment
[quote name='Ashaman73' timestamp='1335346908']
Quote

There is still a bit of garbage that needs to be cleaned up and refactoring that needs to be done. My state data isn't set up properly; I'm storing and loading the scene id, so that's displayed as the location instead of the scene's name. I also kind of hacked things together a little bit to get them working, so currently every object that is loaded is saved and when loading it loads the objects, loads the scene (which reloads those characters) and then their state data is restored. I had to do this because currently the character data doesn't store the current animation's name is memory other than in the animation itself, which isn't loaded until the object is loaded (thus, I load the object, load the scene, copy the data over.)
As far as I understood, you have an issue with resolving (cyclic) references. The trick is, to map your references to unique IDs when saving and resolve this references again after loading them.

Simple example:
character A --friend_of-->character Bcharacter B --knows--> character Ccharacter C --friend_of-->character A1. give each object unique IDcharacter A(1) --friend_of-->character B(2)character B(2) --knows--> character C(3)character C(3) --friend_of-->character A(1)2. save objects, but each reference only contains the ID and not the object:character A(1) --friend_of--> (2)character B(2) --knows--> (3)character C(3) --friend_of-->(1)3. reload the game, use only the ids, but when ever you encounter a object, save it to a map/array(1) ==maps_to==> character A(1)(2) ==maps_to==>character B(2)(3) ==maps_to==>character C(3)4. in a post processing step reconnect the objects by using the unique IDcharacter A(1) --friend_of-->character B(2)character B(2) --knows--> character C(3)character C(3) --friend_of-->character A(1)

Done :-)
[/quote]

Thanks! This is actually pretty much what I'm doing. The setup I have is kind of like so:
Objects are modified via Lua script. Using the __newindex function I inform the engine that the object's state data has been modified and it gets added to a list. During save, the state data for each object is saved to a file along with it's ID (mainly the text for the verbs, the object's numeric state, dialogue topics for characters, etc.) The issue I'm having is that one of the value's being saved is the current animation name. I have my animation object's wrapped up in a class, so I can't currently load in the animation's name without loading in the sprite. I could resolve the issue by either storing the animation name in the object itself or by having a ObjectState class or some such. That gives me an idea for an issue I've been having with another project...


[quote name='r1ckparker' timestamp='1335354574']
I can't get your videos to play
[/quote]
That's odd. They are WMV files, so that might have something to do with it. I know that I had issues with playing them in Chrome (you can try going to [url="http://support.google.com/chrome/bin/answer.py?hl=en&answer=95697"]http://support.google.com/chrome/bin/answer.py?hl=en&answer=95697[/url] and installing the plugin they're direct you to.) The videos are also up on my Youtube channel: [url="http://www.youtube.com/user/Programmer16"]http://www.youtube.com/user/Programmer16[/url]

Thanks for the replies guys!

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now