From 1cfc4a28c4c298dc4d2f3fa3e63c6e54db2660b0 Mon Sep 17 00:00:00 2001 From: Timothy Stack Date: Mon, 16 May 2005 22:14:34 +0000 Subject: [PATCH] For robots, reset anything related to physical location (nodes.destination_x,location_info.loc_x, ...). --- db/nfree.in | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/db/nfree.in b/db/nfree.in index 9cd6b4b50..03be0ca30 100755 --- a/db/nfree.in +++ b/db/nfree.in @@ -316,6 +316,33 @@ foreach my $n (@freed_nodes) { # Clean the interface_settings table for this node. DBQueryWarn("delete from interface_settings where node_id='$n'") || $error++; + # If it's a robot, we need to reset its physical location. + $result = + DBQueryFatal("select building,floor,loc_x,loc_y,orientation ". + "from node_startloc where node_id='$n'"); + if ($result->num_rows()) { + while (my ($bldg,$floor,$x,$y,$o) = $result->fetchrow_array()) { + my $subresult = + DBQueryFatal("select pixels_per_meter from floorimages ". + "where building='$bldg'"); + if ($subresult->num_rows()) { + my ($pixels_per_meter) = $subresult->fetchrow_array(); + + $x = int($x * $pixels_per_meter); + $y = int($y * $pixels_per_meter); + DBQueryWarn("update location_info set ". + "loc_x=$x,loc_y=$y,orientation=$o ". + "where node_id='$n' and building='$bldg' ". + "and floor=$floor") || $error++; + } + else { + warn "No building named $bldg in floorimages"; + } + } + } + DBQueryWarn("update nodes set destination_x=NULL,destination_y=NULL,". + "destination_orientation=NULL where node_id='$n'") || $error++; + # Now its safe to change the reservation. # If the node has a next_reserve entry, change the reservation. -- GitLab