Page 2 of 2
Re: Saving and loading game data
Posted: Tue Jan 04, 2011 1:20 pm
by Ginto8
N64vSNES wrote:dnxviral wrote:Not what we save but how we save it.
Obviously the only way to get data static from a program executing and terminating would be to save it to a file.
Kinda funny how you completely and utterly failed to answer the question he asked. What he's talking about is Serialization, how you take an in-game data structure and put it in a file. The answer is that you have a lot of different choices, mainly depending on what the data itself is. Just look up some info on serialization, google is your friend
Re: Saving and loading game data
Posted: Tue Jan 04, 2011 1:27 pm
by thejahooli
ginto8 wrote:Kinda funny how you completely and utterly failed to answer the question he asked. What he's talking about is Serialization, how you take an in-game data structure and put it in a file. The answer is that you have a lot of different choices, mainly depending on what the data itself is. Just look up some info on serialization, google is your friend
Most of the time you wouldn't want this in games though. Object serialisation is not normally necessary. If this is what he meant and he has a good reason for saving an entire object, then it would be useful and a good way of doing it. However in most situations whole objects are not needed to be saved, only parts of it, and saving the whole object would potentially increase file size and loading times.
Re: Saving and loading game data
Posted: Tue Jan 04, 2011 2:42 pm
by N64vSNES
Ginto8 wrote:N64vSNES wrote:dnxviral wrote:Not what we save but how we save it.
Obviously the only way to get data static from a program executing and terminating would be to save it to a file.
Kinda funny how you completely and utterly failed to answer the question he asked. What he's talking about is Serialization, how you take an in-game data structure and put it in a file. The answer is that you have a lot of different choices, mainly depending on what the data itself is. Just look up some info on serialization, google is your friend
Oh my bad XD
Supposing you had a inventory containing 3 potions and 2 cookies ( why? I dunno cookies rock ).
Your inventory actully probably looks like this:
or
Code: Select all
1 1 1 2 2 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
Or somthing of the sort anyways. So you could ouput this to a file and then when it gets reloaded set your inventory to what it read in.
Your save file could look like this:
Code: Select all
Noob -- Name
22 -- Up to level 22
75 -- You had 25 HP before you quit the game
2054 1023 666 -- X, Y and Z coords you were at when you saved
1 1 1 2 2 0 0 -- Your items
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
From this you could do somthing like this in the program
Code: Select all
shit = LoadShit()
for i = 0 20 do this
if shit.Items(i) not = 0 then
Player.GiveItem(shit.Items(i));
end
end
Player.SetName(shit.Name)
Player.SetHealth(shit.health)
Player.SetCoords(shit.x,shit.y,shit.z)
Level.LoadLevel("Level" + shit.levelnum + ".level")
Crappy example ( no perticular launguage )
But this could do well for somthing like a linear level 1, level 2, level 3 type game. ( Or at least thats how I would go about it )
Re: Saving and loading game data
Posted: Tue Jan 04, 2011 7:05 pm
by dnxviral
Haha Yea I know what your trying to get at. Cookies ftw.
Ginto8 wrote:N64vSNES wrote:dnxviral wrote:Not what we save but how we save it.
Obviously the only way to get data static from a program executing and terminating would be to save it to a file.
Kinda funny how you completely and utterly failed to answer the question he asked. What he's talking about is Serialization, how you take an in-game data structure and put it in a file. The answer is that you have a lot of different choices, mainly depending on what the data itself is. Just look up some info on serialization, google is your friend
Yes and No. I'm trying to secure data to make it virtually impossible for somebody to change their stats, game position, items, etc.
I have map xml files and later items that would be defined through xml files, but these will be stored remotely and the player has no influence over them.
I'm not sure how to save my player's profile securely so it can't be, in a way influenced.
Re: Saving and loading game data
Posted: Tue Jan 04, 2011 7:44 pm
by thejahooli
You could encode the data in the file, I've never really had experiance with this but I'm sure something will come up if you google it.
To be fair you are never going to have a completely secure save data, because after all it is only data, which can be modified in some way regardless of your best efforts.
Re: Saving and loading game data
Posted: Wed Jan 05, 2011 1:37 pm
by N64vSNES
The is no such thing as "secure" data since anything can be decoded.
The simplest way I'd suggest would be to encode the file like thejahooli said, the advantages to this being unreadable is that the file size will be very small and loading shouldn't take too much time.
Re: Saving and loading game data
Posted: Wed Jan 05, 2011 3:28 pm
by dnxviral
thejahooli wrote:You could encode the data in the file, I've never really had experiance with this but I'm sure something will come up if you google it.
To be fair you are never going to have a completely secure save data, because after all it is only data, which can be modified in some way regardless of your best efforts.
Encoding sounds.... fun. And I wouldn't mind if somebody edited the file and have their game file be corrupt either
N64vSNES wrote:The is no such thing as "secure" data since anything can be decoded.
The simplest way I'd suggest would be to encode the file like thejahooli said, the advantages to this being unreadable is that the file size will be very small and loading shouldn't take too much time.
Would be smaller?
How would you do the encoding?/What would you use for the encoding?
Re: Saving and loading game data
Posted: Thu Jan 06, 2011 10:13 am
by dandymcgee
The only secure way is to store data on a server where they can't directly edit a file.
For your purposes saving the file as binary ought to deter cheaters without completely disallowing hardcore modders having fun.
Re: Saving and loading game data
Posted: Thu Jan 06, 2011 12:42 pm
by N64vSNES
dnxviral wrote:thejahooli wrote:You could encode the data in the file, I've never really had experiance with this but I'm sure something will come up if you google it.
To be fair you are never going to have a completely secure save data, because after all it is only data, which can be modified in some way regardless of your best efforts.
Encoding sounds.... fun. And I wouldn't mind if somebody edited the file and have their game file be corrupt either
N64vSNES wrote:The is no such thing as "secure" data since anything can be decoded.
The simplest way I'd suggest would be to encode the file like thejahooli said, the advantages to this being unreadable is that the file size will be very small and loading shouldn't take too much time.
Would be smaller?
How would you do the encoding?/What would you use for the encoding?
Yes the file size will be much smaller.
Depends on what launguage you are using for encoding the file.
Its basically just working with bytes rather than numbers.
1 byte = 1 byte
1 integer = 4 bytes
Re: Saving and loading game data
Posted: Thu Jan 06, 2011 7:21 pm
by dnxviral
dandymcgee wrote:The only secure way is to store data on a server where they can't directly edit a file.
For your purposes saving the file as binary ought to deter cheaters without completely disallowing hardcore modders having fun.
Haha nice
N64vSNES wrote:dnxviral wrote:thejahooli wrote:You could encode the data in the file, I've never really had experiance with this but I'm sure something will come up if you google it.
To be fair you are never going to have a completely secure save data, because after all it is only data, which can be modified in some way regardless of your best efforts.
Encoding sounds.... fun. And I wouldn't mind if somebody edited the file and have their game file be corrupt either
N64vSNES wrote:The is no such thing as "secure" data since anything can be decoded.
The simplest way I'd suggest would be to encode the file like thejahooli said, the advantages to this being unreadable is that the file size will be very small and loading shouldn't take too much time.
Would be smaller?
How would you do the encoding?/What would you use for the encoding?
Yes the file size will be much smaller.
Depends on what launguage you are using for encoding the file.
Its basically just working with bytes rather than numbers.
1 byte = 1 byte
1 integer = 4 bytes
ahh ok. I'll look into both approaches. Server side, and files. Thanks!