Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (522)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (591)
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 2249 times)
0 Members and 1 Guest are viewing this topic.
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Posted 2005-08-15 06: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 Devvie




Doh!


« Reply #1 - Posted 2005-08-15 08: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

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #2 - Posted 2005-08-16 03: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 Devvie




Java games rock!


« Reply #3 - Posted 2005-09-07 07: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 Knight


Medals: 14


falling into the abyss of reality


« Reply #4 - Posted 2005-09-07 18: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! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline Abuse

JGO Knight


Medals: 14


falling into the abyss of reality


« Reply #5 - Posted 2005-09-07 18: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! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #6 - Posted 2005-09-07 23: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 Devvie




Java games rock!


« Reply #7 - Posted 2005-09-08 07: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

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #8 - Posted 2005-09-08 07: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 Devvie




Java games rock!


« Reply #9 - Posted 2005-09-08 08: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.

 

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

The first screenshot will be displayed as a thumbnail.

trollwarrior1 (34 views)
2014-11-22 12:13:56

xFryIx (73 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50

digdugdiggy (46 views)
2014-11-12 21:10:15

digdugdiggy (40 views)
2014-11-12 21:09:33

kovacsa (66 views)
2014-11-07 19:57:14

TehJavaDev (70 views)
2014-11-03 22:04:50

BurntPizza (68 views)
2014-11-03 18:54:52

moogie (83 views)
2014-11-03 06:22:04

CopyableCougar4 (82 views)
2014-11-01 23:36:41
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
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!