mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-19 00:53:20 +00:00
campaignd: Refactor config commit boilerplate into a separate method
This commit is contained in:
parent
796b77d440
commit
ada5a7ca60
@ -196,8 +196,7 @@ server::server(const std::string& cfg_file, size_t min_threads, size_t max_threa
|
||||
server::~server()
|
||||
{
|
||||
delete input_;
|
||||
scoped_ostream out = ostream_file(cfg_file_);
|
||||
write(*out, cfg_);
|
||||
write_config();
|
||||
}
|
||||
|
||||
int server::load_config()
|
||||
@ -263,6 +262,12 @@ void server::load_blacklist()
|
||||
}
|
||||
}
|
||||
|
||||
void server::write_config()
|
||||
{
|
||||
scoped_ostream out = ostream_file(cfg_file_);
|
||||
write(*out, cfg_);
|
||||
}
|
||||
|
||||
void server::fire(const std::string& hook, const std::string& addon)
|
||||
{
|
||||
const std::map<std::string, std::string>::const_iterator itor = hooks_.find(hook);
|
||||
@ -371,8 +376,7 @@ void server::run()
|
||||
}
|
||||
//write config to disk every ten minutes
|
||||
if((increment%(60*10*50)) == 0) {
|
||||
scoped_ostream out = ostream_file(cfg_file_);
|
||||
write(*out, cfg_);
|
||||
write_config();
|
||||
}
|
||||
|
||||
network::process_send_queue();
|
||||
@ -630,8 +634,9 @@ void server::run()
|
||||
|
||||
(*campaign)["size"] = lexical_cast<std::string>(
|
||||
file_size(filename));
|
||||
scoped_ostream out = ostream_file(cfg_file_);
|
||||
write(*out, cfg_);
|
||||
|
||||
write_config();
|
||||
|
||||
network::send_data(construct_message(message), sock);
|
||||
|
||||
fire("hook_post_upload", upload["name"]);
|
||||
@ -673,8 +678,9 @@ void server::run()
|
||||
break;
|
||||
}
|
||||
}
|
||||
scoped_ostream out = ostream_file(cfg_file_);
|
||||
write(*out, cfg_);
|
||||
|
||||
write_config();
|
||||
|
||||
network::send_data(construct_message("Add-on deleted."), sock);
|
||||
|
||||
fire("hook_post_erase", erase["name"]);
|
||||
@ -696,8 +702,9 @@ void server::run()
|
||||
network::send_data(construct_error("No new passphrase was supplied."), sock);
|
||||
} else {
|
||||
campaign["passphrase"] = cpass["new_passphrase"];
|
||||
scoped_ostream out = ostream_file(cfg_file_);
|
||||
write(*out, cfg_);
|
||||
|
||||
write_config();
|
||||
|
||||
network::send_data(construct_message("Passphrase changed."), sock);
|
||||
}
|
||||
}
|
||||
|
@ -63,6 +63,11 @@ private:
|
||||
*/
|
||||
int load_config();
|
||||
|
||||
/**
|
||||
* Writes the server configuration WML back to disk.
|
||||
*/
|
||||
void write_config();
|
||||
|
||||
/**
|
||||
* Reads the add-ons upload blacklist from WML.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user