Skip to content

Commit

Permalink
Merge pull request #46 from mjharwood/d62763ec4445efe4b283e2962c6db38…
Browse files Browse the repository at this point in the history
…54d6a880c

Divide by zero errors - Issue #27
  • Loading branch information
halkeye committed Jun 29, 2011
2 parents 5f53938 + d62763e commit 3639acd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/Games/Lacuna/Client/Governor.pm
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,10 @@ sub pushes { # This stage merely analyzes what we have or need. Actual pushes
for my $res (@reslist) {
my $profile = merge($cfg->{profile}->{$res} || {},$cfg->{profile}->{_default_});
$self->{push_info}->{$pid}->{$res}->{space_left} = ($status->{"$res\_capacity"} * $profile->{requested_level}) - $status->{"$res\_stored"};

# if we have no capacity, nothing we can do...
next unless $status->{"$res\_capacity"};

if (($status->{"$res\_stored"}/$status->{"$res\_capacity"}) < $profile->{request_below}) {
my $amt = int($status->{"$res\_capacity"} * $profile->{requested_level}) - $status->{"$res\_stored"};
$self->{push_info}->{$pid}->{$res}->{requested} = $amt;
Expand Down
2 changes: 1 addition & 1 deletion lib/Games/Lacuna/Client/PrettyPrint.pm
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ sub show_status {
_c_('bold '.($pct_full > 95 ? 'red' : $pct_full > 80 ? 'yellow' : 'green')),
$res eq 'happiness' ? ' --' : sprintf('%3d%%',$pct_full),
_c_('cyan'),
$res eq 'happiness' ? ' --' : sprintf('% 6.1f',($status->{"$res\_capacity"} - $status->{"$res\_stored"})/$status->{"$res\_hour"}),
$res eq 'happiness' ? ' --' : $status->{"$res\_hour"} ? sprintf('% 6.1f',($status->{"$res\_capacity"} - $status->{"$res\_stored"})/$status->{"$res\_hour"}) : ' N/A',
_c_('reset');
}
show_bar('-');
Expand Down

0 comments on commit 3639acd

Please sign in to comment.