diff --git a/GameEngine/Database/db_MYSQL.php b/GameEngine/Database/db_MYSQL.php index 8b709e7e..8300c9e8 100644 --- a/GameEngine/Database/db_MYSQL.php +++ b/GameEngine/Database/db_MYSQL.php @@ -367,40 +367,20 @@ class MYSQL_DB { return mysql_query($q, $this->connection); } } - /* - function generateBase($sector) { - switch($sector) { - case 1: - $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and x < 0 and y > 0 and occupied = 0"; - break; - case 2: - $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and x > 0 and y > 0 and occupied = 0"; - break; - case 3: - $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and x < 0 and y < 0 and occupied = 0"; - break; - case 4: - $q = "Select * from ".TB_PREFIX."wdata where fieldtype = 3 and x > 0 and y < 0 and occupied = 0"; - break; - } - $result = mysql_query($q, $this->connection); - $num_rows = mysql_num_rows($result); - $result = $this->mysql_fetch_all($result); - $base = rand(0, ($num_rows-1)); - return $result[$base]['id']; - } - */ function generateBase($sector, $mode=1) { + $num_rows = 0; + $count_while = 0; + while (!$num_rows){ if (!$mode) { $gamesday=time()-COMMENCE; - if ($gamesday<3600*24*10) { //10 day + if ($gamesday<3600*24*10 && $count_while==0) { //10 day $wide1=1; $wide2=20; - } elseif ($gamesday<3600*24*20) { //20 day + } elseif ($gamesday<3600*24*20 && $count_while==1) { //20 day $wide1=20; $wide2=40; - } elseif ($gamesday<3600*24*30) { //30 day + } elseif ($gamesday<3600*24*30 && $count_while==2) { //30 day $wide1=40; $wide2=80; } else { // over 30 day @@ -428,6 +408,8 @@ class MYSQL_DB { } $result = mysql_query($q, $this->connection); $num_rows = mysql_num_rows($result); + $count_while++; + } $result = $this->mysql_fetch_all($result); $base = rand(0, ($num_rows-1)); return $result[$base]['id'];