User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Game Development section within the Software Development category of DaniWeb, a massive community of 423,510 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,701 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Game Development advertiser: Programming Forums
View Poll Results: Plaintext or XML?
Plaintext 0 0%
XML 4 100.00%
Voters: 4. You may not vote on this poll

Views: 3097 | Replies: 4
Reply
Join Date: Apr 2005
Location: New York state
Posts: 464
Reputation: ShawnCplus will become famous soon enough ShawnCplus will become famous soon enough 
Rep Power: 5
Solved Threads: 72
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Saving Game Data - Plaintext vs. XML

  #1  
Jul 25th, 2007
I've been trying to decide how to handle saving game data. At first I was using plaintext which is quick and straight forward but also very, very ugly. I wanted to delve into the world of XML to save data since although it is a bit slower since it has to run through an XML parser (albeit custom built) but definitely the more elegant of the two. Also, since XML can be ported so easily it could, with very little effort, have a second life in a completely different form, ie. a graphical game instead of textual.

So the argument comes down to quick and dirty or elegant and portable. Which would you choose, or have you found to be successful?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2006
Location: Deptford, London
Posts: 954
Reputation: MattEvans has a spectacular aura about MattEvans has a spectacular aura about 
Rep Power: 5
Solved Threads: 48
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Posting Shark

Re: Saving Game Data - Plaintext vs. XML

  #2  
Jul 25th, 2007
I'm working on an XML game engine at the moment ^_-.. I'm allowing as much as possible ( objects/object traits, map layout, hopefully objectives [ basically everything except binary graphics and sound ] ) to be defined and linked up using XML.. In this case; the XML becomes a sort of 'pseudo source code' and it's thus important for it to be structured and easily interpretable at a glance. The interface should be elegant, the implementation should be quick ( and optionally dirty ); and both should be as portable as possible. In my case, a part of the interface is the structured input..

But if you're just considering save games; as in a player's postition and status in the game at any given point in time; you may WANT to keep those files unreadable - otherwise you'll encourage cheating =P.

Certainly don't worry about time-taken-to-load when considering an option; whether you're opening the game and loading in resources based on an XML manifest, or reading in a players position to re-enter the game :- the load time will usually be a one-off; which becomes irrelevant when compared to optimizations you can make elsewhere; say in the game cycle; physics engine, AI, redraw code, or anything else that has to be done repeatadly..

It might even be faster if you use a good XML parser ( I'd advise looking at an existing one rather than custom building, Apache's Xerces project is very full featured, and pretty stable, and quite fast ); than interpreting a custom file format; which may end up developing a complicated structure out of neccessity rather than any forward planning...
If it only works in Internet Explorer; it doesn't work.
Reply With Quote  
Join Date: Jul 2007
Location: Virginia
Posts: 102
Reputation: TheGathering is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 10
TheGathering's Avatar
TheGathering TheGathering is offline Offline
Junior Poster

Re: Saving Game Data - Plaintext vs. XML

  #3  
Jul 31st, 2007
In our first year of Computer Science (High School) we wrote a few games as end of year projects using XMLs to store information and save info.

We loved the flexibility and structure XMLs gave us but ran into problems in maintenance the next year after Java had released 1.5.0 and rewrote it's XML handling functions.

I would tell you to go with XMLs but keep in mind that the way your language handles XMLs can change, the way it handles text won't.
Last edited by TheGathering : Jul 31st, 2007 at 9:28 am.
Reply With Quote  
Join Date: Mar 2004
Posts: 732
Reputation: Phaelax is on a distinguished road 
Rep Power: 6
Solved Threads: 31
Phaelax Phaelax is offline Offline
Master Poster

Re: Saving Game Data - Plaintext vs. XML

  #4  
Jul 31st, 2007
If you're storing data only your game will need to interact with and requires no outside programs or users to be able to read the data, then I would stick with a standard text file. The only data I would store in XML is stuff that wouldn't be harmed by the user changing the data, such as name of the player, key bindings, or other stuff that's commonly find in other game INI files.
Reply With Quote  
Join Date: Nov 2004
Location: Netherlands
Posts: 5,752
Reputation: jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough 
Rep Power: 18
Solved Threads: 197
Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Saving Game Data - Plaintext vs. XML

  #5  
Aug 3rd, 2007
If you'd used standard APIs for XML handling you'd have had no trouble...

But to the topic.
What you use depends totally on what you're storing.
If it's simple flat data, a properties/ini file is the way to go.
If it's hierarchical (or likely to become so in the future) XML is called for.
If performance is paramount (hardly ever when reading files) a binary format storing entire structs is the way to go.
For games running on servers in a distributed environment, use a relational or object-relational database server.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Game Development Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Game Development Forum

All times are GMT -4. The time now is 4:32 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC