Game Development Reference
In-Depth Information
7
Robust File I/O
Alan Kimball
7.1 Introduction
Reading data from storage is a core feature required in any game engine. Be
it a hard drive, a cartridge, a disc, or from the cloud, game data needs to be
deserialized quickly. At the same time, during development it is vitally important
for game data and formats to be iterated quickly. During much of the development
of a game, assets and game systems need to be developed in parallel. The need
for eciency and robustness can lead to many problems during development. By
building two compatible but different serialization systems inside an engine, both
of these requirements can be handled in a simple and robust manner.
7.2 Existing Technologies
One possible solution to this problem is to rely on existing technologies. Serializing
data is not unique to games, and a large number of solutions have been found for
reading data. Most high-level languages have multiple solutions to the problem:
Java has Hibernate, the .NET runtime has the serialization framework, Python has
pickle. All of these solutions are highly optimized and incredibly robust. These
solutions also suffer from issues which often make them unappealing in game de-
velopment.
First and foremost, they may not be accessible on the platform on which your
game is running, or on the platform which your game may be ported to in the future.
These frameworks are large, and often tightly coupled to their runtime. If a game
needs to change platform, porting a complete serialization API is time-consuming
and sometimes impossible.
Second, for our purposes, these existing solutions are too complicated. These
frameworks are built with robustness, not speed, as the primary goal. When a
game is complete, your data have already been tested and verified, so having an
71