-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.php
47 lines (42 loc) · 1.01 KB
/
util.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/**
* @file
* Util functions.
*
* Sure this could be organized fancily, autoloaded, maybe even Symfony console application, but
* that all seems like overkill for such a small application.
*/
/**
* Override the server port contained in a S2A_INFO2_Packet buffer.
*
* @param ByteBuffer $buffer
* Buffer containing S2A_INFO2_Packet packet.
* @param int $port
* Value to set for the server port.
*/
function set_port(ByteBuffer $buffer, $port)
{
$buffer->rewind();
$buffer->getByte();
$buffer->getString();
$buffer->getString();
$buffer->getString();
$buffer->getString();
$buffer->getShort();
$buffer->getByte();
$buffer->getByte();
$buffer->getByte();
$buffer->getByte();
$buffer->getByte();
$buffer->getByte();
$buffer->getByte();
$buffer->getString();
if($buffer->remaining() > 0) {
$extra_data_flag = $buffer->getByte();
if ($extra_data_flag & S2A_INFO2_Packet::EDF_GAME_PORT) {
$buffer->put(pack('S', $port));
return true;
}
}
return false;
}