Difference between revisions of "Roadblox.dat"

From GTAMods Wiki
Jump to navigation Jump to search
m (cat)
(Several touches)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
Roadblox.dat file stores an information about creation of police roadblocks on the map in GTA SA.
+
Roadblox.dat file stores information about creation of police roadblocks on the map in GTA San Andreas.
 
==Format==
 
==Format==
 
The file begins with the parameter - count of used roadblocks.
 
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.
 
It is followed with information about these roadblocks. Details of one such roadblock includes path area id, and path id in this area.
<source lang="cpp">struct NodeInfo
+
<source lang="C">typedef struct NodeInfo
 
{
 
{
    signed __int16 areaId;
+
int16_t areaId;
    unsigned __int16 nodeId;
+
uint16_t nodeId;
};</source>
+
} NodeInfo;</source>
  
<source lang="cpp">struct _RoadBloxFile
+
<source lang="C">typedef struct RoadBloxFile
 
{
 
{
    signed __int32 count;
+
int32_t count;
    NodeInfo places[325];
+
NodeInfo places[325];
};</source>
+
} RoadBloxFile;</source>
 
==Editing==
 
==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).
 
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==
 
==Example of file reading==
<source lang="C">void main()
+
<source lang="C">int main()
 
{
 
{
    NodeInfo info;
+
NodeInfo info;
    signed int count;
+
int32_t count;
    char line[32];
+
FILE * dat = fopen("data/paths/roadblox.dat", "rb");
    FILE * dat = fopen("data\\paths\\roadblox.dat", "rb");
+
FILE * txt = fopen("data/paths/roadblox.txt", "wt");
    FILE * txt = fopen("data\\paths\\roadblox.txt", "wt");
+
fread(&count, 4, 1, dat);
    fread(&count, 4, 1, dat);
+
fprintf(txt, "count: %d\n", count);
    sprintf(line, "count: %d\n", count);
+
for(int i = 0; i < count; i++)
    fputs(line, txt);
+
{
    for(int i = 1; i < 326; i++)
+
fread(&info, sizeof(info), 1, dat);
    {
+
fprintf(txt, "  %3d area: %2d node: %3u\n", i+1, info.areaId, info.nodeId);
        fread(&info, 4, 1, dat);
+
}
        sprintf(line, "  %3d area: %2d node: %3d\n", i, info.areaId, info.nodeId);
+
fclose(txt);
        fputs(line, txt);
+
fclose(dat);
    }
+
 
    fclose(txt);
+
return 0;
    fclose(dat);
 
 
}</source>
 
}</source>
 +
 +
{{N|SA}}
  
 
[[Category: File Formats]]
 
[[Category: File Formats]]

Latest revision as of 22:28, 29 June 2016

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;
}