Permalink
Browse files

stop N19 giving feed urls for non-existant zones

  • Loading branch information...
1 parent f7ad444 commit e0021466d54789cbdba5a6d797f01442a1d30b13 @fireartist fireartist committed with icydee Mar 19, 2013
Showing with 30 additions and 8 deletions.
  1. +29 −8 lib/Lacuna/DB/Result/Map.pm
  2. +1 −0 lib/Lacuna/RPC/Building/Network19.pm
@@ -32,15 +32,36 @@ use constant zone_size => 250;
sub adjacent_zones {
my ($self) = @_;
my ($x,$y) = $self->parse_zone_into_zone_coords;
+ my $map_size = Lacuna->config->get('map_size');
+ my $bottom_max = $self->determine_zone_coord_from_xy_coord( $map_size->{y}[0] );
+ my $top_max = $self->determine_zone_coord_from_xy_coord( $map_size->{y}[1] );
+ my $left_max = $self->determine_zone_coord_from_xy_coord( $map_size->{x}[0] );
+ my $right_max = $self->determine_zone_coord_from_xy_coord( $map_size->{x}[1] );
my @zones;
- push @zones, $self->format_zone_coords_into_zone($x + 1, $y);
- push @zones, $self->format_zone_coords_into_zone($x - 1, $y);
- push @zones, $self->format_zone_coords_into_zone($x, $y + 1);
- push @zones, $self->format_zone_coords_into_zone($x, $y - 1);
- push @zones, $self->format_zone_coords_into_zone($x - 1, $y - 1);
- push @zones, $self->format_zone_coords_into_zone($x + 1, $y + 1);
- push @zones, $self->format_zone_coords_into_zone($x - 1, $y + 1);
- push @zones, $self->format_zone_coords_into_zone($x + 1, $y - 1);
+ if ( $x < $right_max ) {
+ push @zones, $self->format_zone_coords_into_zone($x + 1, $y);
+ }
+ if ( $x > $left_max ) {
+ push @zones, $self->format_zone_coords_into_zone($x - 1, $y);
+ }
+ if ( $y < $top_max ) {
+ push @zones, $self->format_zone_coords_into_zone($x, $y + 1);
+ }
+ if ( $y > $bottom_max ) {
+ push @zones, $self->format_zone_coords_into_zone($x, $y - 1);
+ }
+ if ( $x > $left_max && $y > $bottom_max ) {
+ push @zones, $self->format_zone_coords_into_zone($x - 1, $y - 1);
+ }
+ if ( $x < $right_max && $y < $top_max ) {
+ push @zones, $self->format_zone_coords_into_zone($x + 1, $y + 1);
+ }
+ if ( $x > $left_max && $y < $top_max ) {
+ push @zones, $self->format_zone_coords_into_zone($x - 1, $y + 1);
+ }
+ if ( $x < $right_max && $y > $bottom_max ) {
+ push @zones, $self->format_zone_coords_into_zone($x + 1, $y - 1);
+ }
return @zones;
}
@@ -22,6 +22,7 @@ sub view_news {
my @all = ($body->zone, $body->adjacent_zones);
my @zones;
foreach (1..(($building->level + 1) / 2)) {
+ last if !@all;
push @zones, shift @all;
}
my $news = Lacuna->db->resultset('Lacuna::DB::Result::News')->search(

0 comments on commit e002146

Please sign in to comment.