Change capital add index

Change capital add index
This commit is contained in:
novgorodschi catalin
2026-06-30 10:32:01 +03:00
parent c62fbc31ab
commit 97d6b7650c
2 changed files with 65 additions and 37 deletions
+29 -2
View File
@@ -8988,8 +8988,35 @@ public function setDebugSettings($warning, $notice, $deprecated, $fatal, $maxSiz
function changeCapital($wref, $mode = 1) { function changeCapital($wref, $mode = 1) {
list($wref, $mode) = $this->escape_input($wref, $mode); list($wref, $mode) = $this->escape_input($wref, $mode);
$q = "UPDATE ".TB_PREFIX."vdata SET capital = ".$mode." WHERE wref = $wref"; $wref = (int)$wref;
return mysqli_query($this->dblink, $q); $mode = (int)$mode;
// We retrieve the owner of the current village.
$owner = (int)$this->getVillageField($wref, 'owner');
if ($owner <= 0) {
return false;
}
// if we are setting a new capital
if ($mode == 1) {
// 1. We reset ALL capitals of that owner (VERY fast)
mysqli_query(
$this->dblink,
"UPDATE " . TB_PREFIX . "vdata
SET capital = 0
WHERE owner = $owner"
);
}
// 2. we set the new capital
return mysqli_query(
$this->dblink,
"UPDATE " . TB_PREFIX . "vdata
SET capital = $mode
WHERE wref = $wref"
);
} }
}; };
+1
View File
@@ -1726,6 +1726,7 @@ KEY `loyalty` (`loyalty`),
KEY `exp1` (`exp1`), KEY `exp1` (`exp1`),
KEY `exp2` (`exp2`), KEY `exp2` (`exp2`),
KEY `exp3` (`exp3`) KEY `exp3` (`exp3`)
KEY `idx_owner_wref` (`owner`, `wref`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --