1: | <?php |
2: | |
3: | |
4: | |
5: | |
6: | |
7: | |
8: | |
9: | |
10: | |
11: | |
12: | |
13: | |
14: | |
15: | |
16: | |
17: | |
18: | |
19: | namespace GameQ\Protocols; |
20: | |
21: | use GameQ\Buffer; |
22: | use GameQ\Result; |
23: | |
24: | |
25: | |
26: | |
27: | |
28: | |
29: | |
30: | |
31: | |
32: | class Justcause2 extends Gamespy4 |
33: | { |
34: | |
35: | |
36: | |
37: | |
38: | |
39: | protected $name = 'justcause2'; |
40: | |
41: | |
42: | |
43: | |
44: | |
45: | |
46: | protected $name_long = "Just Cause 2 Multiplayer"; |
47: | |
48: | |
49: | |
50: | |
51: | |
52: | |
53: | protected $join_link = "steam://connect/%s:%d/"; |
54: | |
55: | |
56: | |
57: | |
58: | |
59: | |
60: | protected $packets = [ |
61: | self::PACKET_CHALLENGE => "\xFE\xFD\x09\x10\x20\x30\x40", |
62: | self::PACKET_ALL => "\xFE\xFD\x00\x10\x20\x30\x40%s\xFF\xFF\xFF\x02", |
63: | ]; |
64: | |
65: | |
66: | |
67: | |
68: | |
69: | |
70: | protected $packetSplit = "/\\x00\\x00\\x00/m"; |
71: | |
72: | |
73: | |
74: | |
75: | |
76: | |
77: | protected $normalize = [ |
78: | 'general' => [ |
79: | |
80: | 'dedicated' => 'dedicated', |
81: | 'gametype' => 'gametype', |
82: | 'hostname' => 'hostname', |
83: | 'mapname' => 'mapname', |
84: | 'maxplayers' => 'maxplayers', |
85: | 'numplayers' => 'numplayers', |
86: | 'password' => 'password', |
87: | ], |
88: | |
89: | 'player' => [ |
90: | 'name' => 'name', |
91: | 'ping' => 'ping', |
92: | ], |
93: | ]; |
94: | |
95: | |
96: | |
97: | |
98: | |
99: | |
100: | |
101: | |
102: | |
103: | protected function processDetails(Buffer &$buffer, Result &$result) |
104: | { |
105: | parent::processDetails($buffer, $result); |
106: | |
107: | |
108: | $result->add('mapname', 'Panau'); |
109: | $result->add('dedicated', 'true'); |
110: | } |
111: | |
112: | |
113: | |
114: | |
115: | |
116: | |
117: | |
118: | |
119: | |
120: | |
121: | |
122: | protected function processPlayersAndTeams(Buffer &$buffer, Result &$result) |
123: | { |
124: | |
125: | while ($buffer->getLength()) { |
126: | $result->addPlayer('name', $buffer->readString()); |
127: | $result->addPlayer('steamid', $buffer->readString()); |
128: | $result->addPlayer('ping', $buffer->readInt16()); |
129: | } |
130: | } |
131: | } |
132: | |