X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=intel.pl;h=c1beff473da2c6281a714af4d1fe9e2d4d9ed25d;hb=5af89dd22a075c6652b779ef471bf21cb9965cb6;hp=d596957149e74e6865c09d08d7e7426dc58d5cc3;hpb=b07e4fe93e809a8c555fd51b89a6a82a722441a5;p=ndwebbie.git diff --git a/intel.pl b/intel.pl index d596957..c1beff4 100644 --- a/intel.pl +++ b/intel.pl @@ -22,6 +22,7 @@ use POSIX; our $BODY; our $DBH; our $LOG; +my $error; $ND::TEMPLATE->param(TITLE => 'Intel'); @@ -73,7 +74,7 @@ if ($planet){ ,undef,$value,$planet->{id})){ $planet->{nick} = $value; }else{ - print "

Something went wrong: ".$DBH->errstr."

"; + $error .= "

Something went wrong: ".$DBH->errstr."

"; } } if (param('cchannel')){ @@ -82,7 +83,7 @@ if ($planet){ ,undef,$value,$planet->{id})){ $planet->{channel} = $value; }else{ - print "

Something went wrong: ".$DBH->errstr."

"; + $error .= "

Something went wrong: ".$DBH->errstr."

"; } } if (param('cstatus')){ @@ -91,7 +92,7 @@ if ($planet){ ,undef,$value,$planet->{id})){ $planet->{planet_status} = $value; }else{ - print "

Something went wrong: ".$DBH->errstr."

"; + $error .= "

Something went wrong: ".$DBH->errstr."

"; } } if (param('calliance')){ @@ -99,10 +100,10 @@ if ($planet){ ,undef,param('alliance'),$planet->{id})){ $planet->{alliance_id} = param('alliance'); }else{ - print "

Something went wrong: ".$DBH->errstr."

"; + $error .= "

Something went wrong: ".$DBH->errstr."

"; } } - $DBH->commit or print "

Something went wrong: ".$DBH->errstr."

"; + $DBH->commit or $error .= "

Something went wrong: ".$DBH->errstr."

"; } } @@ -132,29 +133,35 @@ if ($planet){ $BODY->param(Alliances => \@alliances); my $query = $DBH->prepare(intelquery('o.alliance AS oalliance,coords(o.x,o.y,o.z) AS origin',"t.id = ? $showticks")); - $query->execute($planet->{id}) or print $DBH->errstr; + $query->execute($planet->{id}) or $error .= $DBH->errstr; my @intellists; my @intel; + my $i = 0; while (my $intel = $query->fetchrow_hashref){ if ($intel->{ingal}){ $intel->{missionclass} = 'ingal'; }else{ $intel->{missionclass} = $intel->{mission}; } + $intel->{ODD} = $i % 2; push @intel,$intel; + $i++; } push @intellists,{Message => 'Incoming fleets', Intel => \@intel, Origin => 1}; my $query = $DBH->prepare(intelquery('t.alliance AS talliance,coords(t.x,t.y,t.z) AS target',"o.id = ? $showticks")); - $query->execute($planet->{id}) or print $DBH->errstr; + $query->execute($planet->{id}) or $error .= $DBH->errstr; my @intel; + my $i = 0; while (my $intel = $query->fetchrow_hashref){ if ($intel->{ingal}){ $intel->{missionclass} = 'ingal'; }else{ $intel->{missionclass} = $intel->{mission}; } + $intel->{ODD} = $i % 2; push @intel,$intel; + $i++; } push @intellists,{Message => 'Outgoing Fleets', Intel => \@intel, Target => 1}; @@ -166,17 +173,20 @@ if ($planet){ OR ( t.alliance_id = o.alliance_id AND i.mission = 'Attack')) AND i.sender NOT IN (SELECT planet FROM users u NATURAL JOIN groupmembers gm WHERE gid = 8 AND planet IS NOT NULL) $showticks})); - $query->execute() or print $DBH->errstr; + $query->execute() or $error .= $DBH->errstr; my @intellists; my @intel; + my $i = 0; while (my $intel = $query->fetchrow_hashref){ if ($intel->{ingal}){ $intel->{missionclass} = 'ingal'; }else{ $intel->{missionclass} = $intel->{mission}; } + $intel->{ODD} = $i % 2; push @intel,$intel; + $i++; } push @intellists,{Message => q{Intel where alliances doesn't match}, Intel => \@intel, Origin => 1, Target => 1}; $BODY->param(IntelLIsts => \@intellists); @@ -191,4 +201,5 @@ while (my $message = $query->fetchrow_hashref){ push @messages,$message; } $BODY->param(IntelMessages => \@messages); +$BODY->param(Error => $error); 1;