client/networking/CNetworkManager.cpp
//getting updated data of an entity
getting updated data of an entity
getting updated data of an entity
void CNetworkManager::on_entity_update(librg_event_t *event)
{
	if (!event->entity->user_data)return;
	switch (event->entity->type)
	{
	case eNetworkEntityType::PLAYER:
	{
		CClientPlayer* player = (CClientPlayer*)event->entity->user_data;
		if (player && player->m_bStreamedIn)
		{
			player->position = event->entity->position;
			player->m_iLastPacketTime = GetTickCount();
			player->syncType = (eSyncType)librg_data_ru8(event->data);
			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_rptr(event->data, player->syncData, size);
			player->bSync = true;
		}
		break;
	}
	}
}
void CNetworkManager :: on_entity_update ( librg_event_t * event ) { if ( ! event -> entity -> user_data ) return ; switch ( event -> entity -> type ) { case eNetworkEntityType :: PLAYER : { CClientPlayer * player = ( CClientPlayer * ) event -> entity -> user_data ; if ( player && player -> m_bStreamedIn ) { player -> position = event -> entity -> position ; player -> m_iLastPacketTime = GetTickCount ( ) ; player -> syncType = ( eSyncType ) librg_data_ru8 ( event -> data ) ; 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_rptr ( event -> data , player -> syncData , size ) ; player -> bSync = true ; } break ; } } }
getting updated data of an entity
getting updated data of an entity