Halo.pm

filter: Statementstmt 14.0% 28 / 200 Branchbran 0.0% 0 / 66 Conditioncond 0.0% 0 / 56 MC/DCmcdc 0.0% 0 / 32 Subroutinesub 33.3% 7 / 21 Podpod 15.3% 2 / 13 totaltotal 9.5% 37 / 388 CC 60 SCAR 52.9
CC
60
Cov
9%
decode_game_flags
600.0
new
72.0
info
30.0
CRAP 198.1
↑ Summary sample.pl »
1 package POE::Component::Client::Halo;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 $VERSION = '0.2';
7  
8 sub DEBUG () { 0 };
9  
10 1 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Socket;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use POE qw(Session Wheel::SocketFactory);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 ▶use vars qw(@ISA @EXPORT_OK %EXPORT_TAGS
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 $player_flags $game_flags);
17 1 @ISA = 'Exporter';
18 1 @EXPORT_OK = qw(halo_player_flag halo_game_flag);
19 1 %EXPORT_TAGS = (
20 'flags' => [qw(halo_player_flag halo_game_flag)],
21 );
22  
23 1 $player_flags = {
24 'NumberOfLives' => ['Infinite', 1, 3, 5],
25 'MaximumHealth' => ['50%', '100%', '150%', '200%', '300%', '400%'],
26 'Shields' => [1, 0],
27 'RespawnTime' => [0, 5, 10, 15],
28 'RespawnGrowth' => [0, 5, 10, 15],
29 'OddManOut' => [0, 1],
30 'InvisiblePlayers' => [0, 1],
31 'SuicidePenalty' => [0, 5, 10, 15],
32 'InfiniteGrenades' => [0, 1],
33 'WeaponSet' => ['Normal', 'Pistols', 'Rifles', 'Plasma', 'Sniper',
34 'No Sniping', 'Rocket Launchers', 'Shotguns',
35 'Short Range', 'Human', 'Covenant', 'Classic',
36 'Heavy Weapons'],
37 'StartingEquipment' => ['Custom', 'Generic'],
38 'Indicator' => ['Motion Tracker', 'Nav Points', 'None'],
39 'OtherPlayersOnRadar' => ['No', 'All', undef, 'Friends'],
40 'FriendIndicators' => [0, 1],
41 'FriendlyFire' => ['Off', 'On', 'Shields Only', 'Explosives Only'],
42 'FriendlyFirePenalty' => [0, 5, 10, 15],
43 'AutoTeamBalance' => [0, 1],
44  
45 # Team Flags
46 'VehicleRespawn' => [0, 30, 60, 90, 120, 180, 300],
47 'RedVehicleSet' => ['Default', undef, 'Warthogs', 'Ghosts',
48 'Scorpions', 'Rocket Warthogs', 'Banshees',
49 'Gun Turrets', 'Custom'],
50 'BlueVehicleSet' => ['Default', undef, 'Warthogs', 'Ghosts',
51 'Scorpions', 'Rocket Warthogs', 'Banshees',
52 'Gun Turrets', 'Custom'],
53 };
54  
55 1 $game_flags = {
56 'GameType' => ['Capture the Flag', 'Slayer', 'Oddball',
57 'King of the Hill', 'Race'],
58 # CTF
59 'Assault' => [0, 1],
60 'FlagMustReset' => [0, 1],
61 'FlagAtHomeToScore' => [0, 1],
62 'SingleFlag' => [0, 60, 120, 180, 300, 600],
63 # Slayer
64 'DeathBonus' => [1, 0],
65 'KillPenalty' => [1, 0],
66 'KillInOrder' => [0, 1],
67 # Oddball
68 'RandomStart' => [0, 1],
69 'SpeedWithBall' => ['Slow', 'Normal', 'Fast'],
70 'TraitWithBall' => ['None', 'Invisible', 'Extra Damage', 'Damage Resistant'],
71 'TraitWithoutBall' => ['None', 'Invisible', 'Extra Damage', 'Damage Resistant'],
72 'BallType' => ['Normal', 'Reverse Tag', 'Juggernaut'],
73 'BallSpawnCount' => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
74 # King of the Hill
75 'MovingHill' => [0, 1],
76 # Race
77 'RaceType' => ['Normal', 'Any Order', 'Rally'],
78 'TeamScoring' => ['Minimum', 'Maximum', 'Sum'],
79 };
80  
81 0 ▶sub new {
Subroutine new: not called CC=8 SCAR=42.8
Pod undocumented
82 0 my $type = shift;
83 0 my $self = bless {}, $type;
84  
85 0 ▶ croak "$type requires an event number of parameters" if @_ % 2;
Branch: 1 branch
BranchTrueFalseTotal
if @_ % 2 0 0 0
86  
87 0 my %params = @_;
88  
89 0 my $alias = delete $params{Alias};
90 0 ▶ $alias = 'halo' unless defined $alias;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $alias 0 0 0
91  
92 0 my $timeout = delete $params{Timeout};
93 0 ▶ $timeout = 15 unless defined $timeout and $timeout >= 0;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $timeout and $timeout >= 0 0 0 0
Condition0%0/3
defined $timeout and $timeout >= 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $timeout and $timeout >= 0
defined $timeout $timeout >= 0
Truth table0%0/3
A and B
A= defined $timeoutB= $timeout >= 0
ABresult
0X0
100
111
94  
95 0 my $retry = delete $params{Retry};
96 0 ▶ $retry = 2 unless defined $retry and $retry >= 0;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $retry and $retry >= 0 0 0 0
Condition0%0/3
defined $retry and $retry >= 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $retry and $retry >= 0
defined $retry $retry >= 0
Truth table0%0/3
A and B
A= defined $retryB= $retry >= 0
ABresult
0X0
100
111
97  
98 0 ▶ croak "$type doesn't know these parameters: ", join(', ', sort(keys(%params))) if scalar(keys(%params));
Branch: 1 branch
BranchTrueFalseTotal
if scalar keys %params 0 0 0
99  
100 0 POE::Session->create(
101 inline_states => {
102 _start => \&_start,
103 info => \&info,
104 detail => \&detail,
105  
106 got_socket => \&got_socket,
107 got_response => \&got_response,
108 response_timeout => \&response_timeout,
109 debug_heap => \&debug_heap,
110  
111 got_error => \&got_error,
112 },
113 args => [ $timeout, $retry, $alias ],
114 );
115  
116 0 return $self;
117 }
118  
119 0 ▶sub got_error {
Subroutine got_error: not called CC=1 SCAR=6.9
Pod undocumented
120 0 my ($operation, $errnum, $errstr, $wheel_id, $heap) = @_[ARG0..ARG3,HEAP];
121 0 warn "Wheel $wheel_id generated $operation error $errnum: $errstr\n";
122 0 delete $heap->{w_jobs}->{$wheel_id}; # shut down that wheel
123 }
124  
125 0 ▶sub debug_heap {
Subroutine debug_heap: not called CC=3 SCAR=24.8
Pod undocumented
126 0 my ($kernel, $heap) = @_[KERNEL, HEAP];
127 0 ▶ open(F, ">/tmp/halo-debug") || return;
Branch: 1 branch
BranchTrueFalseTotal
open F, ">/tmp/halo-debug" or return 0 0 0
128 0 print F Dumper($heap);
129 0 ▶ close(F) || return;
Branch: 1 branch
BranchTrueFalseTotal
close F or return 0 0 0
130 0 $kernel->delay('debug_heap', 10);
131 }
132  
133 0 ▶sub _start {
Subroutine _start: not called CC=1 SCAR=6.9
134 0 my ($kernel, $heap, $timeout, $retry, $alias) = @_[KERNEL, HEAP, ARG0..ARG3];
135 0 $heap->{timeout} = $timeout;
136 0 $heap->{retry} = $retry;
137 0 $kernel->alias_set($alias);
138 0 print STDERR "Halo object started.\n" if DEBUG;
139 0 $kernel->yield('debug_heap') if DEBUG;
140 }
141  
142 0 ▶sub info {
Subroutine info: not called CC=5 SCAR=34.0
Pod documented
143 0 my ($kernel, $heap, $sender, $ip, $port, $postback) = @_[KERNEL, HEAP, SENDER, ARG0..ARG2];
144 0 ▶ my ($identifier) = defined($_[ARG3]) ? $_[ARG3] : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $_[13] ? : 0 0 0
145 0 print STDERR "Got request for $ip:$port info with postback $postback\n" if DEBUG;
146 0 ▶ croak "IP address required to execute a query" unless defined $ip;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ip 0 0 0
147 0 ▶ croak "Port requred to execute a query" if !defined $port || $port !~ /^\d+$/;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $port and $port =~ /^\d+$/ 0 0 0
Condition0%0/3
defined $port and $port =~ /^\d+$/
!ll&&!rl&&r
000
MC/DC0%0/2
defined $port and $port =~ /^\d+$/
defined $port $port =~ /^\d+$/
Truth table0%0/3
A and B
A= defined $portB= $port =~ /^\d+$/
ABresult
0X0
100
111
148 0 my $wheel = POE::Wheel::SocketFactory->new(
149 RemoteAddress => $ip,
150 RemotePort => $port,
151 SocketProtocol => 'udp',
152 SuccessEvent => 'got_socket',
153 FailureEvent => 'got_error',
154 );
155 0 $heap->{w_jobs}->{$wheel->ID()} = {
156 ip => $ip,
157 port => $port,
158 postback => $postback,
159 session => $sender->ID(),
160 wheel => $wheel,
161 identifier => $identifier,
162 try => 1, # number of tries...
163 action => 'info',
164 };
165 0 return undef;
166 }
167  
168 0 ▶sub detail {
Subroutine detail: not called CC=5 SCAR=34.0
Pod documented
169 0 my ($kernel, $heap, $sender, $ip, $port, $postback) = @_[KERNEL, HEAP, SENDER, ARG0..ARG2];
170 0 ▶ my ($identifier) = defined($_[ARG3]) ? $_[ARG3] : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $_[13] ? : 0 0 0
171 0 print STDERR "Got request for $ip:$port players with postback $postback\n" if DEBUG;
172 0 ▶ croak "IP address required to execute a query" unless defined $ip;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ip 0 0 0
173 0 ▶ croak "Port requred to execute a query" if !defined $port || $port !~ /^\d+$/;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $port and $port =~ /^\d+$/ 0 0 0
Condition0%0/3
defined $port and $port =~ /^\d+$/
!ll&&!rl&&r
000
MC/DC0%0/2
defined $port and $port =~ /^\d+$/
defined $port $port =~ /^\d+$/
Truth table0%0/3
A and B
A= defined $portB= $port =~ /^\d+$/
ABresult
0X0
100
111
174 0 my $wheel = POE::Wheel::SocketFactory->new(
175 RemoteAddress => $ip,
176 RemotePort => $port,
177 SocketProtocol => 'udp',
178 SuccessEvent => 'got_socket',
179 FailureEvent => 'got_error',
180 );
181 0 $heap->{w_jobs}->{$wheel->ID()} = {
182 ip => $ip,
183 port => $port,
184 postback => $postback,
185 session => $sender->ID(),
186 wheel => $wheel,
187 identifier => $identifier,
188 try => 1, # number of tries...
189 action => 'detail',
190 };
191 0 return undef;
192 }
193  
194 0 ▶sub got_socket {
Subroutine got_socket: not called CC=3 SCAR=24.8
Pod undocumented
195 0 my ($kernel, $heap, $socket, $wheelid) = @_[KERNEL, HEAP, ARG0, ARG3];
196  
197 0 $heap->{jobs}->{$socket} = delete($heap->{w_jobs}->{$wheelid});
198 0 $kernel->select_read($socket, 'got_response');
199 0 my $query = '';
200 0 ▶ if($heap->{jobs}->{$socket}->{action} eq 'info') {
Branch: 2 branches
BranchTrueFalseTotal
if ($heap->{'jobs'}{$socket}{'action'} eq 'info') { } 0 0 0
elsif ($heap->{'jobs'}{$socket}{'action'} eq 'detail') { } 0 0 0
201 0 $query = "\x9c\xb7\x70\x02\x0a\x01\x03\x08\x0a\x05\x06\x13\x33\x36\x0c\x00\x00";
202 } elsif($heap->{jobs}->{$socket}->{action} eq 'detail') {
203 0 $query = "\x33\x8f\x02\x00\xff\xff\xff";
204 } else {
205 0 die("Unknown action!");
206 }
207 0 send($socket, "\xFE\xFD\x00" . $query, 0);
208 0 $heap->{jobs}->{$socket}->{timer} = $kernel->delay_set('response_timeout', $heap->{timeout}, $socket);
209 0 print STDERR "Wheel $wheelid got socket and sent request\n" if DEBUG;
210 }
211  
212 0 ▶sub got_response {
Subroutine got_response: not called CC=5 SCAR=34.0
Pod undocumented
213 0 my ($kernel, $heap, $socket) = @_[KERNEL, HEAP, ARG0];
214  
215 0 my $action = $heap->{jobs}->{$socket}->{action};
216  
217 0 $kernel->select_read($socket);
218 0 ▶ $kernel->alarm_remove($heap->{jobs}->{$socket}->{timer}) if defined $heap->{jobs}->{$socket}->{timer};
Branch: 1 branch
BranchTrueFalseTotal
if defined $heap->{"jobs"}{$socket}{"timer"} 0 0 0
219 0 delete $heap->{jobs}->{$socket}->{timer};
220 0 my $rsock = recv($socket, my $response = '', 16384, 0);
221  
222 0 my %data;
223 0 ▶ if($response eq '') {
Branch: 3 branches
BranchTrueFalseTotal
if ($response eq '') { } 0 0 0
elsif ($action eq 'info') { } 0 0 0
elsif ($action eq 'detail') { } 0 0 0
224 0 $data{ERROR} = 'DOWN';
225 } elsif($action eq 'info') {
226 0 $response = substr($response, 5);
227 0 my @parts = split(/\x00/, $response);
228 0 $data{'Hostname'} = $parts[0];
229 0 $data{'Version'} = $parts[1];
230 0 $data{'Players'} = $parts[2];
231 0 $data{'MaxPlayers'} = $parts[3];
232 0 $data{'Map'} = $parts[4];
233 0 $data{'Mode'} = $parts[5];
234 0 $data{'Password'} = $parts[6];
235 0 $data{'Dedicated'} = $parts[7];
236 0 $data{'Classic'} = $parts[8];
237 0 $data{'Teamplay'} = $parts[9];
238 } elsif($action eq 'detail') {
239 0 $response =~ s/\x00+$//;
240 0 my ($rules, $players, $score) = ($response =~ /^.{5}(.+?)\x00{3}[\x00-\x10](.+)\x00{2}[\x02\x00](.+$)/);
241 0 my @parts = split(/\x00/, $response);
242 0 %{$data{'Rules'}} = split(/\x00/, $rules);
243 0 $data{'PlayerFlags'} = decode_player_flags($data{'Rules'}{'player_flags'});
244 0 $data{'GameFlags'} = decode_game_flags($data{'Rules'}{'game_flags'});
245 0 $data{'Players'} = process_segment($players);
246 0 $data{'Score'} = process_segment($score);
247 } else {
248 0 die("Unknown request!");
249 }
250  
251 $kernel->post($heap->{jobs}->{$socket}->{session},
252 $heap->{jobs}->{$socket}->{postback},
253 $heap->{jobs}->{$socket}->{ip},
254 $heap->{jobs}->{$socket}->{port},
255 $heap->{jobs}->{$socket}->{action},
256 $heap->{jobs}->{$socket}->{identifier},
257 0 \%data);
258 0 delete($heap->{jobs}->{$socket});
259 }
260  
261 0 ▶sub decode_player_flags {
Subroutine decode_player_flags: not called CC=3 SCAR=24.8
Pod undocumented
262 0 my $str = shift;
263 0 my $flags = { };
264 0 ▶ return $flags if $str eq '' || $str !~ /^\d+\,\d+$/;
Branch: 1 branch
BranchTrueFalseTotal
if $str eq "" or not $str =~ /^\d+\,\d+$/ 0 0 0
Condition0%0/3
$str eq "" or not $str =~ /^\d+\,\d+$/
l!l&&r!l&&!r
000
MC/DC0%0/2
$str eq "" or not $str =~ /^\d+\,\d+$/
$str eq "" not $str =~ /^\d+\,\d+$/
Truth table0%0/3
A or not(B)
A= $str eq ""B= not $str =~ /^\d+\,\d+$/
ABresult
1X1
011
000
265  
266 0 my ($player, $vehicle) = split(/\,/, $str);
267  
268 0 $flags->{'Player'}->{'NumberOfLives'} = $player & 3;
269 0 $flags->{'Player'}->{'MaximumHealth'} = ($player >> 2) & 7;
270 0 $flags->{'Player'}->{'Shields'} = ($player >> 5) & 1;
271 0 $flags->{'Player'}->{'RespawnTime'} = ($player >> 6) & 3;
272 0 $flags->{'Player'}->{'RespawnGrowth'} = ($player >> 8) & 3;
273 0 $flags->{'Player'}->{'OddManOut'} = ($player >> 10) & 1;
274 0 $flags->{'Player'}->{'InvisiblePlayers'} = ($player >> 11) & 1;
275 0 $flags->{'Player'}->{'SuicidePenalty'} = ($player >> 12) & 3;
276 0 $flags->{'Player'}->{'InfiniteGrenades'} = ($player >> 14) & 1;
277 0 $flags->{'Player'}->{'WeaponSet'} = ($player >> 15) & 15;
278 0 $flags->{'Player'}->{'StartingEquipment'} = ($player >> 19) & 1;
279 0 $flags->{'Player'}->{'Indicator'} = ($player >> 20) & 3;
280 0 $flags->{'Player'}->{'OtherPlayersOnRadar'} = ($player >> 22) & 3;
281 0 $flags->{'Player'}->{'FriendIndicators'} = ($player >> 24) & 1;
282 0 $flags->{'Player'}->{'FriendlyFire'} = ($player >> 25) & 3;
283 0 $flags->{'Player'}->{'FriendlyFirePenalty'} = ($player >> 27) & 3;
284 0 $flags->{'Player'}->{'AutoTeamBalance'} = ($player >> 29) & 1;
285  
286 0 $flags->{'Team'}->{'VehicleRespawn'} = ($vehicle & 7);
287 0 $flags->{'Team'}->{'RedVehicleSet'} = ($vehicle >> 3) & 15;
288 0 $flags->{'Team'}->{'BlueVehicleSet'} = ($vehicle >> 7) & 15;
289  
290 0 return $flags;
291 }
292  
293 0 ▶sub decode_game_flags {
Subroutine decode_game_flags: not called CC=24 SCAR=64.0
Pod undocumented
294 0 my $str = shift;
295 0 my $flags = { };
296 0 ▶ return $flags if $str eq '' || $str !~ /^\d+$/;
Branch: 1 branch
BranchTrueFalseTotal
if $str eq "" or not $str =~ /^\d+$/ 0 0 0
Condition0%0/3
$str eq "" or not $str =~ /^\d+$/
l!l&&r!l&&!r
000
MC/DC0%0/2
$str eq "" or not $str =~ /^\d+$/
$str eq "" not $str =~ /^\d+$/
Truth table0%0/3
A or not(B)
A= $str eq ""B= not $str =~ /^\d+$/
ABresult
1X1
011
000
297  
298 0 $flags->{'GameType'} = $str & 7;
299 0 ▶ if($flags->{'GameType'} == 1) { # CTF
Branch: 5 branches
BranchTrueFalseTotal
if ($flags->{'GameType'} == 1) { } 0 0 0
elsif ($flags->{'GameType'} == 2) { } 0 0 0
elsif ($flags->{'GameType'} == 3) { } 0 0 0
elsif ($flags->{'GameType'} == 4) { } 0 0 0
elsif ($flags->{'GameType'} == 5) { } 0 0 0
300 0 ▶ $flags->{'Assault'} = ($str >> 3) && 1;
Condition0%0/2
$str >> 3 && 1
!ll
00
MC/DC0%0/1
$str >> 3 && 1
$str >> 3
Truth table0%0/2
A
A= $str >> 3
Aresult
00
11
301 0 ▶ $flags->{'FlagMustReset'} = ($str >> 5) && 1;
Condition0%0/2
$str >> 5 && 1
!ll
00
MC/DC0%0/1
$str >> 5 && 1
$str >> 5
Truth table0%0/2
A
A= $str >> 5
Aresult
00
11
302 0 ▶ $flags->{'FlagAtHomeToScore'} = ($str >> 6) && 1;
Condition0%0/2
$str >> 6 && 1
!ll
00
MC/DC0%0/1
$str >> 6 && 1
$str >> 6
Truth table0%0/2
A
A= $str >> 6
Aresult
00
11
303 0 ▶ $flags->{'SingleFlag'} = ($str >> 7) && 7;
Condition0%0/2
$str >> 7 && 7
!ll
00
MC/DC0%0/1
$str >> 7 && 7
$str >> 7
Truth table0%0/2
A
A= $str >> 7
Aresult
00
11
304 } elsif($flags->{'GameType'} == 2) { # Slayer
305 0 ▶ $flags->{'DeathBonus'} = ($str >> 3) && 1;
Condition0%0/2
$str >> 3 && 1
!ll
00
MC/DC0%0/1
$str >> 3 && 1
$str >> 3
Truth table0%0/2
A
A= $str >> 3
Aresult
00
11
306 0 ▶ $flags->{'KillPenalty'} = ($str >> 5) && 1;
Condition0%0/2
$str >> 5 && 1
!ll
00
MC/DC0%0/1
$str >> 5 && 1
$str >> 5
Truth table0%0/2
A
A= $str >> 5
Aresult
00
11
307 0 ▶ $flags->{'KillInOrder'} = ($str >> 6) && 1;
Condition0%0/2
$str >> 6 && 1
!ll
00
MC/DC0%0/1
$str >> 6 && 1
$str >> 6
Truth table0%0/2
A
A= $str >> 6
Aresult
00
11
308 } elsif($flags->{'GameType'} == 3) { # Oddball
309 0 ▶ $flags->{'RandomStart'} = ($str >> 3) && 1;
Condition0%0/2
$str >> 3 && 1
!ll
00
MC/DC0%0/1
$str >> 3 && 1
$str >> 3
Truth table0%0/2
A
A= $str >> 3
Aresult
00
11
310 0 ▶ $flags->{'SpeedWithBall'} = ($str >> 5) && 3;
Condition0%0/2
$str >> 5 && 3
!ll
00
MC/DC0%0/1
$str >> 5 && 3
$str >> 5
Truth table0%0/2
A
A= $str >> 5
Aresult
00
11
311 0 ▶ $flags->{'TraitWithBall'} = ($str >> 7) && 3;
Condition0%0/2
$str >> 7 && 3
!ll
00
MC/DC0%0/1
$str >> 7 && 3
$str >> 7
Truth table0%0/2
A
A= $str >> 7
Aresult
00
11
312 0 ▶ $flags->{'TraitWithoutBall'} = ($str >> 9) && 3;
Condition0%0/2
$str >> 9 && 3
!ll
00
MC/DC0%0/1
$str >> 9 && 3
$str >> 9
Truth table0%0/2
A
A= $str >> 9
Aresult
00
11
313 0 ▶ $flags->{'BallType'} = ($str >> 11) && 3;
Condition0%0/2
$str >> 11 && 3
!ll
00
MC/DC0%0/1
$str >> 11 && 3
$str >> 11
Truth table0%0/2
A
A= $str >> 11
Aresult
00
11
314 0 ▶ $flags->{'BallSpawnCount'} = ($str >> 13) && 31;
Condition0%0/2
$str >> 13 && 31
!ll
00
MC/DC0%0/1
$str >> 13 && 31
$str >> 13
Truth table0%0/2
A
A= $str >> 13
Aresult
00
11
315 } elsif($flags->{'GameType'} == 4) { # Hill
316 0 ▶ $flags->{'MovingHill'} = ($str >> 3) && 1;
Condition0%0/2
$str >> 3 && 1
!ll
00
MC/DC0%0/1
$str >> 3 && 1
$str >> 3
Truth table0%0/2
A
A= $str >> 3
Aresult
00
11
317 } elsif($flags->{'GameType'} == 5) { # Race
318 0 ▶ $flags->{'RaceType'} = ($str >> 3) && 3;
Condition0%0/2
$str >> 3 && 3
!ll
00
MC/DC0%0/1
$str >> 3 && 3
$str >> 3
Truth table0%0/2
A
A= $str >> 3
Aresult
00
11
319 0 ▶ $flags->{'TeamScoring'} = ($str >> 5) && 3;
Condition0%0/2
$str >> 5 && 3
!ll
00
MC/DC0%0/1
$str >> 5 && 3
$str >> 5
Truth table0%0/2
A
A= $str >> 5
Aresult
00
11
320 }
321  
322 0 return $flags;
323 }
324  
325 0 ▶sub halo_player_flag {
Subroutine halo_player_flag: not called CC=3 SCAR=24.8
Pod undocumented
326 0 my ($flag_name, $flag_value) = (shift, shift);
327  
328 0 ▶ if(defined($player_flags->{$flag_name}) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $POE::Component::Client::Halo::player_flags->{$flag_name} and defined $POE::Component::Client::Halo::player_flags->{$flag_name}[$flag_value]) { } 0 0 0
Condition0%0/3
defined $POE::Component::Client::Halo::player_flags->{$flag_name} and defined $POE::Component::Client::Halo::player_flags->{$flag_name}[$flag_value]
!ll&&!rl&&r
000
MC/DC0%0/2
defined $POE::Component::Client::Halo::player_flags->{$flag_name} and defined $POE::Component::Client::Halo::player_flags->{$flag_name}[$flag_value]
defined $POE::Component::Client::Halo::player_flags->{$flag_name} defined $POE::Component::Client::Halo::player_flags->{$flag_name}[$flag_value]
Truth table0%0/3
A and B
A= defined $POE::Component::Client::Halo::player_flags->{$flag_name}B= defined $POE::Component::Client::Halo::player_flags->{$flag_name}[$flag_value]
ABresult
0X0
100
111
329 defined($player_flags->{$flag_name}->[$flag_value])) {
330 0 return $player_flags->{$flag_name}->[$flag_value];
331 } else {
332 0 return undef;
333 }
334 }
335  
336 0 ▶sub halo_game_flag {
Subroutine halo_game_flag: not called CC=3 SCAR=24.8
Pod undocumented
337 0 my ($flag_name, $flag_value) = (shift, shift);
338  
339 0 ▶ if(defined($game_flags->{$flag_name}) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $POE::Component::Client::Halo::game_flags->{$flag_name} and defined $POE::Component::Client::Halo::game_flags->{$flag_name}[$flag_value]) { } 0 0 0
Condition0%0/3
defined $POE::Component::Client::Halo::game_flags->{$flag_name} and defined $POE::Component::Client::Halo::game_flags->{$flag_name}[$flag_value]
!ll&&!rl&&r
000
MC/DC0%0/2
defined $POE::Component::Client::Halo::game_flags->{$flag_name} and defined $POE::Component::Client::Halo::game_flags->{$flag_name}[$flag_value]
defined $POE::Component::Client::Halo::game_flags->{$flag_name} defined $POE::Component::Client::Halo::game_flags->{$flag_name}[$flag_value]
Truth table0%0/3
A and B
A= defined $POE::Component::Client::Halo::game_flags->{$flag_name}B= defined $POE::Component::Client::Halo::game_flags->{$flag_name}[$flag_value]
ABresult
0X0
100
111
340 defined($game_flags->{$flag_name}->[$flag_value])) {
341 0 return $game_flags->{$flag_name}->[$flag_value];
342 } else {
343 0 return undef;
344 }
345 }
346  
347 0 ▶sub response_timeout {
Subroutine response_timeout: not called CC=4 SCAR=30.0
Pod undocumented
348 0 my ($kernel, $heap, $socket) = @_[KERNEL, HEAP, ARG0];
349 0 ▶ if($heap->{jobs}->{$socket}->{try} > ($heap->{retry} + 1)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($heap->{'jobs'}{$socket}{'try'} > $heap->{'retry'} + 1) { } 0 0 0
350 $kernel->post($heap->{jobs}->{$socket}->{session}, $heap->{jobs}->{$socket}->{postback},
351 $heap->{jobs}->{$socket}->{ip},
352 $heap->{jobs}->{$socket}->{port},
353 $heap->{jobs}->{$socket}->{action},
354 $heap->{jobs}->{$socket}->{identifier},
355 0 { 'ERROR' => 'Timed out waiting for a response.'});
356 0 delete($heap->{jobs}->{$socket});
357 } else {
358 0 print STDERR "Query timed out for $socket. Retrying.\n" if DEBUG;
359 0 my $query = '';
360 0 ▶ if($heap->{jobs}->{$socket}->{action} eq 'info') {
Branch: 2 branches
BranchTrueFalseTotal
if ($heap->{'jobs'}{$socket}{'action'} eq 'info') { } 0 0 0
elsif ($heap->{'jobs'}{$socket}{'action'} eq 'detail') { } 0 0 0
361 0 $query = "\x9c\xb7\x70\x02\x0a\x01\x03\x08\x0a\x05\x06\x13\x33\x36\x0c\x00\x00";
362 } elsif($heap->{jobs}->{$socket}->{action} eq 'detail') {
363 0 $query = "\x33\x8f\x02\x00\xff\xff\xff";
364 } else {
365 0 die("Unknown action!");
366 }
367 0 send($socket, "\xFE\xFD\x00" . $query, 0);
368 0 $heap->{jobs}->{$socket}->{timer} = $kernel->delay_set('response_timeout', $heap->{timeout}, $socket);
369 0 $heap->{jobs}->{$socket}->{try}++;
370 }
371 }
372  
373 0 ▶sub process_segment {
Subroutine process_segment: not called CC=5 SCAR=34.0
Pod undocumented
374 0 my $str = shift;
375  
376 0 my @parts = split(/\x00/, $str);
377 0 my @fields = ();
378 0 foreach(@parts) {
379 0 ▶ last if $_ eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $_ eq "" 0 0 0
380 0 s/_.*$//;
381 0 push(@fields, $_);
382 }
383 0 my $info = {};
384 0 my $ctr = 0;
385 0 my $cur_item = '';
386 0 foreach(splice(@parts, scalar(@fields) + 1)) {
387 0 ▶ if($ctr % scalar(@fields) == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ctr % scalar(@fields) == 0) { } 0 0 0
388 0 $cur_item = $_;
389 0 $info->{$cur_item}->{$fields[0]} = $cur_item;
390 } else {
391 0 $info->{$cur_item}->{$fields[$ctr % scalar(@fields)]} = $_;
392 }
393 0 $ctr++;
394 }
395 0 return $info;
396 }
397  
398 1 1;
399  
400 __END__
↑ Summary sample.pl »