client/networking/CNetworkManager.cpp
//sending data of entities who we have control over
sending data of entities who we have control over
sending data of entities who we have control over
void CNetworkManager::on_client_stream(librg_event_t *event)
{
	if (event->entity->type == eNetworkEntityType::PLAYER)
	{
		CClientPlayer* player = (CClientPlayer *)event->entity->user_data;
		CPed* ped = player->m_pPed;
		event->entity->position = *(zpl_vec3 *)&ped->GetPosition();
        player->syncType = player->BuildSyncData();
        int size;
        if (player->syncType == eSyncType::SYNC_TYPE_ON_FOOT) size = sizeof(OnfootPlayerSyncPacket);
        else if (player->syncType == eSyncType::SYNC_TYPE_ON_FOOT_AIMING)size = sizeof(OnfootPlayerAimingSyncPacket);
        else if (player->syncType == eSyncType::SYNC_TYPE_IN_WATER)size = sizeof(InWaterPlayerSyncPacket);
		librg_data_wu8(event->data, player->syncType);
		librg_data_wptr(event->data, player->syncData, size);
	}
}
void CNetworkManager :: on_client_stream ( librg_event_t * event ) { if ( event -> entity -> type == eNetworkEntityType :: PLAYER ) { CClientPlayer * player = ( CClientPlayer * ) event -> entity -> user_data ; CPed * ped = player -> m_pPed ; event -> entity -> position = * ( zpl_vec3 * ) & ped -> GetPosition ( ) ; player -> syncType = player -> BuildSyncData ( ) ; int size ; if ( player -> syncType == eSyncType :: SYNC_TYPE_ON_FOOT ) size = sizeof ( OnfootPlayerSyncPacket ) ; else if ( player -> syncType == eSyncType :: SYNC_TYPE_ON_FOOT_AIMING ) size = sizeof ( OnfootPlayerAimingSyncPacket ) ; else if ( player -> syncType == eSyncType :: SYNC_TYPE_IN_WATER ) size = sizeof ( InWaterPlayerSyncPacket ) ; librg_data_wu8 ( event -> data , player -> syncType ) ; librg_data_wptr ( event -> data , player -> syncData , size ) ; } }
sending data of entities who we have control over
sending data of entities who we have control over
//we have control over own entity, we set it on the server side on finishing connection