Fix demolish #337

Fix demolish #337
This commit is contained in:
novgorodschi catalin
2026-07-24 18:16:53 +03:00
parent 15a18a1e21
commit a7817f9631
4 changed files with 181 additions and 47 deletions
+12 -17
View File
@@ -210,23 +210,14 @@ trait AutomationBuildQueue {
$buildarray = $GLOBALS["bid".$type];
if ($type == 10 || $type == 38) {
$database->query("
UPDATE ".TB_PREFIX."vdata
SET
`maxstore` = IF(`maxstore` - ".$buildarray[$level]['attri']." <= ".STORAGE_BASE.", ".STORAGE_BASE.", `maxstore` - ".$buildarray[$level]['attri'].")
WHERE
wref=".(int) $vil['vref']);
}
if ($type == 11 || $type == 39) {
$database->query("
UPDATE ".TB_PREFIX."vdata
SET
`maxcrop` = IF(`maxcrop` - ".$buildarray[$level]['attri']." <= ".STORAGE_BASE.", ".STORAGE_BASE.", `maxcrop` - ".$buildarray[$level]['attri'].")
WHERE
wref=".(int) $vil['vref']);
}
// FIX: capacitatea de depozitare se RECALCULEAZA din cladirile
// ramase, dupa ce nivelul nou e scris mai jos. Scaderea de
// dinainte lua `attri` al nivelului, dar `attri` e capacitatea
// TOTALA la acel nivel (1200, 1700, 2300...), nu incrementul -
// deci taia prea mult. Ignora si STORAGE_MULTIPLIER. Efectul era
// ascuns de pragul STORAGE_BASE si "reparat" abia la urmatoarea
// rulare a lui updateStore().
$needsStorageRecalc = in_array($type, [10, 11, 38, 39]);
if ($level == 1) $clear = ",f".$vil['buildnumber']."t=0";
else $clear = "";
@@ -235,6 +226,10 @@ trait AutomationBuildQueue {
$q = "UPDATE ".TB_PREFIX."fdata SET f".$vil['buildnumber']."=".$newLevel." ".$clear." WHERE vref=".(int)$vil['vref'];
$database->query($q);
if ($needsStorageRecalc) {
$database->recalculateStorage($vil['vref']);
}
$pop = $this->getPop($type, $newLevel);
$database->modifyPop($vil['vref'], $pop[0], 1);
$this->procClimbers($database->getVillageField($vil['vref'], 'owner'));