]> ruin.nu Git - ndwebbie.git/blobdiff - lib/NDWeb/Controller/Members.pm
Also signal bots on launch confirmations
[ndwebbie.git] / lib / NDWeb / Controller / Members.pm
index e14cdcc7092d864971703d88d2b11a6b7e4bd427..cfd6d536c62c5a432e66bf6a8c3d66b06ec37c31 100644 (file)
@@ -137,15 +137,26 @@ sub postowncoords : Local {
        if ($c->user->planet){
                $c->flash(error => 'You already have a planet set.'
                        .' Contact a HC if they need to be changed');
-       }elsif ($c->req->param('planet') =~ m/(\d+)\D+(\d+)\D+(\d+)/){
+       }elsif (my ($x,$y,$z) = $c->req->param('planet') =~ m/(\d+)\D+(\d+)\D+(\d+)/){
                my $planet = $dbh->selectrow_array(q{SELECT planetid($1,$2,$3,TICK())
-                       },undef,$1,$2,$3);
+                       },undef,$x,$y,$z);
 
                if ($planet){
-                       $dbh->do(q{UPDATE users SET planet = ? WHERE uid = ?
-                               },undef, $planet , $c->user->id);
+                       eval {
+                               $dbh->do(q{UPDATE users SET pid = ? WHERE uid = ?
+                                       },undef, $planet , $c->user->id);
+                       };
+                       given ($@){
+                               when (''){}
+                               when (/duplicate key value violates/){
+                                       $c->flash(error => "The coords $x:$y:$z are already in use. Talk to hc if these are really your coords.")
+                               }
+                               default {
+                                       $c->flash(error => $@)
+                               }
+                       }
                }else{
-                       $c->flash(error => "No planet at coords: $1:$2:$3");
+                       $c->flash(error => "No planet at coords: $x:$y:$z");
                }
        }else{
                $c->flash(error => $c->req->param('planet') . " are not valid coords.");
@@ -254,7 +265,7 @@ sub postircrequest : Local {
 INSERT INTO irc_requests (uid,channel,message) VALUES($1,$2,$3)
                });
                $query->execute($c->user->id,$c->req->param('channel'),$c->req->param('message'));
-               system 'killall','-USR1', 'irssi';
+               $c->signal_bots;
 
                $c->flash(reply => "Msg sent to: ".$c->req->param('channel'));
                $c->res->redirect($c->uri_for('ircrequest'));
@@ -268,6 +279,7 @@ sub points : Local {
        my ( $self, $c, $order ) = @_;
        my $dbh = $c->model;
 
+       $order //= 'total_points';
        if ($order ~~ /^((?:defense|attack|total|humor|scan|raid)_points)$/
                        || $order ~~ /^(defprio)$/){
                $order = "$1 DESC";
@@ -296,6 +308,7 @@ sub stats : Local {
        my ( $self, $c, $order ) = @_;
        my $dbh = $c->model;
 
+       $order //= 'score';
        if ($order ~~ /^(scre|value|xp|size|race)$/){
                $order = "$1rank";
        }else{
@@ -355,6 +368,11 @@ sub postintelmessage : Local {
                }
        }
 
+       my ($coords,$tick) = $c->model->selectrow_array(q{
+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'));
        $c->forward('/forum/insertThread',[12]);
        $c->forward('/forum/insertPost',[$c->stash->{thread}]);
        $c->flash(intelmessage => 1);
@@ -556,6 +574,7 @@ sub postconfirmation : Local {
                }
                $dbh->commit;
                $c->flash(missions => \@missions);
+               $c->signal_bots;
        };
        if ($@){
                $dbh->rollback;