Roadblox.dat

From GTAMods Wiki
Revision as of 22:28, 29 June 2016 by Silent (talk | contribs) (Several touches)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Roadblox.dat file stores information about creation of police roadblocks on the map in GTA San Andreas.

Format

The file begins with the parameter - count of used roadblocks. It is followed with information about these roadblocks. Details of one such roadblock includes path area id, and path id in this area.

typedef struct NodeInfo
{
	int16_t areaId;
	uint16_t nodeId;
} NodeInfo;
typedef struct RoadBloxFile
{
	int32_t count;
	NodeInfo places[325];
} RoadBloxFile;

Editing

The file can be edited, but its size should not be smaller than the original. Parameter "count" can be set to "-1" (in this case, information on the roadblocks will be ignored).

Example of file reading

int main()
{
	NodeInfo info;
	int32_t count;
	FILE * dat = fopen("data/paths/roadblox.dat", "rb");
	FILE * txt = fopen("data/paths/roadblox.txt", "wt");
	fread(&count, 4, 1, dat);
	fprintf(txt, "count: %d\n", count);
	for(int i = 0; i < count; i++)
	{
		fread(&info, sizeof(info), 1, dat);
		fprintf(txt, "  %3d area: %2d node: %3u\n", i+1, info.areaId, info.nodeId);
	}
	fclose(txt);
	fclose(dat);

	return 0;
}