Beispiel #1
0
function mSInt32($p)
{
    if ($p >= 0) {
        return mUInt32($p);
    }
    $t = -$p;
    if ($t < 64) {
        return mByte($p | 0x40);
    }
    if ($t < 16384) {
        return mShort($p | 0xa000);
    }
    if ($t < 536870912) {
        return mInt($p | 0xd0000000);
    }
    return mInt(-16) . mInt($p);
}
Beispiel #2
0
 function getrolename($id)
 {
     //figure out how far off role ID is from account ID
     $offset = $id % 8;
     $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
     if ($sock) {
         if (socket_connect($sock, GAMEDBDH, GAMEDBDP)) {
             socket_set_block($sock);
             $data = mUInt32(3032) . mByte(8) . mShort(32768) . mShort(0x25) . mInt($id - $offset);
             //hexdump($data);
             socket_send($sock, $data, 8192, 0);
             socket_recv($sock, $buf, 8192, 0);
             //hexdump($buf);
             socket_set_nonblock($sock);
             socket_close($sock);
             //for some reason the number of names
             //doesn't always stay in the same spot
             $pos11 = ord(substr($buf, 11, 1));
             $pos12 = ord(substr($buf, 12, 1));
             if ($pos11 == 0) {
                 $namelen = $pos12;
                 $pholder = 17;
             } else {
                 $namelen = $pos11;
                 $pholder = 16;
             }
             for ($i = 0; $i < $namelen; $i++) {
                 $thisnamelen = ord(substr($buf, $pholder, 1));
                 $names[] = iconv("UCS-2LE", "UTF-8", substr($buf, $pholder + 1, $thisnamelen));
                 //+1 is because it needs to advance one to get where the name starts
                 //+$thisnamelen pushes it all the way to end of name
                 //+4 then skips over the 'useless' bytes to get next name length
                 $pholder += 1 + $thisnamelen + 4;
             }
             if ($names[$offset] != "") {
                 return $names[$offset];
             }
         }
     }
     return "Unable to retrieve";
 }