diff --git a/lib/Lacuna/DB/Result/Map/Body/Planet.pm b/lib/Lacuna/DB/Result/Map/Body/Planet.pm index cbb40807..8bc18b85 100644 --- a/lib/Lacuna/DB/Result/Map/Body/Planet.pm +++ b/lib/Lacuna/DB/Result/Map/Body/Planet.pm @@ -125,7 +125,7 @@ sub sanitize { $self->alliance_id(undef); $self->plans->delete; $self->glyphs->delete; - my $incoming = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({foreign_body_id => $self->id}); + my $incoming = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->search({foreign_body_id => $self->id, direction => 'out'}); while (my $ship = $incoming->next) { $ship->turn_around->update; } -- 2.51.2 From 28695afcde4d293e47d49422cd9dacfd674d85b6 Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Mon, 25 Apr 2011 21:17:55 -0500 Subject: [PATCH 02/34] Fix: Abandoning a planet will no longer cause stolen ships to turn around. --- var/www/public/changes.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index b9c04f58..48d371fc 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -1,5 +1,6 @@ x.xxxx - Add: Lost City of Tyleon credits. + - Fix: Abandoning a planet will no longer cause stolen ships to turn around. 3.0603 - Fix: Space Stations should no longer complain about food. -- 2.51.2 From ba34e92027e4c40fa623d43866fab114bda7c4cc Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Mon, 25 Apr 2011 21:29:26 -0500 Subject: [PATCH 03/34] updated changes.txt --- var/www/public/changes.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 48d371fc..fb2c9853 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -1,6 +1,7 @@ x.xxxx - Add: Lost City of Tyleon credits. - Fix: Abandoning a planet will no longer cause stolen ships to turn around. + - Fix: The typo that crept into Parliament rename star has also been corrected. 3.0603 - Fix: Space Stations should no longer complain about food. -- 2.51.2 From 767d42f7ff77471bece72815777d9b57f6e9940c Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Mon, 25 Apr 2011 22:25:46 -0500 Subject: [PATCH 04/34] Fix: Ships pushed via the Trade Ministry will count against the receiving SpacePort's count as soon as they are sent. --- lib/Lacuna/DB/Result/Building/Trade.pm | 8 ++++++++ var/www/public/changes.txt | 1 + 2 files changed, 9 insertions(+) diff --git a/lib/Lacuna/DB/Result/Building/Trade.pm b/lib/Lacuna/DB/Result/Building/Trade.pm index 1e7b8a57..b39679b8 100644 --- a/lib/Lacuna/DB/Result/Building/Trade.pm +++ b/lib/Lacuna/DB/Result/Building/Trade.pm @@ -135,6 +135,14 @@ sub push_items { } my ($payload, $meta) = $self->structure_payload($items, $space_used); + foreach my $item (@{$items}) { + if ( $item->{type} eq 'ship' ) { + my $ship = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->find($item->{ship_id}); + next unless defined $ship; + $ship->body_id($body->id); + $ship->update; + } + } if ($options->{stay}) { $ship->body_id($target->id); diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index fb2c9853..63f70ded 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -2,6 +2,7 @@ x.xxxx - Add: Lost City of Tyleon credits. - Fix: Abandoning a planet will no longer cause stolen ships to turn around. - Fix: The typo that crept into Parliament rename star has also been corrected. + - Fix: Ships pushed via the Trade Ministry will count against the receiving SpacePort's count as soon as they are sent. 3.0603 - Fix: Space Stations should no longer complain about food. -- 2.51.2 From ccd7888a118323ce59e6e6e88d604e2f5322a0b5 Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Mon, 25 Apr 2011 22:28:41 -0500 Subject: [PATCH 05/34] Fix typo --- lib/Lacuna/DB/Result/Building/Trade.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Lacuna/DB/Result/Building/Trade.pm b/lib/Lacuna/DB/Result/Building/Trade.pm index b39679b8..82dabe39 100644 --- a/lib/Lacuna/DB/Result/Building/Trade.pm +++ b/lib/Lacuna/DB/Result/Building/Trade.pm @@ -139,7 +139,7 @@ sub push_items { if ( $item->{type} eq 'ship' ) { my $ship = Lacuna->db->resultset('Lacuna::DB::Result::Ships')->find($item->{ship_id}); next unless defined $ship; - $ship->body_id($body->id); + $ship->body_id($target->id); $ship->update; } } -- 2.51.2 From 48614cc764ef65e8cf1c2385b883582e77389290 Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Mon, 25 Apr 2011 23:29:16 -0500 Subject: [PATCH 06/34] Fix: Trade Ministry and SST get_prisoners() now includes the sentence expiration of the spy. Fix: Prisoners now list their sentence expiration as well. --- docs/Trade.pod | 5 +++-- docs/Transporter.pod | 1 + lib/Lacuna/Role/Container.pm | 2 +- lib/Lacuna/Role/TraderRpc.pm | 3 ++- var/www/public/changes.txt | 2 ++ 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/Trade.pod b/docs/Trade.pod index ea9bb826..64b519fa 100644 --- a/docs/Trade.pod +++ b/docs/Trade.pod @@ -221,7 +221,8 @@ Returns a list of prisoners that may be traded. Used with the C metho { "id" : "id-goes-here", "name" : "Jack Bauer", - "level" : "5" + "level" : "5", + "sentence_expires" : "01 31 2010 13:09:05 +0600" }, ... ], @@ -495,7 +496,7 @@ Allows you to push items between your colonies. { "status" : { ... }, "ship" : { - "name" : "SS Minow", + "name" : "SS Minnow", "type" : "cargo_ship", "date_arrives" : "01 31 2010 13:09:05 +0600", ... diff --git a/docs/Transporter.pod b/docs/Transporter.pod index 820bd92b..9230ad22 100644 --- a/docs/Transporter.pod +++ b/docs/Transporter.pod @@ -217,6 +217,7 @@ Returns a list of prisoners that may be traded. Used with the C metho "id" : "id-goes-here", "name" : "Jack Bauer", "level" : "5" + "sentence_expires" : "01 31 2010 13:09:05 +0600" }, ... ], diff --git a/lib/Lacuna/Role/Container.pm b/lib/Lacuna/Role/Container.pm index 722611e4..4cc6be88 100644 --- a/lib/Lacuna/Role/Container.pm +++ b/lib/Lacuna/Role/Container.pm @@ -145,7 +145,7 @@ sub format_description_of_payload { foreach my $id (@{$payload->{prisoners}}) { my $spy = $spies->find($id); next unless defined $spy; - push @items, 'Level '.$spy->level.' spy named '.$spy->name . ' (prisoner)'; + push @items, 'Level '.$spy->level.' spy named '.$spy->name . ' (prisoner) sentence expires '.$spy->available_on; } } diff --git a/lib/Lacuna/Role/TraderRpc.pm b/lib/Lacuna/Role/TraderRpc.pm index 2d39ed2b..82228a2f 100644 --- a/lib/Lacuna/Role/TraderRpc.pm +++ b/lib/Lacuna/Role/TraderRpc.pm @@ -100,7 +100,7 @@ sub get_prisoners { my $empire = $self->get_empire_by_session($session_id); my $building = $self->get_building($empire, $building_id); my $prisoners = Lacuna->db->resultset('Lacuna::DB::Result::Spies')->search( - {on_body_id => $building->body_id, task => 'Captured'}, + { on_body_id => $building->body_id, task => 'Captured', available_on => { '>' => DateTime->now } } {order_by => [ 'name' ]} ); my @out; @@ -109,6 +109,7 @@ sub get_prisoners { id => $prisoner->id, name => $prisoner->name, level => $prisoner->level, + sentence_expires => $prisoner->available_on, }; } return { diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 63f70ded..8ee7ffb2 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -3,6 +3,8 @@ x.xxxx - Fix: Abandoning a planet will no longer cause stolen ships to turn around. - Fix: The typo that crept into Parliament rename star has also been corrected. - Fix: Ships pushed via the Trade Ministry will count against the receiving SpacePort's count as soon as they are sent. + - Fix: Trade Ministry and SST get_prisoners() now includes the sentence expiration of the spy. + - Fix: Prisoners now list their sentence expiration as well. 3.0603 - Fix: Space Stations should no longer complain about food. -- 2.51.2 From 2d7b8f82c633be1646fcfd35e199cb5d09f301e3 Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Mon, 25 Apr 2011 23:42:38 -0500 Subject: [PATCH 07/34] Fix: Ships pushed via the Trade Ministry will count against the receiving SpacePort's count as soon as they are sent. --- lib/Lacuna/Role/TraderRpc.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Lacuna/Role/TraderRpc.pm b/lib/Lacuna/Role/TraderRpc.pm index 82228a2f..7e1de609 100644 --- a/lib/Lacuna/Role/TraderRpc.pm +++ b/lib/Lacuna/Role/TraderRpc.pm @@ -100,7 +100,7 @@ sub get_prisoners { my $empire = $self->get_empire_by_session($session_id); my $building = $self->get_building($empire, $building_id); my $prisoners = Lacuna->db->resultset('Lacuna::DB::Result::Spies')->search( - { on_body_id => $building->body_id, task => 'Captured', available_on => { '>' => DateTime->now } } + { on_body_id => $building->body_id, task => 'Captured', available_on => { '>' => DateTime->now } }, {order_by => [ 'name' ]} ); my @out; -- 2.51.2 From 666ee8fa6c5e3524adc4a0ecd6e35b96f195dd27 Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Tue, 26 Apr 2011 20:12:35 -0500 Subject: [PATCH 08/34] Rule: Only allow 5,000 RPC per day and limit rate to no more than 50 per minute. API: Added an RPC boost that doubles the RPC per day and increases the throttle allowance by 50%. --- docs/Empire.pod | 20 ++++++++++++++++++++ lib/Lacuna/DB/Result/Empire.pm | 1 + lib/Lacuna/DB/Result/Map/Body/Planet.pm | 2 +- lib/Lacuna/RPC.pm | 3 +++ lib/Lacuna/RPC/Empire.pm | 17 ++++++++++++++--- t/Boosts.t | 16 ++++++++++++++-- var/upgrades/3.0700.sql | 3 +++ var/www/public/changes.txt | 6 ++++-- 8 files changed, 60 insertions(+), 8 deletions(-) create mode 100644 var/upgrades/3.0700.sql diff --git a/docs/Empire.pod b/docs/Empire.pod index b018315e..a15d80fe 100644 --- a/docs/Empire.pod +++ b/docs/Empire.pod @@ -579,6 +579,7 @@ Shows the dates at which boosts have expired or will expire. Boosts are subsidie "water" : "01 31 2010 13:09:05 +0600", "happiness" : "01 31 2010 13:09:05 +0600", "storage" : "01 31 2010 13:09:05 +0600" + "rpc" : "01 31 2010 13:09:05 +0600" } } @@ -686,6 +687,25 @@ A session id. +=head2 boost_rpc ( session_id ) + +Spends 25 essentia, and boosts the number of RPC calls allowed per minute by 50% as well as doubling the total number RPC calls per day. If a boost is already underway, calling again will add 7 more days. + +NOTE: The boost will not affect the 'rpc_limit' returned as a part of server status. + + { + "status" : { ... }, + "rpc_boost" : "01 31 2010 13:09:05 +0600" + } + +Throws 1011. + +=head3 session_id + +A session id. + + + =head2 enable_self_destruct ( session_id ) Enables a destruction countdown of 24 hours. Sometime after the timer runs out, the empire will vaporize. diff --git a/lib/Lacuna/DB/Result/Empire.pm b/lib/Lacuna/DB/Result/Empire.pm index 46ce11d2..d56e78d6 100644 --- a/lib/Lacuna/DB/Result/Empire.pm +++ b/lib/Lacuna/DB/Result/Empire.pm @@ -45,6 +45,7 @@ __PACKAGE__->add_columns( ore_boost => { data_type => 'datetime', is_nullable => 0, set_on_create => 1 }, energy_boost => { data_type => 'datetime', is_nullable => 0, set_on_create => 1 }, happiness_boost => { data_type => 'datetime', is_nullable => 0, set_on_create => 1 }, + rpc_boost => { data_type => 'datetime', is_nullable => 0, set_on_create => 1 }, facebook_uid => { data_type => 'bigint', is_nullable => 1 }, facebook_token => { data_type => 'varchar', size => 100, is_nullable => 1 }, alliance_id => { data_type => 'int', is_nullable => 1 }, diff --git a/lib/Lacuna/DB/Result/Map/Body/Planet.pm b/lib/Lacuna/DB/Result/Map/Body/Planet.pm index 8bc18b85..f1254842 100644 --- a/lib/Lacuna/DB/Result/Map/Body/Planet.pm +++ b/lib/Lacuna/DB/Result/Map/Body/Planet.pm @@ -991,7 +991,7 @@ sub tick { if ($self->boost_enabled) { my $empire = $self->empire; my $still_enabled = 0; - foreach my $resource (qw(energy water ore happiness food storage)) { + foreach my $resource (qw(energy water ore happiness food storage rpc)) { my $boost = $resource.'_boost'; if ($now_epoch > $empire->$boost->epoch) { $self->needs_recalc(1); diff --git a/lib/Lacuna/RPC.pm b/lib/Lacuna/RPC.pm index e69dd8e3..bda82206 100644 --- a/lib/Lacuna/RPC.pm +++ b/lib/Lacuna/RPC.pm @@ -33,11 +33,14 @@ sub get_empire_by_session { else { my $empire = $self->get_session($session_id)->empire; if (defined $empire) { + my $boost = (time < $empire->rpc_boost->epoch) ? 1 : 0; my $throttle = Lacuna->config->get('rpc_throttle') || 30; + $throttle *= 1.5 if ($boost); if ($empire->rpc_rate > $throttle) { confess [1010, 'Slow down! No more than '.$throttle.' requests per minute.']; } my $max = Lacuna->config->get('rpc_limit') || 2500; + $max *= 2 if ($boost); if ($empire->rpc_count > $max) { confess [1010, 'You have already made the maximum number of requests ('.$max.') you can make for one day.']; } diff --git a/lib/Lacuna/RPC/Empire.pm b/lib/Lacuna/RPC/Empire.pm index bc2f0800..bcaec790 100644 --- a/lib/Lacuna/RPC/Empire.pm +++ b/lib/Lacuna/RPC/Empire.pm @@ -73,14 +73,18 @@ sub login { unless (defined $empire) { confess [1002, 'Empire does not exist.', $name]; } + my $boost = (time < $empire->rpc_boost->epoch) ? 1 : 0; my $throttle = Lacuna->config->get('rpc_throttle') || 30; + $throttle *= 1.5 if ($boost); if ($empire->rpc_rate > $throttle) { confess [1010, 'Slow down! No more than '.$throttle.' requests per minute.']; } my $max = Lacuna->config->get('rpc_limit') || 2500; + $max *= 2 if ($boost); if ($empire->rpc_count > $max) { confess [1010, 'You have already made the maximum number of requests ('.$max.') you can make for one day.']; } + #Lacuna->db->resultset('Lacuna::DB::Result::Log::RPC')->new({ # empire_id => $empire->id, # empire_name => $empire->name, @@ -671,13 +675,19 @@ sub boost_storage { return $self->boost($session_id, 'storage_boost'); } +sub boost_rpc { + my ($self, $session_id) = @_; + return $self->boost($session_id, 'rpc_boost'); +} + sub boost { my ($self, $session_id, $type) = @_; my $empire = $self->get_empire_by_session($session_id); - unless ($empire->essentia >= 5) { + my $cost = $type eq 'rpc' ? 25 : 5; + unless ($empire->essentia >= $cost) { confess [1011, 'Not enough essentia.']; } - $empire->spend_essentia(5, $type.' boost'); + $empire->spend_essentia($cost, $type.' boost'); my $start = DateTime->now; $start = $empire->$type if ($empire->$type > $start); $start->add(days=>7); @@ -702,6 +712,7 @@ sub view_boosts { ore => format_date($empire->ore_boost), energy => format_date($empire->energy_boost), storage => format_date($empire->storage_boost), + rpc => format_date($empire->rpc_boost), } }; } @@ -1023,7 +1034,7 @@ __PACKAGE__->register_rpc_method_names( { name => "benchmark", options => { with_plack_request => 1 } }, { name => "found", options => { with_plack_request => 1 } }, { name => "reset_password", options => { with_plack_request => 1 } }, - qw(redefine_species redefine_species_limits get_invite_friend_url get_species_templates update_species view_species_stats send_password_reset_message invite_friend redeem_essentia_code enable_self_destruct disable_self_destruct change_password set_status_message find view_profile edit_profile view_public_profile is_name_available logout get_full_status get_status boost_storage boost_water boost_energy boost_ore boost_food boost_happiness view_boosts), + qw(redefine_species redefine_species_limits get_invite_friend_url get_species_templates update_species view_species_stats send_password_reset_message invite_friend redeem_essentia_code enable_self_destruct disable_self_destruct change_password set_status_message find view_profile edit_profile view_public_profile is_name_available logout get_full_status get_status boost_storage boost_water boost_energy boost_ore boost_food boost_happiness boost_rpc view_boosts), ); diff --git a/t/Boosts.t b/t/Boosts.t index 91c26833..3a975c37 100644 --- a/t/Boosts.t +++ b/t/Boosts.t @@ -1,8 +1,9 @@ use lib '../lib'; -use Test::More tests => 4; +use Test::More tests => 6; use Test::Deep; use Data::Dumper; use 5.010; +use Lacuna::Util qw(format_date); use TestHelper; my $tester = TestHelper->new->generate_test_empire; @@ -19,12 +20,23 @@ cmp_ok($boosted->{result}{body}{ore_hour}, '>', $base->{result}{body}{ore_hour}, $empire->discard_changes; $empire->ore_boost(DateTime->now->subtract(seconds=>60)); $empire->update; +$empire->add_essentia(25,'testing boosts')->update; my $unboosted = $tester->post('body','get_status', [$session_id, $home->id]); $empire->update; cmp_ok($boosted->{result}{body}{ore_hour}, '>', $unboosted->{result}{body}{ore_hour}, 'ore_hour decreased'); my $unboost_message_recieved = $empire->received_messages->search({ subject => { -like => 'Boosts Have Expired%' } })->count; ok($unboost_message_recieved, 'unboost message received'); - +$tester->post('empire','boost_rpc', [$session_id]); +my $check = $tester->post('empire','get_status', [$session_id, $empire->id]); +my $limit = $check->{result}{server}{rpc_limit}; +Lacuna->cache->set('rpc_count_'.format_date(undef,'%d'), $empire->id, $limit, 60 * 60 * 26); +$check = $tester->post('empire','get_status', [$session_id, $home->id]); +my $limit1 = $limit+1; +is($check->{result}{empire}{rpc_count}, $limit1, "rpc_count is $limit1, no error"); +$limit *= 2; +Lacuna->cache->set('rpc_count_'.format_date(undef,'%d'), $empire->id, $limit, 60 * 60 * 26); +$check = $tester->post('empire','get_status', [$session_id, $home->id]); +is($check->{error}{code}, 1010, 'Reached my boosted limit'); END { $tester->cleanup; } diff --git a/var/upgrades/3.0700.sql b/var/upgrades/3.0700.sql new file mode 100644 index 00000000..10cd2763 --- /dev/null +++ b/var/upgrades/3.0700.sql @@ -0,0 +1,3 @@ +alter table empire add column `rpc_boost` datetime NOT NULL; + + diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 8ee7ffb2..27b0884c 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -1,10 +1,12 @@ -x.xxxx - - Add: Lost City of Tyleon credits. +3.0700 + - Rule: Only allow 5,000 RPC per day and limit rate to no more than 50 per minute. + - API: Added an RPC boost that doubles the RPC per day and increases the throttle allowance by 50%. - Fix: Abandoning a planet will no longer cause stolen ships to turn around. - Fix: The typo that crept into Parliament rename star has also been corrected. - Fix: Ships pushed via the Trade Ministry will count against the receiving SpacePort's count as soon as they are sent. - Fix: Trade Ministry and SST get_prisoners() now includes the sentence expiration of the spy. - Fix: Prisoners now list their sentence expiration as well. + - Add: Lost City of Tyleon credits. 3.0603 - Fix: Space Stations should no longer complain about food. -- 2.51.2 From b018ccbb078c5b49643ce3d58f882b079d627351 Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Tue, 26 Apr 2011 20:33:48 -0500 Subject: [PATCH 09/34] Fix upgrade script --- var/upgrades/3.0700.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/var/upgrades/3.0700.sql b/var/upgrades/3.0700.sql index 10cd2763..3058e869 100644 --- a/var/upgrades/3.0700.sql +++ b/var/upgrades/3.0700.sql @@ -1,3 +1,3 @@ -alter table empire add column `rpc_boost` datetime NOT NULL; +alter table empire add column `rpc_boost` datetime NOT NULL default '2011-01-01 01:00:00'; -- 2.51.2 From 2c2bb88d8d2b4714b4409d93d0cba327e5ec8c16 Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Tue, 26 Apr 2011 21:03:04 -0500 Subject: [PATCH 10/34] Update version --- lib/Lacuna.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Lacuna.pm b/lib/Lacuna.pm index 0a05dd64..2b6110f4 100644 --- a/lib/Lacuna.pm +++ b/lib/Lacuna.pm @@ -7,7 +7,7 @@ use Config::JSON; useall __PACKAGE__; -our $VERSION = 3.0603; +our $VERSION = 3.0700; 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}); -- 2.51.2 From 500f6e3423c07f6817a061612eadba7be9ac43cd Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Tue, 26 Apr 2011 21:42:51 -0500 Subject: [PATCH 11/34] format the date silly --- lib/Lacuna/Role/Container.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Lacuna/Role/Container.pm b/lib/Lacuna/Role/Container.pm index 4cc6be88..5c18349c 100644 --- a/lib/Lacuna/Role/Container.pm +++ b/lib/Lacuna/Role/Container.pm @@ -145,7 +145,7 @@ sub format_description_of_payload { foreach my $id (@{$payload->{prisoners}}) { my $spy = $spies->find($id); next unless defined $spy; - push @items, 'Level '.$spy->level.' spy named '.$spy->name . ' (prisoner) sentence expires '.$spy->available_on; + push @items, 'Level '.$spy->level.' spy named '.$spy->name . ' (prisoner) sentence expires '.$spy->format_available_on; } } -- 2.51.2 From a634bed3debb093d1364545148577c34e83e98fa Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Tue, 26 Apr 2011 21:52:17 -0500 Subject: [PATCH 12/34] format the date silly --- lib/Lacuna/Role/Container.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Lacuna/Role/Container.pm b/lib/Lacuna/Role/Container.pm index 5c18349c..722611e4 100644 --- a/lib/Lacuna/Role/Container.pm +++ b/lib/Lacuna/Role/Container.pm @@ -145,7 +145,7 @@ sub format_description_of_payload { foreach my $id (@{$payload->{prisoners}}) { my $spy = $spies->find($id); next unless defined $spy; - push @items, 'Level '.$spy->level.' spy named '.$spy->name . ' (prisoner) sentence expires '.$spy->format_available_on; + push @items, 'Level '.$spy->level.' spy named '.$spy->name . ' (prisoner)'; } } -- 2.51.2 From 5f57faba9cdc12067465f031ed3009309954c30a Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Tue, 26 Apr 2011 21:53:04 -0500 Subject: [PATCH 13/34] fix changes --- var/www/public/changes.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 27b0884c..9f5e6bc1 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -4,7 +4,7 @@ - Fix: Abandoning a planet will no longer cause stolen ships to turn around. - Fix: The typo that crept into Parliament rename star has also been corrected. - Fix: Ships pushed via the Trade Ministry will count against the receiving SpacePort's count as soon as they are sent. - - Fix: Trade Ministry and SST get_prisoners() now includes the sentence expiration of the spy. + - Fix: SST get_prisoners() now includes the sentence expiration of the spy. - Fix: Prisoners now list their sentence expiration as well. - Add: Lost City of Tyleon credits. -- 2.51.2 From 2d58bb3e73a0680da374454282ff339a4416287f Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Tue, 26 Apr 2011 21:56:00 -0500 Subject: [PATCH 14/34] format the date silly --- lib/Lacuna/Role/Container.pm | 2 +- lib/Lacuna/Role/TraderRpc.pm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Lacuna/Role/Container.pm b/lib/Lacuna/Role/Container.pm index 722611e4..5c18349c 100644 --- a/lib/Lacuna/Role/Container.pm +++ b/lib/Lacuna/Role/Container.pm @@ -145,7 +145,7 @@ sub format_description_of_payload { foreach my $id (@{$payload->{prisoners}}) { my $spy = $spies->find($id); next unless defined $spy; - push @items, 'Level '.$spy->level.' spy named '.$spy->name . ' (prisoner)'; + push @items, 'Level '.$spy->level.' spy named '.$spy->name . ' (prisoner) sentence expires '.$spy->format_available_on; } } diff --git a/lib/Lacuna/Role/TraderRpc.pm b/lib/Lacuna/Role/TraderRpc.pm index 7e1de609..f9e71920 100644 --- a/lib/Lacuna/Role/TraderRpc.pm +++ b/lib/Lacuna/Role/TraderRpc.pm @@ -109,7 +109,7 @@ sub get_prisoners { id => $prisoner->id, name => $prisoner->name, level => $prisoner->level, - sentence_expires => $prisoner->available_on, + sentence_expires => $prisoner->format_available_on, }; } return { -- 2.51.2 From 93581ea8a8a53fe80f344e618265182d57bd833d Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Tue, 26 Apr 2011 21:58:32 -0500 Subject: [PATCH 15/34] fix changes --- var/www/public/changes.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 9f5e6bc1..05af0016 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -4,7 +4,7 @@ - Fix: Abandoning a planet will no longer cause stolen ships to turn around. - Fix: The typo that crept into Parliament rename star has also been corrected. - Fix: Ships pushed via the Trade Ministry will count against the receiving SpacePort's count as soon as they are sent. - - Fix: SST get_prisoners() now includes the sentence expiration of the spy. + - Fix: Trade Min and SST get_prisoners() now includes the sentence expiration of the spy. - Fix: Prisoners now list their sentence expiration as well. - Add: Lost City of Tyleon credits. -- 2.51.2 From 5ca937f128a19ea50b68df4637a728430e92a038 Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Thu, 28 Apr 2011 19:30:25 -0500 Subject: [PATCH 16/34] Fix: Passed RenameAsteroid, RenameStar and RenameUninhabited propositions will no longer fail with not in jurisdiction errors when they should not. --- lib/Lacuna/DB/Result/Propositions/RenameAsteroid.pm | 2 +- lib/Lacuna/DB/Result/Propositions/RenameStar.pm | 2 +- lib/Lacuna/DB/Result/Propositions/RenameUninhabited.pm | 2 +- var/www/public/changes.txt | 3 +++ 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/Lacuna/DB/Result/Propositions/RenameAsteroid.pm b/lib/Lacuna/DB/Result/Propositions/RenameAsteroid.pm index 3782385b..13a65fde 100644 --- a/lib/Lacuna/DB/Result/Propositions/RenameAsteroid.pm +++ b/lib/Lacuna/DB/Result/Propositions/RenameAsteroid.pm @@ -14,7 +14,7 @@ before pass => sub { if ($bodies->search({name=>$name, 'body_id'=>{'!='=>$asteroid->id}})->count) { $self->pass_extra_message('Unfortunately, by the time the proposition passed, the name *'.$name.'* had already taken, effectively nullifying the vote.'); } - elsif ($asteroid->star->station_id = $station->id) { + elsif ($asteroid->star->station_id != $station->id) { $self->pass_extra_message('Unfortunately, by the time the proposition passed, the asteroid was no longer under the jurisdiction of this station, effectively nullifying the vote.'); } else { diff --git a/lib/Lacuna/DB/Result/Propositions/RenameStar.pm b/lib/Lacuna/DB/Result/Propositions/RenameStar.pm index d4e4d1d3..84458e79 100644 --- a/lib/Lacuna/DB/Result/Propositions/RenameStar.pm +++ b/lib/Lacuna/DB/Result/Propositions/RenameStar.pm @@ -13,7 +13,7 @@ before pass => sub { if (Lacuna->db->resultset('Lacuna::DB::Result::Map::Star')->search({name=>$name, 'id'=>{'!='=>$star->id}})->count) { $self->pass_extra_message('Unfortunately, by the time the proposition passed, the name *'.$name.'* had already taken, effectively nullifying the vote.'); } - elsif ($star->station_id == $station->id) { + elsif ($star->station_id != $station->id) { $self->pass_extra_message('Unfortunately, by the time the proposition passed, the star was no longer under the jurisdiction of this station, effectively nullifying the vote.'); } else { diff --git a/lib/Lacuna/DB/Result/Propositions/RenameUninhabited.pm b/lib/Lacuna/DB/Result/Propositions/RenameUninhabited.pm index ae596a23..79b93522 100644 --- a/lib/Lacuna/DB/Result/Propositions/RenameUninhabited.pm +++ b/lib/Lacuna/DB/Result/Propositions/RenameUninhabited.pm @@ -14,7 +14,7 @@ before pass => sub { if ($bodies->search({name=>$name, 'body_id'=>{'!='=>$planet->id}})->count) { $self->pass_extra_message('Unfortunately, by the time the proposition passed, the name *'.$name.'* had already taken, effectively nullifying the vote.'); } - elsif ($planet->star->station_id = $station->id) { + elsif ($planet->star->station_id != $station->id) { $self->pass_extra_message('Unfortunately, by the time the proposition passed, the planet was no longer under the jurisdiction of this station, effectively nullifying the vote.'); } elsif ($planet->empire_id) { diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 05af0016..a9cea554 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -1,3 +1,6 @@ +3.0701 + - Fix: Passed RenameAsteroid, RenameStar and RenameUninhabited propositions will no longer fail with not in jurisdiction errors when they should not. + 3.0700 - Rule: Only allow 5,000 RPC per day and limit rate to no more than 50 per minute. - API: Added an RPC boost that doubles the RPC per day and increases the throttle allowance by 50%. -- 2.51.2 From 8cb838a90c6bc35b81c19c030e097a294d8b060f Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Thu, 28 Apr 2011 20:12:07 -0500 Subject: [PATCH 17/34] Fix: get_bodies_for_star_in_jurisdiction will now throw an exception if you pass it a star outside your jurisdiction. --- lib/Lacuna/RPC/Building/Parliament.pm | 3 +++ var/www/public/changes.txt | 1 + 2 files changed, 4 insertions(+) diff --git a/lib/Lacuna/RPC/Building/Parliament.pm b/lib/Lacuna/RPC/Building/Parliament.pm index 0e305c26..549cd253 100644 --- a/lib/Lacuna/RPC/Building/Parliament.pm +++ b/lib/Lacuna/RPC/Building/Parliament.pm @@ -71,6 +71,9 @@ sub get_bodies_for_star_in_jurisdiction { } my $star = $building->body->stars->find($star_id); my @out; + unless ($star) { + confess [1009, 'That star is not in your jurisdiction.']; + } my $bodies = $star->bodies; while (my $body = $bodies->next) { push @out, $body->get_status($empire); diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index a9cea554..1c0d9251 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -1,5 +1,6 @@ 3.0701 - Fix: Passed RenameAsteroid, RenameStar and RenameUninhabited propositions will no longer fail with not in jurisdiction errors when they should not. + - Fix: get_bodies_for_star_in_jurisdiction will now throw an exception if you pass it a star outside your jurisdiction. 3.0700 - Rule: Only allow 5,000 RPC per day and limit rate to no more than 50 per minute. -- 2.51.2 From 49703a82f753deb11e403510c90b0c825865e3cd Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Thu, 28 Apr 2011 20:22:48 -0500 Subject: [PATCH 18/34] Fix: Spies that have been killed in action can no longer be burned. --- docs/Intelligence.pod | 2 ++ lib/Lacuna/RPC/Building/Intelligence.pm | 4 ++++ var/www/public/changes.txt | 1 + 3 files changed, 7 insertions(+) diff --git a/docs/Intelligence.pod b/docs/Intelligence.pod index 7a7f391a..e1bc78d9 100644 --- a/docs/Intelligence.pod +++ b/docs/Intelligence.pod @@ -155,6 +155,8 @@ Allows you to eliminate one of your spies from your payroll. "status" : { ... } } +Throws 1002, 1010 + =head3 session_id A session id. diff --git a/lib/Lacuna/RPC/Building/Intelligence.pm b/lib/Lacuna/RPC/Building/Intelligence.pm index 214a4c10..c0d3a0b8 100644 --- a/lib/Lacuna/RPC/Building/Intelligence.pm +++ b/lib/Lacuna/RPC/Building/Intelligence.pm @@ -104,6 +104,10 @@ sub burn_spy { if ($spy->task eq 'Captured') { confess [1010, "You can't burn a spy that has been captured. If you did he would have no reason not to tell your enemy all your secrets."]; } + if ($spy->task eq 'Killed In Action') { + confess [1010, "You can't burn a spy that has been killed in action; he's dead, Jim." + } + if ($spy->task $spy->burn; return { status => $self->format_status($empire, $building->body), diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 1c0d9251..8fc46534 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -1,6 +1,7 @@ 3.0701 - Fix: Passed RenameAsteroid, RenameStar and RenameUninhabited propositions will no longer fail with not in jurisdiction errors when they should not. - Fix: get_bodies_for_star_in_jurisdiction will now throw an exception if you pass it a star outside your jurisdiction. + - Fix: Spies that have been killed in action can no longer be burned. 3.0700 - Rule: Only allow 5,000 RPC per day and limit rate to no more than 50 per minute. -- 2.51.2 From 1fbaba53346a049fbfe31811842aa1c880086454 Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Thu, 28 Apr 2011 20:24:24 -0500 Subject: [PATCH 19/34] Fix: Spies that have been killed in action can no longer be burned. --- lib/Lacuna/RPC/Building/Intelligence.pm | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Lacuna/RPC/Building/Intelligence.pm b/lib/Lacuna/RPC/Building/Intelligence.pm index c0d3a0b8..045f7eb3 100644 --- a/lib/Lacuna/RPC/Building/Intelligence.pm +++ b/lib/Lacuna/RPC/Building/Intelligence.pm @@ -107,7 +107,6 @@ sub burn_spy { if ($spy->task eq 'Killed In Action') { confess [1010, "You can't burn a spy that has been killed in action; he's dead, Jim." } - if ($spy->task $spy->burn; return { status => $self->format_status($empire, $building->body), -- 2.51.2 From afa23641590c8e91ee66672004edd6f674c3b49d Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Thu, 28 Apr 2011 20:36:23 -0500 Subject: [PATCH 20/34] Fix: Correct how the Offense/Defense stats are calculated --- bin/summarize_server.pl | 2 +- var/www/public/changes.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/summarize_server.pl b/bin/summarize_server.pl index 235e0cb0..9e2ee278 100644 --- a/bin/summarize_server.pl +++ b/bin/summarize_server.pl @@ -362,7 +362,7 @@ sub summarize_colonies { $colony_data{offense_success_rate} += $spy->offense_success_rate; $colony_data{offense_success_rate_delta} += $spy->offense_success_rate_delta; $colony_data{defense_success_rate} += $spy->defense_success_rate; - $colony_data{offense_success_rate_delta} += $spy->defense_success_rate_delta; + $colony_data{defense_success_rate_delta} += $spy->defense_success_rate_delta; $colony_data{dirtiest} += $spy->dirtiest; $colony_data{dirtiest_delta} += $spy->dirtiest_delta; } diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 8fc46534..0ba35140 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -2,6 +2,7 @@ - Fix: Passed RenameAsteroid, RenameStar and RenameUninhabited propositions will no longer fail with not in jurisdiction errors when they should not. - Fix: get_bodies_for_star_in_jurisdiction will now throw an exception if you pass it a star outside your jurisdiction. - Fix: Spies that have been killed in action can no longer be burned. + - Fix: Correct how the Offense/Defense stats are calculated. 3.0700 - Rule: Only allow 5,000 RPC per day and limit rate to no more than 50 per minute. -- 2.51.2 From 89d093b54ce9944b871eab76ae6db7569a4f2a4e Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Thu, 28 Apr 2011 21:46:04 -0500 Subject: [PATCH 21/34] Fix: Spies that have been killed in action can no longer be burned. --- lib/Lacuna/RPC/Building/Intelligence.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Lacuna/RPC/Building/Intelligence.pm b/lib/Lacuna/RPC/Building/Intelligence.pm index 045f7eb3..ba98df0a 100644 --- a/lib/Lacuna/RPC/Building/Intelligence.pm +++ b/lib/Lacuna/RPC/Building/Intelligence.pm @@ -105,7 +105,7 @@ sub burn_spy { confess [1010, "You can't burn a spy that has been captured. If you did he would have no reason not to tell your enemy all your secrets."]; } if ($spy->task eq 'Killed In Action') { - confess [1010, "You can't burn a spy that has been killed in action; he's dead, Jim." + confess [1010, "You can't burn a spy that has been killed in action; he's dead, Jim."]; } $spy->burn; return { -- 2.51.2 From 2fa8d80983548cc8939f5063c7348c372b1e3a95 Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Thu, 28 Apr 2011 22:25:27 -0500 Subject: [PATCH 22/34] Fix boost cost --- lib/Lacuna/RPC/Empire.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Lacuna/RPC/Empire.pm b/lib/Lacuna/RPC/Empire.pm index bcaec790..aff09ffd 100644 --- a/lib/Lacuna/RPC/Empire.pm +++ b/lib/Lacuna/RPC/Empire.pm @@ -683,7 +683,7 @@ sub boost_rpc { sub boost { my ($self, $session_id, $type) = @_; my $empire = $self->get_empire_by_session($session_id); - my $cost = $type eq 'rpc' ? 25 : 5; + my $cost = $type eq 'rpc_boost' ? 25 : 5; unless ($empire->essentia >= $cost) { confess [1011, 'Not enough essentia.']; } -- 2.51.2 From d69eba4c1bb6c3991a228fc4b94ceb7061bc7c80 Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Thu, 28 Apr 2011 23:10:30 -0500 Subject: [PATCH 23/34] Fix: Space Stations will now be counted in the stats along with the other bodies. --- bin/summarize_server.pl | 2 +- var/www/public/changes.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/summarize_server.pl b/bin/summarize_server.pl index 9e2ee278..f661b782 100644 --- a/bin/summarize_server.pl +++ b/bin/summarize_server.pl @@ -108,8 +108,8 @@ sub generate_overview { my %body_types = ( gas_giants => 'Lacuna::DB::Result::Map::Body::Planet::GasGiant%', habitables => 'Lacuna::DB::Result::Map::Body::Planet::P%', + stations => 'Lacuna::DB::Result::Map::Body::Planet::Station', asteroids => 'Lacuna::DB::Result::Map::Body::Asteroid%', - stations => 'Lacuna::DB::Result::Map::Body::Station', ); foreach my $key (keys %body_types) { out($key); diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 0ba35140..1e2277d3 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -3,6 +3,7 @@ - Fix: get_bodies_for_star_in_jurisdiction will now throw an exception if you pass it a star outside your jurisdiction. - Fix: Spies that have been killed in action can no longer be burned. - Fix: Correct how the Offense/Defense stats are calculated. + - Fix: Space Stations will now be counted in the stats along with the other bodies. 3.0700 - Rule: Only allow 5,000 RPC per day and limit rate to no more than 50 per minute. -- 2.51.2 From 9d9b4cd295959a657bd1b8dab8f566feaea09da4 Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Fri, 29 Apr 2011 08:58:10 -0500 Subject: [PATCH 24/34] fix propose_rename_uninhabited --- lib/Lacuna/DB/Result/Medals.pm | 3 ++- lib/Lacuna/RPC/Building/Parliament.pm | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Lacuna/DB/Result/Medals.pm b/lib/Lacuna/DB/Result/Medals.pm index c622dc0f..ca07f480 100644 --- a/lib/Lacuna/DB/Result/Medals.pm +++ b/lib/Lacuna/DB/Result/Medals.pm @@ -131,7 +131,8 @@ use constant MEDALS => { G2 => 'Settled G2 Type Gas Giant', G3 => 'Settled G3 Type Gas Giant', G4 => 'Settled G4 Type Gas Giant', - G5 => 'Settled G5 Type Gas Giant', + G5 => 'Settled G5 Type Gas Giant', + Station => 'Established a Space Station', A1 => 'Mined A1 Type Asteroid', A2 => 'Mined A2 Type Asteroid', A3 => 'Mined A3 Type Asteroid', diff --git a/lib/Lacuna/RPC/Building/Parliament.pm b/lib/Lacuna/RPC/Building/Parliament.pm index 549cd253..66de46b1 100644 --- a/lib/Lacuna/RPC/Building/Parliament.pm +++ b/lib/Lacuna/RPC/Building/Parliament.pm @@ -489,7 +489,7 @@ sub propose_rename_uninhabited { ->no_restricted_chars ->no_profanity ->no_padding - ->not_ok(Lacuna->db->resultset('Lacuna::DB::Result::Map::Body')->search({name=>$name, 'body_id'=>{'!='=>$planet->id}})->count); # name available + ->not_ok(Lacuna->db->resultset('Lacuna::DB::Result::Map::Body')->search({name=>$name, 'id'=>{'!='=>$planet->id}})->count); # name available my $proposition = Lacuna->db->resultset('Lacuna::DB::Result::Propositions')->new({ type => 'RenameUninhabited', name => 'Rename '.$planet->name, -- 2.51.2 From d0c599f90f3ccc1a27c6df1fc96d62edd556f609 Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Fri, 29 Apr 2011 16:47:47 -0500 Subject: [PATCH 25/34] Add clean_up_game_over.pl --- bin/clean_up_game_over.pl | 47 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 bin/clean_up_game_over.pl diff --git a/bin/clean_up_game_over.pl b/bin/clean_up_game_over.pl new file mode 100644 index 00000000..c23ee3ad --- /dev/null +++ b/bin/clean_up_game_over.pl @@ -0,0 +1,47 @@ +use 5.010; +use strict; +use feature "switch"; +use lib '/data/Lacuna-Server/lib'; +use Lacuna::DB; +use Lacuna; +use List::Util qw(shuffle); +use Lacuna::Util qw(randint format_date); +use Getopt::Long; +$|=1; +our $quiet; +GetOptions( + 'quiet' => \$quiet, +); + + +out('Started'); +my $start = DateTime->now; + +out('Loading DB'); +our $db = Lacuna->db; +my $empires = $db->resultset('Lacuna::DB::Result::Empire'); + + +out('Deleting Empires'); +while (my $empire = $empires->next) { + out('Empire ', $empire->name); +# $empire->delete; +} + +my $finish = time; +out('Finished'); +out((($finish - $start->epoch)/60)." minutes have elapsed"); + + +############### +## SUBROUTINES +############### + +sub out { + my $message = shift; + unless ($quiet) { + say format_date(DateTime->now), " ", $message; + } +} + + -- 2.51.2 From 5bfb0c22ca43645f5369a2894491fb94c6acfa40 Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Fri, 29 Apr 2011 16:54:57 -0500 Subject: [PATCH 26/34] Prevent clean_up_game_over.pl from running if server status is not Game Over --- bin/clean_up_game_over.pl | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bin/clean_up_game_over.pl b/bin/clean_up_game_over.pl index c23ee3ad..55d0f9d1 100644 --- a/bin/clean_up_game_over.pl +++ b/bin/clean_up_game_over.pl @@ -6,6 +6,8 @@ use Lacuna::DB; use Lacuna; use List::Util qw(shuffle); use Lacuna::Util qw(randint format_date); +use Config::JSON; +use Lacuna::Cache; use Getopt::Long; $|=1; our $quiet; @@ -17,14 +19,22 @@ GetOptions( out('Started'); my $start = DateTime->now; +out('Checking server status'); +my $config = Config::JSON->new('/data/Lacuna-Server/etc/lacuna.conf'); +my $cache = Lacuna::Cache->new(servers => $config->get('memcached')); +my $status = $cache->get('server','status'); +unless ( $status eq 'Game Over' ) { + out('Server status is ' . $status); + exit 1; +} + out('Loading DB'); our $db = Lacuna->db; my $empires = $db->resultset('Lacuna::DB::Result::Empire'); - out('Deleting Empires'); while (my $empire = $empires->next) { - out('Empire ', $empire->name); + out('Empire: '. $empire->name); # $empire->delete; } -- 2.51.2 From 641fc19a0a236f685ee86a3209527c6f3d3e843b Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Fri, 29 Apr 2011 16:58:27 -0500 Subject: [PATCH 27/34] Actually delete the empires now --- bin/clean_up_game_over.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/clean_up_game_over.pl b/bin/clean_up_game_over.pl index 55d0f9d1..8b84d82d 100644 --- a/bin/clean_up_game_over.pl +++ b/bin/clean_up_game_over.pl @@ -34,8 +34,8 @@ my $empires = $db->resultset('Lacuna::DB::Result::Empire'); out('Deleting Empires'); while (my $empire = $empires->next) { - out('Empire: '. $empire->name); -# $empire->delete; + out('Deleting Empire: '. $empire->name); + $empire->delete; } my $finish = time; -- 2.51.2 From 96813a0011e25e1836cd0b5743d82c805e333c70 Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Fri, 29 Apr 2011 17:31:55 -0500 Subject: [PATCH 28/34] Fix propose_rename_asteroid --- lib/Lacuna/RPC/Building/Parliament.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Lacuna/RPC/Building/Parliament.pm b/lib/Lacuna/RPC/Building/Parliament.pm index 66de46b1..f38b2a95 100644 --- a/lib/Lacuna/RPC/Building/Parliament.pm +++ b/lib/Lacuna/RPC/Building/Parliament.pm @@ -443,7 +443,7 @@ sub propose_rename_asteroid { ->no_restricted_chars ->no_profanity ->no_padding - ->not_ok(Lacuna->db->resultset('Lacuna::DB::Result::Map::Body')->search({name=>$name, 'body_id'=>{'!='=>$asteroid->id}})->count); # name available + ->not_ok(Lacuna->db->resultset('Lacuna::DB::Result::Map::Body')->search({name=>$name, 'id'=>{'!='=>$asteroid->id}})->count); # name available my $proposition = Lacuna->db->resultset('Lacuna::DB::Result::Propositions')->new({ type => 'RenameAsteroid', name => 'Rename '.$asteroid->name, -- 2.51.2 From 4f316fd7e736dc6211cbe5507fa39b2dbcb793ab Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Fri, 29 Apr 2011 18:16:06 -0500 Subject: [PATCH 29/34] reset_essentia_veins.pl will now add an essentia vein to any Trel colony without one --- bin/trelvestian/reset_essentia_veins.pl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/bin/trelvestian/reset_essentia_veins.pl b/bin/trelvestian/reset_essentia_veins.pl index 2c1a2039..c0e185d3 100644 --- a/bin/trelvestian/reset_essentia_veins.pl +++ b/bin/trelvestian/reset_essentia_veins.pl @@ -27,6 +27,21 @@ while (my $colony = $colonies->next) { if (defined $vein) { $vein->start_work({}, 60 * 60 * 24 * 60)->update; } + else { + my $buildings = $db->resultset('Lacuna::DB::Result::Building'); + my ($x, $y) = $colony->find_free_space; + my $building = $buildings->new({ + class => 'Lacuna::DB::Result::Building::Permanent::EssentiaVein', + level => 0, + x => $x, + y => $y, + body_id => $colony->id, + body => $colony, + }); + out('Added ' . $building->name); + $colony->build_building($building); + $building->finish_upgrade; + } } my $finish = time; -- 2.51.2 From eb0ca42c8cb842c95e126a0736e83661e2d7b088 Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Fri, 29 Apr 2011 19:55:24 -0500 Subject: [PATCH 30/34] Update changes --- var/www/public/changes.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 1e2277d3..d27b37d1 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -1,5 +1,6 @@ 3.0701 - Fix: Passed RenameAsteroid, RenameStar and RenameUninhabited propositions will no longer fail with not in jurisdiction errors when they should not. + - Fix: Passed RenameAsteroid and RenameUninhabited propositions will no longer fail with a DBIx error. - Fix: get_bodies_for_star_in_jurisdiction will now throw an exception if you pass it a star outside your jurisdiction. - Fix: Spies that have been killed in action can no longer be burned. - Fix: Correct how the Offense/Defense stats are calculated. -- 2.51.2 From fdd45d9a4dca94fc59d67c0db99eb69224cd861a Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Fri, 29 Apr 2011 22:05:33 -0500 Subject: [PATCH 31/34] Fix: Cache completed missions sooner in the method call. --- lib/Lacuna/DB/Result/Mission.pm | 2 +- var/www/public/changes.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Lacuna/DB/Result/Mission.pm b/lib/Lacuna/DB/Result/Mission.pm index e81707ee..625d4d45 100644 --- a/lib/Lacuna/DB/Result/Mission.pm +++ b/lib/Lacuna/DB/Result/Mission.pm @@ -46,9 +46,9 @@ sub incomplete { sub complete { my ($self, $body) = @_; + Lacuna->cache->set($self->mission_file_name, $body->empire_id, 1, 60 * 60 * 24 * 30); $self->spend_objectives($body); $self->add_rewards($body); - Lacuna->cache->set($self->mission_file_name, $body->empire_id, 1, 60 * 60 * 24 * 30); Lacuna->db->resultset('Lacuna::DB::Result::News')->new({ zone => $self->zone, headline => sprintf($self->params->get('network_19_completion'), $body->empire->name), diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index d27b37d1..53b9e309 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -5,6 +5,7 @@ - Fix: Spies that have been killed in action can no longer be burned. - Fix: Correct how the Offense/Defense stats are calculated. - Fix: Space Stations will now be counted in the stats along with the other bodies. + - Fix: Cache completed missions sooner in the method call. 3.0700 - Rule: Only allow 5,000 RPC per day and limit rate to no more than 50 per minute. -- 2.51.2 From 1c4ca82d917b1310c1dbe00caf9c9f4912aa1280 Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Fri, 29 Apr 2011 22:27:50 -0500 Subject: [PATCH 32/34] Updated version --- lib/Lacuna.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Lacuna.pm b/lib/Lacuna.pm index 2b6110f4..e1949739 100644 --- a/lib/Lacuna.pm +++ b/lib/Lacuna.pm @@ -7,7 +7,7 @@ use Config::JSON; useall __PACKAGE__; -our $VERSION = 3.0700; +our $VERSION = 3.0701; 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}); -- 2.51.2 From 29650a3ae8342d611a925a9fb78c6f20926ff837 Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Sat, 30 Apr 2011 18:45:03 -0500 Subject: [PATCH 33/34] Fix DeployMiningPlatform and EvictMiningPlatform --- lib/Lacuna/DB/Result/Propositions/EvictMiningPlatform.pm | 2 +- lib/Lacuna/Role/Ship/Arrive/DeployMiningPlatform.pm | 4 +++- var/www/public/changes.txt | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/Lacuna/DB/Result/Propositions/EvictMiningPlatform.pm b/lib/Lacuna/DB/Result/Propositions/EvictMiningPlatform.pm index c3ededb8..9431e9ea 100644 --- a/lib/Lacuna/DB/Result/Propositions/EvictMiningPlatform.pm +++ b/lib/Lacuna/DB/Result/Propositions/EvictMiningPlatform.pm @@ -15,7 +15,7 @@ before pass => sub { if (! defined $platform) { $self->pass_extra_message('Unfortunately, by the time the proposition passed, the platform had already been destroyed, effectively nullifying the vote.'); } - elsif ($self->station_id == $platform->asteroid->star->station_id) { + elsif ($self->station_id != $platform->asteroid->star->station_id) { $self->pass_extra_message('Unfortunately, by the time the proposition passed, the asteroid was no longer under the jurisdiction of this station, effectively nullifying the vote.'); } else { diff --git a/lib/Lacuna/Role/Ship/Arrive/DeployMiningPlatform.pm b/lib/Lacuna/Role/Ship/Arrive/DeployMiningPlatform.pm index c8a62c2c..71478a50 100644 --- a/lib/Lacuna/Role/Ship/Arrive/DeployMiningPlatform.pm +++ b/lib/Lacuna/Role/Ship/Arrive/DeployMiningPlatform.pm @@ -53,7 +53,9 @@ after can_send_to_target => sub { $ministry->can_add_platform($target); if ($target->star->station_id) { if ($target->star->station->laws->search({type => 'MembersOnlyMiningRights'})->count) { - confess [1010, 'Only '.$target->star->station->alliance->name.' members can mine asteroids in the jurisdiction of the space station.']; + unless ($target->star->station->alliance_id == $self->body->alliance_id) { + confess [1010, 'Only '.$target->star->station->alliance->name.' members can mine asteroids in the jurisdiction of the space station.']; + } } } }; diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 53b9e309..277bb367 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -1,11 +1,12 @@ 3.0701 - - Fix: Passed RenameAsteroid, RenameStar and RenameUninhabited propositions will no longer fail with not in jurisdiction errors when they should not. + - Fix: Passed EvictMiningPlatform, RenameAsteroid, RenameStar and RenameUninhabited propositions will no longer fail with not in jurisdiction errors when they should not. - Fix: Passed RenameAsteroid and RenameUninhabited propositions will no longer fail with a DBIx error. - Fix: get_bodies_for_star_in_jurisdiction will now throw an exception if you pass it a star outside your jurisdiction. - Fix: Spies that have been killed in action can no longer be burned. - Fix: Correct how the Offense/Defense stats are calculated. - Fix: Space Stations will now be counted in the stats along with the other bodies. - Fix: Cache completed missions sooner in the method call. + - Fix: Deploying a Mining Platform correctly checks Alliances now. 3.0700 - Rule: Only allow 5,000 RPC per day and limit rate to no more than 50 per minute. -- 2.51.2 From 2bed7a1d0071e9469df9f993cba05f84bc7046d7 Mon Sep 17 00:00:00 2001 From: Matthew Musgrove Date: Sat, 30 Apr 2011 18:54:41 -0500 Subject: [PATCH 34/34] Fix deploy mining platform --- lib/Lacuna/Role/Ship/Arrive/DeployMiningPlatform.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Lacuna/Role/Ship/Arrive/DeployMiningPlatform.pm b/lib/Lacuna/Role/Ship/Arrive/DeployMiningPlatform.pm index 71478a50..1044f572 100644 --- a/lib/Lacuna/Role/Ship/Arrive/DeployMiningPlatform.pm +++ b/lib/Lacuna/Role/Ship/Arrive/DeployMiningPlatform.pm @@ -53,7 +53,7 @@ after can_send_to_target => sub { $ministry->can_add_platform($target); if ($target->star->station_id) { if ($target->star->station->laws->search({type => 'MembersOnlyMiningRights'})->count) { - unless ($target->star->station->alliance_id == $self->body->alliance_id) { + unless ($target->star->station->alliance_id == $self->body->empire->alliance_id) { confess [1010, 'Only '.$target->star->station->alliance->name.' members can mine asteroids in the jurisdiction of the space station.']; } }