SV_Frame.
(long msec)
| 455 | * SV_Frame. |
| 456 | */ |
| 457 | public void update(long msec) { |
| 458 | // if server is not active, do nothing |
| 459 | // like when connected to another server |
| 460 | if (games.isEmpty()) |
| 461 | return; |
| 462 | |
| 463 | realtime += msec; |
| 464 | for (GameImportsImpl game: games.values()) { |
| 465 | game.realtime += msec; |
| 466 | } |
| 467 | |
| 468 | // keep the random time dependent |
| 469 | Lib.rand(); |
| 470 | |
| 471 | // check timeouts |
| 472 | SV_CheckTimeouts(); |
| 473 | |
| 474 | // get packets from clients |
| 475 | SV_ReadPackets(); |
| 476 | |
| 477 | // identify if we need to update the game or it's too early (sleep or skip this update). |
| 478 | // fixedtime - the time of the next scheduled game update. |
| 479 | long delay = fixedtime - realtime; |
| 480 | if (delay > 0) { |
| 481 | // never let the time get too far off |
| 482 | if (delay > 100) { // how is it even possible? |
| 483 | for (GameImportsImpl game: games.values()) |
| 484 | game.realtime = (int) (fixedtime - 100); |
| 485 | delay = 100; |
| 486 | } |
| 487 | NET.Sleep((int) delay); |
| 488 | return; |
| 489 | } |
| 490 | // move autonomous things around if enough time has passed |
| 491 | |
| 492 | frameNum++; |
| 493 | fixedtime = 100 * frameNum; |
| 494 | |
| 495 | // update ping based on the last known frame from all clients |
| 496 | SV_CalcPings(); |
| 497 | |
| 498 | // give the clients some timeslices |
| 499 | SV_GiveMsec(); |
| 500 | |
| 501 | // let everything in the world think and move |
| 502 | for (GameImportsImpl game : games.values()) { |
| 503 | game.SV_RunGameFrame(fixedtime); |
| 504 | } |
| 505 | |
| 506 | // send messages back to the clients that had packets read this frame |
| 507 | SV_SendClientMessages(); |
| 508 | |
| 509 | |
| 510 | // send a heartbeat to the master if needed |
| 511 | //Master_Heartbeat(); |
| 512 | |
| 513 | // clear teleport flags, etc for next frame |
| 514 | for (GameImportsImpl game : games.values()) { |
nothing calls this directly
no test coverage detected