From fa8a6640e210828db37eddd3112aaaca23f5ae1d Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Mon, 4 Dec 2017 11:10:00 +0100 Subject: [PATCH] fix: demolition could bring building level to negative numbers Closes #412 --- GameEngine/Automation.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index 79c2a36e..51af2a72 100755 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -4564,6 +4564,11 @@ class Automation { if ($vil['timetofinish'] <= time()) { $type = $database->getFieldType($vil['vref'],$vil['buildnumber']); $level = $database->getFieldLevel($vil['vref'],$vil['buildnumber']); + + if ($level < 0) { + $level = 0; + } + $buildarray = $GLOBALS["bid".$type]; if ($type==10 || $type==38) { @@ -4588,7 +4593,7 @@ class Automation { if ($village->natar==1 && $type==40) $clear=""; //fix by ronix - $q = "UPDATE ".TB_PREFIX."fdata SET f".$vil['buildnumber']."=".($level-1).$clear." WHERE vref=".(int) $vil['vref']; + $q = "UPDATE ".TB_PREFIX."fdata SET f".$vil['buildnumber']."=".(($level-1 >= 0) ? $level-1 : 0).$clear." WHERE vref=".(int) $vil['vref']; $database->query($q); $pop = $this->getPop($type,$level-1);