SCR Strings-array data format

Written by T.M. @ 27.06.2012 (d.m.Y)


Location 77536 (location starts from zero)
Size 5120 bytes by GTA2 compiler, but any size is supported by GTA2 (0-65535), although, it may be that 5120 is the limit, this has not been tested yet. If zero, then there must be 2 bytes after the length variable, or GTA2 will crash.
Min-size 4 bytes, all of these bytes must be set to Null.

Description:

This array is found at the end of each .scr file (but not in the mission files (which are launched by LAUNCH_MISSION etc commands)).
  • It can be dynamic in size, which allows slightly smaller scr-files to be made, but is preferred to use same size as original GTA2 compiler uses. GTA2 compiler adds uninitialized data to the rest of the 5120 bytes, which may contain personal information that you dont want to share with everyone, thus it is preferred to set these bytes to Null, you can use Epic GTA2 Map Editor to do so.
  • It is filled in reverse order: last = first in the mis script. It has not been tested if the order of the array matters for GTA2.
  • It cannot have the same string twice, even if the types are different, thus: the types doesn't matter at all, it's probably a leftover from debugging. However, using the same name for zone and a mission file will make the compiler to not compile the mission script (no errors shown), though, GTA2 might still be able to read that kind of SCR file without any problems.


Example script
PLAYER_PED p1 = (1.1, 1.1, 1.1) 1 1
SET_STATION_INFO (trak1, 1, 2, 3)
SET_STATION_INFO (trak2, NO_TRAIN)
SET_GANG_INFO (gan1, 1, PISTOL, PISTOL, PISTOL, 0, 1.1, 2.2, 3.3, 1, SPRITE, 1)
SET_GANG_INFO (gan2, 1, SHOTGUN, SHOTGUN, SHOTGUN, 0, 1.1, 2.2, 3.3, 1, BUS, 1)
MAP_ZONE zone1
MAP_ZONE zone2 = (1000, 0, 0, 0, 1000, 0, 0, 0, 1000, 0, 1000)
MAP_ZONE zone3 = (1000, 0, 0, 0, 1000, 0, 0, 0, 1000, 0, 1000)
LAUNCH_MISSION (mission.mis)
LAUNCH_MISSION (mission2.mis)

Example output of strings-array in hex format
array_len:
9800
id:      type:    len:string:
1800 0000 1500 0000 0D:6D697373696F6E322E6D697300 = mission2.mis\0
1500 0000 1500 0000 0D:6D697373696F6E2E6D69730000 = mission.mis\0\0
0800 0000 0A00 0000 07:7A6F6E65330000 = zone3\0\0
0700 0000 0A00 0000 07:7A6F6E65320000 = zone2\0\0
0600 0000 0A00 0000 07:7A6F6E65310000 = zone1\0\0
0500 0000 1100 0000 05:67616E3200 = gan2\0
0400 0000 1100 0000 05:67616E3100 = gan1\0
0300 0000 0A00 0000 07:7472616B320000 = trak2\0\0
0200 0000 0A00 0000 07:7472616B310000 = trak1\0\0

Note: white-space and blue text is not part of the hex data.

Variable Explanation
array_len Uint16, the strings-array length in bytes (array_len variable size is not counted in it). If zero, then there must be 2 bytes of data after this array_len, or GTA2 will crash.
id Uint16, unique ID used to know which string to use. Every script command that uses zones/gangs/filenames, will store the string as this Uint16 value in their script stream data. Later that string can be retrieved from the strings-array by using that integer. This value also points to the first occurence of the string in the script data (the id will have same value as in SCR_CMD_HEADER.cmd_this), but that information is probably useless.
type Uint16, tells what type of string it is. All possible types:
Uint16 Explanation
10 zonename
17 gangname
21 filename
The use of this is unknown, it has not been tested if GTA2 requires this information.
len Uint8, string length. Max: 255. The length counts in the terminating Null char and the possible extra padding char (which is also Null).
string Null terminated string. Note: (length+1) must be divisible by 2! In other words: length must be odd, for example 3,5,7,9,11 etc. A possible extra padding byte must be Null.

C-Structure example
struct string_header {
    Uint16 id;
    Uint16 padding1;
    Uint16 type;
    Uint16 padding2;
    Uint8 len;
};
Note: This struct is used after the array length integer was read, and after this struct you should read the string of len bytes, then repeat until the whole array has been read. You should use 1 byte packing for all structs.


