| 407 | } |
| 408 | |
| 409 | void checkgameservers() |
| 410 | { |
| 411 | ENetBuffer buf; |
| 412 | loopv(gameservers) |
| 413 | { |
| 414 | gameserver &s = *gameservers[i]; |
| 415 | if(s.lastping && s.lastpong && ENET_TIME_LESS_EQUAL(s.lastping, s.lastpong)) |
| 416 | { |
| 417 | if(ENET_TIME_DIFFERENCE(servtime, s.lastpong) > KEEPALIVE_TIME) |
| 418 | { |
| 419 | delete gameservers.remove(i--); |
| 420 | updateserverlist = true; |
| 421 | } |
| 422 | } |
| 423 | else if(!s.lastping || ENET_TIME_DIFFERENCE(servtime, s.lastping) > PING_TIME) |
| 424 | { |
| 425 | if(s.numpings >= PING_RETRY) |
| 426 | { |
| 427 | servermessage(s, "failreg failed pinging server\n"); |
| 428 | delete gameservers.remove(i--); |
| 429 | updateserverlist = true; |
| 430 | } |
| 431 | else |
| 432 | { |
| 433 | static const uchar ping[] = { 1 }; |
| 434 | buf.data = (void *)ping; |
| 435 | buf.dataLength = sizeof(ping); |
| 436 | s.numpings++; |
| 437 | s.lastping = servtime ? servtime : 1; |
| 438 | enet_socket_send(pingsocket, &s.address, &buf, 1); |
| 439 | } |
| 440 | } |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | void messagebuf::purge() |
| 445 | { |