Skip to content

Commit

Permalink
ad_hoc_addon_fetch_session now takes a list of add-ons not just one
Browse files Browse the repository at this point in the history
This is better because you can use one add-on server connection for
the whole transaction.
  • Loading branch information
cbeck88 committed Mar 15, 2015
1 parent 6ffb9df commit bf06585
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
13 changes: 9 additions & 4 deletions src/addon/manager_ui.cpp
Expand Up @@ -1208,7 +1208,7 @@ bool manage_addons(display& disp)
}
}

bool ad_hoc_addon_fetch_session(display & disp, const std::string & addon_id)
bool ad_hoc_addon_fetch_session(display & disp, const std::vector<std::string> & addon_ids)
{
std::string remote_address = preferences::campaign_server();

Expand All @@ -1225,10 +1225,15 @@ bool ad_hoc_addon_fetch_session(display & disp, const std::string & addon_id)
return false;
}

const addon_info& addon = addon_at(addon_id, addons);
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 res.outcome_ == SUCCESS;
ADDON_OP_RESULT res = try_fetch_addon_with_checks(disp, client, addons, addon);
return_value = return_value && (res.outcome_ == SUCCESS);
}

return return_value;

} catch(const config::error& e) {
ERR_CFG << "config::error thrown during transaction with add-on server; \""<< e.message << "\"" << std::endl;
Expand Down
3 changes: 2 additions & 1 deletion src/addon/manager_ui.hpp
Expand Up @@ -17,6 +17,7 @@
#define ADDON_MANAGER_UI_HPP_INCLUDED

#include <string>
#include <vector>

class display;

Expand All @@ -39,6 +40,6 @@ bool manage_addons(display& disp);
*
* @return @a true when we successfully installed the target (possibly the user chose to ignore failures)
*/
bool ad_hoc_addon_fetch_session(display & disp, const std::string & addon_id);
bool ad_hoc_addon_fetch_session(display & disp, const std::vector<std::string> & addon_ids);

#endif
4 changes: 1 addition & 3 deletions src/game_initialization/multiplayer_lobby.cpp
Expand Up @@ -1202,9 +1202,7 @@ void lobby::process_event_impl(const process_event_data & data)
assert(needs_download.size() > 0);

if (gui2::show_message(video(), e_title, err_msg, gui2::tmessage::yes_no_buttons) == gui2::twindow::OK) {
BOOST_FOREACH(const std::string & addon_id, needs_download) {
ad_hoc_addon_fetch_session(disp(), addon_id);
}
ad_hoc_addon_fetch_session(disp(), needs_download);
throw lobby_reload_request_exception();
}
}
Expand Down

0 comments on commit bf06585

Please sign in to comment.