From 2b274dfabd1c85879e86ae0598f7b25f4fb232c1 Mon Sep 17 00:00:00 2001 From: lemming552 Date: Sun, 19 Feb 2012 22:26:59 -0700 Subject: [PATCH] Fixed SSLab position errors in rearrange code. --- lib/Lacuna.pm | 2 +- lib/Lacuna/RPC/Body.pm | 15 +++++++++++---- var/www/public/changes.txt | 3 +++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/Lacuna.pm b/lib/Lacuna.pm index f8218bd6..d9e78ca7 100644 --- a/lib/Lacuna.pm +++ b/lib/Lacuna.pm @@ -7,7 +7,7 @@ use Config::JSON; useall __PACKAGE__; -our $VERSION = 3.0837; +our $VERSION = 3.0838; 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/RPC/Body.pm b/lib/Lacuna/RPC/Body.pm index 43823999..05213ca9 100644 --- a/lib/Lacuna/RPC/Body.pm +++ b/lib/Lacuna/RPC/Body.pm @@ -216,6 +216,14 @@ sub check_positions { my @position_err; for my $id (keys %$new_ids) { my $spot_chk; + if (abs($new_ids->{$id}->{x}) > 5 or abs($new_ids->{$id}->{y}) > 5) { + push @position_err, + sprintf("Trying to place %s at %d,%d which is outside of bounds", + $new_ids->{$id}->{name}, + abs($new_ids->{$id}->{x}), + abs($new_ids->{$id}->{y}) ); + next; + } given ($new_ids->{$id}->{class}) { when("Lacuna::DB::Result::Building::PlanetaryCommand") { unless ($new_ids->{$id}->{x} == 0 && @@ -232,10 +240,9 @@ sub check_positions { } } when("Lacuna::DB::Result::Building::SSLa") { - if ($new_ids->{$id}->{x} == 5 || - $new_ids->{$id}->{y} == 5 || - $new_ids->{$id}->{y} == 1 || - $new_ids->{$id}->{y} == 0 && ($new_ids->{$id}->{x} == -1 || $new_ids->{$id}->{x} == 0)) { + if ($new_ids->{$id}->{x} == 5 || $new_ids->{$id}->{y} == -5 || + ( $new_ids->{$id}->{x} == -1 && ( $new_ids->{$id}->{y} == 0 || $new_ids->{$id}->{y} == 1)) || + ( $new_ids->{$id}->{x} == 0 && $new_ids->{$id}->{y} == 1 ) ) { push @position_err, sprintf("%s can not be placed in that position", $new_ids->{$id}->{name}); } diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 8e5f287d..bc08874d 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -1,3 +1,6 @@ +3.0838: + - Fix: Fixed some position errors in rearrange API. + 3.0837: - Mod: Trade Ministry now trades within a set distance rather than just within zone -- 2.51.2