mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge #6602
6602: Revert "Delay disconnecting until after render call" r=def- a=Robyt3
This reverts commit 5c90fd2b83
.
Delaying the disconnecting causes issues when the client automatically disconnects immediately before connecting to another server or starting demo playback.
It's not necessary to delay the disconnecting to deal with #6387, as #6589 is already enough. It's easier to revert this instead of rewriting the client so connecting and starting demo playback are also delayed.
Closes #6595.
## Checklist
- [X] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)
Co-authored-by: Robert Müller <robytemueller@gmail.com>
This commit is contained in:
commit
2901c19bed
|
@ -327,7 +327,6 @@ CClient::CClient() :
|
|||
m_aRconUsername[0] = '\0';
|
||||
m_aRconPassword[0] = '\0';
|
||||
m_aPassword[0] = '\0';
|
||||
m_aDisconnectReason[0] = '\0';
|
||||
|
||||
// version-checking
|
||||
m_aVersionStr[0] = '0';
|
||||
|
@ -831,14 +830,9 @@ void CClient::Connect(const char *pAddress, const char *pPassword)
|
|||
}
|
||||
|
||||
void CClient::DisconnectWithReason(const char *pReason)
|
||||
{
|
||||
str_copy(m_aDisconnectReason, pReason == nullptr || pReason[0] == '\0' ? "unknown" : pReason);
|
||||
}
|
||||
|
||||
void CClient::DisconnectWithReasonImpl(const char *pReason)
|
||||
{
|
||||
char aBuf[512];
|
||||
str_format(aBuf, sizeof(aBuf), "disconnecting. reason='%s'", pReason);
|
||||
str_format(aBuf, sizeof(aBuf), "disconnecting. reason='%s'", pReason ? pReason : "unknown");
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf, gs_ClientNetworkPrintColor);
|
||||
|
||||
// stop demo playback and recorder
|
||||
|
@ -853,7 +847,7 @@ void CClient::DisconnectWithReasonImpl(const char *pReason)
|
|||
m_ServerSentCapabilities = false;
|
||||
m_UseTempRconCommands = 0;
|
||||
m_pConsole->DeregisterTempAll();
|
||||
m_aNetClient[CONN_MAIN].Disconnect(str_comp(pReason, "unknown") == 0 ? nullptr : pReason);
|
||||
m_aNetClient[CONN_MAIN].Disconnect(pReason);
|
||||
SetState(IClient::STATE_OFFLINE);
|
||||
m_pMap->Unload();
|
||||
m_CurrentServerPingInfoType = -1;
|
||||
|
@ -895,7 +889,7 @@ void CClient::Disconnect()
|
|||
if(m_DummyConnected)
|
||||
DummyDisconnect(0);
|
||||
if(m_State != IClient::STATE_OFFLINE)
|
||||
DisconnectWithReason();
|
||||
DisconnectWithReason(0);
|
||||
|
||||
// make sure to remove replay tmp demo
|
||||
if(g_Config.m_ClReplays)
|
||||
|
@ -2531,10 +2525,10 @@ void CClient::PumpNetwork()
|
|||
// check for errors
|
||||
if(State() != IClient::STATE_OFFLINE && State() < IClient::STATE_QUITTING && m_aNetClient[CONN_MAIN].State() == NETSTATE_OFFLINE)
|
||||
{
|
||||
Disconnect();
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "offline error='%s'", m_aNetClient[CONN_MAIN].ErrorString());
|
||||
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf, gs_ClientNetworkErrPrintColor);
|
||||
DisconnectWithReason(m_aNetClient[CONN_MAIN].ErrorString());
|
||||
}
|
||||
|
||||
if(State() != IClient::STATE_OFFLINE && State() < IClient::STATE_QUITTING && m_DummyConnected &&
|
||||
|
@ -3305,14 +3299,6 @@ void CClient::Run()
|
|||
}
|
||||
}
|
||||
|
||||
// Diconnecting is delayed until after the render call, to ensure
|
||||
// that the map is not unloaded during the render call.
|
||||
if(m_aDisconnectReason[0] != '\0')
|
||||
{
|
||||
DisconnectWithReasonImpl(m_aDisconnectReason);
|
||||
m_aDisconnectReason[0] = '\0';
|
||||
}
|
||||
|
||||
AutoScreenshot_Cleanup();
|
||||
AutoStatScreenshot_Cleanup();
|
||||
AutoCSV_Cleanup();
|
||||
|
|
|
@ -167,7 +167,6 @@ class CClient : public IClient, public CDemoPlayer::IListener
|
|||
char m_aRconPassword[32];
|
||||
int m_UseTempRconCommands;
|
||||
char m_aPassword[32];
|
||||
char m_aDisconnectReason[256];
|
||||
bool m_SendPassword;
|
||||
bool m_ButtonRender = false;
|
||||
|
||||
|
@ -354,8 +353,7 @@ public:
|
|||
void EnterGame(int Conn) override;
|
||||
|
||||
void Connect(const char *pAddress, const char *pPassword = nullptr) override;
|
||||
void DisconnectWithReason(const char *pReason = nullptr);
|
||||
void DisconnectWithReasonImpl(const char *pReason);
|
||||
void DisconnectWithReason(const char *pReason);
|
||||
void Disconnect() override;
|
||||
|
||||
void DummyDisconnect(const char *pReason) override;
|
||||
|
|
Loading…
Reference in a new issue