================== idAsyncClient::RunFrame ================== */
| 1753 | ================== |
| 1754 | */ |
| 1755 | void idAsyncClient::RunFrame( void ) { |
| 1756 | int msec, size; |
| 1757 | bool newPacket; |
| 1758 | idBitMsg msg; |
| 1759 | byte msgBuf[MAX_MESSAGE_SIZE]; |
| 1760 | netadr_t from; |
| 1761 | |
| 1762 | msec = UpdateTime( 100 ); |
| 1763 | |
| 1764 | if ( !clientPort.GetPort() ) { |
| 1765 | return; |
| 1766 | } |
| 1767 | |
| 1768 | // handle ongoing pk4 downloads and patch downloads |
| 1769 | HandleDownloads(); |
| 1770 | |
| 1771 | gameTimeResidual += msec; |
| 1772 | |
| 1773 | // spin in place processing incoming packets until enough time lapsed to run a new game frame |
| 1774 | do { |
| 1775 | |
| 1776 | do { |
| 1777 | |
| 1778 | // blocking read with game time residual timeout |
| 1779 | newPacket = clientPort.GetPacketBlocking( from, msgBuf, size, sizeof( msgBuf ), USERCMD_MSEC - ( gameTimeResidual + clientPredictTime ) - 1 ); |
| 1780 | if ( newPacket ) { |
| 1781 | msg.Init( msgBuf, sizeof( msgBuf ) ); |
| 1782 | msg.SetSize( size ); |
| 1783 | msg.BeginReading(); |
| 1784 | ProcessMessage( from, msg ); |
| 1785 | } |
| 1786 | |
| 1787 | msec = UpdateTime( 100 ); |
| 1788 | gameTimeResidual += msec; |
| 1789 | |
| 1790 | } while( newPacket ); |
| 1791 | |
| 1792 | } while( gameTimeResidual + clientPredictTime < USERCMD_MSEC ); |
| 1793 | |
| 1794 | // update server list |
| 1795 | serverList.RunFrame(); |
| 1796 | |
| 1797 | if ( clientState == CS_DISCONNECTED ) { |
| 1798 | usercmdGen->GetDirectUsercmd(); |
| 1799 | gameTimeResidual = USERCMD_MSEC - 1; |
| 1800 | clientPredictTime = 0; |
| 1801 | return; |
| 1802 | } |
| 1803 | |
| 1804 | if ( clientState == CS_PURERESTART ) { |
| 1805 | clientState = CS_DISCONNECTED; |
| 1806 | Reconnect(); |
| 1807 | gameTimeResidual = USERCMD_MSEC - 1; |
| 1808 | clientPredictTime = 0; |
| 1809 | return; |
| 1810 | } |
| 1811 | |
| 1812 | // if not connected setup a connection |
nothing calls this directly
no test coverage detected