$c->stash(u => $dbh->selectrow_hashref(q{SELECT pid AS planet,defense_points
,attack_points,scan_points,humor_points
, (attack_points+defense_points+scan_points/20)::NUMERIC(5,1) as total_points
- , sms,rank,hostmask,call_if_needed,sms_note,defprio
+ , rank,defprio
FROM users_defprio WHERE uid = ?
},undef,$c->user->id)
);
},undef,$c->user->planet)
);
- my $calls = $dbh->prepare(q{
-SELECT * FROM defcalls
-WHERE uid = $1 AND landing_tick >= tick()
-ORDER BY landing_tick DESC
- });
- $calls->execute($c->user->id);
- $c->stash(calls => $calls->fetchall_arrayref({}) );
-
$c->stash(fleets => member_fleets($dbh, $c->user->id,$c->user->planet));
my $announcements = $dbh->prepare(q{SELECT ft.ftid, u.username,ft.subject,
LEFT OUTER JOIN (SELECT * FROM forum_thread_visits WHERE uid = $1) ftv ON ftv.ftid = ft.ftid
WHERE ft.fbid = 1
GROUP BY ft.ftid, ft.subject,ft.sticky,u.username
- HAVING count(NULLIF(COALESCE(ft.sticky OR fp.time > ftv.time,TRUE),FALSE)) >= 1
+ HAVING count(NULLIF(COALESCE(fp.time > ftv.time,TRUE),FALSE)) >= 1
ORDER BY sticky DESC,last_post DESC
});
$announcements->execute($c->user->id);
}
-sub posthostupdate : Local {
- my ( $self, $c ) = @_;
- my $dbh = $c->model;
-
- $dbh->do(q{UPDATE users SET hostmask = ? WHERE uid = ?
- },undef, html_escape $c->req->param('hostname'), $c->user->id);
-
- $c->res->redirect($c->uri_for(''));
-}
-
sub postattackgroups : Local {
my ( $self, $c ) = @_;
my $dbh = $c->model;
$c->res->redirect($c->uri_for(''));
}
-sub postsmsupdate : Local {
- my ( $self, $c ) = @_;
- my $dbh = $c->model;
-
- my $callme = $c->req->param('callme') || 0;
- $dbh->do(q{
-UPDATE users SET sms = $1, call_if_needed = $2, sms_note = $3 WHERE uid = $4
- },undef, html_escape $c->req->param('sms'),$callme
- ,$c->req->param('smsnote'), $c->user->id);
-
- $c->res->redirect($c->uri_for(''));
-}
-
sub postowncoords : Local {
my ( $self, $c ) = @_;
my $dbh = $c->model;
$c->flash(error => "No planet at coords: $x:$y:$z");
}
}else{
- $c->flash(error => $c->req->param('planet') . " are not valid coords.");
+ my $error = $c->req->param('planet') . " are not valid coords.";
+ $c->flash(error => $error);
}
- $c->res->redirect($c->uri_for(''));
+ $c->res->redirect($c->uri_for('/'.$c->session->{referrer}));
}
sub postfleetsupdates : Local {
my ( $self, $c ) = @_;
my $dbh = $c->model;
+ my $message = $c->req->param('message');
if ($c->req->param('channel')){
my $query = $dbh->prepare(q{
INSERT INTO irc_requests (uid,channel,message) VALUES($1,$2,$3)
});
- $query->execute($c->user->id,$c->req->param('channel'),$c->req->param('message'));
+ my $channel = $c->user->id,$c->req->param('channel');
+ $query->execute($channel, $message);
$c->signal_bots;
- $c->flash(reply => "Msg sent to: ".$c->req->param('channel'));
+ $c->flash(reply => "Msg sent to: ".$channel);
$c->res->redirect($c->uri_for('ircrequest'));
}else{
- $c->stash(ircmessage => $c->req->param('message'));
+ $c->stash(ircmessage => $message);
$c->go('ircrequest');
}
}
my $limit = 'LIMIT 10';
$limit = '' if $c->check_user_roles(qw/members_points_nolimit/);
- my ($races) = $dbh->selectrow_array(q{SELECT enum_range(null::race)::text[]});
+ my ($races) = $dbh->selectrow_array(q{SELECT array_agg(race ORDER BY race_id) FROM races WHERE race_id >= 0});
$c->stash(races => $races);
my $query = $dbh->prepare(q{
SELECT nick
SELECT coords(x,y,z), tick() FROM current_planet_stats WHERE pid = $1
}, undef, $c->user->planet);
- $c->req->param(message => "[i]Posted by $coords at tick $tick [/i]\n\n" . $c->req->param('message'));
+ my $message = "[i]Posted by $coords at tick $tick [/i]\n\n" . $c->req->param('message');
+ $c->req->param(message => $message);
$c->forward('/forum/insertThread',[12]);
$c->forward('/forum/insertPost',[$c->stash->{thread}]);
$c->flash(intelmessage => 1);
});
my @scans;
my $intel = $c->req->param('message');
- while ($intel =~ m{http://[\w.]+/.+?scan(_id|_grp)?=(\w+)}g){
+ while ($intel =~ m{https?://[\w.]+/.+?scan(_id|_grp)?=(\w+)}g){
my $groupscan = (defined $1 && $1 eq '_grp') || 0;
my %scan;
$scan{id} = $2;
});
my @intel;
while ($intel =~ m/(\d+):(\d+):(\d+)\*?\s+(\d+):(\d+):(\d+)
- \*?\s+(.+)(?:Ter|Cat|Xan|Zik|Etd)?
- \s+(\d+)\s+(Attack|Defend)\s+(\d+)/gx){
+ \*?\s+(A|D)\s+(.+?)\s+(?:(?:\w+)\s+)?(\d+)\s+(\d+)/gx){
my $ingal = ($1 == $4 && $2 == $5) || 0;
my $lt = $tick + $10;
my $back = ($ingal ? $lt + 4 : undef);
+ my $mission = $7 eq 'A' ? 'Attack' : 'Defend';
eval {
- $addintel->execute($7,$9,$lt,$1,$2,$3,$4,$5,$6,$tick,$10,$8
+ $addintel->execute($8,$mission,$lt,$1,$2,$3,$4,$5,$6,$tick,$10,$9
,$ingal,$back, $c->user->id);
push @intel,"Added $&";
};
$c->flash(scans => \@scans);
}
-sub addincs : Local {
- my ( $self, $c ) = @_;
- $c->stash(incs => $c->flash->{incs});
-
-}
-
-sub postincs : Local {
- my ( $self, $c ) = @_;
- my $dbh = $c->model;
-
- my @incs;
-
- my $user = $dbh->prepare(q{
-SELECT uid FROM users u
-WHERE pid = planetid($1,$2,$3,tick())
- AND uid IN (SELECT uid FROM groupmembers WHERE gid = 'M')
- });
- my $call = $dbh->prepare(q{
-SELECT call
-FROM calls WHERE uid = $1 AND landing_tick = tick() + $2
- });
- my $fleet = $dbh->prepare(q{
-SELECT pid
-FROM incomings i
-WHERE pid = planetid($1,$2,$3,tick()) AND amount = $4 and fleet = $5 AND call = $6
- });
- my $irc = $dbh->prepare(q{
-INSERT INTO irc_requests (uid,channel,message) VALUES($1,'def',$2)
- });
-
- my $msg = $c->req->param('message');
- while ($msg =~ /expand\s+(\d+):(\d+):(\d+)\*?\s+(\d+):(\d+):(\d+)\s+([^:]*\S+)\s+(?:Ter|Cat|Xan|Zik|Etd)\s+([\d,]+)\s+(\d+)/gc
- || $msg =~ /(\d+):(\d+):(\d+)\s+(\d+):(\d+):(\d+)\s+\((?:Ter|Cat|Xan|Zik|Etd)\)\s+([^,]*\S+)\s+([\d,]+)\s+(\d+)\s+\(\d+\)/gc){
-
- my $inc = {message => $&};
- my $amount = $8;
- {
- $amount =~ s/,//g;
- }
- try {
- my $uid = $dbh->selectrow_array($user,undef,$1,$2,$3);
- die '<i>No user with these coords</i>' unless $uid;
-
- my $call = $dbh->selectrow_array($call,undef,$uid,$9);
- if ($call){
- my $pid = $dbh->selectrow_hashref($fleet,undef,$4,$5,$6,$amount,$7,$call);
- die '<i>Duplicate</i>' if $pid;
-
- }
-
- $irc->execute($c->user->id, $inc->{message});
- $inc->{status} = '<b>Added</b>';
-
- } catch {
- when (m(^(<i>.*</i>) at )){
- $inc->{status} = $1;
- }
- default {
- $inc->{status} = $_;
- }
- };
- push @incs, $inc;
- }
-
- $c->signal_bots if @incs;
- $c->flash(incs => \@incs);
- $c->res->redirect($c->uri_for('addincs'));
-}
-
sub launchConfirmation : Local {
my ( $self, $c ) = @_;
my $fullfleet = $dbh->prepare(q{INSERT INTO full_fleets
(fid,uid) VALUES (?,?)});
$dbh->begin_work;
- my @missions = parseconfirmations($c->req->param('mission'), $c->stash->{TICK});
+ my $mission = $c->req->param('mission');
+ my @missions = parseconfirmations($mission, $c->stash->{TICK});
for my $m (@missions){
if ($m->{mission} eq 'Return'){
$c->forward("addReturnFleet", [$m]);
}else{
$m->{pid} = $c->user->planet;
}
- }elsif ($m->{target} =~ /^(\d+):(\d+):(\d+)$/) {
+ }elsif ($m->{target} ~~ /^(\d+):(\d+):(\d+)$/) {
$m->{pid} = $dbh->selectrow_array($findplanet,undef,$1,$2,$3);
unless ($m->{pid}){
$m->{warning} = "No planet at $m->{target}, try again next tick.";
$missions =~ s/\(\s/(/g;
$missions =~ s/\s\)/)/g;
my $returnetare = qr/(\d+) \s+
- Arrival:(\d+)/sx;
- my $missionetare = qr/(\d+) (\s+ \(\+\d+\))? \s+
- Arrival:(\d+) \s+
+ Arrival:\s*(\d+)/sx;
+ my $missionetare = qr/\s* (\d+ \+ \s*)? (\d+) \s+
+ Arrival:\s*(\d+) \s+
\QReturn ETA:\E\s*(?:(?<eta>Instant) \s+ Cancel \s+ Order
| (?<eta>\d+) \s+ Ticks \s+ Recall \s+ Fleet)/sx;
my $etare = qr/(Galaxy:\d+Universe:\d+(?:Alliance:\d+)?
|$missionetare
|$returnetare)\s*/x;
- my $missre = qr/((?:Fake\ )?\w+)\s*/x;
+ my $missre = qr/((?:Alliance\ Standby)|(?:(?:Fake\ )?\w+))\s*/x;
if ($missions =~ m/
- Ships \s+ Cla \s+ T\s?1 \s+ T\s?2 \s+ T\s?3 \s+ Base \s+ \(i\) \s (?<name>.+?) \s+ \(i\) \s+ (?<name>.+?) \s+ \(i\) \s+ (?<name>.+?) \s+ \(i\) \s+ TOTAL \s+
+ Ships \s+ Cla \s+ T\s?1 \s+ T\s?2 \s+ T\s?3 \s+ ETA \s+ Base \s+ \(i\) \s (?<name>.+?) \s+ \(i\) \s+ (?<name>.+?) \s+ \(i\) \s+ (?<name>.+?) \s+ \(i\) \s+ TOTAL \s+
(?<ships>.+?)
\QTotal Ships in Fleet\E \s+ (\d+) \s+ (?<amount>\d+) \s+ (?<amount>\d+) \s+ (?<amount>\d+) \s+
Mission: \s* (?<missions>(?:$missre)*) \s*
my @targets = split /\s+/, $+{targets};
my @lts = split /\s+/, $+{lts};
my @etas;
- my $_ = $+{etas};
+ local $_ = $+{etas};
while(/$etare/sxg){
push @etas, $1;
}
next;
}
+ if ($missions[0] eq 'Alliance Standby'){
+ shift @missions;
+ push @slots,\%mission;
+ next;
+ }
+
given(shift @etas){
when(/$missionetare/sx){
$mission{tick} = $3;
- $mission{eta} = $1 + $+{eta};
+ $mission{eta} = $2 + $+{eta};
$mission{back} = $3 + $mission{eta} - 1;
$mission{target} = shift @targets;
$mission{lt} = shift @lts;
$mission{target} = shift @targets;
$mission{lt} = shift @lts;
$mission{mission} = shift @missions;
- die 'Did you forget some at the end?' if $mission{mission} ne 'Return';
+ die "Did you forget some at the end? '$mission{mission}'" if $mission{mission} ne 'Return';
}
}
push @slots,\%mission;
amount => 0,
ships => []
};
- while ($match{ships}->[0] =~ m/(\w+)\s+(FI|CO|FR|DE|CR|BS)[^\d]+((?:\d+\s*){5})/g){
+ while ($match{ships}->[0] =~ m/(\w[ \w]+?)\s+(FI|CO|FR|DE|CR|BS|--)[^\d]+\d+\s+((?:\d+\s*){5})/g){
my $ship = $1;
my @amounts = split /\D+/, $3;
my $base = shift @amounts;
,NULL AS recalled, mission
FROM fleets f
WHERE pid = $2 AND tick <= tick() AND tick >= tick() - 24
- AND name IN ('Main','Advanced Unit') AND mission = 'Full fleet'
+ AND name IN ('Main', 'Advanced Unit', 'Military') AND mission = 'Full fleet'
ORDER BY mission,name,tick DESC, fid DESC
) UNION (
SELECT fid,name,landing_tick AS tick, eta, amount