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/setHostile setNick setAlly setChannel/;
33 my ($msg, $command) = @_;
35 if(defined $msg && $msg =~ /^(\d+)\D(\d+)\D(\d+)$/){
40 $ND::server->command("notice $ND::nick Usage: .$command X:Y:Z");
44 my $findid = $ND::DBH->prepare_cached(q{SELECT planetid(?,?,?,0)});
45 my ($id) = $ND::DBH->selectrow_array($findid,undef,$x,$y,$z);
46 my $rv = $ND::DBH->do(q{UPDATE planets SET planet_status = 'Hostile' WHERE id = $1},undef,$id);
48 $ND::server->command("msg $ND::target $x:$y:$z is now marked s hostile");
49 intel_log $user->{uid},$id,"Set planet_status to: 'Hostile'";
55 my ($msg, $command) = @_;
57 if(defined $msg && $msg =~ /^(\d+)\D(\d+)\D(\d+) (\S+)$/){
63 $ND::server->command("notice $ND::nick Usage: .$command X:Y:Z nick");
66 if (my $user = officer){
67 my $findid = $ND::DBH->prepare_cached(q{SELECT nick, id FROM planets
68 WHERE id = planetid(?,?,?,0)});
69 my ($oldnick,$id) = $ND::DBH->selectrow_array($findid,undef,$x,$y,$z);
70 if ($ND::DBH->do('UPDATE planets SET nick = $1 WHERE id = $2'
72 unless (defined $oldnick){
73 $ND::server->command("msg $ND::target $x:$y:$z nick has been set to $ND::B$nick");
75 $ND::server->command("msg $ND::target $x:$y:$z nick has been changed from $ND::B$oldnick$ND::B to $ND::B$nick");
77 intel_log $user->{uid},$id,"Set nick to: $nick";
83 my ($msg, $command) = @_;
85 if(defined $msg && $msg =~ /^(\d+)\D(\d+)\D(\d+) (\S+)$/){
91 $ND::server->command("notice $ND::nick Usage: .$command X:Y:Z ally | | % can be used for wildcards \%-crew\% will match [F-Crew]");
94 if (my $user = officer){
96 if ($ally ne 'unknown'){
97 ($aid,$ally) = $ND::DBH->selectrow_array("SELECT id,name FROM alliances WHERE name ILIKE ?",undef,$ally);
100 my $findid = $ND::DBH->prepare_cached(q{SELECT id,alliance FROM current_planet_stats
101 WHERE x = ? AND y = ? and z = ?});
102 my ($id,$alliance) = $ND::DBH->selectrow_array($findid,undef,$x,$y,$z);
103 if($id && $ND::DBH->do('UPDATE planets SET alliance_id = $1 WHERE id = $2'
105 if (defined $alliance){
106 $ND::server->command("msg $ND::target Changed $x:$y:$z from $ND::B$alliance$ND::B to $ND::B$ally");
108 $ND::server->command("msg $ND::target Setting $x:$y:$z as $ND::B$ally");
110 intel_log $user->{uid},$id,"Set alliance_id to: $aid ($ally)";
112 $ND::server->command("msg $ND::target Couldn't find a planet at $x:$y:$z");
115 $ND::server->command("msg $ND::target Couldn't find such an alliance");
121 my ($msg, $command) = @_;
122 my ($x,$y,$z,$channel);
123 if(defined $msg && $msg =~ /^(\d+)\D(\d+)\D(\d+) (\S+)$/){
129 $ND::server->command("notice $ND::nick Usage: .$command X:Y:Z channel");
132 if (my $user = officer()){
133 my $findid = $ND::DBH->prepare_cached(q{SELECT id,channel FROM current_planet_stats
134 WHERE x = ? AND y = ? and z = ?});
135 my ($id,$c) = $ND::DBH->selectrow_array($findid,undef,$x,$y,$z);
136 if ($ND::DBH->do('UPDATE planets SET channel = $1 WHERE id = $2'
137 ,undef,$channel,$id)){
140 $ND::server->command("msg $ND::target Changed $x:$y:$z from $ND::B$c$ND::B to $ND::B$channel");
142 $ND::server->command("msg $ND::target Setting $x:$y:$z as $ND::B$channel");
144 intel_log $user->{uid},$id,"Set channel to: $channel";
146 $ND::server->command("msg $ND::target Couldn't find a planet at $x:$y:$z");