Some important fixes

Some important fixes
This commit is contained in:
novgorodschi catalin
2026-08-10 09:08:09 +03:00
parent 2095a59b7e
commit da58de16b4
14 changed files with 105 additions and 19 deletions
@@ -340,7 +340,11 @@ trait DatabaseMovementQueries {
list($id) = $this->escape_input($id);
$vinfo = $this->getVillage($id);
$vtribe = $this->getUserField($vinfo['owner'], "tribe", 0);
// Satul poate lipsi (sters intre timp). Fara proprietar nu avem ce trib
// sa citim, deci nu are rost sa continuam cu null.
$vOwner = is_array($vinfo) && isset($vinfo['owner']) ? (int) $vinfo['owner'] : 0;
$vtribe = $vOwner > 0 ? $this->getUserField($vOwner, "tribe", 0) : 0;
$movingunits = [];
$outgoingarray = $this->getMovement(3, $id, 0);
+20 -2
View File
@@ -316,7 +316,11 @@ trait DatabaseUserQueries {
}
$result = mysqli_query($this->dblink,$q);
$dbarray = mysqli_fetch_array($result);
return $dbarray[$field];
// Cont inexistent: intoarcem null in loc sa citim dintr-un rand gol.
return (is_array($dbarray) && array_key_exists($field, $dbarray))
? $dbarray[$field]
: null;
}
function login($username, $password) {
@@ -341,6 +345,18 @@ trait DatabaseUserQueries {
$dbarray = mysqli_fetch_array($result);
/**
* Utilizator inexistent: iesim imediat, cu acelasi rezultat ca o parola
* gresita (functia intoarce false si mai jos).
*
* Inainte se continua si se citeau $dbarray['password'], ['is_bcrypt'],
* ['id'] si ['sessid'] dintr-un rand gol - de aici sirul de avertismente
* la fiecare incercare de autentificare cu un nume care nu exista.
*/
if (!is_array($dbarray)) {
return false;
}
// even if we didn't do a DB conversion for bcrypt passwords,
// we still need to check if this password wasn't encrypted via password_hash,
// since all methods were updated to use that instead of md5 and therefore
@@ -539,7 +555,9 @@ trait DatabaseUserQueries {
$q = "SELECT sit FROM " . TB_PREFIX . "online WHERE uid = $uid LIMIT 1";
$result = mysqli_query($this->dblink,$q);
$dbarray = mysqli_fetch_array($result);
return $dbarray['sit'];
// Utilizatorul poate lipsi (cont sters). Fara sitter, intoarcem 0.
return (is_array($dbarray) && isset($dbarray['sit'])) ? $dbarray['sit'] : 0;
}
function UpdateOnline($mode, $name = "", $time = "", $uid = 0) {
+26 -3
View File
@@ -104,7 +104,13 @@ trait DatabaseVillageQueries {
}
function getVrefField($ref, $field, $use_cache = true) {
return $this->getVillage($ref, 0, $use_cache)[$field];
// getVillage() intoarce null pentru un sat inexistent (sters, cucerit
// sau id gresit). Fara verificare, apelantul primea un avertisment.
$village = $this->getVillage($ref, 0, $use_cache);
return (is_array($village) && array_key_exists($field, $village))
? $village[$field]
: null;
}
// no need to cache this method
@@ -254,7 +260,18 @@ trait DatabaseVillageQueries {
//Count each kid in its own array, to check how many villages must be created
foreach($villageArrays as $village){
if($village['wid'] == 0) $countedWids[$village['mode']][$village['kid']]++;
if($village['wid'] == 0) {
// prima aparitie a perechii mode/kid: pornim de la zero, altfel
// incrementam o cheie inexistenta
$vMode = $village['mode'];
$vKid = $village['kid'];
if (!isset($countedWids[$vMode][$vKid])) {
$countedWids[$vMode][$vKid] = 0;
}
$countedWids[$vMode][$vKid]++;
}
}
//Generate the number of desired village for each kid
@@ -2347,7 +2364,13 @@ trait DatabaseVillageQueries {
}
for($i = 0; $i <= count($cropholder) - 1; $i++){
$basecrop += $bid4[$buildarray[$cropholder[$i]]]['prod'];
// Un slot fara cladire nu are nivel in $buildarray, iar bid4 nu are
// intrare pentru el. Sarim peste, in loc sa adunam null.
$cropLevel = isset($buildarray[$cropholder[$i]]) ? $buildarray[$cropholder[$i]] : null;
if ($cropLevel !== null && isset($bid4[$cropLevel]['prod'])) {
$basecrop += $bid4[$cropLevel]['prod'];
}
}
$crop = $basecrop + $basecrop * 0.25 * $cropo;