Game Development Reference
In-Depth Information
Tradeoffs
The primary advantage of using a binary file is that it's going to be a smaller file,
and also one that can be loaded more quickly. Rather than having to spend time
parsing in text and converting it into the appropriate in-memory format, it's of-
ten possible to directly load in chunks of the binary file without any conversion.
Because efficiency is so important for games, it's on that merit alone that binary
typically wins out for files that are going to contain large amounts of information,
such as the layout of a level.
However, the extra speed does come with a cost. One big disadvantage of binary
files is that they don't work as well with a source control system (if you aren't fa-
miliar with source control, you should check Appendix B , Useful Tools for Pro-
grammers ). The reason is that it can be very hard to figure out what has changed
between two versions of a binary file.
For example, suppose a game stores its level data in a binary format (such as the
.pkgfilesthatUnrealuses).Nowfurthersupposethatadesignergoesintothelevel
editor and makes ten different changes to the level. Without testing the level, the
designer then decides to submit the updated level. For whatever reason, this level
actually does not load after the changes. At this point, to fix the game so that the
level can load, the only course of action is to revert to the previous version of the
file, thus losing all ten changes. But what if only one of the ten changes was bad?
In a binary file, there's typically no way to go through and actually change the one
part of it that's bad, so all the changes have to be undone.
Granted, this scenario does expose some other problems—why is the designer
checking in something without testing it, and why can the level editor save bad
data? But the fact of the matter is that between two revisions of this hypothetical
binary level file format, it's going to be very hard to tell what has changed without
loading the level.
Foratext-basedfileformat,however,itwouldbeveryeasytolookattwodifferent
versions of the file and see the differences between them. This means that if there
were ten changes to a level, with one not working, it would be possible to go
through and actually remove the specific change that's breaking the level.
There's also the fact that a text-based file format can be more easily edited by end
users. For something such as configuring the keyboard input, it may be preferable
to have a text file so it's very easy to change in a standard text editor. But on the
other hand, this may be a disadvantage for the level data, because it would be easy
for a player to change the behavior of the game and break it.
Search WWH ::




Custom Search