mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-06 07:53:26 +00:00
addon/client: Use the standard parser.cpp write() function...
...to generate _info.cfg Through addon_info::write() we can get rid of the previous, annoying variable interpolation hack and generalize more logic. Instead of using the parser.cpp write() function on a file stream, we use a string stream whose contents are inserted into the add-on archive before unpacking, as usual.
This commit is contained in:
parent
a9b1e42e31
commit
86eb697cd9
@ -22,6 +22,7 @@
|
||||
#include "gettext.hpp"
|
||||
#include "gui/dialogs/message.hpp"
|
||||
#include "log.hpp"
|
||||
#include "serialization/parser.hpp"
|
||||
#include "serialization/string_utils.hpp"
|
||||
|
||||
#include "addon/client.hpp"
|
||||
@ -234,21 +235,21 @@ bool addons_client::install_addon(config& archive_cfg, const addon_info& info)
|
||||
vars["version"] = info.version.str();
|
||||
vars["type"] = get_addon_type_string(info.type);
|
||||
|
||||
static const std::string info_file_template =
|
||||
std::ostringstream info_contents;
|
||||
config wml;
|
||||
|
||||
info_contents <<
|
||||
"#\n"
|
||||
"# File automatically generated by Wesnoth to keep track\n"
|
||||
"# of version information on installed add-ons. DO NOT EDIT!\n"
|
||||
"#\n"
|
||||
"[info]\n"
|
||||
" type=\"$type\"\n"
|
||||
" uploads=\"$uploads\"\n"
|
||||
" version=\"$version\"\n"
|
||||
"[/info]\n";
|
||||
"#\n";
|
||||
|
||||
info.write(wml.add_child("info"));
|
||||
write(info_contents, wml);
|
||||
|
||||
config file;
|
||||
file["name"] = "_info.cfg";
|
||||
file["contents"] = utils::interpolate_variables_into_string(
|
||||
info_file_template, &vars);
|
||||
file["contents"] = info_contents.str();
|
||||
|
||||
maindir->add_child("file", file);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user