All possible script commands that can fill up and use this strings-array:

mis script command Decompiler source enum(s) Hex
SET_STATION_INFO SCRCMD_SET_STATION
SCRCMD_SET_EMPTY_STATION
1D01
1E01
MAP_ZONE SCRCMD_MAP_ZONE_SET
SCRCMD_MAP_ZONE1
6600
6500
START_BONUS_CHECK SCRCMD_START_BONUS1
SCRCMD_START_BONUS2
SCRCMD_START_BONUS3
2001
2101
2201
SET_GANG_INFO SCRCMD_SET_GANG_INFO1DF00
DO_EASY_PHONE_TEMPLATESCRCMD_DO_EASY_PHONE4901
DO_PHONE_TEMPLATESCRCMD_PHONE_TEMPLATE0701
ADD_CHAR_TO_GANGSCRCMD_ADD_CHAR_TO_GANG0201
LAUNCH_MISSIONSCRCMD_LAUNCH_MISSION1201
CHANGE_GANG_CHAR_RESPECTSCRCMD_CHANGE_RESPECT0601
CHANGE_GANG_CHAR_RESPECT_AND_UPDATESCRCMD_CHANGE_GANG_RESP8901
SET_BADCAR_RATIOSCRCMD_SET_BAD_CAR6900
SET_CARTHIEF_RATIOSCRCMD_SET_CARTHIEF6D00
SET_CAR_DENSITYSCRCMD_SET_CAR_DENSITY6700
SET_ELVIS_RATIOSCRCMD_SET_ELVIS6E00
SET_GANG_RATIOSCRCMD_SET_GANG6F00
SET_GANGCAR_RATIOSCRCMD_SET_GANGCARRATIO7401
SET_GANG_KILL_REACTIONSCRCMD_SET_GANG_RESPECTE000
SET_GOODCAR_RATIOSCRCMD_SET_GOOD_CAR6800
SET_MUGGER_RATIOSCRCMD_SET_MUGGER6C00
SET_PEDDENSITYSCRCMD_SET_PED_DENSITY6B00
SET_POLICECAR_RATIOSCRCMD_SET_POLICE_CAR6A00
SET_POLICEPED_RATIOSCRCMD_SET_POLICE_PED7000
IS_CHAR_IN_GANGZONESCRCMD_IS_CHAR_IN_GANGE800
IS_CHAR_IN_ZONESCRCMD_IS_CHAR_IN_ZONEF200
CHECK_RESPECT_GREATERSCRCMD_CHECK_RESPECT_GREATERC600
CHECK_RESPECT_EQUALSCRCMD_CHECK_RESPECT_ISE700
CHECK_RESPECT_LOWERSCRCMD_CHECK_RESPECT_LESSC700




Datatypes etc. explained:

Script command Any function (or its integer value), such as PLAYER_PED.
- char
- character
Byte. Can also mean a letter of a text. Usually 1 byte in size.
string An array of bytes representing letters of a text. Each letter is 1 byte in size.
Null terminated string A string that contains a Null byte as the last character of the string.
- Null
- NULL
Means a value that has all bits set to zero, thus an integer of this type would be same as 0. The byte-size of this value is not defined.
\0 Null value, always 1 byte in length. Used in strings.
- padding
- pad
- unknown
- unk
- unused
Used in structure definitions, a variable that has no purpose now or yet, but is required for the structure to work correctly. These variables may have a number after them.
Uint8 Unsigned Integer, always 1 byte in length.
Uint16 Unsigned Integer, always 2 bytes in length.
Uint32 Unsigned Integer, always 4 bytes in length.
Sint8 Signed Integer, always 1 byte in length.
Sint16 Signed Integer, always 2 bytes in length.
Sint32 Signed Integer, always 4 bytes in length.

SCR_CMD_HEADER
Type Variable Explanation
Uint16 cmd_this Current pointer index.
Uint16 type Which function type, PLAYER_PED etc.
Uint16 cmd_next Next pointer index.
Uint16 return_value Used by IF_JUMP's and boolean functions, seems to be return value for boolean functions, and endif marker for if_jumps (if zero).