Closed gunzino closed 8 years ago
Are you running on a 32 bit machine? If yes read the notes: http://php.net/manual/de/function.long2ip.php
There is nothing wrong with TFS, it is converting in big endian as PHP uses little endian. You should do a function to get the string from a big endian encoded long as Game.convertIpToString: https://github.com/otland/forgottenserver/blob/33d074fe1cb28d7f094e0e6896ada65d9cd472a2/data/lib/core/game.lua#L11
And one to convert big endian long to little endian long.
Yeah thats what I do. If you copy TFS long to any converter on the web you will get bad result.
Is there some special reason to use big endian ?
It was inherited from https://github.com/opentibia/server. It can't be fixed without breaking everything that depends on the old format.
TFS saving IP addresses in opposite way. For example IP 0.0.0.1 should be in long format 1 but in TFS it is 16777216.
Expected behaviour
I am not 100% about that but PHP functions long2ip and ip2long should be working with TFS databases. Instead, you need to create special functions that swap the quads of an ip address.
Actual behaviour
I need to use edited functions to get the IP from long. There is an example code: `
public static function TfsLong2Ip($tfs_ip) { $ipp = long2ip($tfs_ip); $quads = explode(".", $ipp); $ip = $quads[3].".".$quads[2].".".$quads[1].".".$quads[0]; return $ip; }
Environment
TFS & PHP