X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=NDWeb%2FPages%2FIntel.pm;h=a5dfc5e77b37cf5d6832c01276fae568ee7cb18a;hb=62e8f0d857b12761d85b8c97ffab2bc02d4b6777;hp=58a8c67510ab72320e08e516fc117114ca9e0655;hpb=a074bd17f5e8ba341a22bbfca1da7093b8351774;p=ndwebbie.git diff --git a/NDWeb/Pages/Intel.pm b/NDWeb/Pages/Intel.pm index 58a8c67..a5dfc5e 100644 --- a/NDWeb/Pages/Intel.pm +++ b/NDWeb/Pages/Intel.pm @@ -48,7 +48,7 @@ sub render_body { my $planet; if (defined param('coords') && param('coords') =~ /^(\d+)(?: |:)(\d+)(?: |:)(\d+)$/){ - my $query = $DBH->prepare(q{SELECT x,y,z,coords(x,y,z),id, nick, alliance,alliance_id, planet_status,channel,ftid FROM current_planet_stats + my $query = $DBH->prepare(q{SELECT x,y,z,coords(x,y,z),id, nick, alliance,alliance_id, planet_status,channel,ftid,gov FROM current_planet_stats WHERE x = ? AND y = ? AND z = ?}); $planet = $DBH->selectrow_hashref($query,undef,$1,$2,$3) or $ND::ERROR .= p $DBH->errstr; } @@ -127,6 +127,16 @@ sub render_body { $error .= "

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

"; } } + if (param('cgov')){ + my $value = escapeHTML(param('gov')); + if ($DBH->do(q{UPDATE planets SET gov = ? WHERE id =?} + ,undef,$value,$planet->{id})){ + intel_log $ND::UID,$planet->{id},"Set government to: $value"; + $planet->{gov} = $value; + }else{ + $error .= "

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

"; + } + } if (param('calliance')){ if ($DBH->do(q{UPDATE planets SET alliance_id = NULLIF(?,-1) WHERE id =?} ,undef,param('alliance'),$planet->{id})){ @@ -157,9 +167,14 @@ sub render_body { $BODY->param(Planet => $planet->{id}); $BODY->param(Nick => escapeHTML($planet->{nick})); $BODY->param(Channel => $planet->{channel}); + my @gov; + for my $gov ("","Feu", "Dic", "Dem","Uni"){ + push @gov,{Gov => $gov, Selected => $gov eq $planet->{gov}} + } + $BODY->param(Gov => \@gov); my @status; - for my $status (" ","Friendly", "NAP", "Hostile"){ - push @status,{Status => $status, Selected => defined $planet->{planet_status} && $status eq $planet->{planet_status}} + for my $status ("","Friendly", "NAP", "Hostile"){ + push @status,{Status => $status, Selected => $status eq $planet->{planet_status}} } $BODY->param(PlanetStatus => \@status); my @alliances = alliances($planet->{alliance_id}); @@ -171,15 +186,12 @@ sub render_body { $query->execute($planet->{id}) or $error .= $DBH->errstr; my @intellists; my @incomings; - my $i = 0; while (my $intel = $query->fetchrow_hashref){ if ($intel->{ingal}){ $intel->{missionclass} = 'ingal'; }else{ $intel->{missionclass} = $intel->{mission}; } - $i++; - $intel->{ODD} = $i % 2; push @incomings,$intel; } push @intellists,{Message => 'Incoming fleets', Intel => \@incomings, Origin => 1}; @@ -187,15 +199,12 @@ sub render_body { $query = $DBH->prepare(intelquery('t.alliance AS talliance,coords(t.x,t.y,t.z) AS target',"o.id = ? $showticks")); $query->execute($planet->{id}) or $error .= $DBH->errstr; my @outgoings; - $i = 0; while (my $intel = $query->fetchrow_hashref){ if ($intel->{ingal}){ $intel->{missionclass} = 'ingal'; }else{ $intel->{missionclass} = $intel->{mission}; } - $i++; - $intel->{ODD} = $i % 2; push @outgoings,$intel; } push @intellists,{Message => 'Outgoing Fleets', Intel => \@outgoings, Target => 1}; @@ -204,7 +213,7 @@ sub render_body { }elsif(!param('coords')){ my $query = $DBH->prepare(intelquery('o.alliance AS oalliance,coords(o.x,o.y,o.z) AS origin, t.alliance AS talliance,coords(t.x,t.y,t.z) AS target',qq{not ingal - AND ((( t.alliance_id != o.alliance_id OR t.alliance_id IS NULL OR o.alliance_id IS NULL) AND i.mission != 'Attack') + AND ((( t.alliance_id != o.alliance_id OR t.alliance_id IS NULL OR o.alliance_id IS NULL) AND (i.mission = 'Defend' OR i.mission = 'AllyDef' )) OR ( t.alliance_id = o.alliance_id AND i.mission = 'Attack')) AND i.sender NOT IN (SELECT planet FROM users u NATURAL JOIN groupmembers gm WHERE gid = 8 AND planet IS NOT NULL) $showticks})); @@ -212,15 +221,12 @@ sub render_body { my @intellists; my @intel; - my $i = 0; while (my $intel = $query->fetchrow_hashref){ if ($intel->{ingal}){ $intel->{missionclass} = 'ingal'; }else{ $intel->{missionclass} = $intel->{mission}; } - $i++; - $intel->{ODD} = $i % 2; push @intel,$intel; } push @intellists,{Message => q{Intel where alliances doesn't match}, Intel => \@intel, Origin => 1, Target => 1};