changeset 5225 | af5d9de16c8d |
parent 5211 | fb4dc0ca975d |
child 5228 | 26dc9acf7d94 |
5224:df36f84cbb6c | 5225:af5d9de16c8d |
---|---|
47 |
47 |
48 static GRFFile *_cur_grffile; |
48 static GRFFile *_cur_grffile; |
49 GRFFile *_first_grffile; |
49 GRFFile *_first_grffile; |
50 GRFConfig *_first_grfconfig; |
50 GRFConfig *_first_grfconfig; |
51 static SpriteID _cur_spriteid; |
51 static SpriteID _cur_spriteid; |
52 static int _cur_stage; |
52 static GrfLoadingStage _cur_stage; |
53 static uint32 _nfo_line; |
53 static uint32 _nfo_line; |
54 |
54 |
55 /* Miscellaneous GRF features, set by Action 0x0D, parameter 0x9E */ |
55 /* Miscellaneous GRF features, set by Action 0x0D, parameter 0x9E */ |
56 static byte _misc_grf_features = 0; |
56 static byte _misc_grf_features = 0; |
57 |
57 |
61 /* Used by Action 0x06 to preload a pseudo sprite and modify its content */ |
61 /* Used by Action 0x06 to preload a pseudo sprite and modify its content */ |
62 static byte *_preload_sprite = NULL; |
62 static byte *_preload_sprite = NULL; |
63 |
63 |
64 /* Set if any vehicle is loaded which uses 2cc (two company colours) */ |
64 /* Set if any vehicle is loaded which uses 2cc (two company colours) */ |
65 bool _have_2cc = false; |
65 bool _have_2cc = false; |
66 |
|
67 |
|
68 typedef enum GrfLoadingStage { |
|
69 GLS_LABELSCAN, |
|
70 GLS_INIT, |
|
71 GLS_ACTIVATION, |
|
72 GLS_END, |
|
73 } GrfLoadingStage; |
|
74 |
66 |
75 |
67 |
76 typedef enum GrfDataType { |
68 typedef enum GrfDataType { |
77 GDT_SOUND, |
69 GDT_SOUND, |
78 } GrfDataType; |
70 } GrfDataType; |
2552 check_length(len, 6, "GRFError"); |
2544 check_length(len, 6, "GRFError"); |
2553 severity = buf[1]; |
2545 severity = buf[1]; |
2554 msgid = buf[3]; |
2546 msgid = buf[3]; |
2555 |
2547 |
2556 // Undocumented TTDPatch feature. |
2548 // Undocumented TTDPatch feature. |
2557 if ((severity & 0x80) == 0 && _cur_stage < 2) { |
2549 if ((severity & 0x80) == 0 && _cur_stage < GLS_ACTIVATION) { |
2558 DEBUG(grf, 7) ("Skipping non-fatal GRFError in stage 1"); |
2550 DEBUG(grf, 7) ("Skipping non-fatal GRFError in stage 1"); |
2559 return; |
2551 return; |
2560 } |
2552 } |
2561 severity &= 0x7F; |
2553 severity &= 0x7F; |
2562 |
2554 |
2643 /* Patch variables */ |
2635 /* Patch variables */ |
2644 grfmsg(GMS_NOTICE, "ParamSet: Reading Patch variables unsupported."); |
2636 grfmsg(GMS_NOTICE, "ParamSet: Reading Patch variables unsupported."); |
2645 return; |
2637 return; |
2646 } else { |
2638 } else { |
2647 /* GRF Resource Management */ |
2639 /* GRF Resource Management */ |
2648 if (_cur_stage != 2) { |
2640 if (_cur_stage != GLS_ACTIVATION) { |
2649 /* Ignore GRM during initialization */ |
2641 /* Ignore GRM during initialization */ |
2650 src1 = 0; |
2642 src1 = 0; |
2651 } else { |
2643 } else { |
2652 uint8 op = src1; |
2644 uint8 op = src1; |
2653 uint8 feature = GB(data, 8, 8); |
2645 uint8 feature = GB(data, 8, 8); |
3526 } |
3518 } |
3527 free(buf); |
3519 free(buf); |
3528 } |
3520 } |
3529 |
3521 |
3530 |
3522 |
3531 static void LoadNewGRFFile(const char* filename, uint file_index, uint stage) |
3523 static void LoadNewGRFFile(const char *filename, uint file_index, GrfLoadingStage stage) |
3532 { |
3524 { |
3533 uint16 num; |
3525 uint16 num; |
3534 |
3526 |
3535 /* A .grf file is activated only if it was active when the game was |
3527 /* A .grf file is activated only if it was active when the game was |
3536 * started. If a game is loaded, only its active .grfs will be |
3528 * started. If a game is loaded, only its active .grfs will be |
3539 * action 8 hasn't been skipped using an action 7. |
3531 * action 8 hasn't been skipped using an action 7. |
3540 * |
3532 * |
3541 * During activation, only actions 0, 1, 2, 3, 4, 5, 7, 8, 9, 0A and 0B are |
3533 * During activation, only actions 0, 1, 2, 3, 4, 5, 7, 8, 9, 0A and 0B are |
3542 * carried out. All others are ignored, because they only need to be |
3534 * carried out. All others are ignored, because they only need to be |
3543 * processed once at initialization. */ |
3535 * processed once at initialization. */ |
3544 if (stage != 0) { |
3536 if (stage != GLS_LABELSCAN) { |
3545 _cur_grffile = GetFileByFilename(filename); |
3537 _cur_grffile = GetFileByFilename(filename); |
3546 if (_cur_grffile == NULL) error("File ``%s'' lost in cache.\n", filename); |
3538 if (_cur_grffile == NULL) error("File ``%s'' lost in cache.\n", filename); |
3547 if (stage > 1 && !(_cur_grffile->flags & 0x0001)) return; |
3539 if (stage > 1 && !(_cur_grffile->flags & 0x0001)) return; |
3548 } |
3540 } |
3549 |
3541 |