mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-10 20:52:18 +00:00
Undo the undocumented interface changes in 2011-06-01T12:25:31Z!anonymissimus@arcor.de...
...and refactor code a little to keep the actual bugfix
This commit is contained in:
parent
fde98f1884
commit
f84133b29b
@ -53,6 +53,17 @@ static lg::log_domain log_network("network");
|
|||||||
#define ERR_NET LOG_STREAM(err , log_network)
|
#define ERR_NET LOG_STREAM(err , log_network)
|
||||||
#define LOG_NET LOG_STREAM(info, log_network)
|
#define LOG_NET LOG_STREAM(info, log_network)
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
std::string get_pbl_file_path(const std::string& addon_name)
|
||||||
|
{
|
||||||
|
const std::string& parentd = get_addon_campaigns_dir();
|
||||||
|
// Cope with old-style or new-style file organization
|
||||||
|
const std::string exterior = parentd + "/" + addon_name + ".pbl";
|
||||||
|
const std::string interior = parentd + "/" + addon_name + "/_server.pbl";
|
||||||
|
return file_exists(exterior) ? exterior : interior;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool have_addon_in_vcs_tree(const std::string& addon_name)
|
bool have_addon_in_vcs_tree(const std::string& addon_name)
|
||||||
{
|
{
|
||||||
static const std::string parentd = get_addon_campaigns_dir();
|
static const std::string parentd = get_addon_campaigns_dir();
|
||||||
@ -70,26 +81,15 @@ bool have_addon_pbl_info(const std::string& addon_name)
|
|||||||
file_exists(parentd+"/"+addon_name+"/_server.pbl");
|
file_exists(parentd+"/"+addon_name+"/_server.pbl");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get_addon_info(const std::string& addon_name, config& cfg)
|
void get_addon_info(const std::string& addon_name, config& cfg)
|
||||||
{
|
{
|
||||||
const std::string parentd = get_addon_campaigns_dir();
|
scoped_istream stream = istream_file(get_pbl_file_path(addon_name));
|
||||||
|
|
||||||
// Cope with old-style or new-style file organization
|
|
||||||
const std::string exterior = parentd + "/" + addon_name + ".pbl";
|
|
||||||
const std::string interior = parentd + "/" + addon_name + "/_server.pbl";
|
|
||||||
const bool is_old_style = file_exists(exterior);
|
|
||||||
const std::string pbl_file = (is_old_style ? exterior : interior);
|
|
||||||
|
|
||||||
scoped_istream stream = istream_file(pbl_file);
|
|
||||||
read(cfg, *stream);
|
read(cfg, *stream);
|
||||||
return is_old_style;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_addon_info(const std::string& addon_name, const config& cfg, const bool is_old_style)
|
void set_addon_info(const std::string& addon_name, const config& cfg)
|
||||||
{
|
{
|
||||||
const std::string parentd = get_addon_campaigns_dir();
|
scoped_ostream stream = ostream_file(get_pbl_file_path(addon_name));
|
||||||
scoped_ostream stream = ostream_file(parentd + "/" + addon_name + "/_server.pbl");
|
|
||||||
if(is_old_style) stream = ostream_file(parentd + "/" + addon_name + ".pbl");
|
|
||||||
write(*stream, cfg);
|
write(*stream, cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -501,7 +501,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
config cfg;
|
config cfg;
|
||||||
const bool is_old_style = get_addon_info(addon,cfg);
|
get_addon_info(addon,cfg);
|
||||||
|
|
||||||
std::string passphrase = cfg["passphrase"];
|
std::string passphrase = cfg["passphrase"];
|
||||||
// generate a random passphrase and write it to disk
|
// generate a random passphrase and write it to disk
|
||||||
@ -512,7 +512,7 @@ namespace {
|
|||||||
passphrase[n] = 'a' + (rand()%26);
|
passphrase[n] = 'a' + (rand()%26);
|
||||||
}
|
}
|
||||||
cfg["passphrase"] = passphrase;
|
cfg["passphrase"] = passphrase;
|
||||||
set_addon_info(addon,cfg,is_old_style);
|
set_addon_info(addon,cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg["name"] = addon;
|
cfg["name"] = addon;
|
||||||
|
@ -49,7 +49,7 @@ bool have_addon_in_vcs_tree(const std::string& addon_name);
|
|||||||
* @param cfg A config object to store the add-on's
|
* @param cfg A config object to store the add-on's
|
||||||
* properties.
|
* properties.
|
||||||
*/
|
*/
|
||||||
bool get_addon_info(const std::string& addon_name, class config& cfg);
|
void get_addon_info(const std::string& addon_name, class config& cfg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the publish information for an add-on
|
* Sets the publish information for an add-on
|
||||||
@ -58,7 +58,7 @@ bool get_addon_info(const std::string& addon_name, class config& cfg);
|
|||||||
* @param cfg A config object from which the add-on's
|
* @param cfg A config object from which the add-on's
|
||||||
* properties are copied.
|
* properties are copied.
|
||||||
*/
|
*/
|
||||||
void set_addon_info(const std::string& addon_name, const class config& cfg, const bool is_old_style);
|
void set_addon_info(const std::string& addon_name, const class config& cfg);
|
||||||
|
|
||||||
/** Returns a list of local add-ons that can be published. */
|
/** Returns a list of local add-ons that can be published. */
|
||||||
std::vector<std::string> available_addons();
|
std::vector<std::string> available_addons();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user