mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-19 03:20:26 +00:00
made the campaign server store the size of campaigns being downloaded
This commit is contained in:
parent
50b2dce055
commit
c8277f3b30
@ -118,7 +118,9 @@ void campaign_server::run()
|
||||
const config* const data = upload->child("data");
|
||||
if(data != NULL) {
|
||||
compression_schema schema;
|
||||
write_file((*campaign)["filename"],data->write_compressed(schema));
|
||||
const std::string& filedata = data->write_compressed(schema);
|
||||
write_file((*campaign)["filename"],filedata);
|
||||
(*campaign)["size"] = lexical_cast<std::string>(filedata.size());
|
||||
}
|
||||
|
||||
write_file(file_,cfg_.write());
|
||||
|
21
src/game.cpp
21
src/game.cpp
@ -1043,7 +1043,7 @@ void game_controller::download_campaigns()
|
||||
}
|
||||
|
||||
std::vector<std::string> campaigns, options;
|
||||
options.push_back(_(",Name,Version,Author,Downloads"));
|
||||
options.push_back(_(",Name,Version,Author,Downloads,Size"));
|
||||
const config::child_list& cmps = campaigns_cfg->get_children("campaign");
|
||||
const std::vector<std::string>& publish_options = available_campaigns();
|
||||
|
||||
@ -1058,8 +1058,25 @@ void game_controller::download_campaigns()
|
||||
delete_options.push_back(name);
|
||||
}
|
||||
|
||||
size_t size = lexical_cast_default<size_t>((**i)["size"],0);
|
||||
std::string size_str = "";
|
||||
|
||||
if(size > 0) {
|
||||
std::string size_postfix = _("B");
|
||||
if(size > 1024) {
|
||||
size /= 1024;
|
||||
size_postfix = _("KB");
|
||||
if(size > 1024) {
|
||||
size /= 1024;
|
||||
size_postfix = _("MB");
|
||||
}
|
||||
}
|
||||
|
||||
size_str = lexical_cast<std::string>(size) + size_postfix;
|
||||
}
|
||||
|
||||
std::replace(name.begin(),name.end(),'_',' ');
|
||||
options.push_back("&" + (**i)["icon"] + "," + name + "," + (**i)["version"] + "," + (**i)["author"] + "," + (**i)["downloads"]);
|
||||
options.push_back("&" + (**i)["icon"] + "," + name + "," + (**i)["version"] + "," + (**i)["author"] + "," + (**i)["downloads"] + "," + size_str);
|
||||
}
|
||||
|
||||
for(std::vector<std::string>::const_iterator j = publish_options.begin(); j != publish_options.end(); ++j) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user