From 432b92220f21eba4b00278136533f5d3e5573dbc Mon Sep 17 00:00:00 2001 From: lietuvis10 <50807912+lietuvis10@users.noreply.github.com> Date: Thu, 23 Oct 2025 19:46:45 +0300 Subject: [PATCH] Update Database.php fixed query. --- GameEngine/Database.php | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/GameEngine/Database.php b/GameEngine/Database.php index e4f19f62..203c3997 100755 --- a/GameEngine/Database.php +++ b/GameEngine/Database.php @@ -619,26 +619,25 @@ class MYSQLi_DB implements IDbConnection { References: lietuvis10 ***************************/ - public function getBestOasisCropBonus($x, $y) { - $x = (int)$x; - $y = (int)$y; - - // Adjust oasis type codes if your fork differs: - // - 50% crop only: type IN (12) - // - 25% crop (pure or mixed w/ wood/clay/iron): type IN (4,9,10,11) - - $sql = "SELECT COALESCE(SUM(bonus), 0) AS total FROM (SELECT CASE - WHEN o.type IN (12) THEN 50 WHEN o.type IN (4,9,10,11) THEN 25 ELSE 0 - END AS bonus FROM " . TB_PREFIX . "wdata w JOIN " . TB_PREFIX . "odata o ON o.wref = w.id - WHERE w.fieldtype = 0 AND ABS(w.x - $x) <= 3 AND ABS(w.y - $y) <= 3 - AND o.type IN (12,4,9,10,11) -- only crop-giving oases ORDER BY bonus DESC LIMIT 3) t"; +public function getBestOasisCropBonus($x, $y) { + $x = (int)$x; + $y = (int)$y; - $q = mysqli_query($this->dblink, $sql); - $row = mysqli_fetch_assoc($q); - $total = (int)($row['total'] ?? 0); - if ($total > 150) $total = 150; // safety cap - return $total; - } + // Adjust oasis type codes if your fork differs: + // - 50% crop only: type IN (12) + // - 25% crop (pure or mixed w/ wood/clay/iron): type IN (4,9,10,11) + $sql = "SELECT COALESCE(SUM(bonus), 0) AS total FROM (SELECT CASE + WHEN o.type IN (12) THEN 50 WHEN o.type IN (4,9,10,11) THEN 25 ELSE 0 + END AS bonus FROM " . TB_PREFIX . "wdata w JOIN " . TB_PREFIX . "odata o ON o.wref = w.id + WHERE w.fieldtype = 0 AND ABS(w.x - $x) <= 3 AND ABS(w.y - $y) <= 3 AND o.type IN (12,4,9,10,11) + ORDER BY bonus DESC LIMIT 3) t"; + + $q = mysqli_query($this->dblink, $sql); + $row = mysqli_fetch_assoc($q); + $total = (int)($row['total'] ?? 0); + if ($total > 150) $total = 150; // safety cap + return $total; +} /*************************** Function to process MYSQLi->fetch_all (Only exist in MYSQL)