From aec0380e1761f660b2beb292b169d4db90b75fc3 Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Wed, 22 Nov 2017 16:29:25 +0100 Subject: [PATCH] fix: resources falling to 0 will auto-fill warehouse/crop to max value --- GameEngine/Database.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/GameEngine/Database.php b/GameEngine/Database.php index 9f89ba27..86df23bc 100755 --- a/GameEngine/Database.php +++ b/GameEngine/Database.php @@ -3287,15 +3287,17 @@ class MYSQLi_DB implements IDbConnection { list($vid, $wood, $clay, $iron, $crop, $mode) = $this->escape_input((int) $vid, (int) $wood, (int) $clay, (int) $iron, (int) $crop, $mode); $sign = (!$mode ? '-' : '+'); - return mysqli_query( $this->dblink, " + $q = " UPDATE " . TB_PREFIX . "vdata SET - wood = IF(wood $sign $wood > 0 AND wood $sign $wood < maxstore, wood $sign $wood, ".($mode ? 'maxstore' : '0')."), - clay = IF(clay $sign $clay > 0 AND clay $sign $clay < maxstore, clay $sign $clay, ".($mode ? 'maxstore' : '0')."), - iron = IF(iron $sign $iron > 0 AND iron $sign $iron < maxstore, iron $sign $iron, ".($mode ? 'maxstore' : '0')."), - crop = IF(crop $sign $crop > 0 AND crop $sign $crop < maxcrop, crop $sign $crop, ".($mode ? 'maxcrop' : '0').") + wood = IF(wood $sign $wood < 0, 0, IF(wood $sign $wood > maxstore, maxstore, $sign $wood)), + clay = IF(clay $sign $clay < 0, 0, IF(clay $sign $clay > maxstore, maxstore, $sign $clay)), + iron = IF(iron $sign $iron < 0, 0, IF(iron $sign $iron > maxstore, maxstore, iron $sign $iron)), + crop = IF(crop $sign $crop < 0, 0, IF(crop $sign $crop > maxcrop, maxcrop, crop $sign $crop)) WHERE - wref = " . $vid ); + wref = " . $vid ; + + return mysqli_query( $this->dblink, $q); } function setMaxStoreForVillage($vid, $maxLevel) {