Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions src/TNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,6 @@ TNetwork::TNetwork(TServer& Server, TPPSMonitor& PPSMonitor, TResourceManager& R
, mResourceManager(ResourceManager) {
Application::SetSubsystemStatus("TCPNetwork", Application::Status::Starting);
Application::SetSubsystemStatus("UDPNetwork", Application::Status::Starting);
Application::RegisterShutdownHandler([&] {
beammp_debug("Kicking all players due to shutdown");
Server.ForEachClient([&](std::weak_ptr<TClient> client) -> bool {
if (!client.expired()) {
ClientKick(*client.lock(), "Server shutdown");
}
return true;
});
});
Application::RegisterShutdownHandler([&] {
Application::SetSubsystemStatus("UDPNetwork", Application::Status::ShuttingDown);
if (mUDPThread.joinable()) {
Expand Down
19 changes: 15 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

#include "ArgsParser.h"
#include "Client.h"
#include "Common.h"
#include "Http.h"
#include "LuaAPI.h"
Expand Down Expand Up @@ -175,10 +176,6 @@ int BeamMPServerMain(MainArguments Arguments) {
Application::SetSubsystemStatus("Main", Application::Status::ShuttingDown);
Shutdown = true;
});
Application::RegisterShutdownHandler([] {
auto Futures = LuaAPI::MP::Engine->TriggerEvent("onShutdown", "");
TLuaEngine::WaitForAll(Futures, std::chrono::seconds(5));
});

TServer Server(Arguments.List);

Expand All @@ -200,6 +197,20 @@ int BeamMPServerMain(MainArguments Arguments) {

TPluginMonitor PluginMonitor(fs::path(Application::Settings.getAsString(Settings::Key::General_ResourceFolder)) / "Server", LuaEngine);

Application::RegisterShutdownHandler([] {
auto Futures = LuaAPI::MP::Engine->TriggerEvent("onShutdown", "");
TLuaEngine::WaitForAll(Futures, std::chrono::seconds(5));
});
Application::RegisterShutdownHandler([&Server, &Network] {
beammp_debug("Kicking all players due to shutdown");
Server.ForEachClient([&Network](std::weak_ptr<TClient> client) -> bool {
if (!client.expired()) {
Network.ClientKick(*client.lock(), "Server shutdown");
}
return true;
});
});

RegisterThread("Main(Waiting)");

std::set<std::string> IgnoreSubsystems {
Expand Down