From 8b488bd8c0724eb0ae0b8ad676ff9c0019f9907d Mon Sep 17 00:00:00 2001 From: fireartist Date: Wed, 23 Jan 2013 12:36:50 +0000 Subject: [PATCH] admin/add-building check plot is empty and add a lock on it --- lib/Lacuna/Web/Admin.pm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/Lacuna/Web/Admin.pm b/lib/Lacuna/Web/Admin.pm index 5b567899..00b7bf69 100644 --- a/lib/Lacuna/Web/Admin.pm +++ b/lib/Lacuna/Web/Admin.pm @@ -362,6 +362,17 @@ sub www_add_building { if ( !length $x || !length $y ) { ($x, $y) = $body->find_free_space; } + + # check the plot lock + if ($body->is_plot_locked($x, $y)) { + confess [1013, "That plot is reserved for another building.", [$x,$y]]; + } + else { + $body->lock_plot($x,$y); + } + # is the plot empty? + $body->check_for_available_build_space( $x, $y ); + my $building = Lacuna->db->resultset('Lacuna::DB::Result::Building')->new({ x => $x, y => $y, -- 2.51.2