Rcon.pm

filter: Statementstmt 14.1% 21 / 148 Branchbran 0.0% 0 / 66 Conditioncond 0.0% 0 / 27 MC/DCmcdc 0.0% 0 / 18 Subroutinesub 31.5% 6 / 19 Podpod 16.6% 2 / 12 totaltotal 10.0% 29 / 290 CC 45 SCAR 39.5
CC
45
Cov
9%
new
110.0
rcon
110.0
players
72.0
CRAP 51.9
↑ Summary sample.pl »
1 package POE::Component::Client::Rcon;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use vars qw($VERSION $playerSN);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 $VERSION = '0.23';
7 1 $playerSN = 0;
8  
9 1 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Socket;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Time::HiRes qw(time);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use POE qw(Session Wheel::SocketFactory);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 sub DEBUG () { 0 };
15  
16 0 ▶sub new {
Subroutine new: not called CC=10 SCAR=47.0
Pod undocumented
17 0 my $type = shift;
18 0 my $self = bless {}, $type;
19  
20 0 ▶ croak "$type requires an event number of parameters" if @_ % 2;
Branch: 1 branch
BranchTrueFalseTotal
if @_ % 2 0 0 0
21  
22 0 my %params = @_;
23  
24 0 my $alias = delete $params{Alias};
25 0 ▶ $alias = 'rcon' unless defined $alias;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $alias 0 0 0
26  
27 0 my $timeout = delete $params{Timeout};
28 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
29  
30 0 my $retry = delete $params{Retry};
31 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
32  
33 0 my $bytes = delete $params{Bytes};
34 0 ▶ $bytes = 8192 unless defined $bytes and $bytes > 0;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $bytes and $bytes > 0 0 0 0
Condition0%0/3
defined $bytes and $bytes > 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $bytes and $bytes > 0
defined $bytes $bytes > 0
Truth table0%0/3
A and B
A= defined $bytesB= $bytes > 0
ABresult
0X0
100
111
35  
36 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
37  
38 0 POE::Session->create(
39 inline_states => {
40 _start => \&_start,
41 rcon => \&rcon,
42 got_socket => \&got_socket,
43 got_message => \&got_message,
44 got_error => \&got_error,
45 got_challenge => \&got_challenge,
46 got_rcon_response => \&got_rcon_response,
47 challenge_timeout => \&challenge_timeout,
48 rcon_timeout => \&rcon_timeout,
49 players => \&players,
50 player_response => \&player_response,
51 player_parse_hl => \&player_parse_hl,
52 player_parse_quake => \&player_parse_quake,
53 },
54 args => [ $timeout, $retry, $alias, $bytes ],
55 );
56  
57 0 return $self;
58 }
59  
60 0 ▶sub _start {
Subroutine _start: not called CC=1 SCAR=6.9
61 0 my ($kernel, $heap, $timeout, $retry, $alias, $bytes) = @_[KERNEL, HEAP, ARG0..ARG3];
62 0 $heap->{timeout} = $timeout;
63 0 $heap->{retry} = $retry;
64 0 $heap->{bytes} = $bytes;
65 0 $kernel->alias_set($alias);
66 0 print STDERR "Rcon object started.\n" if DEBUG;
67 }
68  
69 0 ▶sub rcon {
Subroutine rcon: not called CC=10 SCAR=47.0
Pod documented
70 0 my ($kernel, $heap, $sender, $type, $ip, $port, $pw, $cmd, $postback) = @_[KERNEL, HEAP, SENDER, ARG0..ARG5];
71 0 ▶ my ($identifier) = defined($_[ARG6]) ? $_[ARG6] : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $_[16] ? : 0 0 0
72 0 print STDERR "Got $ip:$port with password $pw running command $cmd with postback $postback\n" if DEBUG;
73 0 ▶ croak "IP address required to execute an Rcon command" unless defined $ip;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ip 0 0 0
74 0 ▶ croak "Port requred to execute an Rcon command" 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
75 0 ▶ croak "Password requires to execute an Rcon command" if !defined $pw || $pw eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $pw or $pw eq "" 0 0 0
Condition0%0/3
not defined $pw or $pw eq ""
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $pw or $pw eq ""
not defined $pw $pw eq ""
Truth table0%0/3
not(A) or B
A= not defined $pwB= $pw eq ""
ABresult
1X1
011
000
76 0 ▶ croak "Command required to execute an Rcon command" if !defined $cmd || $cmd eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $cmd or $cmd eq "" 0 0 0
Condition0%0/3
not defined $cmd or $cmd eq ""
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $cmd or $cmd eq ""
not defined $cmd $cmd eq ""
Truth table0%0/3
not(A) or B
A= not defined $cmdB= $cmd eq ""
ABresult
1X1
011
000
77 0 ▶ croak "Server type was not recognized" unless $type =~ /^(?:qw|q2|q3|oldhl|hl)$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $type =~ /^(?:qw|q2|q3|oldhl|hl)$/ 0 0 0
78 0 my $challenge = '';
79 0 my $wheel = POE::Wheel::SocketFactory->new(
80 RemoteAddress => $ip,
81 RemotePort => $port,
82 SocketProtocol => 'udp',
83 SuccessEvent => 'got_socket',
84 FailureEvent => 'got_error',
85 );
86 0 $heap->{w_jobs}->{$wheel->ID()} = {
87 ip => $ip,
88 port => $port,
89 pw => $pw,
90 cmd => $cmd,
91 postback => $postback,
92 session => $sender->ID(),
93 wheel => $wheel,
94 identifier => $identifier,
95 type => $type,
96 try => 1, # number of tries...
97 };
98 0 return undef;
99 }
100  
101 0 ▶sub got_error {
Subroutine got_error: not called CC=1 SCAR=6.9
Pod undocumented
102 0 my ($operation, $errnum, $errstr, $wheel_id, $heap) = @_[ARG0..ARG3,HEAP];
103 0 warn "Wheel $wheel_id generated $operation error $errnum: $errstr\n";
104 0 delete $heap->{w_jobs}->{$wheel_id}; # shut down that wheel
105 }
106  
107 0 ▶sub got_socket {
Subroutine got_socket: not called CC=2 SCAR=17.9
Pod undocumented
108 0 my ($kernel, $heap, $socket, $wheelid) = @_[KERNEL, HEAP, ARG0, ARG3];
109  
110 0 $heap->{jobs}->{$socket} = delete($heap->{w_jobs}->{$wheelid});
111 0 ▶ if($heap->{jobs}->{$socket}->{type} eq 'hl') {
Branch: 1 branch
BranchTrueFalseTotal
if ($heap->{'jobs'}{$socket}{'type'} eq 'hl') { } 0 0 0
112 0 $kernel->select_read($socket, 'got_challenge');
113 0 send($socket, "\xFF\xFF\xFF\xFFchallenge rcon\n\0", 0);
114 0 $heap->{jobs}->{$socket}->{timer} = $kernel->delay_set('challenge_timeout', $heap->{timeout}, $socket);
115 0 print STDERR "Wheel $wheelid got socket and sent rcon challenge\n" if DEBUG;
116 } else {
117 0 $kernel->yield('got_challenge', $socket);
118 }
119 }
120  
121 0 ▶sub got_challenge {
Subroutine got_challenge: not called CC=4 SCAR=30.0
Pod undocumented
122 0 my ($kernel, $heap, $socket) = @_[KERNEL, HEAP, ARG0];
123  
124 0 ▶ if($heap->{jobs}->{$socket}->{type} eq 'hl') {
Branch: 1 branch
BranchTrueFalseTotal
if ($heap->{'jobs'}{$socket}{'type'} eq 'hl') { } 0 0 0
125 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
126 0 delete($heap->{jobs}->{$socket}->{timer});
127 0 $kernel->select_read($socket);
128 0 recv($socket, my $response = '', 8192, 0);
129
130 0 print STDERR "got_challenge got the response \"$response\" for $socket\n" if DEBUG;
131 0 ▶ if($response =~ /challenge +rcon +(\d+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response =~ /challenge +rcon +(\d+)/) { } 0 0 0
132 0 $heap->{jobs}->{$socket}->{challenge} = $1;
133 0 $kernel->select_read($socket, 'got_rcon_response');
134 0 send($socket, "\xFF\xFF\xFF\xFFrcon $1 \"" . $heap->{jobs}->{$socket}->{pw} . "\" " . $heap->{jobs}->{$socket}->{cmd} . "\0", 0);
135 0 $heap->{jobs}->{$socket}->{timer} = $kernel->delay_set('rcon_timeout', $heap->{timeout}, $socket);
136 0 print STDERR "Got rcon response and sent rcon command\n" if DEBUG;
137 } else {
138 $kernel->post($heap->{jobs}->{$socket}->{session}, $heap->{jobs}->{$socket}->{postback},
139 $heap->{jobs}->{$socket}->{type}.
140 $heap->{jobs}->{$socket}->{ip},
141 $heap->{jobs}->{$socket}->{port},
142 $heap->{jobs}->{$socket}->{cmd},
143 $heap->{jobs}->{$socket}->{identifier},
144 0 'ERROR: No challenge receieved from server.');
145 0 delete($heap->{jobs}->{$socket});
146 }
147 } else {
148 0 $kernel->select_read($socket, 'got_rcon_response');
149 0 send($socket, "\xFF\xFF\xFF\xFFrcon \"" . $heap->{jobs}->{$socket}->{pw} . "\" " . $heap->{jobs}->{$socket}->{cmd} . "\0", 0);
150 0 $heap->{jobs}->{$socket}->{timer} = $kernel->delay_set('rcon_timeout', $heap->{timeout}, $socket);
151 0 print STDERR "Got socket and sent rcon command\n" if DEBUG;
152 }
153 }
154  
155 0 ▶sub got_rcon_response {
Subroutine got_rcon_response: not called CC=3 SCAR=24.8
Pod undocumented
156 0 my ($kernel, $heap, $socket) = @_[KERNEL, HEAP, ARG0];
157  
158 0 $kernel->select_read($socket);
159 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
160 0 delete $heap->{jobs}->{$socket}->{timer};
161 0 my $rsock = recv($socket, my $response = '', $heap->{bytes}, 0);
162  
163 0 ▶ if($response =~ /bad (?:rconpassword|rcon_password)/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response =~ /bad (?:rconpassword|rcon_password)/i) { } 0 0 0
164 $kernel->post($heap->{jobs}->{$socket}->{session}, $heap->{jobs}->{$socket}->{postback},
165 $heap->{jobs}->{$socket}->{type},
166 $heap->{jobs}->{$socket}->{ip},
167 $heap->{jobs}->{$socket}->{port},
168 $heap->{jobs}->{$socket}->{cmd},
169 $heap->{jobs}->{$socket}->{identifier},
170 0 'ERROR: Bad Rcon password.');
171 } else {
172 # following regex's thanks to kkrcon
173 0 $response =~ s/\x00+$//; # terminator
174 0 $response =~ s/^\xff\xff\xff\xffl//; # new HL
175 0 $response =~ s/^\xff\xff\xff\xffn//; # qw
176 0 $response =~ s/^\xff\xff\xff\xff//; # q2/q3
177 0 $response =~ s/^\xfe\xff\xff\xff.....//; # old hl bug
178 $kernel->post($heap->{jobs}->{$socket}->{session}, $heap->{jobs}->{$socket}->{postback},
179 $heap->{jobs}->{$socket}->{type},
180 $heap->{jobs}->{$socket}->{ip},
181 $heap->{jobs}->{$socket}->{port},
182 $heap->{jobs}->{$socket}->{cmd},
183 $heap->{jobs}->{$socket}->{identifier},
184 0 $response);
185 0 print STDERR "Rcon Response was $response\n" if DEBUG;
186 }
187 0 delete($heap->{jobs}->{$socket});
188 }
189  
190 0 ▶sub challenge_timeout {
Subroutine challenge_timeout: not called CC=2 SCAR=17.9
Pod undocumented
191 0 my ($kernel, $heap, $socket) = @_[KERNEL, HEAP, ARG0];
192 0 ▶ if($heap->{jobs}->{$socket}->{try} > ($heap->{retry} + 1)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($heap->{'jobs'}{$socket}{'try'} > $heap->{'retry'} + 1) { } 0 0 0
193 $kernel->post($heap->{jobs}->{$socket}->{session}, $heap->{jobs}->{$socket}->{postback},
194 $heap->{jobs}->{$socket}->{type},
195 $heap->{jobs}->{$socket}->{ip},
196 $heap->{jobs}->{$socket}->{port},
197 $heap->{jobs}->{$socket}->{cmd},
198 $heap->{jobs}->{$socket}->{identifier},
199 0 'ERROR: Timed out trying to obtain challenge.');
200 } else {
201 0 print STDERR "Challenge request timed out for $socket. Retrying.\n" if DEBUG;
202 0 send($socket, "\xFF\xFF\xFF\xFFchallenge rcon\n\0", 0);
203 0 $heap->{jobs}->{$socket}->{timer} = $kernel->delay_set('challenge_timeout', $heap->{timeout}, $socket);
204 0 $heap->{jobs}->{$socket}->{try}++;
205 }
206 }
207  
208 0 ▶sub rcon_timeout {
Subroutine rcon_timeout: not called CC=4 SCAR=30.0
Pod undocumented
209 0 my ($kernel, $heap, $socket) = @_[KERNEL, HEAP, ARG0];
210 0 ▶ if($heap->{jobs}->{$socket}->{try} > ($heap->{retry} + 1)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($heap->{'jobs'}{$socket}{'try'} > $heap->{'retry'} + 1) { } 0 0 0
211 $kernel->post($heap->{jobs}->{$socket}->{session}, $heap->{jobs}->{$socket}->{postback},
212 $heap->{jobs}->{$socket}->{type},
213 $heap->{jobs}->{$socket}->{ip},
214 $heap->{jobs}->{$socket}->{port},
215 $heap->{jobs}->{$socket}->{cmd},
216 $heap->{jobs}->{$socket}->{identifier},
217 0 'ERROR: Timed out waiting for Rcon response.');
218 } else {
219 0 print STDERR "Rcon timed out for $socket. Retrying.\n" if DEBUG;
220 0 ▶ send($socket, "\xFF\xFF\xFF\xFFrcon " . $heap->{jobs}->{$socket}->{challenge} . " \"" . $heap->{jobs}->{$socket}->{pw} . "\" " . $heap->{jobs}->{$socket}->{cmd} . "\0", 0) if $heap->{jobs}->{$socket}->{type} =~ /hl$/;
Branch: 1 branch
BranchTrueFalseTotal
if $heap->{"jobs"}{$socket}{"type"} =~ /hl$/ 0 0 0
221 0 ▶ send($socket, "\xFF\xFF\xFF\xFFrcon \"" . $heap->{jobs}->{$socket}->{pw} . "\" " . $heap->{jobs}->{$socket}->{cmd} . "\0", 0) if $heap->{jobs}->{$socket}->{type} =~ /^(?:q2|q3|qw)$/;
Branch: 1 branch
BranchTrueFalseTotal
if $heap->{"jobs"}{$socket}{"type"} =~ /^(?:q2|q3|qw)$/ 0 0 0
222 0 $heap->{jobs}->{$socket}->{timer} = $kernel->delay_set('rcon_timeout', $heap->{timeout}, $socket);
223 0 $heap->{jobs}->{$socket}->{try}++;
224 }
225 }
226  
227 0 ▶sub players {
Subroutine players: not called CC=8 SCAR=42.8
Pod documented
228 0 my ($kernel, $heap, $sender, $type, $ip, $port, $password, $postback) = @_[KERNEL, HEAP, SENDER, ARG0..ARG4];
229 0 ▶ my $identifier = defined($_[ARG5]) ? $_[ARG5] : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $_[15] ? : 0 0 0
230 0 ▶ croak "IP address required to execute an Rcon command" unless defined $ip;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ip 0 0 0
231 0 ▶ croak "Port requred to execute an Rcon command" 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
232 0 ▶ croak "Password requires to execute an Rcon command" if !defined $password || $password eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $password or $password eq "" 0 0 0
Condition0%0/3
not defined $password or $password eq ""
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $password or $password eq ""
not defined $password $password eq ""
Truth table0%0/3
not(A) or B
A= not defined $passwordB= $password eq ""
ABresult
1X1
011
000
233 0 ▶ croak "Server type was not recognized" unless $type =~ /^(?:qw|q2|q3|oldhl|hl)$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $type =~ /^(?:qw|q2|q3|oldhl|hl)$/ 0 0 0
234 0 my $jobid = $playerSN;
235 0 $playerSN++;
236 0 print STDERR "Got a request for players at $ip:$port with jobid $jobid\n" if DEBUG;
237 0 $kernel->yield('rcon', $type, $ip, $port, $password, 'status', 'player_response', $jobid);
238 0 $heap->{p_jobs}->{$jobid} = {
239 ip => $ip,
240 port => $port,
241 pw => $password,
242 identifier => $identifier,
243 session => $sender->ID(),
244 postback => $postback,
245 type => $type,
246 };
247 }
248  
249 0 ▶sub player_response {
Subroutine player_response: not called CC=4 SCAR=30.0
Pod undocumented
250 0 my ($kernel, $heap, $jobid, $response) = @_[KERNEL, HEAP, ARG4, ARG5];
251 0 print STDERR "Got a player request response for job $jobid\n" if DEBUG;
252 0 ▶ if($response =~ /^ERROR\: /) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response =~ /^ERROR\: /) { } 0 0 0
253 $kernel->post($heap->{p_jobs}->{$jobid}->{session},
254 $heap->{p_jobs}->{$jobid}->{postback},
255 $heap->{p_jobs}->{$jobid}->{type},
256 $heap->{p_jobs}->{$jobid}->{ip},
257 $heap->{p_jobs}->{$jobid}->{port},
258 $heap->{p_jobs}->{$jobid}->{identifier},
259 0 $response
260 ); # One of the errors generated from the rcon command...
261 } else {
262 0 ▶ if($heap->{p_jobs}->{$jobid}->{type} =~ /hl$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($heap->{'p_jobs'}{$jobid}{'type'} =~ /hl$/) { } 0 0 0
elsif ($heap->{'p_jobs'}{$jobid}{'type'} =~ /^(?:q2|q3|qw)$/) { } 0 0 0
263 0 $kernel->yield('player_parse_hl', $jobid, $response);
264 } elsif($heap->{p_jobs}->{$jobid}->{type} =~ /^(?:q2|q3|qw)$/) {
265 0 $kernel->yield('player_parse_quake', $jobid, $response);
266 }
267 }
268 }
269  
270 0 ▶sub player_parse_hl {
Subroutine player_parse_hl: not called CC=3 SCAR=24.8
Pod undocumented
271 0 my ($kernel, $heap, $jobid, $response) = @_[KERNEL, HEAP, ARG0, ARG1];
272 # This code is partially adapted from KKrcon
273 0 my %players;
274 0 foreach(split(/[\r\n]+/, $response)) {
275 0 ▶ if(/^\#[\s\d]\d\s+
Branch: 1 branch
BranchTrueFalseTotal
if (/^\#[\s\d]\d\s+ (?:\")(.+)(?:\")\s+ # Player name (\d+)\s+ # Player ID (\d+)\s+ # WonID ([\d-]+)\s+ # Frag count ([\d:]+)\s+ # time (\d+)\s+ # ping (\d+)\s+ # packetloss (\S+) # ip:port $/x) 0 0 0
276 (?:\")(.+)(?:\")\s+ # Player name
277 (\d+)\s+ # Player ID
278 (\d+)\s+ # WonID
279 ([\d-]+)\s+ # Frag count
280 ([\d:]+)\s+ # time
281 (\d+)\s+ # ping
282 (\d+)\s+ # packetloss
283 (\S+) # ip:port
284 $/x) {
285 0 $players{$2} = {
286 "Name" => $1,
287 "UserID" => $2,
288 "WonID" => $3,
289 "Frags" => $4,
290 "Time" => $5,
291 "Ping" => $6,
292 "Loss" => $7,
293 "Address" => $8,
294 };
295 }
296 }
297 $kernel->post($heap->{p_jobs}->{$jobid}->{session},
298 $heap->{p_jobs}->{$jobid}->{postback},
299 $heap->{p_jobs}->{$jobid}->{type},
300 $heap->{p_jobs}->{$jobid}->{ip},
301 $heap->{p_jobs}->{$jobid}->{port},
302 $heap->{p_jobs}->{$jobid}->{identifier},
303 0 \%players
304 );
305 0 delete($heap->{p_jobs}->{$jobid});
306 }
307  
308 0 ▶sub player_parse_quake {
Subroutine player_parse_quake: not called CC=5 SCAR=34.0
Pod undocumented
309 0 my ($kernel, $heap, $jobid, $response) = @_[KERNEL, HEAP, ARG0, ARG1];
310 0 my %players;
311 0 foreach(split(/[\r\n]+/, $response)) {
312 0 ▶ if(/^\s*
Branch: 1 branch
BranchTrueFalseTotal
if (/^\s* (\d+)\s+ # num ([\d-]+)\s+ # score (\d+)\s+ # ping (.+) # name \s+(\d+)\s+ # lastmsg (\S+)\s+ # address (\d+) # qport (?:\s+(\d+)|) # rate $/x) 0 0 0
313 (\d+)\s+ # num
314 ([\d-]+)\s+ # score
315 (\d+)\s+ # ping
316 (.+) # name
317 \s+(\d+)\s+ # lastmsg
318 (\S+)\s+ # address
319 (\d+) # qport
320 (?:\s+(\d+)|) # rate
321 $/x) {
322 0 $players{$1} = {
323 "num" => $1,
324 "score" => $2,
325 "ping" => $3,
326 "name" => $4,
327 "lastmsg" => $5,
328 "address" => $6,
329 "qport" => $7,
330 };
331 0 ▶ if(defined($8) && $8 ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $8 and $8 ne "") 0 0 0
Condition0%0/3
defined $8 and $8 ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $8 and $8 ne ""
defined $8 $8 ne ""
Truth table0%0/3
A and B
A= defined $8B= $8 ne ""
ABresult
0X0
100
111
332 0 $players{$1}{"rate"} = $8;
333 }
334 }
335 }
336 $kernel->post($heap->{p_jobs}->{$jobid}->{session},
337 $heap->{p_jobs}->{$jobid}->{postback},
338 $heap->{p_jobs}->{$jobid}->{type},
339 $heap->{p_jobs}->{$jobid}->{ip},
340 $heap->{p_jobs}->{$jobid}->{port},
341 $heap->{p_jobs}->{$jobid}->{identifier},
342 0 \%players
343 );
344 0 delete($heap->{p_jobs}->{$jobid});
345 }
346 1 1;
347  
348 __END__
↑ Summary sample.pl »