1
0
Fork 0

Fix: NewGRF Global variables 0D, 0E and 1E refer to wrong GRFFile.

These variables used GrfProcessingState, which is only valid while loading GRFs, after which they always point to the last loaded GRFFile.
pull/13986/head
Peter Nelson 2025-04-10 17:43:47 +01:00
parent 936d78fefc
commit ea272261f7
No known key found for this signature in database
GPG Key ID: 8EF8F0A467DF75ED
1 changed files with 3 additions and 3 deletions

View File

@ -458,11 +458,11 @@ bool GetGlobalVariable(uint8_t param, uint32_t *value, const GRFFile *grffile)
} }
case 0x0D: // TTD Version, 00=DOS, 01=Windows case 0x0D: // TTD Version, 00=DOS, 01=Windows
*value = _cur.grfconfig->palette & GRFP_USE_MASK; *value = GetGRFConfig(grffile->grfid)->palette & GRFP_USE_MASK;
return true; return true;
case 0x0E: // Y-offset for train sprites case 0x0E: // Y-offset for train sprites
*value = _cur.grffile->traininfo_vehicle_pitch; *value = grffile->traininfo_vehicle_pitch;
return true; return true;
case 0x0F: // Rail track type cost factors case 0x0F: // Rail track type cost factors
@ -509,7 +509,7 @@ bool GetGlobalVariable(uint8_t param, uint32_t *value, const GRFFile *grffile)
/* Add the local flags */ /* Add the local flags */
assert(!bits.Test(GrfMiscBit::TrainWidth32Pixels)); assert(!bits.Test(GrfMiscBit::TrainWidth32Pixels));
if (_cur.grffile->traininfo_vehicle_width == VEHICLEINFO_FULL_VEHICLE_WIDTH) bits.Set(GrfMiscBit::TrainWidth32Pixels); if (grffile->traininfo_vehicle_width == VEHICLEINFO_FULL_VEHICLE_WIDTH) bits.Set(GrfMiscBit::TrainWidth32Pixels);
*value = bits.base(); *value = bits.base();
return true; return true;