Update some files & remove unused code

Update some files & remove unused code
This commit is contained in:
novgorodschi catalin
2026-06-23 13:43:17 +03:00
parent 6472b30bd2
commit 8d492bebd3
7 changed files with 54 additions and 75 deletions
+46 -67
View File
@@ -117,8 +117,9 @@ class Automation {
} }
/** /**
* Returneaza datele utilizatorului cu cache local * Retrieve user data using local cache.
*/ **/
private function getCachedUser($uid, $mode = 1) { private function getCachedUser($uid, $mode = 1) {
global $database; global $database;
$uid = (int)$uid; $uid = (int)$uid;
@@ -387,7 +388,7 @@ class Automation {
private function culturePoints() { private function culturePoints() {
global $database; global $database;
$database->updateVSumField('cp'); $database->updateVSumField('cp');
} }
@@ -455,7 +456,6 @@ class Automation {
// if we updated Embassy, update maximum members that the alliance can take // if we updated Embassy, update maximum members that the alliance can take
if($indi['type'] == 18) Automation::updateMax($villageOwner); if($indi['type'] == 18) Automation::updateMax($villageOwner);
// by SlimShady95 aka Manuel Mannhardt < manuel_mannhardt@web.de >
if ($indi['type'] == 40 && ($indi['level'] % 5 == 0 || $indi['level'] > 95) && $indi['level'] != 100) { if ($indi['type'] == 40 && ($indi['level'] % 5 == 0 || $indi['level'] > 95) && $indi['level'] != 100) {
$this->startNatarAttack($indi['level'], $indi['wid'], $indi['timestamp']); $this->startNatarAttack($indi['level'], $indi['wid'], $indi['timestamp']);
} }
@@ -514,7 +514,6 @@ class Automation {
} }
} }
// by SlimShady95 aka Manuel Mannhardt < manuel_mannhardt@web.de >
private function startNatarAttack($level, $vid, $time) { private function startNatarAttack($level, $vid, $time) {
global $database; global $database;
@@ -4175,10 +4174,10 @@ class Automation {
$varray = $database->getDemolition(); $varray = $database->getDemolition();
foreach($varray as $vil) { foreach($varray as $vil) {
if ($vil['lvl'] < 0) { if ($vil['lvl'] < 0) {
$database->delDemolition($vil['vref'], true); $database->delDemolition($vil['vref'], true);
continue; continue;
} }
if ($vil['timetofinish'] <= time()) { if ($vil['timetofinish'] <= time()) {
$type = $database->getFieldType($vil['vref'],$vil['buildnumber']); $type = $database->getFieldType($vil['vref'],$vil['buildnumber']);
$level = $database->getFieldLevel($vil['vref'],$vil['buildnumber']); $level = $database->getFieldLevel($vil['vref'],$vil['buildnumber']);
@@ -4209,14 +4208,7 @@ if ($vil['lvl'] < 0) {
else $clear = ""; else $clear = "";
if ($database->getVillageField($vil['vref'], 'natar') == 1 && $type == 40) $clear = ""; //fix by ronix - fixed by iopietro if ($database->getVillageField($vil['vref'], 'natar') == 1 && $type == 40) $clear = ""; //fix by ronix - fixed by iopietro
$q = "UPDATE ".TB_PREFIX."fdata SET f".$vil['buildnumber']."=".$newLevel." ".$clear." WHERE vref=".(int)$vil['vref'];
$q = "
UPDATE ".TB_PREFIX."fdata
SET
f".$vil['buildnumber']."=".$newLevel."
".$clear."
WHERE
vref=".(int)$vil['vref'];
$database->query($q); $database->query($q);
$pop = $this->getPop($type, $newLevel); $pop = $this->getPop($type, $newLevel);
@@ -4351,7 +4343,6 @@ WHERE
} }
} }
// by SlimShady95, aka Manuel Mannhardt < manuel_mannhardt@web.de > UPDATED FROM songeriux < haroldas.snei@gmail.com >
private function updateStore() { private function updateStore() {
global $database, $bid10, $bid38, $bid11, $bid39; global $database, $bid10, $bid38, $bid11, $bid39;
@@ -4401,25 +4392,6 @@ WHERE
mysqli_commit($database->dblink); mysqli_commit($database->dblink);
} }
/*private function oasisResourcesProduce() {
global $database;
$speedMultiplier = (8 * (SPEED/3600));
$database->query("
UPDATE " . TB_PREFIX . "odata
SET
lastupdated = UNIX_TIMESTAMP(),
wood = IF(wood + ($speedMultiplier * (UNIX_TIMESTAMP() - lastupdated)) > maxstore, maxstore, wood + ($speedMultiplier * (UNIX_TIMESTAMP() - lastupdated))),
clay = IF(clay + ($speedMultiplier * (UNIX_TIMESTAMP() - lastupdated)) > maxstore, maxstore, clay + ($speedMultiplier * (UNIX_TIMESTAMP() - lastupdated))),
iron = IF(iron + ($speedMultiplier * (UNIX_TIMESTAMP() - lastupdated)) > maxstore, maxstore, iron + ($speedMultiplier * (UNIX_TIMESTAMP() - lastupdated))),
crop = IF(crop + ($speedMultiplier * (UNIX_TIMESTAMP() - lastupdated)) > maxcrop, maxcrop, crop + ($speedMultiplier * (UNIX_TIMESTAMP() - lastupdated)))
WHERE
wood < 800 OR
clay < 800 OR
iron < 800 OR
crop < 800");
}*/
private function checkInvitedPlayes() { private function checkInvitedPlayes() {
global $database; global $database;
@@ -4527,25 +4499,24 @@ WHERE
* Refactored by iopietro * Refactored by iopietro
*/ */
//TODO: This function needs to be splitted in many subfunctions (for TravianZ refactor)
private function starvation() { private function starvation() {
global $database, $technology; global $database, $technology;
// Starvation este dezactivat in perioada de pace (sarbatori) // Starvation is disabled during the peace period (holidays).
if(PEACE) return; if(PEACE) return;
$time = time(); $time = time();
// 1. Actualizeaza datele de starvation pentru toate satele // 1. Update starvation data for all villages.
$this->starvationUpdateAllVillages(); $this->starvationUpdateAllVillages();
// 2. Incarca satele cu productie negativa // 2. Load villages with negative production.
$starvarray = $this->starvationGetVillagesWithDeficit(); $starvarray = $this->starvationGetVillagesWithDeficit();
if (empty($starvarray)) return; if (empty($starvarray)) return;
$vilIDs = array_column($starvarray, 'wref'); $vilIDs = array_column($starvarray, 'wref');
// 3. Pregateste cache-urile pentru a reduce query-urile // 3. Prepare caches to reduce queries.
$this->starvationPrepareCaches($vilIDs); $this->starvationPrepareCaches($vilIDs);
foreach ($starvarray as $starv) { foreach ($starvarray as $starv) {
@@ -4554,8 +4525,9 @@ WHERE
} }
/** /**
* Actualizeaza tabela de starvation pentru toate satele * Update the starvation table for all villages.
*/ **/
private function starvationUpdateAllVillages() { private function starvationUpdateAllVillages() {
global $database; global $database;
$starvarray = $database->getProfileVillages(0, 7); $starvarray = $database->getProfileVillages(0, 7);
@@ -4565,16 +4537,18 @@ WHERE
} }
/** /**
* Returneaza satele cu deficit de crop * Return villages with crop deficit.
*/ **/
private function starvationGetVillagesWithDeficit() { private function starvationGetVillagesWithDeficit() {
global $database; global $database;
return $database->getStarvation(); return $database->getStarvation();
} }
/** /**
* Pregateste cache-urile pentru trupe * Prepare troop caches.
*/ **/
private function starvationPrepareCaches(array $vilIDs) { private function starvationPrepareCaches(array $vilIDs) {
global $database; global $database;
$database->getEnforceVillage($vilIDs, 0); $database->getEnforceVillage($vilIDs, 0);
@@ -4586,18 +4560,19 @@ WHERE
} }
/** /**
* Proceseaza un singur sat pentru starvation * Process a single village for starvation.
*/ **/
private function starvationProcessVillage($starv, $time) { private function starvationProcessVillage($starv, $time) {
global $database, $technology; global $database, $technology;
$unitarrays = $this->getAllUnits($starv['wref']); $unitarrays = $this->getAllUnits($starv['wref']);
// Formula originala de upkeep - pastrata exact // Original upkeep formula
$upkeep = $starv['pop'] + $technology->getUpkeep($unitarrays, 0, $starv['wref']); $upkeep = $starv['pop'] + $technology->getUpkeep($unitarrays, 0, $starv['wref']);
$troopData = $this->starvationFindFirstTroopGroup($starv); $troopData = $this->starvationFindFirstTroopGroup($starv);
if (empty($troopData['troops'])) { if (empty($troopData['troops'])) {
// Nu exista trupe, verifica doar resetarea // No troops exist, only check reset.
$this->starvationCheckReset($starv, $upkeep); $this->starvationCheckReset($starv, $upkeep);
return; return;
} }
@@ -4610,12 +4585,12 @@ WHERE
$cropProd = $database->getCropProdstarv($starv['wref']) - $starv['starv']; $cropProd = $database->getCropProdstarv($starv['wref']) - $starv['starv'];
if($cropProd < 0){ if($cropProd < 0){
// Calcul deficit - formula originala pastrata // Deficit calculation
$starvsec = (abs($cropProd) / 3600); $starvsec = (abs($cropProd) / 3600);
$difcrop = ($timedif * $starvsec); $difcrop = ($timedif * $starvsec);
$oldcrop = $database->getVillageField($starv['wref'], 'crop'); $oldcrop = $database->getVillageField($starv['wref'], 'crop');
// Consuma mai intai crop-ul din hambar // Use granary crop first for consumption.
if ($oldcrop > 100) { if ($oldcrop > 100) {
$difcrop = $difcrop - $oldcrop; $difcrop = $difcrop - $oldcrop;
if($difcrop < 0){ if($difcrop < 0){
@@ -4634,9 +4609,10 @@ WHERE
} }
/** /**
* Gaseste primul grup de trupe care poate muri de foame * Locate the first troop group eligible for starvation.
* Ordinea: enforce oasis, enforce village, prisoners, unitati proprii, atacuri * Processing order: oasis enforcement → village enforcement → prisoners → own units → attacks.
*/ **/
private function starvationFindFirstTroopGroup($starv) { private function starvationFindFirstTroopGroup($starv) {
global $database; global $database;
@@ -4673,8 +4649,9 @@ WHERE
} }
/** /**
* Ucide trupele conform deficitului de crop * Kill troops according to crop deficit.
*/ **/
private function starvationKillTroops($starv, &$starvingTroops, $type, $subtype, $difcrop, $upkeep, $time) { private function starvationKillTroops($starv, &$starvingTroops, $type, $subtype, $difcrop, $upkeep, $time) {
global $database; global $database;
@@ -4704,7 +4681,7 @@ WHERE
if($maxtype > 0){ if($maxtype > 0){
$starvingTroops[$utype.$maxtype]--; $starvingTroops[$utype.$maxtype]--;
$killedUnits[$maxtype] = ($killedUnits[$maxtype] ?? 0) + 1; $killedUnits[$maxtype] = ($killedUnits[$maxtype] ?? 0) + 1;
// Formula originala de consum crop per unitate // Original per-unit crop consumption formula unchanged.
$unitIndex = $special ? $maxtype + ($tribe - 1) * 10 : $maxtype; $unitIndex = $special ? $maxtype + ($tribe - 1) * 10 : $maxtype;
$difcrop -= $GLOBALS['u'.$unitIndex]['crop']; $difcrop -= $GLOBALS['u'.$unitIndex]['crop'];
} else break; } else break;
@@ -4713,7 +4690,7 @@ WHERE
$totalKilledUnits = array_sum($killedUnits); $totalKilledUnits = array_sum($killedUnits);
$newCrop = 0; $newCrop = 0;
// Verifica daca eroul moare // Determine whether the hero dies.
if($starvingTroops[$heroType] > 0 && ($totalUnits == 0 || $totalUnits == $totalKilledUnits)){ if($starvingTroops[$heroType] > 0 && ($totalUnits == 0 || $totalUnits == $totalKilledUnits)){
$totalKilledUnits += $starvingTroops[$heroType]; $totalKilledUnits += $starvingTroops[$heroType];
$totalUnits += $starvingTroops[$heroType]; $totalUnits += $starvingTroops[$heroType];
@@ -4732,8 +4709,9 @@ WHERE
} }
/** /**
* Aplica modificarile in baza de date * Apply starvation changes to the database.
*/ **/
private function starvationApplyDatabaseChanges($starv, $starvingTroops, $type, $killedUnits, $totalUnits, $totalKilledUnits, $newCrop, $upkeep, $time) { private function starvationApplyDatabaseChanges($starv, $starvingTroops, $type, $killedUnits, $totalUnits, $totalKilledUnits, $newCrop, $upkeep, $time) {
global $database; global $database;
@@ -4754,10 +4732,10 @@ WHERE
$database->modifyUnit($starvingTroops['wref'], ["99o"], [$totalUnits], [0]); $database->modifyUnit($starvingTroops['wref'], ["99o"], [$totalUnits], [0]);
} }
break; break;
case 2: // unitati proprii case 2: // own units
$database->modifyUnit($starv['wref'], array_keys($killedUnits), array_values($killedUnits), [0]); $database->modifyUnit($starv['wref'], array_keys($killedUnits), array_values($killedUnits), [0]);
break; break;
case 3: // atacuri in miscare case 3: // moving attacks.
if($totalKilledUnits < $totalUnits){ if($totalKilledUnits < $totalUnits){
$database->modifyAttack2($starvingTroops['id'], array_keys($killedUnits), array_values($killedUnits), 0); $database->modifyAttack2($starvingTroops['id'], array_keys($killedUnits), array_values($killedUnits), 0);
} else { } else {
@@ -4771,8 +4749,9 @@ WHERE
} }
/** /**
* Verifica daca starvation poate fi resetat * Verify whether starvation reset is allowed.
*/ **/
private function starvationCheckReset($starv, $upkeep) { private function starvationCheckReset($starv, $upkeep) {
global $database; global $database;
$crop = $database->getCropProdstarv($starv['wref'], false); $crop = $database->getCropProdstarv($starv['wref'], false);
+1 -1
View File
@@ -54,7 +54,7 @@ AccessLogger::logRequest();
<td><a href="anleitung.php"><span>Manual</span></a></td> <td><a href="anleitung.php"><span>Manual</span></a></td>
<td><a href="http://forum.travian.com/" target="_blank"><span>Forum</span></a></td> <td><a href="https://github.com/Shadowss/TravianZ/discussions" target="_blank"><span>Forum</span></a></td>
+1 -1
View File
@@ -107,7 +107,7 @@ AccessLogger::logRequest();
<tr> <tr>
<td><a href="tutorial.php"><span>Tutorial</span></a></td> <td><a href="tutorial.php"><span>Tutorial</span></a></td>
<td><a href="anleitung.php"><span>Manual</span></a></td> <td><a href="anleitung.php"><span>Manual</span></a></td>
<td><a href="forum.php" target="_blank"><span>Forum</span></a></td> <td><a href="https://github.com/Shadowss/TravianZ/discussions" target="_blank"><span>Forum</span></a></td>
<td><a href="index.php?signup"><span>Register</span></a></td> <td><a href="index.php?signup"><span>Register</span></a></td>
<td><a href="index.php?login"><span>Login</span></a></td> <td><a href="index.php?login"><span>Login</span></a></td>
</tr> </tr>
+3 -3
View File
@@ -12,9 +12,10 @@ use App\Utils\AccessLogger;
## Filename: index.php ## ## Filename: index.php ##
## Developed by: Dzoki & Advocaite & Donnchadh ## ## Developed by: Dzoki & Advocaite & Donnchadh ##
## Reworked by: ZZJHONS ## ## Reworked by: ZZJHONS ##
## Refactored by: Shadow ##
## License: TravianZ Project ## ## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2018. All rights reserved. ## ## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
## URLs: http://travian.shadowss.ro ## ## URLs: http://travianz.org ##
## Source code: https://github.com/Shadowss/TravianZ ## ## Source code: https://github.com/Shadowss/TravianZ ##
## ## ## ##
################################################################################# #################################################################################
@@ -201,7 +202,6 @@ AccessLogger::logRequest();
</div> </div>
<div id="footer"> <div id="footer">
<div class="container"> <div class="container">
<a rel="license" href="https://creativecommons.org/licenses/by-nc-sa/3.0/" class="logo"><img alt="Licencia Creative Commons" style="border-width:0; height:31px; width:88px;" src="https://i.creativecommons.org/l/by-nc-sa/3.0/88x31.png" class="logo_traviangames" /></a>
<ul class="menu"> <ul class="menu">
<li><a href="anleitung.php?s=3"><?php echo FAQ; ?></a>|</li> <li><a href="anleitung.php?s=3"><?php echo FAQ; ?></a>|</li>
<li><a href="index.php?screenshots"><?php echo SCREENSHOTS; ?></a>|</li> <li><a href="index.php?screenshots"><?php echo SCREENSHOTS; ?></a>|</li>
+1 -1
View File
@@ -3,7 +3,7 @@
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ## ## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
## --------------------------------------------------------------------------- ## ## --------------------------------------------------------------------------- ##
## Filename config.php ## ## Filename config.php ##
## Version 8.0 ## ## Version 10.0 Full Refactor & Security ##
## Developed by: Dzoki and Dixie Edited by Advocaite ## ## Developed by: Dzoki and Dixie Edited by Advocaite ##
## License: TravianZ Project ## ## License: TravianZ Project ##
## Copyright: TravianZ (c) 2013-2026. All rights reserved. ## ## Copyright: TravianZ (c) 2013-2026. All rights reserved. ##
+1 -1
View File
@@ -55,7 +55,7 @@ AccessLogger::logRequest();
<td><a href="anleitung.php"><span>Manual</span></a></td> <td><a href="anleitung.php"><span>Manual</span></a></td>
<td><a href="http://forum.travian.com/" target="_blank"><span>Forum</span></a></td> <td><a href="https://github.com/Shadowss/TravianZ/discussions" target="_blank"><span>Forum</span></a></td>
+1 -1
View File
@@ -91,7 +91,7 @@ AccessLogger::logRequest();
<tr> <tr>
<td><a href="tutorial.php"><span>Tutorial</span></a></td> <td><a href="tutorial.php"><span>Tutorial</span></a></td>
<td><a href="anleitung.php"><span>Manual</span></a></td> <td><a href="anleitung.php"><span>Manual</span></a></td>
<td><a href="forum.php" target="_blank"><span>Forum</span></a></td> <td><a href="https://github.com/Shadowss/TravianZ/discussions" target="_blank"><span>Forum</span></a></td>
<td><a href="index.php?signup"><span>Register</span></a></td> <td><a href="index.php?signup"><span>Register</span></a></td>
<td><a href="index.php?login"><span>Login</span></a></td> <td><a href="index.php?login"><span>Login</span></a></td>
</tr> </tr>