diff --git a/lib/Lacuna.pm b/lib/Lacuna.pm index 412cbf0c..dcf77f7a 100644 --- a/lib/Lacuna.pm +++ b/lib/Lacuna.pm @@ -7,7 +7,7 @@ use Config::JSON; useall __PACKAGE__; -our $VERSION = 3.0865; +our $VERSION = 3.0866; my $config = Config::JSON->new('/data/Lacuna-Server/etc/lacuna.conf'); my $db = Lacuna::DB->connect($config->get('db/dsn'),$config->get('db/username'),$config->get('db/password'), { mysql_enable_utf8 => 1}); diff --git a/lib/Lacuna/DB/Result/Map/Body/Planet.pm b/lib/Lacuna/DB/Result/Map/Body/Planet.pm index 247d8702..4e79d5ca 100644 --- a/lib/Lacuna/DB/Result/Map/Body/Planet.pm +++ b/lib/Lacuna/DB/Result/Map/Body/Planet.pm @@ -1409,7 +1409,7 @@ sub tick_to { } # Process excavator sites if ( my $arch = $self->archaeology) { - if ($arch->efficiency == 100) { + if ($arch->efficiency == 100 and $arch->level > 0) { my $dig_sec = $now->epoch - $arch->last_check->epoch; if ($dig_sec >= 3600) { my $dig_hours = int($dig_sec/3600); diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 1009dfe3..1ef283fb 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -1,3 +1,6 @@ +3.0866: + - Fix: Freshly built ArchMin were returning results before completing their build. + 3.0865: - Mod: Removed option to disable display of incoming ships. (To see if it fixes some resource issues) - Mod: Attempt to make Counter Espionage tutorial message clearer since people don't read the entire email. -- 2.51.2 From a1f0622216fa78f0341b83b82266249899fb4b9c Mon Sep 17 00:00:00 2001 From: ysth Date: Wed, 22 Aug 2012 00:20:24 -0700 Subject: [PATCH 2/7] Prevent "No such spy" trying to skills train level 0 spy --- lib/Lacuna/DB/Result/Building/IntelTraining.pm | 4 ++-- lib/Lacuna/DB/Result/Building/MayhemTraining.pm | 4 ++-- lib/Lacuna/DB/Result/Building/PoliticsTraining.pm | 4 ++-- lib/Lacuna/DB/Result/Building/TheftTraining.pm | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/Lacuna/DB/Result/Building/IntelTraining.pm b/lib/Lacuna/DB/Result/Building/IntelTraining.pm index dd6180e1..fa081ca1 100644 --- a/lib/Lacuna/DB/Result/Building/IntelTraining.pm +++ b/lib/Lacuna/DB/Result/Building/IntelTraining.pm @@ -136,8 +136,8 @@ sub train_spy { my ($self, $spy_id, $time_to_train) = @_; my $empire = $self->body->empire; my $spy = $self->get_spy($spy_id); - unless ($time_to_train) { - $time_to_train = $self->training_costs($spy)->{time}; + unless (defined $time_to_train) { + $time_to_train = $self->training_costs($spy_id)->{time}; } unless ($spy->task ~~ ['Counter Espionage','Idle']) { confess [1011, 'Spy must be idle to train.']; diff --git a/lib/Lacuna/DB/Result/Building/MayhemTraining.pm b/lib/Lacuna/DB/Result/Building/MayhemTraining.pm index 2455933b..5b7e29e1 100644 --- a/lib/Lacuna/DB/Result/Building/MayhemTraining.pm +++ b/lib/Lacuna/DB/Result/Building/MayhemTraining.pm @@ -139,8 +139,8 @@ sub train_spy { my ($self, $spy_id, $time_to_train) = @_; my $empire = $self->body->empire; my $spy = $self->get_spy($spy_id); - unless ($time_to_train) { - $time_to_train = $self->training_costs($spy)->{time}; + unless (defined $time_to_train) { + $time_to_train = $self->training_costs($spy_id)->{time}; } unless ($spy->task ~~ ['Counter Espionage','Idle']) { confess [1011, 'Spy must be idle to train.']; diff --git a/lib/Lacuna/DB/Result/Building/PoliticsTraining.pm b/lib/Lacuna/DB/Result/Building/PoliticsTraining.pm index 02c16882..94c52f7d 100644 --- a/lib/Lacuna/DB/Result/Building/PoliticsTraining.pm +++ b/lib/Lacuna/DB/Result/Building/PoliticsTraining.pm @@ -136,8 +136,8 @@ sub train_spy { my ($self, $spy_id, $time_to_train) = @_; my $empire = $self->body->empire; my $spy = $self->get_spy($spy_id); - unless ($time_to_train) { - $time_to_train = $self->training_costs($spy)->{time}; + unless (defined $time_to_train) { + $time_to_train = $self->training_costs($spy_id)->{time}; } unless ($spy->task ~~ ['Counter Espionage','Idle']) { confess [1011, 'Spy must be idle to train.']; diff --git a/lib/Lacuna/DB/Result/Building/TheftTraining.pm b/lib/Lacuna/DB/Result/Building/TheftTraining.pm index f2a37f7e..3bad2dbd 100644 --- a/lib/Lacuna/DB/Result/Building/TheftTraining.pm +++ b/lib/Lacuna/DB/Result/Building/TheftTraining.pm @@ -136,8 +136,8 @@ sub train_spy { my ($self, $spy_id, $time_to_train) = @_; my $empire = $self->body->empire; my $spy = $self->get_spy($spy_id); - unless ($time_to_train) { - $time_to_train = $self->training_costs($spy)->{time}; + unless (defined $time_to_train) { + $time_to_train = $self->training_costs($spy_id)->{time}; } unless ($spy->task ~~ ['Counter Espionage','Idle']) { confess [1011, 'Spy must be idle to train.']; -- 2.51.2 From 05e96d4dc03a16e1269dc73abf04b28a9f618c63 Mon Sep 17 00:00:00 2001 From: lemming552 Date: Sat, 25 Aug 2012 11:31:58 -0600 Subject: [PATCH 3/7] Do not recalc a supply chain for an asteroid target. --- lib/Lacuna/RPC/Building/BlackHoleGenerator.pm | 36 ++++++++++--------- var/www/public/changes.txt | 1 + 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/lib/Lacuna/RPC/Building/BlackHoleGenerator.pm b/lib/Lacuna/RPC/Building/BlackHoleGenerator.pm index 839fd651..3e070716 100644 --- a/lib/Lacuna/RPC/Building/BlackHoleGenerator.pm +++ b/lib/Lacuna/RPC/Building/BlackHoleGenerator.pm @@ -484,24 +484,26 @@ sub bhg_swap { }); unless ($new_data->{type} eq "empty") { - $target->update({ - needs_recalc => 1, - x => $old_data->{x}, - y => $old_data->{y}, - zone => $old_data->{zone}, - star_id => $old_data->{star_id}, - orbit => $old_data->{orbit}, - }); - my $target_waste = Lacuna->db->resultset('Lacuna::DB::Result::WasteChain') - ->search({ planet_id => $target->id }); - if ($target_waste->count > 0) { - while (my $chain = $target_waste->next) { - $chain->update({ - star_id => $old_data->{star_id} - }); + $target->update({ + needs_recalc => 1, + x => $old_data->{x}, + y => $old_data->{y}, + zone => $old_data->{zone}, + star_id => $old_data->{star_id}, + orbit => $old_data->{orbit}, + }); + if ($new_data->{type} ne 'asteroid') { + my $target_waste = Lacuna->db->resultset('Lacuna::DB::Result::WasteChain') + ->search({ planet_id => $target->id }); + if ($target_waste->count > 0) { + while (my $chain = $target_waste->next) { + $chain->update({ + star_id => $old_data->{star_id} + }); + } + } + $target->recalc_chains; # Recalc all chains } - } - $target->recalc_chains; # Recalc all chains } my $waste_chain = Lacuna->db->resultset('Lacuna::DB::Result::WasteChain') diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 1ef283fb..e1450505 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -1,5 +1,6 @@ 3.0866: - Fix: Freshly built ArchMin were returning results before completing their build. + - Fix: No longer will recalculate a supply chain on an asteroid. 3.0865: - Mod: Removed option to disable display of incoming ships. (To see if it fixes some resource issues) -- 2.51.2 From 2caaf76a199c681117fe8e67481dcd97139ea9e2 Mon Sep 17 00:00:00 2001 From: lemming552 Date: Sat, 25 Aug 2012 12:45:58 -0600 Subject: [PATCH 4/7] Minimum training times for spies. --- lib/Lacuna/DB/Result/Building/IntelTraining.pm | 10 ++++++++-- lib/Lacuna/DB/Result/Building/MayhemTraining.pm | 8 ++++++-- lib/Lacuna/DB/Result/Building/PoliticsTraining.pm | 8 ++++++-- lib/Lacuna/DB/Result/Building/TheftTraining.pm | 8 ++++++-- var/www/public/changes.txt | 1 + 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/lib/Lacuna/DB/Result/Building/IntelTraining.pm b/lib/Lacuna/DB/Result/Building/IntelTraining.pm index fa081ca1..a49dbcf0 100644 --- a/lib/Lacuna/DB/Result/Building/IntelTraining.pm +++ b/lib/Lacuna/DB/Result/Building/IntelTraining.pm @@ -96,15 +96,21 @@ sub training_costs { }; if ($spy_id) { my $spy = $self->get_spy($spy_id); - $costs->{time} = sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100)); + my $train_time = sprintf('%.0f', 3600 * $spy->level * + ((100 - (5 * $self->body->empire->management_affinity)) / 100)); + $train_time = 3600 if ($train_time < 3600); + $costs->{time} = $train_time; } else { my $spies = $self->get_spies->search({ task => { in => ['Counter Espionage','Idle'] } }); while (my $spy = $spies->next) { + my $train_time = sprintf('%.0f', 3600 * $spy->level * + ((100 - (5 * $self->body->empire->management_affinity)) / 100)); + $train_time = 3600 if ($train_time < 3600); push @{$costs->{time}}, { spy_id => $spy->id, name => $spy->name, - time => sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100)), + time => $train_time, }; } } diff --git a/lib/Lacuna/DB/Result/Building/MayhemTraining.pm b/lib/Lacuna/DB/Result/Building/MayhemTraining.pm index 5b7e29e1..1f56a2ad 100644 --- a/lib/Lacuna/DB/Result/Building/MayhemTraining.pm +++ b/lib/Lacuna/DB/Result/Building/MayhemTraining.pm @@ -99,15 +99,19 @@ sub training_costs { }; if ($spy_id) { my $spy = $self->get_spy($spy_id); - $costs->{time} = sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100)); + my $train_time = sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100)); + $train_time = 3600 if ($train_time < 3600); + $costs->{time} = $train_time; } else { my $spies = $self->get_spies->search({ task => { in => ['Counter Espionage','Idle'] } }); while (my $spy = $spies->next) { + my $train_time = sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100)); + $train_time = 3600 if ($train_time < 3600); push @{$costs->{time}}, { spy_id => $spy->id, name => $spy->name, - time => sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100)), + time => $train_time, }; } } diff --git a/lib/Lacuna/DB/Result/Building/PoliticsTraining.pm b/lib/Lacuna/DB/Result/Building/PoliticsTraining.pm index 94c52f7d..463b3670 100644 --- a/lib/Lacuna/DB/Result/Building/PoliticsTraining.pm +++ b/lib/Lacuna/DB/Result/Building/PoliticsTraining.pm @@ -96,15 +96,19 @@ sub training_costs { }; if ($spy_id) { my $spy = $self->get_spy($spy_id); - $costs->{time} = sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100)); + my $train_time = sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100)); + $train_time = 3600 if ($train_time < 3600); + $costs->{time} = $train_time; } else { my $spies = $self->get_spies->search({ task => { in => ['Counter Espionage','Idle'] } }); while (my $spy = $spies->next) { + my $train_time = sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100)); + $train_time = 3600 if ($train_time < 3600); push @{$costs->{time}}, { spy_id => $spy->id, name => $spy->name, - time => sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100)), + time => $train_time, }; } } diff --git a/lib/Lacuna/DB/Result/Building/TheftTraining.pm b/lib/Lacuna/DB/Result/Building/TheftTraining.pm index 3bad2dbd..e15a5323 100644 --- a/lib/Lacuna/DB/Result/Building/TheftTraining.pm +++ b/lib/Lacuna/DB/Result/Building/TheftTraining.pm @@ -96,15 +96,19 @@ sub training_costs { }; if ($spy_id) { my $spy = $self->get_spy($spy_id); - $costs->{time} = sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100)); + my $train_time = sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100)); + $train_time = 3600 if ($train_time < 3600); + $costs->{time} = $train_time; } else { my $spies = $self->get_spies->search({ task => { in => ['Counter Espionage','Idle'] } }); while (my $spy = $spies->next) { + my $train_time = sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100)); + $train_time = 3600 if ($train_time < 3600); push @{$costs->{time}}, { spy_id => $spy->id, name => $spy->name, - time => sprintf('%.0f', 3600 * $spy->level * ((100 - (5 * $self->body->empire->management_affinity)) / 100)), + time => $train_time, }; } } diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index e1450505..be8b1b4c 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -1,6 +1,7 @@ 3.0866: - Fix: Freshly built ArchMin were returning results before completing their build. - Fix: No longer will recalculate a supply chain on an asteroid. + - Fix: Minimum training times in spy training buildings. 3.0865: - Mod: Removed option to disable display of incoming ships. (To see if it fixes some resource issues) -- 2.51.2 From 8587e99748c84f30a57e47a941dcbac18ced262c Mon Sep 17 00:00:00 2001 From: lemming552 Date: Sat, 25 Aug 2012 14:38:54 -0600 Subject: [PATCH 5/7] Fixed placing a BHG on a SS. --- .../DB/Result/Building/Permanent/BlackHoleGenerator.pm | 6 ++++-- var/www/public/changes.txt | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Lacuna/DB/Result/Building/Permanent/BlackHoleGenerator.pm b/lib/Lacuna/DB/Result/Building/Permanent/BlackHoleGenerator.pm index 9782e9c8..3a13a2ca 100644 --- a/lib/Lacuna/DB/Result/Building/Permanent/BlackHoleGenerator.pm +++ b/lib/Lacuna/DB/Result/Building/Permanent/BlackHoleGenerator.pm @@ -37,8 +37,10 @@ after finish_upgrade => sub { sub can_build_on { my $self = shift; - unless ($self->body->isa('Lacuna::DB::Result::Map::Body::Planet') && - !$self->body->isa('Lacuna::DB::Result::Map::Body::Planet::GasGiant')) { + + if ( !$self->body->isa('Lacuna::DB::Result::Map::Body::Planet') || + $self->body->isa('Lacuna::DB::Result::Map::Body::Planet::Station') || + $self->body->isa('Lacuna::DB::Result::Map::Body::Planet::Gas Giant')) { confess [1009, 'Can only be built on habitable planets.']; } return 1; diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index be8b1b4c..12abfba3 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -2,6 +2,7 @@ - Fix: Freshly built ArchMin were returning results before completing their build. - Fix: No longer will recalculate a supply chain on an asteroid. - Fix: Minimum training times in spy training buildings. + - Fix: Can no longer place a useless BHG on a space station. 3.0865: - Mod: Removed option to disable display of incoming ships. (To see if it fixes some resource issues) -- 2.51.2 From 5da8add776ceb5b0b440f46fdcd75aaf67094516 Mon Sep 17 00:00:00 2001 From: ysth Date: Mon, 27 Aug 2012 19:49:31 -0700 Subject: [PATCH 6/7] BHG could place multiple decor in one plot --- lib/Lacuna/DB/Result/Map/Body/Planet.pm | 6 ++++-- lib/Lacuna/RPC/Building/BlackHoleGenerator.pm | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/Lacuna/DB/Result/Map/Body/Planet.pm b/lib/Lacuna/DB/Result/Map/Body/Planet.pm index 4e79d5ca..cc2fcd2d 100644 --- a/lib/Lacuna/DB/Result/Map/Body/Planet.pm +++ b/lib/Lacuna/DB/Result/Map/Body/Planet.pm @@ -899,7 +899,7 @@ sub is_plot_locked { } sub build_building { - my ($self, $building, $in_parallel) = @_; + my ($self, $building, $in_parallel, $no_upgrade) = @_; unless ($building->isa('Lacuna::DB::Result::Building::Permanent')) { $self->building_count( $self->building_count + 1 ); $self->plots_available( $self->plots_available - 1 ); @@ -911,7 +911,9 @@ sub build_building { $building->insert; $building->body($self); weaken($building->{_relationship_data}{body}); - $building->start_upgrade(undef, $in_parallel); + unless ($no_upgrade) { + $building->start_upgrade(undef, $in_parallel); + } $self->building_cache([@{$self->building_cache}, $building]); } diff --git a/lib/Lacuna/RPC/Building/BlackHoleGenerator.pm b/lib/Lacuna/RPC/Building/BlackHoleGenerator.pm index 3e070716..d939cefc 100644 --- a/lib/Lacuna/RPC/Building/BlackHoleGenerator.pm +++ b/lib/Lacuna/RPC/Building/BlackHoleGenerator.pm @@ -789,18 +789,18 @@ sub bhg_decor { } $max_level = 30 if $max_level > 30; my $planted = 0; - my $now = DateTime->now; foreach my $cnt (1..$plant) { my ($x, $y) = eval { $body->find_free_space}; unless ($@) { - my $deployed = Lacuna->db->resultset('Lacuna::DB::Result::Building')->new({ - date_created => $now, - class => random_element(\@decor), + my $building = Lacuna->db->resultset('Lacuna::DB::Result::Building')->new({ x => $x, y => $y, level => randint(1, $max_level), body_id => $body->id, - })->insert; + body => $body, + class => random_element(\@decor), + }); + $body->build_building($building, undef, 1); $planted++; } else { -- 2.51.2 From 161c4d87309b36ee8f072dbe52763fda53333d5e Mon Sep 17 00:00:00 2001 From: lemming552 Date: Tue, 28 Aug 2012 14:04:56 -0600 Subject: [PATCH 7/7] Slight tweak in order of rechecking plot count after building. --- lib/Lacuna/DB/Result/Map/Body/Planet.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Lacuna/DB/Result/Map/Body/Planet.pm b/lib/Lacuna/DB/Result/Map/Body/Planet.pm index cc2fcd2d..5041c32f 100644 --- a/lib/Lacuna/DB/Result/Map/Body/Planet.pm +++ b/lib/Lacuna/DB/Result/Map/Body/Planet.pm @@ -900,11 +900,6 @@ sub is_plot_locked { sub build_building { my ($self, $building, $in_parallel, $no_upgrade) = @_; - unless ($building->isa('Lacuna::DB::Result::Building::Permanent')) { - $self->building_count( $self->building_count + 1 ); - $self->plots_available( $self->plots_available - 1 ); - $self->update; - } $building->date_created(DateTime->now); $building->body_id($self->id); $building->level(0) unless $building->level; @@ -915,6 +910,11 @@ sub build_building { $building->start_upgrade(undef, $in_parallel); } $self->building_cache([@{$self->building_cache}, $building]); + unless ($building->isa('Lacuna::DB::Result::Building::Permanent')) { + $self->building_count( $self->building_count + 1 ); + $self->plots_available( $self->plots_available - 1 ); + $self->update; + } } sub found_colony {