Skip to content

Commit

Permalink
Addon Manager: serialize local_only info key
Browse files Browse the repository at this point in the history
This fixes an issue that's probably existed since Feb. 2017 (187731c): after installing
any addon, local publishable addons get considered "Published", instead of "Ready to Publish".
This was because when the addon map was recreated, it did so from the saved config. and the is-local
info was lost, and so the game considered its state ADDON_INSTALLED instead of ADDON_INSTALLED_LOCAL_ONLY.
Keeping is_local= in the addon's config entry means addon_info::local_only is properly set beyond the
initial setup.
  • Loading branch information
Vultraz committed Feb 10, 2018
1 parent 8b9ebda commit c1841e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/addon/info.cpp
Expand Up @@ -83,6 +83,8 @@ void addon_info::read(const config& cfg)

this->updated = cfg["timestamp"].to_time_t();
this->created = cfg["original_timestamp"].to_time_t();

this->local_only = cfg["local_only"].to_bool();
}

void addon_info::write(config& cfg) const
Expand Down
6 changes: 4 additions & 2 deletions src/gui/dialogs/addon/manager.cpp
Expand Up @@ -475,13 +475,15 @@ void addon_manager::load_addon_list(window& window)
if(addons_.find(id) == addons_.end()) {
// Get a config from the addon's pbl file
// Note that the name= key is necessary or stuff breaks, since the filter code uses this key
// to match add-ons in the config list. It also fills in addon_info's id field.
// to match add-ons in the config list. It also fills in addon_info's id field. It's also
// neccessay to set local_only here so that flag can be properly set after addons_ is cleared
// and recreated by read_addons_list.
config pbl_cfg = get_addon_pbl_info(id);
pbl_cfg["name"] = id;
pbl_cfg["local_only"] = true;

// Add the add-on to the list.
addon_info addon(pbl_cfg);
addon.local_only = true;
addons_[id] = addon;

// Add the addon to the config entry
Expand Down

0 comments on commit c1841e3

Please sign in to comment.