Skip to content

Map Database

imshooter edited this page Oct 23, 2026 · 2 revisions

The map the component simulates comes from scriptfiles/3dandreas/world.db, a database built from the files of the game. The release ships one built from GTA San Andreas and the models SA-MP adds.

What it holds

Data Count From
Models 11,339 The collision files in the IMG archives, named by the IDE files
Map objects 38,995 The IPL files and their binary streams
Water polygons 307 water.dat
Surfaces 179 surfinfo.dat
Models the game moves 826 object.dat
Road nodes and links 30,587 and 62,936 nodes0.dat to nodes63.dat in gta3.img
Path nodes and links for pedestrians 37,650 and 80,686 The same files

Each model keeps its spheres, boxes and faces with the surface of each, its bounding box and sphere, and for the 826 models of object.dat how the game moves them. Each map object keeps its model, position, rotation and interior.

About 2,800 models have no collision. They keep their bounds for A3D_GetModelBoundingBox, and their 5,577 map objects, plants and other things players walk through, are left out of the world. The low detail models are left out too.

Each road node keeps whether it is on a highway, on a road the traffic of the game leaves alone or on a lane for boats, and each link of a road how many lanes go its way, from the navigation nodes of the game. Each link of a path for pedestrians keeps whether it crosses a road and whether lights guard the crossing. Routes are found on them.

The file takes 21.1 MB. It is read in about 130 milliseconds, and the bodies of the map are built in about as long, on every core.

Building it

phydb is built with the component. It needs a folder with GTA San Andreas, with the SA-MP client installed for the models SA-MP adds:

phydb "C:\Games\GTA San Andreas" world.db
phydb "C:\Games\GTA San Andreas" world.db --no-samp

--no-samp leaves the models of SA-MP out. It reads:

  • data/default.dat and data/gta.dat, for the IDE and IPL files they list,
  • the IDE files, and SAMP/SAMP.ide and SAMP/CUSTOM.ide,
  • models/gta3.img, models/gta_int.img and SAMP/SAMPCOL.img,
  • the IPL files and the binary streams inside the archives,
  • data/object.dat, data/surfinfo.dat and data/water.dat,
  • nodes0.dat to nodes63.dat inside models/gta3.img, for the paths.

It cleans the collision on the way: it welds the vertices that lie at the same place and drops the faces with no area and the faces given twice. It prints what it read and wrote:

11339 models (826 dynamic, 2800 without collision) from 252 collision files, 20 unnamed
1426441 faces and 938834 vertices kept of 1434474 and 939623, 8033 faces without area or given twice
38995 placements of 50769 read (185 streams, 5577 of models without collision), 307 water polygons, 179 surfaces
30587 road nodes and 62936 links, 37650 walk nodes and 80686 links
world.db written in 1.06 s, 21126370 bytes

The same game folder always gives the same file.

Put the file in scriptfiles/3dandreas, or point 3dandreas.database at it. See Configuration.

A ColAndreas database

When world.db is missing, the component reads scriptfiles/colandreas/ColAndreas.cadb instead and warns in the log. A ColAndreas database has the shapes and the map objects, but no surfaces, no water and no object.dat data:

The world at start

The component builds the shape of every model the map places, the largest first and on every core, and adds the 38,995 map objects to the world as static bodies. The faces of the game turn clockwise and Jolt collides with the front of a face only, so every face is turned the other way.

The interiors of the game stand in the sky above the city, and every map object belongs to every virtual world. A3D_RemoveBuilding takes map objects out, for every world or for one.

The format

For those who write tools, world.db is little endian, written field by field with no padding.

Part Fields
Header char[4] magic PHDB, u32 version 2, u32 counts of surfaces, models, map objects and water polygons
Surface name and group as a u8 length and that many bytes, f32 tyre grip, f32 wet grip, u32 flags
Model u16 id, u8 flags (1 when object.dat moves it), u8 reserved, f32[10] bounds (min, max, centre, radius), then the dynamics when flagged, then u16 spheres, u16 boxes, u32 vertices, u32 faces and each of them
Dynamics f32 mass, turn mass, air resistance, elasticity, percent submerged, uproot limit, damage multiplier, then u8 damage effect, special response, camera avoid, explosion
Sphere f32 x, y, z, radius, u8 surface
Box f32 min x, y, z, max x, y, z, u8 surface
Vertex i16 x, y, z in steps of 1/128 metre
Face u16 a, b, c, u8 surface
Map object u16 model, u8 interior, u8 reserved, f32 x, y, z, f32 quaternion x, y, z, w as the IPL stores it
Water polygon u8 corners, f32[4] x, f32[4] y, f32[4] z
Paths the roads, then the paths of pedestrians, each as u32 nodes, u32 links, each node, then u32 first link of each node and one more for the end, then each link
Path node f32 x, y, z, u8 flags (1 highway, 2 left alone by the traffic, 4 lane for boats), u8 width
Path link u32 node it leads to, f32 length, u8 lanes going that way, u8 flags (1 crosses a road, 2 lights guard the crossing)

The links of node n run from the first link of n to the first link of n + 1. A road link with no lanes is one way the other way. A database of version 1 ends after the water and has no paths.

The flags of a surface hold one bit for each of the 29 columns of surfinfo.dat from SOFTLAND to CLIMBABLE that is not zero, in the order of the file. A water polygon of four corners is a quad given as its corners in the order of water.dat, two triangles.

Home

Guides

Reference

Functions

Creating objects
Motion
Placement
Behaviour
Display and data
Rays
Shapes
Players, vehicles and actors
Map probes
Screen
Map objects
Water
Models and surfaces
Rotations and offsets
Vehicles
Routes
Route display
Walking
Callbacks

Clone this wiki locally