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 Bf4 extends Bf3 |
33: | { |
34: | |
35: | |
36: | |
37: | |
38: | |
39: | protected $name = 'bf4'; |
40: | |
41: | |
42: | |
43: | |
44: | |
45: | |
46: | protected $name_long = "Battlefield 4"; |
47: | |
48: | |
49: | |
50: | |
51: | |
52: | |
53: | |
54: | |
55: | |
56: | protected function processDetails(Buffer $buffer) |
57: | { |
58: | |
59: | $items = $this->decode($buffer); |
60: | |
61: | |
62: | $result = new Result(); |
63: | |
64: | |
65: | $result->add('dedicated', 1); |
66: | |
67: | |
68: | $result->add('hostname', $items[1]); |
69: | $result->add('num_players', (int) $items[2]); |
70: | $result->add('max_players', (int) $items[3]); |
71: | $result->add('gametype', $items[4]); |
72: | $result->add('map', $items[5]); |
73: | $result->add('roundsplayed', (int) $items[6]); |
74: | $result->add('roundstotal', (int) $items[7]); |
75: | $result->add('num_teams', (int) $items[8]); |
76: | |
77: | |
78: | $index_current = 9; |
79: | |
80: | |
81: | $teamCount = $result->get('num_teams'); |
82: | |
83: | |
84: | for ($id = 1; $id <= $teamCount; $id++, $index_current++) { |
85: | |
86: | $result->addTeam('tickets', $items[$index_current]); |
87: | |
88: | $result->addTeam('id', $id); |
89: | } |
90: | |
91: | |
92: | $result->add('targetscore', (int) $items[$index_current]); |
93: | $result->add('online', 1); |
94: | $result->add('ranked', (int) $items[$index_current + 2]); |
95: | $result->add('punkbuster', (int) $items[$index_current + 3]); |
96: | $result->add('password', (int) $items[$index_current + 4]); |
97: | $result->add('uptime', (int) $items[$index_current + 5]); |
98: | $result->add('roundtime', (int) $items[$index_current + 6]); |
99: | $result->add('ip_port', $items[$index_current + 7]); |
100: | $result->add('punkbuster_version', $items[$index_current + 8]); |
101: | $result->add('join_queue', (int) $items[$index_current + 9]); |
102: | $result->add('region', $items[$index_current + 10]); |
103: | $result->add('pingsite', $items[$index_current + 11]); |
104: | $result->add('country', $items[$index_current + 12]); |
105: | |
106: | $result->add('blaze_player_count', (int) $items[$index_current + 13]); |
107: | $result->add('blaze_game_state', (int) $items[$index_current + 14]); |
108: | |
109: | unset($items, $index_current, $teamCount, $buffer); |
110: | |
111: | return $result->fetch(); |
112: | } |
113: | } |
114: | |