From ff80fc6183b3a45a92732dca466f64c81ab1abd5 Mon Sep 17 00:00:00 2001 From: Mark Lemming Date: Tue, 16 Dec 2014 16:36:41 -0700 Subject: [PATCH] Only one notification per empire per system for probes. --- lib/Lacuna.pm | 2 +- lib/Lacuna/DB/Result/Empire.pm | 15 +++++++++------ var/www/public/changes.txt | 5 ++++- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/Lacuna.pm b/lib/Lacuna.pm index 8347706a..d98d294a 100644 --- a/lib/Lacuna.pm +++ b/lib/Lacuna.pm @@ -7,7 +7,7 @@ use Config::JSON; useall __PACKAGE__; -our $VERSION = 3.0908; +our $VERSION = 3.0909; 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/Empire.pm b/lib/Lacuna/DB/Result/Empire.pm index 886ff298..1290cb23 100644 --- a/lib/Lacuna/DB/Result/Empire.pm +++ b/lib/Lacuna/DB/Result/Empire.pm @@ -890,13 +890,16 @@ sub add_observatory_probe { })->insert; # send notifications - # this could be a performance problem in the future depending upon the number of probes in a star system my $star = Lacuna->db->resultset('Map::Star')->find($star_id); - # Get all systems that are probed (real or virtual) - my $probes = Lacuna->db->resultset('Probes')->search_any({ star_id => $star_id, empire_id => {'!=', $self->id } }); - while (my $probe = $probes->next) { - my $that_empire = $probe->empire; - next unless defined $that_empire; + # Get all empires to be notified that have probes (real or virtual) + my %to_notify = map { $_->empire_id => 1 } Lacuna->db->resultset('Probes') + ->search_any({ + star_id => $star_id, + empire_id => {'!=', $self->id } + }); + for my $eid (keys %to_notify) { + my $that_empire = Lacuna->db->resultset('Empire')->find($eid); + next unless $that_empire; if (!$that_empire->skip_probe_detected) { $that_empire->send_predefined_message( filename => 'probe_detected.txt', diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 2daf8204..81abd93a 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -1,3 +1,7 @@ +3.0909: + - Add: Admin UI to set alliance logo. + - Fix: Only one notification per empire per star on probe detection. + 3.0908: - Mod: trash_messages_where now defaults to not returning deleted message IDs. - Mod: Firing BFG now requires captcha. @@ -5,7 +9,6 @@ - UI : Reasons for not being able to use a BHG function now always displayed for every task. - Fix: Instead of going via parliament, go via body or star to view_laws. This allows everyone access to passed laws by a station. - UI : No more nagging if you want to spend halls. - - Add: Admin UI to set alliance logo. 3.0907: - Add: Timer added to colony object preventing passage into Neutral Zone. -- 2.51.2