polaris-/dwc_network_server_emulator — pull request #63 by SMTDDR (2014-08-31 22:06:00+00:00)
Title: Support PAL/NTSC or international or something...

I'm running the altwfc code on a cloud server. http://altwfc.udon.dontrush.me/

A Tatsunok-vsCapcom(TvC) player in Croatia, using the PAL version the game,
was never able to play other people until these changes were made. This is
probably how the official servers worked.

2 problems

* First, his game/console gave altwfc a userid "0932730654601". That leading zero gets dropped by the int() conversion before the call to base32_encode and thus the string returned by this function was one char too short. Because the uniquenick is created by concat'ing this string and the gsbrcd, the PAL TvC player was getting a uniquenick that was 19 chars when everyone else got 20. I prepend the base32 encoded string with "0"s until it is 9 chars long. This seems to be the correct solution because doing this does not effect the result of the decoding function and notice in this screenshot http://i.imgur.com/maVe0tK.png , that "aim" value gets the "0" prepended even though the uniquenick was missing it.

* Second, for some reason the publicport is not the same as the localport in the heartbeat packets. This TvC player is the only one that this difference. http://i.imgur.com/NNigdNO.png The encrypted list of servers returned by gamespy_backend_server.py seems to end up using the localport. The very first search the game does is a search for itself, presumably to determine what the publicip and publicport is from the point of view of the outside world. By using the localport instead of the publicport in this list, the game appears to get confused and try again. 8-10 seconds later the game sets dwc_suspend=1 in the heartbeats and keeps doing searches only for itself over & over. Perhaps the correct fix is to make sure the backendServer uses the publicport when available instead of the publicport. After looking at that code for awhile I simply couldn't figure it out and maybe it's doing the right thing incase people are playing against each other locally. I concluded that maybe the dwc_suspend thing is being used for this situation somehow so I added code to detect when this happens and manually set the publicport to the value the heartbeat was received from.