]> ruin.nu Git - NDIRC.git/commitdiff
Merge branch 'master' into noeos
authorMichael Andreen <harv@ruin.nu>
Sat, 30 Jan 2010 19:09:08 +0000 (20:09 +0100)
committerMichael Andreen <harv@ruin.nu>
Sat, 30 Jan 2010 19:09:08 +0000 (20:09 +0100)
1  2 
Commands/Def.pm

diff --combined Commands/Def.pm
index 5aec9314ef42690f12d6a2f3013433b1d2ebc7c7,bdfc6776c9beaba28722f790246f886b40aea2e8..ae206309ceb6bc8333c4375761cc4501bf0aeb68
@@@ -25,6 -25,20 +25,6 @@@ use feature ':5.10'
  use MooseX::Declare;
  use NDIRC::Dispatcher;
  
 -command anon => {
 -      help => q(syntax: .anon nick message),
 -      type => q(def),
 -      acl => q(irc_anondef),
 -}, class extends NDIRC::Command {
 -      method execute($c,$msg) {
 -
 -              my ($target,$mess) = $msg =~ /^(\S+) (.*)$/ or die 'ARGS';
 -
 -              $c->message(privmsg => $target, "<b>$mess</b>");
 -              $c->message(privmsg => $c->channel, "<c03>$target << $mess</c>");
 -      }
 -};
 -
  command defcall => {
        help => q(syntax: .defcall [callid] | if a call id is given, then shiptypes and eta will be fetched from the database and added to the message),
        type => q(def),
@@@ -219,6 -233,7 +219,7 @@@ command report_incs => 
        help => q(Used to report incs, same as pasting in pm. Use ~ prefix to send output to channel),
        type => q(def),
  }, class extends NDIRC::Command {
+       use Try::Tiny;
        method execute($c,$msg) {
  
                $msg =~ /(\d+):(\d+):(\d+)\*?\s+(\d+):(\d+):(\d+)\s+([^:]*\S+)\s+(?:Ter|Cat|Xan|Zik|Etd)\s+([\d,]+)\s+Attack\s+(\d+)/
@@@ -243,27 -258,27 +244,27 @@@ SELECT nick,alliance,pid,planet_status,
  FROM current_planet_stats WHERE x = ? AND y = ? AND z = ?
                        });
                        if (my @attacker = $dbh->selectrow_array($st,undef,$4,$5,$6)){
-                               $dbh->begin_work;
-                               my $landing_tick = $dbh->selectrow_array(q{SELECT tick() + ?},undef,$9);
-                               my @call = $dbh->selectrow_array(q{
+                               try {
+                                       $dbh->begin_work;
+                                       my $landing_tick = $dbh->selectrow_array(q{SELECT tick() + ?},undef,$9);
+                                       my @call = $dbh->selectrow_array(q{
  SELECT call,status,calc
  FROM calls WHERE uid = ? AND landing_tick = ?
-                               },undef,$user->{uid},$landing_tick);
-                               my $threefleeter = $dbh->selectrow_array(q{
+                                               },undef,$user->{uid},$landing_tick);
+                                       my $threefleeter = $dbh->selectrow_array(q{
  SELECT COALESCE(gid = 'X',false)
  FROM groupmembers WHERE uid = ? AND gid = 'X'
-                               },undef,$user->{uid});
-                               unless (@call){ #call doesn't exists, create a new one
-                                       @call = $dbh->selectrow_array(q{
+                                               },undef,$user->{uid});
+                                       unless (@call){ #call doesn't exists, create a new one
+                                               @call = $dbh->selectrow_array(q{
  INSERT INTO calls (uid,landing_tick,info) VALUES(?,?,'') RETURNING call,status,calc
-                                       },undef,$user->{uid},$landing_tick);
-                                       if ($threefleeter){
-                                               $dbh->do(q{UPDATE calls SET status = 'Ignored' WHERE call = $1},undef,$call[0]);
-                                               $c->def_log($call[0], 'This member has been marked as [B]NoDef[/B], do [B]not cover[/B] unless you have a good reaon.');
-                                               $call[1] = 'Ignored';
+                                                       },undef,$user->{uid},$landing_tick);
+                                               if ($threefleeter){
+                                                       $dbh->do(q{UPDATE calls SET status = 'Ignored' WHERE call = $1},undef,$call[0]);
+                                                       $c->def_log($call[0], 'This member has been marked as [B]NoDef[/B], do [B]not cover[/B] unless you have a good reaon.');
+                                                       $call[1] = 'Ignored';
+                                               }
                                        }
-                               }
-                               if (@call){
                                        my $pointlimits = $dbh->prepare(q{SELECT value :: float FROM misc WHERE id = ?});
                                        my ($minpoints) = $dbh->selectrow_array($pointlimits,undef,'DEFMINPRIO');
                                        my ($maxpoints) = $dbh->selectrow_array($pointlimits,undef,'DEFMAXPRIO');
@@@ -301,8 -316,11 +302,11 @@@ SELECT count(*) FROM launch_confirmatio
                                        if ($fleetcatch > 0){
                                                $c->reply("<c04>THIS IS A POSSIBLE FLEETCATCH!</c>");
                                        }
-                               }
-                               $dbh->commit;
+                                       $dbh->commit;
+                               } catch {
+                                       $dbh->rollback;
+                                       die $_;
+                               };
                        }else{
                                $c->reply("<c04>Didn't find any planet with coordinates $4:$5:$6 at this tick</c>");
                        }