-3
\$\begingroup\$

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)?

\$\endgroup\$
1

2 Answers 2

6
\$\begingroup\$

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:

\$\endgroup\$
3
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – Philipp
    Oct 25, 2012 at 11:20
  • \$\begingroup\$ 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 \$\endgroup\$
    – Bugster
    Oct 25, 2012 at 15:59
  • 1
    \$\begingroup\$ @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. \$\endgroup\$
    – Cypher
    Oct 25, 2012 at 16:39
3
\$\begingroup\$

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

\$\endgroup\$
9
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – House
    Oct 25, 2012 at 5:40
  • 1
    \$\begingroup\$ As @Byte56 i would simply make all my items serializable and write them in a file whenever i need to save them. \$\endgroup\$
    – nathan
    Oct 25, 2012 at 7:56
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – Cypher
    Oct 25, 2012 at 16:41
  • 1
    \$\begingroup\$ @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. \$\endgroup\$ Oct 25, 2012 at 17:03
  • 1
    \$\begingroup\$ @ktodisco I don't think you understand what serializing is if you think that XML is one of the formats. \$\endgroup\$
    – House
    Oct 25, 2012 at 17:31

Not the answer you're looking for? Browse other questions tagged .