Map system

From GTAMods Wiki
Jump to navigation Jump to search

This article describes the most important aspects of the GTA map system. It gives an overview over different files and which role they play for the game. Also it describes general information about the game.

Coordinate system

All Grand Theft Auto games use the same coordinate system rules. Unlike DirectX or OpenGL standard coordinate systems, a location in the game world gets defined by an east-west, north-south and a height information where the axis are:

  • X – east-west direction
  • Y – north-south direction
  • Z – height information

Map file types

Map listing file

See main article: gta.dat

The map listing file is the first one to get loaded by the game, if a new game is started. It stores information about the files that define the map itself. Each file that defines a part of the map needs to be defined inside this file.


See main article: IMG

Images are collections of different files for GTA. Since the models and textures are streamed to reduce the memory the game allocates they need to be loaded every time they are shown and not yet inside the memory. Files are combined to archives to reduce the amount of processor and hard drive access time that comes with opening a file.

Item definition

See main article: IDE

Item definition files are holding information about the appearance of a model inside the game.

An object typically gets defined by an unique index, a model file, a texture archive file, draw distance information and appearance flags. GTA also allows to define additional information for special objects (like time controlled or animated objects). Once defined an object can be placed multiple times.

To easily address objects every definition gets an unique index. The index range is different for each game and cannot be increased. It defines the size of the object definition pool – a structure holding all item definitions after the game has loaded all IDE files.

Item placement

See main article: IPL

Item placement file store locations of (previously defined) objects or other aspects like map zones, culling zones or garages.

Just as item definitions are limited by an hardcoded index range, map placements are limited to map boundaries which differs in each game.

Streaming IPLs

San Andreas also makes use streaming or binary item placement files. The game searches for streaming IPLs for each plain-text IPL file it loads inside the image files. Those binary item placement files are called just like their "parent" files with the additional "_streamXX" in front of the file extension. XX represents an incrementing number what means there can be multiple streaming files for one IPL file.

Some pseudo-code algorithm searching for streaming files could look like this:

void setupStreamsForItemPlacementFile(IPLFile* pSourceFile)
	// Pointer to the streaming item placement file
	IPLFile* pStreamFile(NULL);
	// Number of the current streaming file, starting with 0
	DWORD dwCurrentStream(0);

	// Search for streams inside an global image file pool as long as there are some
	// The method builds up the file name somehow like this:
	// sprintf(buffer, "%s_stream%d.ipl", pSourceFile->fileName, dwCurrentStream);
	while ((pStreamFile = searchForStreamingFile(pSourceFile, dwCurrentStream)) != NULL)
		// Extent the current item placement file

However it is important that streaming files extent their base files since LOD indices are relative to the first index inside the original non-binary file.

See also