| 148 | COMMAND(modlanconnect, ""); |
| 149 | |
| 150 | void 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 | |
| 189 | void trydisconnect() |
| 190 | { |
no test coverage detected