From 0e6c1451999de92887e5fc76524e2e526e9172e7 Mon Sep 17 00:00:00 2001 From: lemming552 Date: Thu, 16 Aug 2012 18:34:32 -0600 Subject: [PATCH] Some checks. --- bin/tick_planets.pl | 5 +++-- lib/Lacuna/DB/Result/Map/Body/Planet.pm | 26 ++++++++++++------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/bin/tick_planets.pl b/bin/tick_planets.pl index 4f61a3a2..7e475390 100644 --- a/bin/tick_planets.pl +++ b/bin/tick_planets.pl @@ -5,6 +5,7 @@ use Lacuna::DB; use Lacuna; use Lacuna::Util qw(randint format_date); use Getopt::Long; +use utf8; $|=1; our $quiet; GetOptions( @@ -21,14 +22,14 @@ our $db = Lacuna->db; out('Ticking planets'); my $planets_rs = $db->resultset('Lacuna::DB::Result::Map::Body')->search({empire_id => {'!=' => 0}}); while (my $planet = $planets_rs->next) { - out('Ticking '.$planet->name); + out('Ticking '.$planet->name.' : '.$planet->id); eval{$planet->tick}; my $reason = $@; if (ref $reason eq 'ARRAY' && $reason->[0] eq -1) { # this is an expected exception, it means one of the roles took over } elsif ( ref $reason eq 'ARRAY') { - out('Ticking '.$planet->name); + out('Ticking '.$planet->name); out(sprintf("Ticking %s resulted in errno: %d, %s\n", $planet->name, $reason->[0], $reason->[1])); } elsif ( $reason ) { diff --git a/lib/Lacuna/DB/Result/Map/Body/Planet.pm b/lib/Lacuna/DB/Result/Map/Body/Planet.pm index ba2db3fb..247d8702 100644 --- a/lib/Lacuna/DB/Result/Map/Body/Planet.pm +++ b/lib/Lacuna/DB/Result/Map/Body/Planet.pm @@ -784,29 +784,29 @@ sub has_room_in_build_queue { use constant operating_resource_names => qw(food_hour energy_hour ore_hour water_hour); has future_operating_resources => ( - is => 'rw', - clearer => 'clear_future_operating_resources', - lazy => 1, - default => sub { + is => 'rw', + clearer => 'clear_future_operating_resources', + lazy => 1, + default => sub { my $self = shift; - # get current + # get current my %future; foreach my $method ($self->operating_resource_names) { - $future{$method} = $self->$method; + $future{$method} = $self->$method; } - # adjust for what's already in build queue + # adjust for what's already in build queue my @queued_builds = @{$self->builds}; foreach my $build (@queued_builds) { - my $other = $build->stats_after_upgrade; - foreach my $method ($self->operating_resource_names) { - $future{$method} += $other->{$method} - $build->$method; - } + my $other = $build->stats_after_upgrade; + foreach my $method ($self->operating_resource_names) { + $future{$method} += $other->{$method} - $build->$method; + } } return \%future; }, - ); +); sub has_resources_to_operate { my ($self, $building) = @_; @@ -1286,7 +1286,7 @@ sub tick { return undef; } else { - $cache->set('ticking',$self->id, 1, 60); + $cache->set('ticking',$self->id, 1, 300); } my $now = DateTime->now; -- 2.51.2