| 429 | */ |
| 430 | extern cvar_t *cl_newClock; |
| 431 | void SV_Frame( int msec,float fractionMsec ) { |
| 432 | int frameMsec; |
| 433 | int startTime=0; |
| 434 | |
| 435 | // the menu kills the server with this cvar |
| 436 | if ( sv_killserver->integer ) { |
| 437 | SV_Shutdown ("Server was killed.\n"); |
| 438 | Cvar_Set( "sv_killserver", "0" ); |
| 439 | return; |
| 440 | } |
| 441 | |
| 442 | if ( !com_sv_running->integer ) { |
| 443 | return; |
| 444 | } |
| 445 | |
| 446 | extern void SE_CheckForLanguageUpdates(void); |
| 447 | SE_CheckForLanguageUpdates(); // will fast-return else load different language if menu changed it |
| 448 | |
| 449 | // allow pause if only the local client is connected |
| 450 | if ( SV_CheckPaused() ) { |
| 451 | return; |
| 452 | } |
| 453 | |
| 454 | // go ahead and let time slip if the server really hitched badly |
| 455 | if ( msec > 1000 ) { |
| 456 | Com_DPrintf( "SV_Frame: Truncating msec of %i to 1000\n", msec ); |
| 457 | msec = 1000; |
| 458 | } |
| 459 | |
| 460 | // if it isn't time for the next frame, do nothing |
| 461 | if ( sv_fps->integer < 1 ) { |
| 462 | Cvar_Set( "sv_fps", "10" ); |
| 463 | } |
| 464 | frameMsec = 1000 / sv_fps->integer ; |
| 465 | |
| 466 | sv.timeResidual += msec; |
| 467 | sv.timeResidualFraction+=fractionMsec; |
| 468 | if (sv.timeResidualFraction>=1.0f) |
| 469 | { |
| 470 | sv.timeResidualFraction-=1.0f; |
| 471 | if (cl_newClock&&cl_newClock->integer) |
| 472 | { |
| 473 | sv.timeResidual++; |
| 474 | } |
| 475 | } |
| 476 | if ( sv.timeResidual < frameMsec ) { |
| 477 | return; |
| 478 | } |
| 479 | |
| 480 | // if time is about to hit the 32nd bit, restart the |
| 481 | // level, which will force the time back to zero, rather |
| 482 | // than checking for negative time wraparound everywhere. |
| 483 | // 2giga-milliseconds = 23 days, so it won't be too often |
| 484 | if ( sv.time > 0x70000000 ) { |
| 485 | SV_Shutdown( "Restarting server due to time wrapping" ); |
| 486 | Com_Printf("You win. if you can play this long and not die, you deserve to win.\n"); |
| 487 | return; |
| 488 | } |
no test coverage detected