Some additional fixes for PHP errors

Some additional fixes for PHP errors
This commit is contained in:
novgorodschi catalin
2026-08-17 10:31:03 +03:00
parent d9df87c622
commit 0f81a2b25e
11 changed files with 27 additions and 12 deletions
+3 -4
View File
@@ -16,16 +16,15 @@ The taskmaster will help you on your way to establishing your empire with advice
<b>Game World Timeline</b>
This game world is expected to run until approximately <b>%WORLD_END_DATE%</b>
.
The estimated end date is calculated dynamically from the World Wonder Construction Plan release, the time required to construct the World Wonder from level 0 to level 100 at the current server speed, and an additional <b>5 days</b> to allow for final attacks and possible World Wonder setbacks.
This game world is expected to run until approximately <b>%WORLD_END_DATE%</b>. The estimated end date is calculated dynamically, following the timeline below, plus an additional <b>5 days</b> to allow for final attacks and possible World Wonder setbacks.
<ul style="margin-top:0;margin-bottom:0;">
<li><b>Natars appear:</b> %NATARS_DATE%</li>
<li><b>World Wonder villages appear:</b> %WW_VILLAGES_DATE%</li>
<li><b>World Wonder Construction Plans appear:</b> %WW_PLANS_DATE%</li>
<li><b>World Wonder construction time from level 0 to 100:</b> %WW_BUILD_TIME%</li>
<li><b>World Wonder build time (level 0 &rarr; 100):</b> %WW_BUILD_TIME%</li>
<li><b>Estimated World Wonder completion:</b> %WW100_DATE%</li>
<li><b>Estimated world end date:</b> %WORLD_END_DATE%</li>
</ul>
<b>Natars</b>
@@ -217,7 +217,7 @@ trait DatabaseBuildingQueries {
if($job['id'] == $d) $jobToDelete = $job;
}
if($canBeRemoved && $jobToDelete['field'] > 18 && $jobToDelete['field'] != 99 && $jobToDelete['level'] - 1 == 0){
if($canBeRemoved && !empty($jobToDelete) && $jobToDelete['field'] > 18 && $jobToDelete['field'] != 99 && $jobToDelete['level'] - 1 == 0){
$this->setVillageLevel($wid, ["f".$jobToDelete['field']."t"], [0]);
}
@@ -1563,7 +1563,7 @@ trait DatabaseVillageQueries {
$y1 = intval($coor['y']);
$prevdist = 0;
$array2 = $this->getVillage(0, 4);
$vill = $array2['wref'];
$vill = $array2['wref'] ?? 0;
if ($array && count($array)){
foreach($array as $village){
+1 -1
View File
@@ -289,7 +289,7 @@ class MyGenerator
*/
public function getMapCheck($wref)
{
return substr(md5($wref), 5, 2);
return substr(md5((string) $wref), 5, 2);
}
/**
+8
View File
@@ -740,6 +740,14 @@ class Message
public function sendWelcome($uid, $username){
global $database;
/*
* FIX: $bid40 / $bid15 sunt deja incarcate global de Session.php
* (include_once("Data/buidata.php")), care ruleaza pe orice pagina.
* Fara "global" aici, require_once() de mai jos e no-op (fisierul
* e deja inclus o data in script), iar $bid40/$bid15 raman nesetate
* local -> blocul de calcul WW e sarit -> wwBuildSeconds = 0.
*/
global $bid40, $bid15;
$welcomemsg = file_get_contents("GameEngine/Admin/welcome.tpl");
+6
View File
@@ -138,6 +138,12 @@ class Units {
if(!empty($post['dname']) && $post['x'] != "" && $post['y'] != "") return "Insert name or coordinates";
// Neither a village name nor coordinates were provided at all -> $id would
// otherwise stay undefined and reach array_push() below unset.
if(empty($post['dname']) && (!isset($post['x']) || !isset($post['y']) || $post['x'] === "" || $post['y'] === "")) {
return "Insert name or coordinates";
}
if(isset($post['dname']) && !empty($post['dname'])) {
$id = $database->resolveVillageInput(stripslashes($post['dname']),
(int) ($session->uid ?? 0)); // accepta si "Nume (x|y)"
+2 -1
View File
@@ -25,7 +25,8 @@ $field = 'f' . $id;
$currentLevel = (int) ($village->resarray[$field] ?? 0);
$buildingType = $village->resarray[$field . 't'] ?? 0;
$currentCapacity = $bid10[$currentLevel]['attri'] * STORAGE_MULTIPLIER;
// $bid10 is keyed from level 1 upward; at level 0 (not built yet) fall back to the base capacity
$currentCapacity = ($currentLevel > 0) ? $bid10[$currentLevel]['attri'] * STORAGE_MULTIPLIER : STORAGE_BASE;
$isMax = $building->isMax($buildingType, $id);
$maxLevel = 20;
+2 -1
View File
@@ -25,7 +25,8 @@ $field = 'f' . $id;
$currentLevel = (int) ($village->resarray[$field] ?? 0);
$buildingType = $village->resarray[$field . 't'] ?? 0;
$currentCapacity = $bid11[$currentLevel]['attri'] * STORAGE_MULTIPLIER;
// $bid11 is keyed from level 1 upward; at level 0 (not built yet) fall back to the base capacity
$currentCapacity = ($currentLevel > 0) ? $bid11[$currentLevel]['attri'] * STORAGE_MULTIPLIER : STORAGE_BASE;
$isMax = $building->isMax($buildingType, $id);
$maxLevel = 20;
+1 -1
View File
@@ -41,7 +41,7 @@ if($village->capital == 1 && $village->resarray['f'.$_GET['id'].'t'] == 35 && $s
$clay = $festival['clay'];
$iron = $festival['iron'];
$crop = $festival['crop'];
$database->modifyResource($village->resarray['vref'],$wood,$clay,$iron,$crop,$mode);
$database->modifyResource($village->resarray['vref'],$wood,$clay,$iron,$crop,0);
$database->addFestival($village->resarray['vref'],$endtime);
}
}
+1 -1
View File
@@ -27,7 +27,7 @@ use App\Utils\AccessLogger;
include_once("GameEngine/Village.php");
AccessLogger::logRequest();
$amount = $_SESSION['amount'];
$amount = $_SESSION['amount'] ?? 0;
if(isset($_GET['newdid'])) {
$_SESSION['wid'] = $_GET['newdid'];
header("Location: ".$_SERVER['PHP_SELF']);
+1 -1
View File
@@ -26,7 +26,7 @@ use App\Utils\AccessLogger;
include_once("GameEngine/Village.php");
AccessLogger::logRequest();
$amount = $_SESSION['amount'];
$amount = $_SESSION['amount'] ?? 0;
if(isset($_GET['newdid'])) {
$_SESSION['wid'] = $_GET['newdid'];
header("Location: ".$_SERVER['PHP_SELF']);