Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (408)
games submitted by our members
Games in WIP (293)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Different way to make saves from ObjectOutputStream? (version unreadability)  (Read 1835 times)
0 Members and 1 Guest are viewing this topic.
Offline Eli Delventhal
« League of Dukes »

JGO Kernel


Medals: 39
Projects: 12


Game Engineer


« Posted 2005-08-15 08:56:00 »

Hello friends,

I have a game and currently we save levels with the ObjectOutputStream, where it just writes all the objects in the level to a data file.  This works fine, except for if I update any of the classes saved at all, like adding in a new method or modifying the parameters of an old one. There's the issue. In something other than a game, I'm sure you can ignore this, but that is simply impossible in a game that may release patches or new versions.

So, what's a solution? I was thinking I would save all the specific primitives to a file in a certain order, and then construct each object upon loading of the level, but this would get very tedious for so many classes and would mean modifying the load level code each version update. I will do this if nobody can think of a better way, but I wouldn't be surprised if I'm not the first one who's dealt with this.

If there is an way in LWJGL, I'll try that also, as I will eventually convert much of the game to it.

Thanks.

See my work:
OTC Software
Offline shmoove

Junior Member




Doh!


« Reply #1 - Posted 2005-08-15 10:27:48 »

Looks like you arrived at the wrong forum, seeing as there are no ObjectOutputStreams in MIDP and no support for LWJGL.

shmoove
Offline Eli Delventhal
« League of Dukes »

JGO Kernel


Medals: 39
Projects: 12


Game Engineer


« Reply #2 - Posted 2005-08-16 05:32:25 »

Isn't J2ME just the standard Java? I could have sworn it was... I guess this should go into game design, then...

So, if any mods wants to delete this...

See my work:
OTC Software
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline OverKill

Junior Member




Java games rock!


« Reply #3 - Posted 2005-09-07 09:28:13 »

Any reason why are you using ObjectOutputStreams?
Why not save the data in binary form?
Add a version tag and then if you updated it, the version tag will tell the reader how to read it.
Offline Abuse

JGO Coder


Medals: 2


falling into the abyss of reality


« Reply #4 - Posted 2005-09-07 20:08:05 »

Any reason why are you using ObjectOutputStreams?
Why not save the data in binary form?
Add a version tag and then if you updated it, the version tag will tell the reader how to read it.

To save reinventing the wheel?

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here!
Offline Abuse

JGO Coder


Medals: 2


falling into the abyss of reality


« Reply #5 - Posted 2005-09-07 20:11:50 »

Hello friends,

I have a game and currently we save levels with the ObjectOutputStream, where it just writes all the objects in the level to a data file.  This works fine, except for if I update any of the classes saved at all, like adding in a new method or modifying the parameters of an old one. There's the issue. In something other than a game, I'm sure you can ignore this, but that is simply impossible in a game that may release patches or new versions.

So, what's a solution? I was thinking I would save all the specific primitives to a file in a certain order, and then construct each object upon loading of the level, but this would get very tedious for so many classes and would mean modifying the load level code each version update. I will do this if nobody can think of a better way, but I wouldn't be surprised if I'm not the first one who's dealt with this.

If there is an way in LWJGL, I'll try that also, as I will eventually convert much of the game to it.

Thanks.

If you want version independance you should override the classes writeObject and readObject implementations with your own loading/saving that is not version sensitive (or atleast offers backward compatability)

Have a look at java.io.Serializable

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here!
Offline Eli Delventhal
« League of Dukes »

JGO Kernel


Medals: 39
Projects: 12


Game Engineer


« Reply #6 - Posted 2005-09-08 01:50:47 »

If you want to do it that way then you need to use Externalizable.

In any case, I reposted and have it all figured out and explained here http://192.18.37.44/forums/index.php?topic=10522.0 if anyone is curious.

See my work:
OTC Software
Offline OverKill

Junior Member




Java games rock!


« Reply #7 - Posted 2005-09-08 09:11:19 »

Any reason why are you using ObjectOutputStreams?
Why not save the data in binary form?
Add a version tag and then if you updated it, the version tag will tell the reader how to read it.

To save reinventing the wheel?
We are still talking about J2ME dev, aren't we?
IIRC there is no ObjectOutputStream under J2ME.
Some devices might have it as a bonus feature but it is not standard.
Offline Eli Delventhal
« League of Dukes »

JGO Kernel


Medals: 39
Projects: 12


Game Engineer


« Reply #8 - Posted 2005-09-08 09:56:36 »

No, read above. I was thinking J2ME is J2SE, just got my initials messed up. This thread should be deleted, unless you guys feel like talking about file saving in J2ME.

See my work:
OTC Software
Offline OverKill

Junior Member




Java games rock!


« Reply #9 - Posted 2005-09-08 10:02:00 »

No, read above. I was thinking J2ME is J2SE, just got my initials messed up. This thread should be deleted, unless you guys feel like talking about file saving in J2ME.
Ah, ok. Now I understand.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Browse for soundtracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (125 views)
2013-05-17 21:29:12

alaslipknot (133 views)
2013-05-16 21:24:48

gouessej (163 views)
2013-05-16 00:53:38

gouessej (155 views)
2013-05-16 00:17:58

theagentd (168 views)
2013-05-15 15:01:13

theagentd (153 views)
2013-05-15 15:00:54

StreetDoggy (197 views)
2013-05-14 15:56:26

kutucuk (221 views)
2013-05-12 17:10:36

kutucuk (220 views)
2013-05-12 15:36:09

UnluckyDevil (224 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!
Page created in 0.077 seconds with 22 queries.