Difference between revisions of "GrfLoadingStages"
m (7 revisions) |
m (Bot: Automated text replacement (--= +==)) |
||
Line 1: | Line 1: | ||
+ | == Introduction == |
||
− | '''''Stages of loading a GRF file''''' |
||
=The stages of loading a grf file= |
=The stages of loading a grf file= |
||
− | Processing of .grf files is done in several passes, most of which happen repeatedly, once per activations, which is whenever a game is started/loaded or the |
+ | Processing of .grf files is done in several passes, most of which happen repeatedly, once per activations, which is whenever a game is started/loaded or the "Apply" button in the GRF Status Window is pressed. Each pass processes all files in the order they appear in the GRF Status Window. |
Essentially, initialization is a two-pass system (first resolve jump targets, then initialize everything) that happens only once, activation is a two-pass system (first define cargos and reserve GRM IDs, then activate) that happens multiple times, and testing is a one-pass system run per click on a red/green flag in the GRF Status Window. |
Essentially, initialization is a two-pass system (first resolve jump targets, then initialize everything) that happens only once, activation is a two-pass system (first define cargos and reserve GRM IDs, then activate) that happens multiple times, and testing is a one-pass system run per click on a red/green flag in the GRF Status Window. |
||
+ | {| |
||
− | + | !Pass!!Description |
|
+ | |- |
||
− | Post-Load|Run once after loading all files. Initializes the targets of action 7&9 (to resolve goto jumps), ignores all other actions. |
+ | |Post-Load||Run once after loading all files. Initializes the targets of action 7&9 (to resolve goto jumps), ignores all other actions. |
+ | |- |
||
− | Initialization|Run once after the post-load pass. Checks action 0 for validity, records action 1 sprite numbers, resolves action 2 references (to the sprite numbers within the grf file of action 1 sprites and references to variational/random action 2), executes actions 6, 9, B, D and F, initializes action 3, 4, 8 and 11, and ignores the rest of the actions (including in particular action 7). |
+ | |Initialization||Run once after the post-load pass. Checks action 0 for validity, records action 1 sprite numbers, resolves action 2 references (to the sprite numbers within the grf file of action 1 sprites and references to variational/random action 2), executes actions 6, 9, B, D and F, initializes action 3, 4, 8 and 11, and ignores the rest of the actions (including in particular action 7). |
+ | |- |
||
− | Reserve|Called just before activation, to reserve GRM IDs. Also applies action 0 for cargos to make cargo labels valid to check in action 7/9 independent of order of .grf files. Ignores all actions except action 0 (for cargos), 6, 7, 8, 9, B, D and E. |
+ | |Reserve||Called just before activation, to reserve GRM IDs. Also applies action 0 for cargos to make cargo labels valid to check in action 7/9 independent of order of .grf files. Ignores all actions except action 0 (for cargos), 6, 7, 8, 9, B, D and E. |
+ | |- |
||
− | Activate|Called during activation. Applies all actions except F and 10. |
+ | |Activate||Called during activation. Applies all actions except F and 10. |
+ | |- |
||
− | Test|Called when user clicks to enable/disable file in the GRF Status Window to check which other files react to the change. Ignores all actions except 6, 7, 8, 9, B, D and E. |
+ | |Test||Called when user clicks to enable/disable file in the GRF Status Window to check which other files react to the change. Ignores all actions except 6, 7, 8, 9, B, D and E. |
+ | |} |
||
A .grf file is activated only if it was active when the game was started. If a game is loaded, only its active .grfs will be reactivated. A .grf file is considered active if its action 8 has been processed, i.e. its action 8 hasn't been skipped using an action 7. |
A .grf file is activated only if it was active when the game was started. If a game is loaded, only its active .grfs will be reactivated. A .grf file is considered active if its action 8 has been processed, i.e. its action 8 hasn't been skipped using an action 7. |
||
Line 24: | Line 31: | ||
The following table shows exactly which actions are excuted in which passes (X=action executed, I=action initialized, empty=action ignored). |
The following table shows exactly which actions are excuted in which passes (X=action executed, I=action initialized, empty=action ignored). |
||
+ | {| |
||
− | + | !Action!!Load!!Init!!Res!!Act!!Test!!Notes |
|
+ | |- |
||
− | 0| |<center>X</center>|<center>X*</center>|<center>X</center>| |During reservation stage especially cargo- and railtypes are reserved, so their existence can be tested by all GRFs in activation stage independent of loading order. |
+ | |0|| ||<center>X</center>||<center>X*</center>||<center>X</center>|| ||During reservation stage especially cargo- and railtypes are reserved, so their existence can be tested by all GRFs in activation stage independent of loading order. |
+ | |- |
||
− | 1| |<center>I</center>| |<center>X</center>| | |
+ | |1|| ||<center>I</center>|| ||<center>X</center>|| || |
+ | |- |
||
− | 2| |<center>I</center>| |<center>X</center>| | |
+ | |2|| ||<center>I</center>|| ||<center>X</center>|| || |
+ | |- |
||
− | 3| |<center>I</center>| |<center>X</center>| | |
+ | |3|| ||<center>I</center>|| ||<center>X</center>|| || |
+ | |- |
||
− | 4| |<center>I</center>| |<center>X</center>| | |
+ | |4|| ||<center>I</center>|| ||<center>X</center>|| || |
+ | |- |
||
− | 5| | | |<center>X</center>| | |
+ | |5|| || || ||<center>X</center>|| || |
+ | |- |
||
− | 6| |<center>X</center>|<center>X</center>|<center>X*</center>|<center>X</center>|Processed during activation in a51 and later. |
+ | |6|| ||<center>X</center>||<center>X</center>||<center>X*</center>||<center>X</center>||Processed during activation in a51 and later. |
+ | |- |
||
− | 7|<center>I</center>| |<center>X</center>|<center>X</center>|<center>X</center>| |
+ | |7||<center>I</center>|| ||<center>X</center>||<center>X</center>||<center>X</center>|| |
+ | |- |
||
− | 8| |<center>I</center>|<center>X</center>|<center>X</center>|<center>X</center>|When executed for an inactive file, skips remainder of file. |
+ | |8|| ||<center>I</center>||<center>X</center>||<center>X</center>||<center>X</center>||When executed for an inactive file, skips remainder of file. |
+ | |- |
||
− | 9|<center>I</center>|<center>X</center>|<center>X</center>|<center>X</center>|<center>X</center>| |
+ | |9||<center>I</center>||<center>X</center>||<center>X</center>||<center>X</center>||<center>X</center>|| |
+ | |- |
||
− | A| | | |<center>X</center>| | |
+ | |A|| || || ||<center>X</center>|| || |
+ | |- |
||
− | B| |<center>X*</center>|<center>X</center>|<center>X</center>|<center>X</center>|Processed during initialization only if bit 7 of severity is set. |
+ | |B|| ||<center>X*</center>||<center>X</center>||<center>X</center>||<center>X</center>||Processed during initialization only if bit 7 of severity is set. |
+ | |- |
||
− | C| | | | | | |
+ | |C|| || || || || || |
+ | |- |
||
− | D| |<center>X</center>|<center>X</center>|<center>X</center>|<center>X</center>| |
+ | |D|| ||<center>X</center>||<center>X</center>||<center>X</center>||<center>X</center>|| |
+ | |- |
||
− | E| | |<center>X</center>|<center>X</center>|<center>X</center>| |
+ | |E|| || ||<center>X</center>||<center>X</center>||<center>X</center>|| |
+ | |- |
||
− | F| |<center>X</center>| | | | |
+ | |F|| ||<center>X</center>|| || || || |
+ | |- |
||
− | 10|<center>X</center>| | | | | |
+ | |10||<center>X</center>|| || || || || |
+ | |- |
||
− | 11| |<center>I</center>| |<center>X</center>| | |
+ | |11|| ||<center>I</center>|| ||<center>X</center>|| || |
+ | |- |
||
− | 12| | | |<center>X</center>| | If TTDPatch encounters any Action12 during any stage (including |
+ | |12|| || || ||<center>X</center>|| || If TTDPatch encounters any Action12 during any stage (including "Load"), Unicode handling is enabled. |
+ | |- |
||
− | 13| | | |<center>X</center>| | |
+ | |13|| || || ||<center>X</center>|| || |
+ | |- |
||
− | 14| | | | | | Processed by OpenTTD only when scanning for files. Not processed during the normal loading/activation. |
+ | |14|| || || || || || Processed by OpenTTD only when scanning for files. Not processed during the normal loading/activation. |
+ | |} |
Revision as of 23:42, 14 June 2011
Introduction
The stages of loading a grf file
Processing of .grf files is done in several passes, most of which happen repeatedly, once per activations, which is whenever a game is started/loaded or the "Apply" button in the GRF Status Window is pressed. Each pass processes all files in the order they appear in the GRF Status Window.
Essentially, initialization is a two-pass system (first resolve jump targets, then initialize everything) that happens only once, activation is a two-pass system (first define cargos and reserve GRM IDs, then activate) that happens multiple times, and testing is a one-pass system run per click on a red/green flag in the GRF Status Window.
Pass | Description |
---|---|
Post-Load | Run once after loading all files. Initializes the targets of action 7&9 (to resolve goto jumps), ignores all other actions. |
Initialization | Run once after the post-load pass. Checks action 0 for validity, records action 1 sprite numbers, resolves action 2 references (to the sprite numbers within the grf file of action 1 sprites and references to variational/random action 2), executes actions 6, 9, B, D and F, initializes action 3, 4, 8 and 11, and ignores the rest of the actions (including in particular action 7). |
Reserve | Called just before activation, to reserve GRM IDs. Also applies action 0 for cargos to make cargo labels valid to check in action 7/9 independent of order of .grf files. Ignores all actions except action 0 (for cargos), 6, 7, 8, 9, B, D and E. |
Activate | Called during activation. Applies all actions except F and 10. |
Test | Called when user clicks to enable/disable file in the GRF Status Window to check which other files react to the change. Ignores all actions except 6, 7, 8, 9, B, D and E. |
A .grf file is activated only if it was active when the game was started. If a game is loaded, only its active .grfs will be reactivated. A .grf file is considered active if its action 8 has been processed, i.e. its action 8 hasn't been skipped using an action 7.
The following table shows exactly which actions are excuted in which passes (X=action executed, I=action initialized, empty=action ignored).
Action | Load | Init | Res | Act | Test | Notes |
---|---|---|---|---|---|---|
0 | During reservation stage especially cargo- and railtypes are reserved, so their existence can be tested by all GRFs in activation stage independent of loading order. | |||||
1 | ||||||
2 | ||||||
3 | ||||||
4 | ||||||
5 | ||||||
6 | Processed during activation in a51 and later. | |||||
7 | ||||||
8 | When executed for an inactive file, skips remainder of file. | |||||
9 | ||||||
A | ||||||
B | Processed during initialization only if bit 7 of severity is set. | |||||
C | ||||||
D | ||||||
E | ||||||
F | ||||||
10 | ||||||
11 | ||||||
12 | If TTDPatch encounters any Action12 during any stage (including "Load"), Unicode handling is enabled. | |||||
13 | ||||||
14 | Processed by OpenTTD only when scanning for files. Not processed during the normal loading/activation. |