Sleeps msec or until net socket is ready.
(int msec)
| 263 | |
| 264 | /** Sleeps msec or until net socket is ready. */ |
| 265 | public static void Sleep(int msec) { |
| 266 | if (ip_sockets[NS_SERVER] == null |
| 267 | || (Globals.dedicated != null && Globals.dedicated.value == 0)) |
| 268 | return; // we're not a server, just run full speed |
| 269 | |
| 270 | try { |
| 271 | //TODO: check for timeout |
| 272 | Thread.sleep(msec); |
| 273 | } catch (InterruptedException e) { |
| 274 | } |
| 275 | //ip_sockets[NS_SERVER]. |
| 276 | |
| 277 | // this should wait up to 100ms until a packet |
| 278 | /* |
| 279 | * struct timeval timeout; |
| 280 | * fd_set fdset; |
| 281 | * extern cvar_t *dedicated; |
| 282 | * extern qboolean stdin_active; |
| 283 | * |
| 284 | * if (!ip_sockets[NS_SERVER] || (dedicated && !dedicated.value)) |
| 285 | * return; // we're not a server, just run full speed |
| 286 | * |
| 287 | * FD_ZERO(&fdset); |
| 288 | * |
| 289 | * if (stdin_active) |
| 290 | * FD_SET(0, &fdset); // stdin is processed too |
| 291 | * |
| 292 | * FD_SET(ip_sockets[NS_SERVER], &fdset); // network socket |
| 293 | * |
| 294 | * timeout.tv_sec = msec/1000; |
| 295 | * timeout.tv_usec = (msec%1000)*1000; |
| 296 | * |
| 297 | * select(ip_sockets[NS_SERVER]+1, &fdset, NULL, NULL, &timeout); |
| 298 | */ |
| 299 | } |
| 300 | } |