MCPcopy Create free account
hub / github.com/assaultcube/AC / disconnect

Function disconnect

source/src/client.cpp:150–187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148COMMAND(modlanconnect, "");
149
150void disconnect(int onlyclean, int async)
151{
152 bool cleanup = onlyclean!=0;
153 if(curpeer)
154 {
155 if(!discmillis)
156 {
157 enet_peer_disconnect(curpeer, DISC_BECAUSE);
158 enet_host_flush(clienthost);
159 discmillis = totalmillis;
160 }
161 if(curpeer->state!=ENET_PEER_STATE_DISCONNECTED)
162 {
163 if(async) return;
164 enet_peer_reset(curpeer);
165 }
166 curpeer = NULL;
167 discmillis = 0;
168 connected = 0;
169 conoutf("disconnected");
170 cleanup = true;
171 }
172
173 if(cleanup)
174 {
175 player1->clientnum = -1;
176 player1->lifesequence = 0;
177 player1->clientrole = CR_DEFAULT;
178 lastpm = -1;
179 kickallbots();
180 loopv(players) zapplayer(players[i]);
181 clearvote();
182 audiomgr.clearworldsounds(false);
183 localdisconnect();
184 }
185 if(!onlyclean) localconnect();
186 exechook(HOOK_SP_MP, "onDisconnect", "%d", -1);
187}
188
189void trydisconnect()
190{

Callers 11

neterrFunction · 0.85
parsemessagesFunction · 0.85
trydisconnectFunction · 0.85
cleanupclientFunction · 0.85
gets2cFunction · 0.85
performMethod · 0.85
resetMethod · 0.85
set_hostMethod · 0.85
set_portMethod · 0.85
connectMethod · 0.85
getMethod · 0.85

Calls 12

enet_peer_disconnectFunction · 0.85
enet_host_flushFunction · 0.85
enet_peer_resetFunction · 0.85
kickallbotsFunction · 0.85
zapplayerFunction · 0.85
clearvoteFunction · 0.85
localdisconnectFunction · 0.85
localconnectFunction · 0.85
exechookFunction · 0.85
clearworldsoundsMethod · 0.80
conoutfFunction · 0.70
loopvFunction · 0.70

Tested by

no test coverage detected