Data Corruption when using RaiseEvent

Options
So I'm using the loadBalancingPeer in the lower level Unity SDK (Photon-Unity3D-Sdk_v4-1-1-7). I'm running into an issue where when I call a function like this:
this.loadBalancingPeer.OpRaiseEvent(PhotonConstants.EvPosition, photonPlayer.WriteEvMove(), false, null);

Where PhotonPlayer.WriteEvMove() is:
using Hashtable = ExitGames.Client.Photon.Hashtable;
...
public float PosX { get; set; }
public float PosY { get; set; }
public float Rotation { get; set; }
...
public Hashtable WriteEvMove()
{
Hashtable evContent = new Hashtable();

evContent[(byte)1] = this.PosX;
evContent[(byte)2] = this.PosY;
evContent[(byte)3] = this.Rotation;
evContent[(byte)4] = this.NickName;
Debug.Log("PhotonPlayer.cs writing an eventmove for nickname: " + this.NickName);
return evContent;
}

The x position makes it through, but the y position is corrupted. Here is the receive code:

public void ReadEvMove(Hashtable evContent)
{
float x = 0;
float y = 0;
float r = 0;
if (evContent.ContainsKey((byte)1))
{
x = (float)evContent[(byte)1];
}
else if (evContent.ContainsKey("1"))
{
x = System.Convert.ToSingle(evContent["1"]);
}

if (evContent.ContainsKey((byte)2))
{
y = (float)evContent[(byte)2];
}
else if (evContent.ContainsKey("2"))
{
y = System.Convert.ToSingle(evContent["2"]);
}

if (evContent.ContainsKey((byte)3))
{
y = (float)evContent[(byte)3];
}
else if (evContent.ContainsKey("3"))
{
y = System.Convert.ToSingle(evContent["3"]);
}

string nickNameToUpdate = "";

if (evContent.ContainsKey((byte)4))
{
nickNameToUpdate = (string)evContent[(byte)4];
}
else if (evContent.ContainsKey("4"))
{
nickNameToUpdate = System.Convert.ToString(evContent["4"]);
}
}


Any ideas as to why the y position and later values would be corrupted? I'm basically just sending floats in the hashtable...

Any tips would be super helpful.

Thanks,
Curt

Best Answer

  • bererton
    bererton
    Answer ✓
    Options
    Bah! I figured it out. I was overwriting the y position with the rotation (see where I look up parameter 3 in the receive code).

    Sigh. Sometimes posting a long post makes you look for basic things you did wrong.

Answers

  • bererton
    bererton
    Answer ✓
    Options
    Bah! I figured it out. I was overwriting the y position with the rotation (see where I look up parameter 3 in the receive code).

    Sigh. Sometimes posting a long post makes you look for basic things you did wrong.