ucsdvgdc/project-eva — pull request #15 by ozzmotic (2013-09-29 19:53:48+00:00)
Title: Scores and player names synchronized across the network

Added:

-sniper rifle works, uses same RPC call to deal damage as the rifle
-kills to win option under the host game setup screen.
-I had previously added a string "name" to the Player struct, but realized that it wasn't being shared through the RPC calls when a new player joins. I added this and the names seem to be working correctly now.

Had some weird issues where the "dead" player would be the same as the "killer" player in the ReportDeath function. I couldn't figure out why, so I added a function "FindPlayerByViewID" and that seemed to work correctly, with the correct players being passed through the RPC call.

Another weird thing is that when using the FindPlayer function, the player's own representation of their score ("my.score") was not updating despite it being changed via these lines of (psuedo) code:

Player killerplayer = FindPlayer(...);

through FindPlayer, this should return a reference to the player "my", because you are trying to find yourself. However I would get killerplayer.score updating but my.score staying at zero. The player returned is correct...Because of this I've added a check to see if the player is yourself, and then updating my.score separately. This seems kind of hacky but I can't figure out an alternative at the moment. FindPlayer should return a reference to my, not a copy, so it makes no sense that my is not updated by incrementing killerplayer.score.

I'm hoping I don't get this exact same problem when I update the otherPlayers list when the player being found is not "my". If that is the case, and otherPlayers is NOT being updated correctly (even though killerplayer.score IS), then trying to create a scoreboard with the sorted scores of otherPlayers and my (which I suppose will have to be concatenated into a single list) will not work because they will all show up as zero with the exception of "my", which I am updating through the process I described above (see lines 203 and on in NetworkManager).