1
0
Fork 0

Fix: Make GrfMsg() behave like Debug() when not loading NewGRFs. (#13991)

GrfMsg() outputs the currently loading NewGRF and current line/sprite number. This is invalid when not NewGRFs are not actually being loaded.
pull/13992/head
Peter Nelson 2025-04-12 13:05:33 +01:00 committed by GitHub
parent 1744156149
commit 34b1f7a992
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 1 deletions

View File

@ -87,7 +87,11 @@ ReferenceThroughBaseContainer<std::vector<GRFTempEngineData>> _gted; ///< Tempo
*/
void GrfMsgI(int severity, const std::string &msg)
{
Debug(grf, severity, "[{}:{}] {}", _cur_gps.grfconfig->filename, _cur_gps.nfo_line, msg);
if (_cur_gps.grfconfig == nullptr) {
Debug(grf, severity, "{}", msg);
} else {
Debug(grf, severity, "[{}:{}] {}", _cur_gps.grfconfig->filename, _cur_gps.nfo_line, msg);
}
}
/**
@ -371,6 +375,7 @@ void GRFUnsafe(ByteReader &)
/** Reset and clear all NewGRFs */
static void ResetNewGRF()
{
_cur_gps.grfconfig = nullptr;
_cur_gps.grffile = nullptr;
_grf_files.clear();
@ -1823,6 +1828,10 @@ void LoadNewGRF(SpriteID load_index, uint num_baseset)
}
}
/* We've finished reading files. */
_cur_gps.grfconfig = nullptr;
_cur_gps.grffile = nullptr;
/* Pseudo sprite processing is finished; free temporary stuff */
_cur_gps.ClearDataForNextFile();