mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-08-16 08:16:09 +00:00
Add setting for the information packet
This commit is contained in:
parent
6aeb2eb736
commit
956d6f50e1
@ -86,7 +86,8 @@ struct Settings {
|
|||||||
General_LogChat,
|
General_LogChat,
|
||||||
General_ResourceFolder,
|
General_ResourceFolder,
|
||||||
General_Debug,
|
General_Debug,
|
||||||
General_AllowGuests
|
General_AllowGuests,
|
||||||
|
General_InformationPacket,
|
||||||
};
|
};
|
||||||
|
|
||||||
Sync<std::unordered_map<Key, SettingsTypeVariant>> SettingsMap;
|
Sync<std::unordered_map<Key, SettingsTypeVariant>> SettingsMap;
|
||||||
|
@ -317,6 +317,14 @@ void LuaAPI::MP::Set(int ConfigID, sol::object NewValue) {
|
|||||||
beammp_lua_error("set invalid argument [2] expected string");
|
beammp_lua_error("set invalid argument [2] expected string");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 7: // Information packet
|
||||||
|
if (NewValue.is<bool>()) {
|
||||||
|
Application::Settings.set(Settings::Key::General_InformationPacket, NewValue.as<bool>());
|
||||||
|
beammp_info(std::string("Set `InformationPacket` to ") + (Application::Settings.getAsBool(Settings::Key::General_InformationPacket) ? "true" : "false"));
|
||||||
|
} else {
|
||||||
|
beammp_lua_error("set invalid argument [2] expected boolean");
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
beammp_warn("Invalid config ID \"" + std::to_string(ConfigID) + "\". Use `MP.Settings.*` enum for this.");
|
beammp_warn("Invalid config ID \"" + std::to_string(ConfigID) + "\". Use `MP.Settings.*` enum for this.");
|
||||||
break;
|
break;
|
||||||
@ -339,6 +347,8 @@ TLuaValue LuaAPI::MP::Get(int ConfigID) {
|
|||||||
return Application::Settings.getAsString(Settings::Key::General_Name);
|
return Application::Settings.getAsString(Settings::Key::General_Name);
|
||||||
case 6: // Desc
|
case 6: // Desc
|
||||||
return Application::Settings.getAsString(Settings::Key::General_Description);
|
return Application::Settings.getAsString(Settings::Key::General_Description);
|
||||||
|
case 7: // Information packet
|
||||||
|
return Application::Settings.getAsBool(Settings::Key::General_InformationPacket);
|
||||||
default:
|
default:
|
||||||
beammp_warn("Invalid config ID \"" + std::to_string(ConfigID) + "\". Use `MP.Settings.*` enum for this.");
|
beammp_warn("Invalid config ID \"" + std::to_string(ConfigID) + "\". Use `MP.Settings.*` enum for this.");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -34,6 +34,7 @@ Settings::Settings() {
|
|||||||
{ General_ResourceFolder, std::string("Resources") },
|
{ General_ResourceFolder, std::string("Resources") },
|
||||||
{ General_Debug, false },
|
{ General_Debug, false },
|
||||||
{ General_AllowGuests, true },
|
{ General_AllowGuests, true },
|
||||||
|
{ General_InformationPacket, true },
|
||||||
{ Misc_SendErrorsShowMessage, true },
|
{ Misc_SendErrorsShowMessage, true },
|
||||||
{ Misc_SendErrors, true },
|
{ Misc_SendErrors, true },
|
||||||
{ Misc_ImScaredOfUpdates, true },
|
{ Misc_ImScaredOfUpdates, true },
|
||||||
@ -54,6 +55,7 @@ Settings::Settings() {
|
|||||||
{ { "General", "ResourceFolder" }, { General_ResourceFolder, READ_ONLY } },
|
{ { "General", "ResourceFolder" }, { General_ResourceFolder, READ_ONLY } },
|
||||||
{ { "General", "Debug" }, { General_Debug, READ_WRITE } },
|
{ { "General", "Debug" }, { General_Debug, READ_WRITE } },
|
||||||
{ { "General", "AllowGuests" }, { General_AllowGuests, READ_WRITE } },
|
{ { "General", "AllowGuests" }, { General_AllowGuests, READ_WRITE } },
|
||||||
|
{ { "General", "InformationPacket" }, { General_InformationPacket, READ_WRITE } },
|
||||||
{ { "Misc", "SendErrorsShowMessage" }, { Misc_SendErrorsShowMessage, READ_WRITE } },
|
{ { "Misc", "SendErrorsShowMessage" }, { Misc_SendErrorsShowMessage, READ_WRITE } },
|
||||||
{ { "Misc", "SendErrors" }, { Misc_SendErrors, READ_WRITE } },
|
{ { "Misc", "SendErrors" }, { Misc_SendErrors, READ_WRITE } },
|
||||||
{ { "Misc", "ImScaredOfUpdates" }, { Misc_ImScaredOfUpdates, READ_WRITE } },
|
{ { "Misc", "ImScaredOfUpdates" }, { Misc_ImScaredOfUpdates, READ_WRITE } },
|
||||||
|
@ -1024,7 +1024,8 @@ TLuaEngine::StateThreadData::StateThreadData(const std::string& Name, TLuaStateI
|
|||||||
"MaxPlayers", 3,
|
"MaxPlayers", 3,
|
||||||
"Map", 4,
|
"Map", 4,
|
||||||
"Name", 5,
|
"Name", 5,
|
||||||
"Description", 6);
|
"Description", 6,
|
||||||
|
"InformationPacket", 7);
|
||||||
|
|
||||||
MPTable.create_named("CallStrategy",
|
MPTable.create_named("CallStrategy",
|
||||||
"BestEffort", CallStrategy::BestEffort,
|
"BestEffort", CallStrategy::BestEffort,
|
||||||
|
@ -249,7 +249,7 @@ void TNetwork::Identify(TConnection&& RawConnection) {
|
|||||||
return;
|
return;
|
||||||
} else if (Code == 'I') {
|
} else if (Code == 'I') {
|
||||||
boost::system::error_code ec;
|
boost::system::error_code ec;
|
||||||
write(RawConnection.Socket, buffer(THeartbeatThread::lastCall), ec);
|
write(RawConnection.Socket, buffer(Application::Settings.getAsBool(Settings::Key::General_InformationPacket) ? THeartbeatThread::lastCall : ""), ec);
|
||||||
} else {
|
} else {
|
||||||
beammp_errorf("Invalid code got in Identify: '{}'", Code);
|
beammp_errorf("Invalid code got in Identify: '{}'", Code);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user