From 7ffa7cb3d5e558716ab054787fbcda0a1fba53de Mon Sep 17 00:00:00 2001 From: Iain C Docherty Date: Sat, 23 Mar 2013 11:45:21 -0400 Subject: [PATCH] Fix for Glyph Building upgrades without a hall --- lib/Lacuna/DB/Result/Building/Permanent/EssentiaVein.pm | 5 +++-- lib/Lacuna/RPC/Building.pm | 2 ++ lib/Lacuna/Role/Building/UpgradeWithHalls.pm | 4 +++- var/www/public/changes.txt | 3 +++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/Lacuna/DB/Result/Building/Permanent/EssentiaVein.pm b/lib/Lacuna/DB/Result/Building/Permanent/EssentiaVein.pm index 78bacb2a..b133a605 100644 --- a/lib/Lacuna/DB/Result/Building/Permanent/EssentiaVein.pm +++ b/lib/Lacuna/DB/Result/Building/Permanent/EssentiaVein.pm @@ -41,10 +41,11 @@ before start_upgrade => sub { my ($self, $cost) = @_; my ($plans) = grep {$_->class eq 'Lacuna::DB::Result::Building::Permanent::HallsOfVrbansk'} @{$self->body->plan_cache}; - $self->body->delete_many_plans($plans, $self->level + 1); + if ($cost->{halls}) { + $self->body->delete_many_plans($plans, $cost->{halls}); + } }; - use constant image => 'essentiavein'; sub image_level { diff --git a/lib/Lacuna/RPC/Building.pm b/lib/Lacuna/RPC/Building.pm index 71f655e1..c5e1c613 100644 --- a/lib/Lacuna/RPC/Building.pm +++ b/lib/Lacuna/RPC/Building.pm @@ -40,6 +40,7 @@ sub upgrade { my $plan = $body->get_plan($building->class, $building->level + 1); if (defined $plan) { $body->delete_one_plan($plan); + $cost->{halls} = 0; } else { $body->spend_water($cost->{water}); @@ -48,6 +49,7 @@ sub upgrade { $body->spend_ore($cost->{ore}); $body->add_waste($cost->{waste}); $body->update; + $cost->{halls} = $building->level + 1; } $building->start_upgrade($cost); diff --git a/lib/Lacuna/Role/Building/UpgradeWithHalls.pm b/lib/Lacuna/Role/Building/UpgradeWithHalls.pm index 141d6f49..e41ecfb3 100644 --- a/lib/Lacuna/Role/Building/UpgradeWithHalls.pm +++ b/lib/Lacuna/Role/Building/UpgradeWithHalls.pm @@ -27,7 +27,9 @@ before start_upgrade => sub { my ($self, $cost) = @_; my ($plans) = grep {$_->class eq 'Lacuna::DB::Result::Building::Permanent::HallsOfVrbansk'} @{$self->body->plan_cache}; - $self->body->delete_many_plans($plans, $self->level + 1); + if (defined $cost and $cost->{halls}) { + $self->body->delete_many_plans($plans, $cost->{halls}); + } }; 1; diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 36a35351..5f582b76 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -1,3 +1,6 @@ +3.0884: + - Fix: Bug when upgrading Glyph buildings, but with no hall plans + 3.0883: - Fix: Library timer was too excessive. - Mod: Gradual increase in TM range from 465 to 900. -- 2.51.2