MCPcopy Create free account
hub / github.com/ddnet/ddnet / DisconnectWithReason

Method DisconnectWithReason

src/engine/client/client.cpp:709–765  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

707}
708
709void CClient::DisconnectWithReason(const char *pReason)
710{
711 if(pReason != nullptr && pReason[0] == '\0')
712 pReason = nullptr;
713
714 DummyDisconnect(pReason);
715
716 char aBuf[512];
717 str_format(aBuf, sizeof(aBuf), "disconnecting. reason='%s'", pReason ? pReason : "unknown");
718 m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf, CLIENT_NETWORK_PRINT_COLOR);
719
720 // stop demo playback and recorder
721 // make sure to remove replay tmp demo
722 m_DemoPlayer.Stop();
723 for(int Recorder = 0; Recorder < RECORDER_MAX; Recorder++)
724 {
725 DemoRecorder(Recorder)->Stop(Recorder == RECORDER_REPLAYS ? IDemoRecorder::EStopMode::REMOVE_FILE : IDemoRecorder::EStopMode::KEEP_FILE);
726 }
727
728 m_aRconAuthed[0] = 0;
729 // Make sure to clear credentials completely from memory
730 mem_zero(m_aRconUsername, sizeof(m_aRconUsername));
731 mem_zero(m_aRconPassword, sizeof(m_aRconPassword));
732 m_MapDetails = std::nullopt;
733 m_ServerSentCapabilities = false;
734 m_UseTempRconCommands = 0;
735 m_ExpectedRconCommands = -1;
736 m_GotRconCommands = 0;
737 m_pConsole->DeregisterTempAll();
738 m_ExpectedMaplistEntries = -1;
739 m_vMaplistEntries.clear();
740 GameClient()->ForceUpdateConsoleRemoteCompletionSuggestions();
741 m_aNetClient[CONN_MAIN].Disconnect(pReason);
742 SetState(IClient::STATE_OFFLINE);
743 GameClient()->Map()->Unload();
744 m_CurrentServerPingInfoType = -1;
745 m_CurrentServerPingBasicToken = -1;
746 m_CurrentServerPingToken = -1;
747 mem_zero(&m_CurrentServerPingUuid, sizeof(m_CurrentServerPingUuid));
748 m_CurrentServerCurrentPingTime = -1;
749 m_CurrentServerNextPingTime = -1;
750
751 ResetMapDownload(true);
752
753 // clear the current server info
754 mem_zero(&m_CurrentServerInfo, sizeof(m_CurrentServerInfo));
755
756 // clear snapshots
757 m_aapSnapshots[0][SNAP_CURRENT] = nullptr;
758 m_aapSnapshots[0][SNAP_PREV] = nullptr;
759 m_aReceivedSnapshots[0] = 0;
760 m_LastDummy = false;
761
762 // 0.7
763 m_TranslationContext.Reset();
764 m_Sixup = false;
765}
766

Callers

nothing calls this directly

Calls 10

str_formatFunction · 0.85
mem_zeroFunction · 0.85
DeregisterTempAllMethod · 0.80
PrintMethod · 0.45
StopMethod · 0.45
DisconnectMethod · 0.45
UnloadMethod · 0.45
MapMethod · 0.45
ResetMethod · 0.45

Tested by

no test coverage detected