<commit_before>﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class PlayerNetwork : MonoBehaviour 
{
    private Vector3 m_targetPosition = default(Vector3);
    private Quaternion m_targetRotation = default(Quaternion);
    private Vector3 m_lastPosition = default(Vector3);
    private Quaternion m_lastRotation = default(Quaternion);

    private bool m_hasPosition = false;

    private PhotonView m_photon = null;
    private float m_lerpTime = 0.0f;

    public bool HasTeleported { get; set; }

    void Start()
    {
        m_photon = this.GetComponent<PhotonView>();
    }

    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting)   
        {       
            //We own this player: send the others our data       
            stream.SendNext(this.transform.position);
            stream.SendNext(this.transform.rotation);
            stream.SendNext(this.HasTeleported);

            // Reset flags
            this.HasTeleported = false;
        }   
        else   
        {       
            //Network player, receive data        
            m_targetPosition = (Vector3)stream.ReceiveNext();
            m_targetRotation = (Quaternion)stream.ReceiveNext();
            var didPortal = (bool)stream.ReceiveNext();

            if (!m_hasPosition || didPortal)
            {
                m_lastPosition = m_targetPosition;
                m_lastRotation = m_targetRotation;
                m_hasPosition = true;
            }
            else
            {
                m_lastPosition = this.transform.position;
                m_lastRotation = this.transform.rotation;
            }

            m_lerpTime = 0.0f;
        }
    }

    void Update()
    {
        if (!m_photon.isMine)
        {
            m_lerpTime += Time.deltaTime * 9;
            this.transform.position = Vector3.Lerp(m_lastPosition, m_targetPosition, m_lerpTime);
            this.transform.rotation = Quaternion.Lerp(m_lastRotation, m_targetRotation, m_lerpTime);
        }
    }
}<commit_msg>[Fix] Make sure we have data before using it.<commit_after>﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class PlayerNetwork : MonoBehaviour 
{
    private Vector3 m_targetPosition = default(Vector3);
    private Quaternion m_targetRotation = default(Quaternion);
    private Vector3 m_lastPosition = default(Vector3);
    private Quaternion m_lastRotation = default(Quaternion);

    private bool m_hasPosition = false;

    private PhotonView m_photon = null;
    private float m_lerpTime = 0.0f;
    private bool m_hasData = false;

    public bool HasTeleported { get; set; }

    void Start()
    {
        m_photon = this.GetComponent<PhotonView>();
    }

    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting)   
        {       
            //We own this player: send the others our data       
            stream.SendNext(this.transform.position);
            stream.SendNext(this.transform.rotation);
            stream.SendNext(this.HasTeleported);

            // Reset flags
            this.HasTeleported = false;
        }   
        else   
        {       
            //Network player, receive data        
            m_targetPosition = (Vector3)stream.ReceiveNext();
            m_targetRotation = (Quaternion)stream.ReceiveNext();
            var didPortal = (bool)stream.ReceiveNext();

            if (!m_hasPosition || didPortal)
            {
                m_lastPosition = m_targetPosition;
                m_lastRotation = m_targetRotation;
                m_hasPosition = true;
            }
            else
            {
                m_lastPosition = this.transform.position;
                m_lastRotation = this.transform.rotation;
            }

            m_lerpTime = 0.0f;
            m_hasData = true;
        }
    }

    void Update()
    {
        if (!m_photon.isMine && m_hasData)
        {
            m_lerpTime += Time.deltaTime * 9;
            this.transform.position = Vector3.Lerp(m_lastPosition, m_targetPosition, m_lerpTime);
            this.transform.rotation = Quaternion.Lerp(m_lastRotation, m_targetRotation, m_lerpTime);
        }
    }
}
{'fraction_non_alphanumeric': 0.08179911442554183, 'fraction_numerical': 0.005127010020974132, 'mean_word_length': 1.943758573388203, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3390348', 'n_tokens_mistral': 1230, 'n_tokens_neox': 1171, 'n_words': 241}