diff options
author | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2023-01-04 00:36:51 +0000 |
---|---|---|
committer | GeckoEidechse <gecko.eidechse+git@pm.me> | 2023-01-04 14:59:34 +0100 |
commit | 2c4a25a0f2b28ba278a46c1755637374f90e9b35 (patch) | |
tree | 011a61c651a7f2244ffe828696fc3247012f15c6 /NorthstarDLL/client/rejectconnectionfixes.cpp | |
parent | a7018f0178006f0271077863149283c9f3d95d64 (diff) | |
download | NorthstarLauncher-2c4a25a0f2b28ba278a46c1755637374f90e9b35.tar.gz NorthstarLauncher-2c4a25a0f2b28ba278a46c1755637374f90e9b35.zip |
generally cleanup authentication code and fix client state issues with rejection from local server (#360)v1.11.2-rc2
* generally cleanup authentication code and fix client state issues with
rejection from local server
* fix formatting
* fix formatting
* use client-provided uid for logging disconnect failure as it won't be
copied to player if authentication fails
* support loading savegame and use more reliable method for fixing
client rejection issues
* oops forgot to add rejectconnectionfixes.cpp
* fixup formatting
Diffstat (limited to 'NorthstarDLL/client/rejectconnectionfixes.cpp')
-rw-r--r-- | NorthstarDLL/client/rejectconnectionfixes.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/NorthstarDLL/client/rejectconnectionfixes.cpp b/NorthstarDLL/client/rejectconnectionfixes.cpp new file mode 100644 index 00000000..994e9747 --- /dev/null +++ b/NorthstarDLL/client/rejectconnectionfixes.cpp @@ -0,0 +1,35 @@ +#include "pch.h"
+#include "engine/r2engine.h"
+
+AUTOHOOK_INIT()
+
+// this is called from when our connection is rejected, this is the only case we're hooking this for
+// clang-format off
+AUTOHOOK(COM_ExplainDisconnection, engine.dll + 0x1342F0,
+void,, (bool a1, const char* fmt, ...))
+// clang-format on
+{
+ va_list va;
+ va_start(va, fmt);
+ char buf[4096];
+ vsnprintf_s(buf, 4096, fmt, va);
+ va_end(va);
+
+ // slightly hacky comparison, but patching the function that calls this for reject would be worse
+ if (!strncmp(fmt, "Connection rejected: ", 21))
+ {
+ // when COM_ExplainDisconnection is called from engine.dll + 19ff1c for connection rejected, it doesn't
+ // call Host_Disconnect, which properly shuts down listen server
+ // not doing this gets our client in a pretty weird state so we need to shut it down manually here
+
+ // don't call Cbuf_Execute because we don't need this called immediately
+ R2::Cbuf_AddText(R2::Cbuf_GetCurrentPlayer(), "disconnect", R2::cmd_source_t::kCommandSrcCode);
+ }
+
+ return COM_ExplainDisconnection(a1, buf);
+}
+
+ON_DLL_LOAD_CLIENT("engine.dll", RejectConnectionFixes, (CModule module))
+{
+ AUTOHOOK_DISPATCH()
+}
|