1
0
Fork 0

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

These variables used GrfProcessingState, which is only valid while loading GRFs, after which they always point to the last loaded GRFFile.
pull/13982/head
Peter Nelson 2025-04-11 18:53:05 +01:00 committed by GitHub
parent eaa2afda5e
commit 786893a844
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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
*value = _cur.grfconfig->palette & GRFP_USE_MASK;
*value = GetGRFConfig(grffile->grfid)->palette & GRFP_USE_MASK;
return true;
case 0x0E: // Y-offset for train sprites
*value = _cur.grffile->traininfo_vehicle_pitch;
*value = grffile->traininfo_vehicle_pitch;
return true;
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 */
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();
return true;