Copyright © 2002 Katrin Becker 1998-2002 Last Modified August 27, 2001 04:32 PM

Cpsc 461 Assignment:

File Formats

  Credit for original idea: Bioware Inc., Edmonton, AB (creators of Baldur's Gate, among other things)

Role-playing games require a number of different types of data resource, e.g. creature statistics, item information, dialogue text, model geometry and texture bitmaps. Each type of resource has its own file format that the game engine must be able to read. We have found that Over the course of the game's development these formats change a great deal. Data fields are often added or modified to support new features that were not in the original game design. In order to avoid constant modifications to the game engine itself, what is required is a more generic file format that could be used to store all of these types of data.
Your job is to design a file format and a C++ class that allows the game engine to open, read, and close a filw. The ability to change the file is not necessary so no write operation is required. To demonstrate that it works you must write a program that uses this class to open and read the files and display the following information:

1. the type of resource (i.e. creature stats, texture, dialogue, etc.)
2. for each field:

1. field ID
2. type
3. size
4. value (if the field contains audio or pictures it is assumed it will be in a standard format, in which case the type would be something like '.gif' and the value need not be printed. An unknown format should generate an appropriate message but may not terminate the program).

The design must obey the following restrictions:
- The format must be both forward and backward compatible-that is, if a file contains a data field that the game does not expect, it is ignored; and, if a file is missing a data field that the game expects, the game has the opportunity to substitute a default value for the missing field. This restriction allows the game to use resource files that are older or newer than the version it expects.
- A data field can be of any type, including, but not limited to: known C++ types, text, and standard formats for audio, video, and graphics, and variable length byte buffer. The game should be able to detect the type and size of a data field's value. It is not necessary to implement the read methods for all of these data types (just a few in each group), but it is necessary to demonstrate how the rest of them can be done.
- The format must identify itself somehow in the file, so that the game engine can parse it correctly.
- The format must identify what type of resource it stores. Because the same file format can store any kind of resource data, the game must have a way of identifying what resource type it contains.
- The C++ class must be able to parse the file format in minimal time. This restriction allows the game to load resources during game-play without visibly pausing (speed and efficiency are always key issues in games design).
- The format must be small, in memory and in disk usage. Both types of space are particularly limited on console systems. Ideally, it should be possible to parse and access specfic fields in the file without reading it entirely).
In order to demonstrate the function of your format you will have to create a number of test data files. As most of the fields will not be in ASCII form it may be necessary to write a program to create the files.
The read operations for the format's class may be specific to the type of resource being read since the game will most often be requesting information from a specific resource.

Copyright © 2002 Katrin Becker 1998-2002 Last Modified August 27, 2001 04:32 PM