Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Possible Duplicate:
Would it be better to use XML/JSON/Text or a database to store game content?
How to choose how to store data?

When I look at games such as warcraft 3, or Diablo, or basically any games that contain items in them I notice that each item is unique. They all have different stats, different graphics, different names.

I took a wild guess that they don't use XML, although I know I might be wrong, but I just figured they use something that isn't easily human-editable to prevent casual hacking.

How is data such as item attributes stored in a game (2d or 3d, I suppose it works the same way in both)?

share|improve this question

marked as duplicate by Byte56, bummzack, doppelgreener, Laurent Couvidou, Tetrad Oct 25 '12 at 19:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2  
Common question. Please check the related question list that populates when you're typing your question. gamedev.stackexchange.com/questions/7952/… gamedev.stackexchange.com/questions/10932/… gamedev.stackexchange.com/questions/19046/… –  Byte56 Oct 25 '12 at 5:32

2 Answers 2

up vote 5 down vote accepted

Good guess, XML is not by default the simplest method of storing plain text data. It depends on a lot of things, mostly what existing tools you are planning to use. Some questions to ask yourself before choosing XML:

  • Do you feel XML editors make you (or your team) more productive? (If you are a programmer, used to a text editor, the answer is probably no.)
  • Do you want schema validation? (Will your data structure be complex enough to require this.)
  • What will XML bring to the table another, less verbose, easier text-editable, plain text configuration language doesn't have?

As Jonathan Blow eloquently put it:

Many modern programmers seem to have some kind of knee-jerk inclination to use XML whenever a textual format is desired, but I think XML is one of the worst file formats ever created, and I have no idea why anyone uses it for anything at all, except that perhaps they drank the XML Kool-Aid or have XML Stockholm Syndrome. Yes, there are XML-specific tools out there in the world, and whatever, but I didn’t see how any such tool would be of practical use to us. One of our primary concerns is human-readability, so that people can make intelligent decisions when attempting to resolve revision control conflicts. XML is not particularly readable, but we can modify our own format to be as readable as it needs to be in response to whatever real-world problems arise.

Some alternatives are:

share|improve this answer
1  
I made some good experiences with using JSON as a configuration language. It's not as bloated as XML, but it supports arrays and nesting, which can be pretty useful. –  Philipp Oct 25 '12 at 11:20
    
The ini file format is something I've never seen a game store it's data in. I wish someone would give a more popular example on how famous games such as diablo have stored their weapon attributes and such. I accepted this answer instead as it seems proper. +1 –  Bugster Oct 25 '12 at 15:59
1  
@ThePlan many games simply use a proprietary format to store game data (Eric's fourth bullet point). It may be some sort of delimited-text or even just binary. There are lots of options for storing game-data and there is no one true answer. If you want to know how Diablo 1/2 stores game data, google it. It's been hacked to death by now. –  Cypher Oct 25 '12 at 16:39

It really depends on the engine or tools used internally by the developer. The simplest method of storing data is, in fact, XML, or XML-like syntax. The format for models will probably be something different; for example, Unity uses the FBX format for it's models (and it can also import MAs and MBs, Maya's format). The format for textures would be any standard image format.

It's true that XML would be easily hacked, since it's human readable, and that's why the files will be compressed and possibly encrypted in the installation, both to prevent hand-editing and also to cut down on the space the game requires. The engine will have a way of reading the compressed files.

Going off on a tangent, it's entirely possible that the data will not be compressed. A specific example I can provide is that some early installs of GTA IV had an uncompressed/unencrypted WeaponsInfo file, which I had a lot of fun editing :)

EDIT: Here is a link to the WeaponInfo file from GTA IV. Note that it is XML: https://dl.dropbox.com/u/2789977/WeaponInfo.xml

share|improve this answer
1  
I would say the simplest method of storing data is serializing the data structures you're already using in game. But maybe that's just me. –  Byte56 Oct 25 '12 at 5:40
1  
As @Byte56 i would simply make all my items serializable and write them in a file whenever i need to save them. –  nathan Oct 25 '12 at 7:56
1  
I don't understand how XML is the simplest method of storing game data... I actually find it to be quite a pain to parse. I have to agree with @Byte56, I find simply serializing my game data the easiest way to get things on disk, and back into memory; especially as the structure of my data changes. –  Cypher Oct 25 '12 at 16:41
1  
@Cypher XML is easy to use as a format when you start with a reliable third-party parser. For example, TinyXml: grinninglizard.com/tinyxml. Of course, the decision for a data format also depends on the power of the tools you have to create and modify that data. –  ktodisco Oct 25 '12 at 17:03
1  
@ktodisco I don't think you understand what serializing is if you think that XML is one of the formats. –  Byte56 Oct 25 '12 at 17:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.