Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixing buildable (which got pickier about x & y)

  • Loading branch information...
commit 43f006698e84efdabd489acbf21155dd323c7226 1 parent eaed9b4
T. Alexander Popiel authored
Showing with 15 additions and 1 deletion.
  1. +15 −1 Client.pm
View
16 Client.pm
@@ -318,7 +318,6 @@ sub body_buildable {
my $result = $self->cache_read( type => 'buildable', id => $body_id );
return $result if $result;
- $result = $self->call(body => get_buildable => $body_id);
my $buildings = $self->body_buildings($body_id);
my @completions;
for my $building (values(%{$buildings->{buildings}})) {
@@ -333,6 +332,21 @@ sub body_buildable {
if ($body->{incoming_own_ships}) {
push(@completions, map { parse_time($_->{date_arrives}) } @{$body->{incoming_own_ships}});
}
+
+ my %plots;
+ for my $building (values %{$buildings->{buildings}}) {
+ $plots{$building->{x},$building->{y}} = 1;
+ }
+ my @plots;
+ for my $x (-5 .. 5) {
+ for my $y (-5 .. 5) {
+ # next if $x >= 3 && $y >= 3;
+ push(@plots, [ $x, $y ]) unless $plots{$x,$y};
+ }
+ }
+
+ $result = $self->call(body => get_buildable => $body_id, $plots[0][0], $plots[0][1]);
+
my $invalid = List::Util::max(time() + 30, List::Util::min(time() + 600, @completions));
$self->cache_write( type => 'buildable', id => $body_id, invalid => $invalid, data => $result );
return $result;
Please sign in to comment.
Something went wrong with that request. Please try again.