X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=alliances.pl;h=4f89a48f264131c3e28794f7f11d0d67a400cb27;hb=27f3358d4b4cc93f855eb30dd04d65764d52d990;hp=8b5830836b8db4d63d9ef2aa5c2943879acda37a;hpb=dfdaf29be0eb73b0b900ce3bced443120b1fca96;p=ndwebbie.git diff --git a/alliances.pl b/alliances.pl index 8b58308..4f89a48 100644 --- a/alliances.pl +++ b/alliances.pl @@ -19,9 +19,10 @@ use strict; use warnings FATAL => 'all'; +use ND::Include; our $BODY; our $DBH; -our $LOG; +our $ERROR; my $error; $ND::TEMPLATE->param(TITLE => 'Alliances'); @@ -40,22 +41,24 @@ if ($alliance && defined param('cmd') && param ('cmd') eq 'change'){ if ($DBH->do(q{UPDATE alliances SET relationship = ? WHERE id =?} ,undef,$value,$alliance->{id})){ $alliance->{relationship} = $value; - $LOG->execute($ND::UID,"HC set alliance: $alliance->{id} relationship: $value"); + log_message $ND::UID,"HC set alliance: $alliance->{id} relationship: $value"; }else{ $error .= "

Something went wrong: ".$DBH->errstr."

"; } } my $coords = param('coords'); + my $findplanet = $DBH->prepare(q{SELECT id FROM current_planet_stats WHERE x = ? AND y = ? AND z = ?}); my $addplanet = $DBH->prepare(q{ -UPDATE planets SET alliance_id = ?, nick = coalesce(?,nick) -WHERE id = (SELECT id FROM current_planet_stats WHERE x = ? AND y = ? AND z = ?); +UPDATE planets SET alliance_id = $2, nick = coalesce($3,nick) +WHERE id = $1; }); while ($coords =~ m/(\d+):(\d+):(\d+)(?:\s+nick=\s*(\S+))?/g){ - if ($addplanet->execute($alliance->{id},$4,$1,$2,$3)){ + my ($id) = $DBH->selectrow_array($findplanet,undef,$1,$2,$3) or $ERROR .= p $DBH->errstr; + if ($addplanet->execute($id,$alliance->{id},$4)){ my $nick = ''; $nick = '(nick $4)' if defined $4; $error .= "

Added planet $1:$2:$3 $nick to this alliance

"; - $LOG->execute($ND::UID,"HC Added planet $1:$2:$3 $nick to alliance: $alliance->{id}"); + intel_log $ND::UID,$id,"HC Added planet $1:$2:$3 $nick to alliance: $alliance->{id} ($alliance->{name})"; }else{ $error .= "

Something went wrong: ".$DBH->errstr."

"; }