Some additional fixes

Some additional fixes
This commit is contained in:
novgorodschi catalin
2026-09-01 07:56:14 +03:00
parent 054fde6e66
commit 71e73dde95
13 changed files with 169 additions and 28 deletions
@@ -317,7 +317,18 @@ trait AutomationBattleResolution {
if ($i == 41) $i = 99;
if ($bdo['f'.$i] > 0 && $i != 40) $list[] = $i;
}
$catapultTarget2 = $list[ rand(0, count($list) - 1) ];
// FIX (PHP log): daca $list e gol (niciun target alternativ
// cu nivel>0), rand(0, count($list)-1) devine rand(0,-1).
// PHP NU arunca eroare aici (verificat pe 8.3) - intoarce
// pseudo-random 0 sau -1, ambele chei inexistente in $list,
// deci "Undefined array key -1"/0 si $catapultTarget2=null.
// Pastram fallback-ul 99 folosit deja mai sus (linia ~301)
// pentru cazul "niciun target gasit".
if (!empty($list)) {
$catapultTarget2 = $list[ rand(0, count($list) - 1) ];
} else {
$catapultTarget2 = 99;
}
}
/**
+33 -5
View File
@@ -299,7 +299,7 @@ class Building {
// upgrade
$loopLevel = $this->isLoop($fieldId);
$currentLevel = $this->isCurrent($fieldId);
if ($this->isMax($gid, $fieldId, $loopLevel + $currentLevel)) {
$this->redirect($fieldId);
}
@@ -524,6 +524,13 @@ class Building {
switch ($resourceCheck) {
// FIX (PHP log): cod nou intors de checkResource() cand nivelul
// cerut nu mai e definit (deja la maxim) - vezi nota din
// checkResource(). Mapam la acelasi mesaj (MAX_LEVEL) ca gate-ul
// isMax() de mai sus (return 1 la inceputul functiei).
case 0:
return 1;
case 1:
return 5;
@@ -1208,6 +1215,21 @@ class Building {
$nextLevel = $this->vil->resarray['f'.$fieldId] + $plus;
// FIX (PHP log): daca $nextLevel depaseste nivelul maxim definit in
// $dataarray, $dataarray[$nextLevel] nu exista -> "Undefined array
// key" + acces pe null pe liniile de mai jos. Costurile null
// comparate cu > (wood>maxstore etc.) treceau silentios drept 0,
// deci functia ajungea sa intoarca 4 ("resurse suficiente") pentru
// un upgrade care nu ar trebui sa mai fie posibil. In mod normal
// isMax() din canBuild()/canProcess() ar trebui sa opreasca cererea
// inainte sa ajunga aici - acesta e doar un fallback defensiv daca
// acele verificari sunt ocolite (vezi nota din canProcess() despre
// Master Builder). Cod nou (0), distinct de 1-4 existente, mapat mai
// jos in canBuild() la mesajul MAX_LEVEL.
if (!isset($dataarray[$nextLevel])) {
return 0;
}
$required = $dataarray[$nextLevel];
$wood = $required['wood'];
@@ -1758,8 +1780,16 @@ class Building {
$dataarray = isset($GLOBALS['bid'.$gid]) ? $GLOBALS['bid'.$gid] : null;
// safety
if (!$dataarray) {
$level = $this->vil->resarray['f'.$fieldId] + $plus;
// FIX (PHP log): pattern-ul de siguranta de mai jos verifica doar daca
// $dataarray exista deloc, nu si daca $level (curent + plus) e in
// limitele lui. Cand cladirea a scapat deja la nivelul maxim definit
// (ex. gid normal cu nivel 20, plus=1 -> $dataarray[21] nu exista),
// $required devenea null si $required['wood'] etc. dadeau "Trying to
// access array offset on null". Extindem verificarea sa acopere si
// cazul asta, cu acelasi fallback de "cost zero" folosit deja mai jos.
if (!$dataarray || !isset($dataarray[$level])) {
$empty = array(
'wood' => 0,
@@ -1774,8 +1804,6 @@ class Building {
return $this->resourceReqCache[$cacheKey] = $empty;
}
$level = $this->vil->resarray['f'.$fieldId] + $plus;
$required = $dataarray[$level];
$result = array(
@@ -143,17 +143,29 @@ trait DatabaseBuildingQueries {
global ${'bid'.$tid}, $bid15;
$dataArray = ${'bid'.$tid};
$level = $buildingArray['f'.$id] + $plus;
// FIX (PHP log): daca $level depaseste nivelul maxim definit in
// $dataArray (cladire deja la nivel maxim - acelasi guard pus si in
// Building::checkResource()/resourceRequired()), $dataArray[$level]
// nu exista -> "Undefined array key 21" + acces pe null pe ['time'].
// Timp 0 e fallback sigur (apelantii trateaza deja "cost zero" ca
// raspuns pentru cazul de nivel maxim, vezi resourceRequired()).
if (!isset($dataArray[$level])) {
return 0;
}
//Check if we've the main building or not
$mainBuilding = $this->getFieldLevelInVillage($wref, 15);
if($tid == 15){
if($mainBuilding == 0) return round($dataArray[$buildingArray['f'.$id] + $plus]['time'] / SPEED * 5);
else return round($dataArray[$buildingArray['f'.$id] + $plus]['time'] / SPEED);
if($mainBuilding == 0) return round($dataArray[$level]['time'] / SPEED * 5);
else return round($dataArray[$level]['time'] / SPEED);
}else{
if($mainBuilding > 0) {
return round($dataArray[$buildingArray['f'.$id] + $plus]['time'] * ($bid15[$mainBuilding]['attri'] / 100) / SPEED);
return round($dataArray[$level]['time'] * ($bid15[$mainBuilding]['attri'] / 100) / SPEED);
}
else return round($dataArray[$buildingArray['f'.$id] + $plus]['time'] * 5 / SPEED);
else return round($dataArray[$level]['time'] * 5 / SPEED);
}
}
+17 -1
View File
@@ -405,7 +405,11 @@ References: User ID/Message ID, Mode
// first of all, check if we should be using cache and whether the field
// required is already cached
if ($use_cache && ($cachedValue = self::returnCachedContent(self::$noticesCacheById, $id)) && !is_null($cachedValue)) {
return $cachedValue[$field];
// FIX (PHP log): cand $field e null (apelantul vrea randul intreg,
// nu un camp anume), vechiul cod facea $cachedValue[$field] cu
// $field=null -> PHP converteste cheia null in "" -> "Undefined
// array key \"\"". Acelasi tratament ca pe ramura fara cache mai jos.
return is_null($field) ? $cachedValue : $cachedValue[$field];
}
$q = "SELECT * FROM " . TB_PREFIX . "ndata where `id` = $id ORDER BY time ".(isset($_GET['o']) && $_GET['o'] == 1 ? 'ASC' : 'DESC')." LIMIT 1";
@@ -413,6 +417,18 @@ References: User ID/Message ID, Mode
$dbarray = mysqli_fetch_array($result);
self::$noticesCacheById[$id] = $dbarray;
// FIX (PHP log): id inexistent in ndata (notice sters / link stale)
// -> mysqli_fetch_array() intoarce null -> $dbarray e null. Vechiul
// cod incerca oricum self::$noticesCacheById[$id][$field] pe el,
// dand "Trying to access array offset on null". Notice-ul chiar nu
// exista, deci intoarcem null direct (comportament identic la
// consumatori: Message::getReadNotice() trateaza deja null ca
// "nu am gasit/nu am voie", vezi fix-ul din Message.php).
if (is_null($dbarray)) {
return null;
}
return is_null($field) ? self::$noticesCacheById[$id] : self::$noticesCacheById[$id][$field];
}
@@ -92,8 +92,12 @@ trait DatabaseStatisticsQueries {
* jucatorii acelor triburi nu-si vedeau niciodata satele acolo.
*
* Aceeasi lista completa e folosita deja in winner.php.
*
* BUG REPARAT #2: u.access<8/10 excludea Multihunter(8)/Admin(9) dar nu si
* conturile banate (access=0, 0 < 8 e adevarat); u.access>0 adaugat, deci
* satele unui cont banat nu mai sunt colorate dupa rang pe harta lumii.
*/
$q = "SELECT v.wref,v.name,v.owner,v.pop FROM " . TB_PREFIX . "vdata AS v," . TB_PREFIX . "users AS u WHERE v.owner=u.id AND u.tribe IN(1,2,3,6,7,8,9".(SHOW_NATARS ? ',5' : '').") AND v.wref != '' AND u.access<" . (INCLUDE_ADMIN ? "10" : "8");
$q = "SELECT v.wref,v.name,v.owner,v.pop FROM " . TB_PREFIX . "vdata AS v," . TB_PREFIX . "users AS u WHERE v.owner=u.id AND u.tribe IN(1,2,3,6,7,8,9".(SHOW_NATARS ? ',5' : '').") AND v.wref != '' AND u.access>0 AND u.access<" . (INCLUDE_ADMIN ? "10" : "8");
$result = mysqli_query($this->dblink,$q);
return $this->mysqli_fetch_all($result);
}
+9
View File
@@ -436,6 +436,15 @@ class Message
{
global $database, $session;
$notice = $database->getNotice2($id);
// FIX (PHP log): id inexistent (notice sters / link stale) ->
// getNotice2() intoarce null -> $notice['uid'] pica cu "Trying to
// access array offset on null". Tratam identic cu cazul
// "neautorizat" de mai jos (return null).
if ($notice === null) {
return null;
}
if (
$notice['uid'] == $session->uid ||
$notice['ally'] == $session->alliance
+9 -4
View File
@@ -277,6 +277,8 @@
if($GLOBALS['db']->countUser() > 0){
$holder = array();
$tribeCondition = SHOW_NATARS ? "(u.tribe <= 9) AND (u.id > 5 OR u.id = 3)" : "u.tribe IN (1,2,3,6,7,8,9) AND u.id > 5";
// BUG REPARAT: access<8/10 excludea Multihunter(8)/Admin(9) dar nu si
// conturile banate (access=0, 0 < 8 e adevarat); access>0 adaugat.
$q = "
SELECT
u.id AS userid,
@@ -292,7 +294,7 @@
LEFT JOIN " . TB_PREFIX . "alidata a
ON a.id = u.alliance
WHERE
u.access < " . (INCLUDE_ADMIN ? 10 : 8) . "
u.access > 0 AND u.access < " . (INCLUDE_ADMIN ? 10 : 8) . "
AND $tribeCondition
GROUP BY
u.id
@@ -328,10 +330,11 @@
global $multisort, $database;
$race = $database->escape((int) $race);
$holder = array();
// BUG REPARAT: vezi comentariul din procRankArray() de mai sus (access>0 adaugat).
$q = "SELECT u.id AS userid, u.tribe, u.username, u.alliance, COALESCE(SUM(v.pop),0) AS totalpop, COUNT(CASE WHEN v.type != 99 THEN v.wref END) AS totalvillages, a.tag AS allitag
FROM " . TB_PREFIX . "users u LEFT JOIN " . TB_PREFIX . "vdata v ON v.owner = u.id LEFT JOIN " . TB_PREFIX . "alidata a ON a.id = u.alliance
WHERE u.tribe = $race
AND u.access < " . (INCLUDE_ADMIN ? "10" : "8") . " AND u.id > 5 GROUP BY u.id ORDER BY totalpop DESC, totalvillages DESC, userid DESC";
AND u.access > 0 AND u.access < " . (INCLUDE_ADMIN ? "10" : "8") . " AND u.id > 5 GROUP BY u.id ORDER BY totalpop DESC, totalvillages DESC, userid DESC";
$result = (mysqli_query($database->dblink,$q));
$datas = [];
while($row = mysqli_fetch_assoc($result)) {
@@ -366,9 +369,10 @@
public function procAttRankArray() {
global $multisort, $database;
$holder = array();
// BUG REPARAT: vezi comentariul din procRankArray() mai sus (access>0 adaugat).
$q = "SELECT u.id AS userid, u.username, u.apall, COUNT(CASE WHEN v.type != 99 THEN v.wref END) AS totalvillages, COALESCE(SUM(v.pop),0) AS pop
FROM " . TB_PREFIX . "users u LEFT JOIN " . TB_PREFIX . "vdata v ON v.owner = u.id
WHERE u.apall >= 0 AND u.access < " . (INCLUDE_ADMIN ? 10 : 8) . " AND u.tribe IN (1,2,3,6,7,8,9) AND u.id > 5
WHERE u.apall >= 0 AND u.access > 0 AND u.access < " . (INCLUDE_ADMIN ? 10 : 8) . " AND u.tribe IN (1,2,3,6,7,8,9) AND u.id > 5
GROUP BY u.id ORDER BY u.apall DESC, pop DESC, u.id DESC";
$result = mysqli_query($database->dblink,$q) or die(mysqli_error($database->dblink));
$datas = [];
@@ -394,9 +398,10 @@
public function procDefRankArray() {
global $database;
$holder = array();
// BUG REPARAT: vezi comentariul din procRankArray() mai sus (access>0 adaugat).
$q = "SELECT u.id AS userid, u.username, u.dpall, COUNT(CASE WHEN v.type != 99 THEN v.wref END) AS totalvillages, COALESCE(SUM(v.pop),0) AS pop
FROM " . TB_PREFIX . "users u LEFT JOIN " . TB_PREFIX . "vdata v ON v.owner = u.id
WHERE u.dpall >= 0 AND u.access < " . (INCLUDE_ADMIN ? 10 : 8) . " AND u.tribe IN (1,2,3,6,7,8,9) AND u.id > 5
WHERE u.dpall >= 0 AND u.access > 0 AND u.access < " . (INCLUDE_ADMIN ? 10 : 8) . " AND u.tribe IN (1,2,3,6,7,8,9) AND u.id > 5
GROUP BY u.id ORDER BY u.dpall DESC, pop DESC, u.id DESC";
$result = mysqli_query($database->dblink,$q) or die(mysqli_error($database->dblink));
$datas = [];