void CLevel::OnMessage (void* data, u32 size) { DemoCS.Enter(); if (IsDemoPlay() ) { if (m_bDemoStarted) { DemoCS.Leave(); return; } if (!m_aDemoData.empty() && net_IsSyncronised()) { // NET_Packet *P = &(m_aDemoData.front()); DemoDataStruct *P = &(m_aDemoData.front()); u32 CurTime = timeServer_Async(); timeServer_UserDelta(P->m_dwTimeReceive - CurTime); m_bDemoStarted = TRUE; Msg("! ------------- Demo Started ------------"); m_dwCurDemoFrame = P->m_dwFrame; DemoCS.Leave(); return; } }; if (IsDemoSave() && net_IsSyncronised()) { Demo_StoreData(data, size, DATA_CLIENT_PACKET); } IPureClient::OnMessage(data, size); DemoCS.Leave(); };
BOOL CLevel::Connect2Server (LPCSTR options) { NET_Packet P; m_bConnectResultReceived = false ; m_bConnectResult = true ; if (!Connect(options)) return FALSE; //--------------------------------------------------------------------------- if(psNET_direct_connect) m_bConnectResultReceived = true; u32 EndTime = GetTickCount() + ConnectionTimeOut; while (!m_bConnectResultReceived) { ClientReceive (); Sleep (5); if(Server) Server->Update() ; //----------------------------------------- u32 CurTime = GetTickCount(); if (CurTime > EndTime) { NET_Packet P; P.B.count = 0; P.r_pos = 0; P.w_u8(0); P.w_u8(0); P.w_stringZ("Data verification failed. Cheater? [1]"); OnConnectResult(&P); } if (net_isFails_Connect()) { OnConnectRejected (); Disconnect () ; return FALSE; } //----------------------------------------- } Msg ("%c client : connection %s - <%s>", m_bConnectResult ?'*':'!', m_bConnectResult ? "accepted" : "rejected", m_sConnectResult.c_str()); if (!m_bConnectResult) { OnConnectRejected (); Disconnect () ; return FALSE ; }; if(psNET_direct_connect) net_Syncronised = TRUE; else net_Syncronize (); while (!net_IsSyncronised()) { }; //--------------------------------------------------------------------------- P.w_begin (M_CLIENT_REQUEST_CONNECTION_DATA); Send (P, net_flags(TRUE, TRUE, TRUE, TRUE)); //--------------------------------------------------------------------------- return TRUE; };
void CLevel::Demo_StartFrame () { if (!IsDemoSave() || !net_IsSyncronised()) return; DemoCS.Enter(); DemoFrameTime CurFrameTime; CurFrameTime.dwTimeDelta = Device.dwTimeDelta; CurFrameTime.dwTimeGlobal = Device.dwTimeGlobal; CurFrameTime.dwTimeServer = Level().timeServer(); CurFrameTime.dwTimeServer_Delta = Level().timeServer_Delta(); CurFrameTime.fTimeDelta = Device.fTimeDelta; CurFrameTime.fTimeGlobal= Device.fTimeGlobal; Demo_StoreData(&CurFrameTime, sizeof(CurFrameTime), DATA_FRAME); DemoCS.Leave(); };
BOOL CLevel::Connect2Server (LPCSTR options) { NET_Packet P; m_bConnectResultReceived = false ; m_bConnectResult = true ; if (!Connect(options)) return FALSE; //--------------------------------------------------------------------------- if(psNET_direct_connect) m_bConnectResultReceived = true; while (!m_bConnectResultReceived) { ClientReceive (); Sleep (5); if(Server) Server->Update() ; } Msg ("%c client : connection %s - <%s>", m_bConnectResult ?'*':'!', m_bConnectResult ? "accepted" : "rejected", m_sConnectResult.c_str()); if (!m_bConnectResult) { OnConnectRejected (); Disconnect () ; return FALSE ; }; if(psNET_direct_connect) net_Syncronised = TRUE; else net_Syncronize (); while (!net_IsSyncronised()) { }; //--------------------------------------------------------------------------- P.w_begin (M_CLIENT_REQUEST_CONNECTION_DATA); Send (P); //--------------------------------------------------------------------------- return TRUE; };
void CLevel::ClientSend() { if (!GameID() == GAME_SINGLE || OnClient()) if (GameID() == GAME_SINGLE || OnClient()) { if ( !net_HasBandwidth() ) return; }; #ifdef BATTLEYE battleye_system.UpdateClient(); #endif // BATTLEYE NET_Packet P; u32 start = 0; //----------- for E3 ----------------------------- // if () { // if (!(Game().local_player) || Game().local_player->testFlag(GAME_PLAYER_FLAG_VERY_VERY_DEAD)) return; if (CurrentControlEntity()) { CObject* pObj = CurrentControlEntity(); if (!pObj->getDestroy() && pObj->net_Relevant()) { P.w_begin (M_CL_UPDATE); P.w_u16 (u16(pObj->ID()) ); P.w_u32 (0); //reserved place for client's ping pObj->net_Export (P); if (P.B.count>9) { if (OnServer()) { if (net_IsSyncronised() && IsDemoSave()) { DemoCS.Enter(); Demo_StoreData(P.B.data, P.B.count, DATA_CLIENT_PACKET); DemoCS.Leave(); } } else Send (P, net_flags(FALSE)); } } } }; if (OnClient()) { Flush_Send_Buffer(); return; } //------------------------------------------------- while (1) { P.w_begin (M_UPDATE); start = Objects.net_Export (&P, start, max_objects_size); if (P.B.count>2) { Device.Statistic->TEST3.Begin(); Send (P, net_flags(FALSE)); Device.Statistic->TEST3.End(); }else break; } }