Tuesday, August 31, 2010

High Score Sharing - Done

Yes, you read that right. It is now done. Working really well and the hiccups are very minimal. I cannot say entirely removed, i think because of network session underlying code can do that. However the stuff on top appears to be clean and working.

I found my bug. I needed to make sure i waited a second or two before terminating the session from the Host. For some reason this caused the ElapsedTime field of Gametime to get really really small. As there is a timer on the sharing code to only do stuff every so many seconds, then it basically stalled me out. Once i sent in a fixed time delta (1/60th) it updated fine as well. so with both these things fixed it all works very nicely.

Testing it has taken some time. I am methodical and commited to doing that part properly, so i have left it running over several hours to see what it would do. And it works great.

The last thing i added was a Previous Hosts list. This is a class that will store anyone you connected to (the host). Then there is a timer on them. This effectively causes a timeout from matching up with the again. I might set this at 4-5 minutes, i am not sure. I could see this being game dependant though. for examply 10 minutes playing my game is quite a lot, but 5 minutes is low. So i could set my previous Host expired timer to soemwhere between those figures.

I intend to share this code once i have finished tidying it up. there are plenty of comments already, but some of the names are a bit wrong. Once it is done i shall make it open source. Oh.. and it is about 600 lines of code (including comments and lots of debug messages.

G'night
Tonight i go to bed a much happier man. Next up is encrypting my save file.

No comments:

Post a Comment