aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/misccommands.cpp
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-10-19 20:22:04 +0100
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-10-19 20:22:04 +0100
commit48acde84bd58c82eaa3a9838757dfcd05ab4ebf5 (patch)
tree429dd17294784175cce59b01ba071c728b3eabd1 /NorthstarDedicatedTest/misccommands.cpp
parented7e4fed4ddedaf9d4c181052ca552a0914d57bb (diff)
downloadNorthstarLauncher-48acde84bd58c82eaa3a9838757dfcd05ab4ebf5.tar.gz
NorthstarLauncher-48acde84bd58c82eaa3a9838757dfcd05ab4ebf5.zip
add reconnecting to local lobby with auth on leave
Diffstat (limited to 'NorthstarDedicatedTest/misccommands.cpp')
-rw-r--r--NorthstarDedicatedTest/misccommands.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/NorthstarDedicatedTest/misccommands.cpp b/NorthstarDedicatedTest/misccommands.cpp
index c03ba713..27dbbbc4 100644
--- a/NorthstarDedicatedTest/misccommands.cpp
+++ b/NorthstarDedicatedTest/misccommands.cpp
@@ -2,6 +2,8 @@
#include "misccommands.h"
#include "concommand.h"
#include "gameutils.h"
+#include "masterserver.h"
+#include "serverauthentication.h"
void ForceLoadMapCommand(const CCommand& arg)
{
@@ -12,17 +14,29 @@ void ForceLoadMapCommand(const CCommand& arg)
strncpy(g_pHostState->m_levelName, arg.Arg(1), sizeof(g_pHostState->m_levelName));
}
-void LeaveToLobbyCommand(const CCommand& arg)
+void SelfAuthAndLeaveToLobbyCommand(const CCommand& arg)
{
- SetCurrentPlaylist("tdm");
+ // hack for special case where we're on a local server, so we erase our own newly created auth data on disconnect
- // note: for host, this will kick all clients, since it hits HS_GAME_SHUTDOWN
- g_pHostState->m_iNextState = HS_NEW_GAME;
+ g_MasterServerManager->m_bNewgameAfterSelfAuth = true;
+ g_MasterServerManager->AuthenticateWithOwnServer(g_LocalPlayerUserID, (char*)"");
+}
+
+void EndSelfAuthAndLeaveToLobbyCommand(const CCommand& arg)
+{
+ Cbuf_AddText(Cbuf_GetCurrentPlayer(), fmt::format("serverfilter {}", g_ServerAuthenticationManager->m_authData.begin()->first).c_str(), cmd_source_t::kCommandSrcCode);
+ Cbuf_Execute();
+
+ g_ServerAuthenticationManager->m_bNeedLocalAuthForNewgame = true;
+ SetCurrentPlaylist("tdm");
strcpy(g_pHostState->m_levelName, "mp_lobby");
+ g_pHostState->m_iNextState = HS_NEW_GAME;
}
void AddMiscConCommands()
{
RegisterConCommand("force_newgame", ForceLoadMapCommand, "forces a map load through directly setting g_pHostState->m_iNextState to HS_NEW_GAME", FCVAR_NONE);
- RegisterConCommand("ns_leave_to_lobby", LeaveToLobbyCommand, "called by the server, used to return the player to lobby when leaving a game", FCVAR_SERVER_CAN_EXECUTE);
+ RegisterConCommand("ns_start_reauth_and_leave_to_lobby", SelfAuthAndLeaveToLobbyCommand, "called by the server, used to reauth and return the player to lobby when leaving a game", FCVAR_SERVER_CAN_EXECUTE);
+ // this is a concommand because we make a deferred call to it from another thread
+ RegisterConCommand("ns_end_reauth_and_leave_to_lobby", EndSelfAuthAndLeaveToLobbyCommand, "", FCVAR_NONE);
} \ No newline at end of file