diff --git a/src/Client.cpp b/src/Client.cpp index 6311e2e..079a934 100644 --- a/src/Client.cpp +++ b/src/Client.cpp @@ -84,6 +84,7 @@ void TClient::Disconnect(std::string_view Reason) { if (ec) { beammp_debugf("Failed to shutdown client socket: {}", ec.message()); } + mSocket.cancel(); mSocket.close(ec); if (ec) { beammp_debugf("Failed to close client socket: {}", ec.message()); diff --git a/src/TLuaEngine.cpp b/src/TLuaEngine.cpp index fbd5758..52ed1d7 100644 --- a/src/TLuaEngine.cpp +++ b/src/TLuaEngine.cpp @@ -43,6 +43,8 @@ static sol::protected_function AddTraceback(sol::state_view StateView, sol::prot static std::optional GetLuaHandler(sol::state_view StateView, const std::string Handler, const std::string EventName); static std::optional GetLuaHandler(sol::state_view StateView, const std::string Handler, const std::string EventName) { + if (!StateView) + return std::nullopt; auto Res = StateView.safe_script("return " + Handler, sol::script_pass_on_error); if (!Res.valid()) { beammp_errorf("invalid handler for event \"{}\". handler: \"{}\"", EventName, Handler);