-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcomp_up.pl
executable file
·117 lines (95 loc) · 2.02 KB
/
comp_up.pl
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/bin/perl
#
# Update OLC comps
#
# Geoff Wong 2007-2019
#
require DBD::mysql;
use POSIX qw(ceil floor);
#use Data::Dumper;
use TrackLib qw(:all);
use Defines qw(:all);
use strict;
my $dbh;
sub round
{
my ($number) = @_;
return int($number + .5);
}
#
# Find the task totals and update ..
# tasTotalDistanceFlown, tasPilotsLaunched, tasPilotsTotal
# tasPilotsGoal, tasPilotsLaunched,
#
sub track_update
{
my ($comPk, $ctype, $opt) = @_;
my @tracks;
my $flag;
my $out;
my $ref;
my $retv;
# Now check for pre-submitted tracks ..
my $sth = $dbh->prepare("select traPk from tblComTaskTrack where comPk=$comPk order by traPk");
$sth->execute();
my $tracks = ();
$flag = 1;
while ($ref = $sth->fetchrow_hashref())
{
push @tracks, $ref->{'traPk'};
}
# Re-optimising pre-submitted tracks against the task
for my $tpk (@tracks)
{
print "Re-optimise pre-submitted track ($ctype): $tpk\n";
$out = '';
$retv = 0;
$out = `${Defines::BINDIR}optimise_flight.pl $tpk $comPk 0 $opt`;
print $out;
if ($ctype eq 'airgain-count')
{
$out = `${Defines::BINDIR}airgain_verify.pl $tpk $comPk`;
print $out;
}
}
return $flag;
}
#
# Main program here ..
#
my $dist;
my $comPk;
my $task;
my $quality;
my $pth;
my $out;
my $formula;
my $comp;
if (scalar @ARGV < 1)
{
print "comp_up.pl <comPk>\n";
exit 1;
}
$comPk = 0 + $ARGV[0];
if ($comPk < 1)
{
print "comp_up.pl <comPk>\n";
exit 1;
}
# Work out all the task totals to make it easier later
$dbh = db_connect();
$comp = read_competition($comPk);
$formula = read_formula($comPk);
if ($comp->{'type'} ne 'OLC')
{
print "Not an OLC type competition\n";
exit 1;
}
if (track_update($comPk, $formula->{'version'}, $formula->{'olcpoints'}) == 1)
{
print("tracks re-verified - now rescore.");
#$pth = $BINDIR . 'task_score.pl';
#$out = `$pth $tasPk`;
#print $out;
}
#print "Task dist=$dist\n";