6540: Fix inconsistent client state after disconnecting with network error r=def- a=Robyt3

The `Disconnect` function did not fully clear all server data, because the client state was already set to offline manually before the function is called. This was causing inconsistent behavior when connecting to another server after being disconnected. For example, the client could get stuck at "getting game info" when connecting the next time.

## 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:
bors[bot] 2023-04-28 16:25:23 +00:00 committed by GitHub
commit 8375fd83a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2524,7 +2524,6 @@ void CClient::PumpNetwork()
// check for errors // check for errors
if(State() != IClient::STATE_OFFLINE && State() < IClient::STATE_QUITTING && m_aNetClient[CONN_MAIN].State() == NETSTATE_OFFLINE) if(State() != IClient::STATE_OFFLINE && State() < IClient::STATE_QUITTING && m_aNetClient[CONN_MAIN].State() == NETSTATE_OFFLINE)
{ {
SetState(IClient::STATE_OFFLINE);
Disconnect(); Disconnect();
char aBuf[256]; char aBuf[256];
str_format(aBuf, sizeof(aBuf), "offline error='%s'", m_aNetClient[CONN_MAIN].ErrorString()); str_format(aBuf, sizeof(aBuf), "offline error='%s'", m_aNetClient[CONN_MAIN].ErrorString());