Skip to content

Commit

Permalink
Changed so that the effect spreads as a 'band' rather than zone by zone.
Browse files Browse the repository at this point in the history
  • Loading branch information
icydee committed Aug 30, 2012
1 parent 61c1dee commit 9ac579e
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 40 deletions.
65 changes: 35 additions & 30 deletions bin/util/revamp_map.pl
Expand Up @@ -9,9 +9,11 @@
$|=1;
our $quiet;
GetOptions(
'quiet' => \$quiet,
'quiet' => \$quiet,
);

my $band_width = 20;

out('Started');
my $start = time;

Expand All @@ -27,38 +29,47 @@
my @habital_types = qw(P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13 P14 P15 P16 P17 P18 P19 P20 P21 P22 P23 P24 P25 P26 P27 P28 P29 P30 P31 P32 P33 P34 P35 P36 P37 P38 P39 P40);
my @gas_giant_types = qw(G1 G2 G3 G4 G5);

my $z_config = $db_config->search({name => 'revamp_zone'})->single;
my $x_min = int($config->get('map_size/x')->[0]/250);
my $y_min = int($config->get('map_size/y')->[0]/250);
my $x_max = int($config->get('map_size/x')->[1]/250);
my $y_max = int($config->get('map_size/y')->[1]/250);
my $revamp_x = $db_config->search({name => 'revamp_x'})->single;
my $x_min = int($config->get('map_size/x')->[0]);
my $x_max = int($config->get('map_size/x')->[1]);

