Skip to content

Commit

Permalink
fix an assertion failure if an add-on is not available on server
Browse files Browse the repository at this point in the history
If someone hosts an mp game using an add-on which is not published,
the client of another player cannot know that, so it may prompt
them to connect to the add-on server and try to download.

However the previous implementation of "ad_hoc_addon_fetch_session"
used the "addon_at" helper function, which gives an assertion
failure if the add-on does not exist, presumably because this was
used only with the add-on manager gui before.

In this commit we change the fetch session function to explicitly
search for the addon id and handle a missing add-on with an error
message rather than assertion failure.
  • Loading branch information
cbeck88 committed Mar 15, 2015
1 parent 235acd7 commit 7dc8c70
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/addon/manager_ui.cpp
Expand Up @@ -1227,10 +1227,17 @@ bool ad_hoc_addon_fetch_session(display & disp, const std::vector<std::string> &

bool return_value = true;
BOOST_FOREACH(const std::string & addon_id, addon_ids) {
const addon_info& addon = addon_at(addon_id, addons);

ADDON_OP_RESULT res = try_fetch_addon_with_checks(disp, client, addons, addon);
return_value = return_value && (res.outcome_ == SUCCESS);
addons_list::const_iterator it = addons.find(addon_id);
if(it != addons.end()) {
const addon_info& addon = it->second;
ADDON_OP_RESULT res = try_fetch_addon_with_checks(disp, client, addons, addon);
return_value = return_value && (res.outcome_ == SUCCESS);
} else {
utils::string_map symbols;
symbols["addon_id"] = addon_id;
gui2::show_error_message(disp.video(), vgettext("Could not find an add-on matching id $addon_id on the add-on server.", symbols));
return_value = false;
}
}

return return_value;
Expand Down

0 comments on commit 7dc8c70

Please sign in to comment.