mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-09-22 18:06:37 +08:00
Change capital add index
Change capital add index
This commit is contained in:
+29
-2
@@ -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"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
--
|
--
|
||||||
|
|||||||
Reference in New Issue
Block a user