X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=Intel.pm;h=bc9a92559285d2544287808422be6b607dc8487e;hb=490d9c4cc048f00111f8979b20a34c5adaf22006;hp=1fc7680d1a5866afe745c3f77731f46696cc7db7;hpb=2f3dd8afdb3ea3661cd8f6ba127240fb8dbcd08a;p=NDIRC.git diff --git a/Intel.pm b/Intel.pm index 1fc7680..bc9a925 100644 --- a/Intel.pm +++ b/Intel.pm @@ -41,7 +41,7 @@ sub setHostile { return; } if(my $user = dc()){ - my $findid = $ND::DBH->prepare_cached(q{SELECT planetid(?,?,?,0)}); + my $findid = $ND::DBH->prepare_cached(q{SELECT planetid(?,?,?,tick())}); my ($id) = $ND::DBH->selectrow_array($findid,undef,$x,$y,$z); my $rv = $ND::DBH->do(q{UPDATE planets SET planet_status = 'Hostile' WHERE id = $1},undef,$id); if ($rv == 1){ @@ -65,9 +65,9 @@ sub setNick { } if (my $user = officer){ my $findid = $ND::DBH->prepare_cached(q{SELECT nick, id FROM planets - WHERE id = planetid(?,?,?,0)}); + WHERE id = planetid(?,?,?,tick())}); my ($oldnick,$id) = $ND::DBH->selectrow_array($findid,undef,$x,$y,$z); - if ($ND::DBH->do('UPDATE planets SET nick = $1 WHERE id = $2' + if ($id && $ND::DBH->do('UPDATE planets SET nick = $1 WHERE id = $2' ,undef,$nick,$id)){ unless (defined $oldnick){ $ND::server->command("msg $ND::target $x:$y:$z nick has been set to $ND::B$nick"); @@ -75,6 +75,8 @@ sub setNick { $ND::server->command("msg $ND::target $x:$y:$z nick has been changed from $ND::B$oldnick$ND::B to $ND::B$nick"); } intel_log $user->{uid},$id,"Set nick to: $nick"; + }else{ + $ND::server->command("msg $ND::target Couldn't find any planet with coords $x:$y:$z"); } } } @@ -97,10 +99,14 @@ sub setAlly { ($aid,$ally) = $ND::DBH->selectrow_array("SELECT id,name FROM alliances WHERE name ILIKE ?",undef,$ally); } if ($ally){ - my $findid = $ND::DBH->prepare_cached(q{SELECT id,alliance FROM current_planet_stats + my $findid = $ND::DBH->prepare(q{SELECT id,alliance FROM current_planet_stats WHERE x = ? AND y = ? and z = ?}); my ($id,$alliance) = $ND::DBH->selectrow_array($findid,undef,$x,$y,$z); - if($id && $ND::DBH->do('UPDATE planets SET alliance_id = $1 WHERE id = $2' + unless ($id){ + $ND::server->command("msg $ND::target Couldn't find a planet at $x:$y:$z"); + return; + } + if($ND::DBH->do('UPDATE planets SET alliance_id = $1 WHERE id = $2' ,undef,$aid,$id)){ if (defined $alliance){ $ND::server->command("msg $ND::target Changed $x:$y:$z from $ND::B$alliance$ND::B to $ND::B$ally"); @@ -109,7 +115,7 @@ sub setAlly { } intel_log $user->{uid},$id,"Set alliance_id to: $aid ($ally)"; }else{ - $ND::server->command("msg $ND::target Couldn't find a planet at $x:$y:$z"); + $ND::server->command("msg $ND::target Couldn't set alliance_id to: $aid"); } }else{ $ND::server->command("msg $ND::target Couldn't find such an alliance");