another attempt to fix #105

This commit is contained in:
Lion Kortlepel 2022-07-09 22:27:05 +02:00
parent 696e080e1c
commit 38eeec39b4
No known key found for this signature in database
GPG Key ID: 4322FF2B4C71259B
2 changed files with 15 additions and 11 deletions

View File

@ -7,6 +7,7 @@
- FIXED `MP.CreateEventTimer` filling up the queue (see <https://wiki.beammp.com/en/Scripting/new-lua-scripting#mpcreateeventtimerevent_name-string-interval_ms-number-strategy-number-since-v302>)
- FIXED `MP.TriggerClientEvent` not kicking the client if it failed
- FIXED Lua result queue handling not checking all results
- FIXED bug which caused ServerConfig.toml to generate incorrectly
# v3.0.1

View File

@ -92,13 +92,20 @@ void TConfig::FlushToFile() {
data["HTTP"][StrHTTPServerEnabled.data()] = Application::Settings.HTTPServerEnabled;
SetComment(data["HTTP"][StrHTTPServerEnabled.data()].comments(), " Enables the internal HTTP server");
std::stringstream Ss;
Ss << data;
std::ofstream Stream(mConfigFileName, std::ios::trunc | std::ios::out);
Stream << "# This is the BeamMP-Server config file.\n"
"# Help & Documentation: `https://wiki.beammp.com/en/home/server-maintenance`\n"
"# IMPORTANT: Fill in the AuthKey with the key you got from `https://beammp.com/k/dashboard` on the left under \"Keys\"\n"
<< Ss.str();
Stream.flush();
Ss << "# This is the BeamMP-Server config file.\n"
"# Help & Documentation: `https://wiki.beammp.com/en/home/server-maintenance`\n"
"# IMPORTANT: Fill in the AuthKey with the key you got from `https://beammp.com/k/dashboard` on the left under \"Keys\"\n"
<< data;
auto File = std::fopen(mConfigFileName.c_str(), "w+");
if (!File) {
beammp_error("Failed to create/write to config file: " + GetPlatformAgnosticErrorString());
throw std::runtime_error("Failed to create/write to config file");
}
auto Str = Ss.str();
auto N = std::fwrite(Str.data(), sizeof(char), Str.size(), File);
if (N != Str.size()) {
beammp_error("Failed to write to config file properly, config file might be misshapen");
}
}
void TConfig::CreateConfigFile(std::string_view name) {
@ -113,10 +120,6 @@ void TConfig::CreateConfigFile(std::string_view name) {
beammp_error("an error occurred and was ignored during config transfer: " + std::string(e.what()));
}
{ // create file context
std::ofstream ofs(name.data());
}
FlushToFile();
}