diff options
author | Rubidium <rubidium@openttd.org> | 2021-07-11 09:16:54 +0200 |
---|---|---|
committer | rubidium42 <rubidium42@users.noreply.github.com> | 2021-07-11 11:20:07 +0200 |
commit | f6955a304c52e4755e9dfcec5fe94370aef1896d (patch) | |
tree | ee50fb7abdbcc4a48c838b2d700dda953d3616ae /src | |
parent | e99134654b4609d37d03098cb34d6b692fead9da (diff) | |
download | openttd-f6955a304c52e4755e9dfcec5fe94370aef1896d.tar.xz |
Fix: ensure no more than the allowed number of NewGRFs are loaded from the configuration
Diffstat (limited to 'src')
-rw-r--r-- | src/settings.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/settings.cpp b/src/settings.cpp index d3d93eadd..a90dad537 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -956,6 +956,7 @@ static GRFConfig *GRFLoadConfig(IniFile &ini, const char *grpname, bool is_stati if (group == nullptr) return nullptr; + uint num_grfs = 0; for (item = group->item; item != nullptr; item = item->next) { GRFConfig *c = nullptr; @@ -1030,8 +1031,14 @@ static GRFConfig *GRFLoadConfig(IniFile &ini, const char *grpname, bool is_stati continue; } - /* Mark file as static to avoid saving in savegame. */ - if (is_static) SetBit(c->flags, GCF_STATIC); + if (is_static) { + /* Mark file as static to avoid saving in savegame. */ + SetBit(c->flags, GCF_STATIC); + } else if (++num_grfs > NETWORK_MAX_GRF_COUNT) { + /* Check we will not load more non-static NewGRFs than allowed. This could trigger issues for game servers. */ + ShowErrorMessage(STR_CONFIG_ERROR, STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED, WL_CRITICAL); + break; + } /* Add item to list */ *curr = c; |