if (not defined $z_config) {
my $starting_zone = "$x_min|$y_min";
out("Starting on zone $starting_zone. Good Luck!");
if (not defined $revamp_x) {
out("Starting at x = $x_min. Good Luck!");

$z_config = $db_config->create({
name => 'revamp_zone',
value => $starting_zone,
$revamp_x = $db_config->create({
name => 'revamp_x',
value => $x_min,
});
}
my $zone = $z_config->value;
my ($x,$y) = $zone =~ m/(-?\d+)\|(-?\d+)/;
my $ribben_from = $revamp_x->value;
my $ribben_to = $revamp_x->value + $band_width;

my %zone_details;

out('Working on zone '.$zone);
my $first_in_zone = 1;
my $zone_bodies = $bodies->search({zone => $zone},{order_by => ['x','y']});
determine_zone_details();
if ($x > $x_max || $y > $y_max) {
out("Ribbon is between x=$ribben_from and x=$ribben_to");
my $first_in_ribbon = 1;
my $bodies = $bodies->search({ -and => [
{ x => {'>=' => $ribben_from }},
{ x => {'<' => $ribben_to }},
]},
{ order_by => 'y' }
);

if ($revamp_x->value > $x_max) {
out('All done! You may stop the cron job!');
exit;
}
while (my $body = $zone_bodies->next) {
while (my $body = $bodies->next) {
# I know it is inefficient to calculate this for every body, but we are only doing it once!
my $zone = $body->zone;
my ($x,$y) = $zone =~ m/(-?\d+)|(-?\d+)/;
# seed the random number generator so it starts at the same point for every zone
srand($x*10000+$y);
determine_zone_details();

if ($body->empire_id > 1) {
if ($first_in_zone) {
$first_in_zone = 0;
if ($first_in_ribbon) {
$first_in_ribbon = 0;
$body->add_news(100,'... --- ...');
$body->add_news(100,'- .... . .-. .. -... -... --- -. .. ... .... . .-. .');
$body->add_news(100,'a$'.randint(1111,9999).' ribbon ha$ ajd..a# zone '.$zone.'___23kkd..');
Expand All @@ -75,14 +86,8 @@
}
}

$x = $x + 1;
if ($x > $x_max) {
$x = $x_min;
$y = $y + 1;
}

$z_config->value("$x|$y");
$z_config->update;
$revamp_x->value($revamp_x->value + $band_width);
$revamp_x->update;

sub wreck_planet {
my $body = shift;
Expand Down
15 changes: 12 additions & 3 deletions bin/util/revamp_map_message_1.pl
Expand Up @@ -7,8 +7,10 @@
use Getopt::Long;
$|=1;
our $quiet;
our $all;
GetOptions(
'quiet' => \$quiet,
'quiet' => \$quiet,
'all' => \$all,
);


Expand All @@ -18,15 +20,22 @@
out('Loading DB');
our $db = Lacuna->db;
my $empires = $db->resultset('Lacuna::DB::Result::Empire');

my $lec = $empires->find(1);

if (not $all) {
$empires = $empires->search({ is_admin => 1 });
}

$empires = $empires->search({ id => {'>' => 1}});

my $message = q{Over the past three years the Expanse has seen an explosion of new races seeking assylum from whatever they left behind. We were glad to have the new trading partners. However, some of you may have inadvertantly destroyed us all. The Sābēn Demesne were nothing compared to the threat we face now.
It has come to my attention that some of you have been experimenting with singularities through devices you call Black Hole Generators. These technologies are barely within your comprehension, yet you use them as freely as you peel a Beeldeban! These devices are dangerous. I'm sure you've experienced some of their side-effects, but what you do not understand can kill us all.
A storm approaches. Those of you manipulating these singularities have built up a form of energy on the entire expanse. It's like the static electricity that's built up on your body when you walk across carpet in wool socks; only in this case, the energy envelops the entire expanse. When this energy discharges, it could rip a hole in the fabric of space and time itself!
A storm approaches. Those of you manipulating these singularities have built up a form of energy on the entire expanse. It's like the static electricity that's built up on your body when you walk across carpet in wool socks; only in this case, the energy envelops the entire expanse. When this energy discharges, it could form a cosmic string, ripping a hole in the fabric of space and time itself!
Stop using thse blasted devices now, while we try to sort out how to resolve this mess.
Stop using these blasted devices now, while we try to sort out how to resolve this mess.
Your Trading Partner,
Expand Down
16 changes: 12 additions & 4 deletions bin/util/revamp_map_message_2.pl
Expand Up @@ -7,22 +7,30 @@
use Getopt::Long;
$|=1;
our $quiet;
our $all;
GetOptions(
'quiet' => \$quiet,
'quiet' => \$quiet,
'all' => \$all,
);


out('Started');
my $start = time;

out('Loading DB');
our $db = Lacuna->db;
my $empires = $db->resultset('Lacuna::DB::Result::Empire');

my $lec = $empires->find(1);

if (not $all) {
$empires = $empires->search({ is_admin => 1 });
}

$empires = $empires->search({ id => {'>' => 1}});


my $message = q{You didn't heed our warning. The storm has been unleashed. All we can do is brace ourselves and hope that the Expanse doesn't tear itself apart as the storm washes over us.
The use of these singularities has created a ribbon of energy that is passing over the entire Expanse. The discharge is so great that all ships and probes we've sent to investigate were instantly destroyed. Our sensors cannot see beyond the ribbon, so we are unable to see if the Expanse remains behind it in any form, or if it has been completely destroyed.
The use of these singularities has created a cosmic string, a ribbon of energy that is passing over the entire Expanse. The discharge is so great that all ships and probes we've sent to investigate were instantly destroyed. Our sensors cannot see beyond the ribbon, so we are unable to see if the Expanse remains behind it in any form, or if it has been completely destroyed.
We suggest you do what you can to fortify your empire. With any luck the ribbon will not ignite your atmosphere as it washes over your planet. Good luck. Hope to see you on the other side.
Expand Down
12 changes: 9 additions & 3 deletions bin/util/revamp_map_message_3.pl
Expand Up @@ -7,19 +7,25 @@
use Getopt::Long;
$|=1;
our $quiet;
our $all;
GetOptions(
'quiet' => \$quiet,
'quiet' => \$quiet, 'all' => \$all,
);


out('Started');
my $start = time;

out('Loading DB');
our $db = Lacuna->db;
my $empires = $db->resultset('Lacuna::DB::Result::Empire');

my $lec = $empires->find(1);

if (not $all) {
$empires = $empires->search({ is_admin => 1 });
}

$empires = $empires->search({ id => {'>' => 1}});

my $message = q{Luckily we appear to have weathered the storm, but it appears that the Expanse is forever changed.
Early sensor data indicates that the energy ribbon did not in-fact destroy the Expanse, but rather evolved it. Many bodies have changed their very composition. In many ways this is an entirely new Expanse. While I'm sure that adventure seekers will love the opportunities for exploration, but we stand reserved.
Expand Down

3 comments on commit 9ac579e

@fireartist
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This moves the call to determine_zone_details() from before the body loop, to inside it.
I think this would result in the basic body sizes / ore compositions being recalculated for every body, and not for every zone or band.
Is that a bug?

@icydee
Copy link
Member Author

@icydee icydee commented on 9ac579e Sep 4, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a bug, don't forget the srand immediately before it. This ensures that whatever zone the body is in it will always compute the same 'random' distribution of planet types in that zone. We can't compute it once before the loop for all bodies in a zone since a band covers many zones and a zone has many bands.

@fireartist
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I'd read about srand in perldoc, but never had need to use it - interesting use!
Sorry for the noise

Please sign in to comment.