1 #**************************************************************************
2 # Copyright (C) 2006 by Michael Andreen <harvATruinDOTnu> *
4 # This program is free software; you can redistribute it and/or modify *
5 # it under the terms of the GNU General Public License as published by *
6 # the Free Software Foundation; either version 2 of the License, or *
7 # (at your option) any later version. *
9 # This program is distributed in the hope that it will be useful, *
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 # GNU General Public License for more details. *
14 # You should have received a copy of the GNU General Public License *
15 # along with this program; if not, write to the *
16 # Free Software Foundation, Inc., *
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 #**************************************************************************/
28 our @ISA = qw/Exporter/;
30 our @EXPORT = qw/setAlly setChannel/;
33 my ($msg, $command) = @_;
35 if(defined $msg && $msg =~ /^(\d+)\D(\d+)\D(\d+) (\S+)$/){
41 $ND::server->command("notice $ND::nick Usage: .$command X:Y:Z ally | | % can be used for wildcards \%-crew\% will match [F-Crew]");
44 if (my $user = intel){
46 if ($ally ne 'unknown'){
47 ($aid,$ally) = $ND::DBH->selectrow_array("SELECT id,name FROM alliances WHERE name ILIKE ?",undef,$ally);
50 my $findid = $ND::DBH->prepare(q{SELECT id,alliance FROM current_planet_stats
51 WHERE x = ? AND y = ? and z = ?});
52 my ($id,$alliance) = $ND::DBH->selectrow_array($findid,undef,$x,$y,$z);
54 $ND::server->command("msg $ND::target Couldn't find a planet at $x:$y:$z");
57 if($ND::DBH->do('UPDATE planets SET alliance_id = $1 WHERE id = $2'
59 if (defined $alliance){
60 $ND::server->command("msg $ND::target Changed $x:$y:$z from $ND::B$alliance$ND::B to $ND::B$ally");
62 $ND::server->command("msg $ND::target Setting $x:$y:$z as $ND::B$ally");
64 intel_log $user->{uid},$id,"Set alliance_id to: $aid ($ally)";
66 $ND::server->command("msg $ND::target Couldn't set alliance_id to: $aid");
69 $ND::server->command("msg $ND::target Couldn't find such an alliance");
75 my ($msg, $command) = @_;
76 my ($x,$y,$z,$channel);
77 if(defined $msg && $msg =~ /^(\d+)\D(\d+)\D(\d+) (\S+)$/){
83 $ND::server->command("notice $ND::nick Usage: .$command X:Y:Z channel");
86 if (my $user = intel){
87 my $findid = $ND::DBH->prepare_cached(q{SELECT id,channel FROM current_planet_stats
88 WHERE x = ? AND y = ? and z = ?});
89 my ($id,$c) = $ND::DBH->selectrow_array($findid,undef,$x,$y,$z);
90 if ($ND::DBH->do('UPDATE planets SET channel = $1 WHERE id = $2'
91 ,undef,$channel,$id)){
94 $ND::server->command("msg $ND::target Changed $x:$y:$z from $ND::B$c$ND::B to $ND::B$channel");
96 $ND::server->command("msg $ND::target Setting $x:$y:$z as $ND::B$channel");
98 intel_log $user->{uid},$id,"Set channel to: $channel";
100 $ND::server->command("msg $ND::target Couldn't find a planet at $x:$y:$z");