addon/mg: Ensure _info.cfg has an [info] node when reading it

Fixes the dreaded "Mandatory WML child missing yet untested for. Please
report" error occurring when reading _info.cfg files that don't have a
valid [info] tag. In particular, this would cause the game version
dialog to crash to desktop.
This commit is contained in:
Iris Morelle 2020-12-10 03:21:00 -03:00
parent d8f943664f
commit 220792dd07
2 changed files with 3 additions and 1 deletions

View file

@ -3,6 +3,8 @@
* Fixed inability to write files (including the server configuration file) on Windows.
* Dropped plain text passphrase migration, unused in production since version 1.12.7 and 1.13.0 (issue #5080).
* Uploading add-ons with versions not greater than the latest uploaded version is no longer allowed (issue #5079).
### Add-ons client
* Fix potential crashes when working with installed add-ons that have a corrupted _info.cfg file.
### Campaigns
### Multiplayer
* Added `/roll N` command to multiplayer games and game lobbies which produces a publicly visible random integer number ranged from 1 to N inclusively (issue #5221, PR #5326).

View file

@ -192,7 +192,7 @@ std::map<std::string, std::string> installed_addons_and_versions()
} else if(filesystem::file_exists(get_info_file_path(addon_id))) {
config temp;
get_addon_install_info(addon_id, temp);
addons[addon_id] = !temp.empty() ? temp.child("info")["version"].str() : "Unknown";
addons[addon_id] = !temp.empty() && temp.has_child("info") ? temp.child("info")["version"].str() : "Unknown";
} else {
addons[addon_id] = "Unknown";
}