lib = $lib; $this->db = $this->lib->game->db; } // Returns the length of a planet's build queue function getLength($pl) { if (is_null($this->qLen[$pl])) { $q = $this->db->query("SELECT COUNT(*) FROM buildqueue WHERE planet = $pl"); list($this->qLen[$pl]) = dbFetchArray($q); } return $this->qLen[$pl]; } // Moves an item down the build queue function moveDown($pl, $it) { $bql = $this->lib->call('getLength', $pl); $np = $it + 1; $this->db->query("UPDATE buildqueue SET bq_order = $bql WHERE planet = $pl AND bq_order = $it"); $this->db->query("UPDATE buildqueue SET bq_order = $it WHERE planet = $pl AND bq_order = $np"); $this->db->query("UPDATE buildqueue SET bq_order = $np,workunits=0 WHERE planet = $pl AND bq_order = $bql"); } // Moves an item up the build queue function moveUp($pl, $it) { $bql = $this->lib->call('getLength', $pl); $np = $it - 1; $this->db->query("UPDATE buildqueue SET bq_order = $bql WHERE planet = $pl AND bq_order = $it"); $this->db->query("UPDATE buildqueue SET bq_order = $it WHERE planet = $pl AND bq_order = $np"); $this->db->query("UPDATE buildqueue SET bq_order = $np,workunits=0 WHERE planet = $pl AND bq_order = $bql"); } } ?>