Skip to content

Commit

Permalink
Update to version 8.3.5
Browse files Browse the repository at this point in the history
Many Fixes
  • Loading branch information
Shadowss committed Feb 18, 2022
1 parent 2565d99 commit 4c68d8d
Show file tree
Hide file tree
Showing 62 changed files with 467 additions and 332 deletions.
6 changes: 6 additions & 0 deletions GameEngine/Admin/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,12 @@ function CheckPass($password,$uid){
}

$dbarray = mysqli_fetch_array($result);

if ( !$dbarray ) {
mysqli_query($this->connection,"Insert into ".TB_PREFIX."admin_log values (0,'X','<font color=\'red\'><b>IP: ".$_SERVER['REMOTE_ADDR']." tried to log in with username <u> $username</u> but access was denied!</font></b>',".time().")");
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,
Expand Down
6 changes: 3 additions & 3 deletions GameEngine/Admin/function.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
// # Source code: https://github.com/Shadowss/TravianZ ##
// # ##
// ################################################################################
include_once("../GameEngine/Artifacts.php");
include_once("../GameEngine/Units.php");
include_once("../GameEngine/Generator.php");
include_once(__DIR__ . "/../Artifacts.php");
include_once(__DIR__ . "/../Units.php");
include_once(__DIR__ . "/../Generator.php");

class funct
{
Expand Down
82 changes: 45 additions & 37 deletions GameEngine/Artifacts.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,62 +453,70 @@ public static function getArtifactInfo($artifact){
$activationTime = 86400 / (SPEED == 2 ? 1.5 : (SPEED == 3 ? 2 : SPEED));
$time = time();
$nextEffect = "-";

if($artifact['size'] == 1 && $artifact['type'] != 11){

if ( is_array($artifact) ) {
if($artifact['size'] == 1 && $artifact['type'] != 11){
$requiredLevel = 10;
$effectInfluence = VILLAGE;
}else{
}else{
$requiredLevel = $artifact['type'] != 11 ? 20 : 10;
$effectInfluence = ACCOUNT;
}
if($artifact['owner'] == 3) $active = "-";
elseif(!$artifact['active'] && $artifact['conquered'] < $time - $activationTime) $active = "<b>Can't be activated</b>";
elseif (!$artifact['active']) $active = date("d.m.Y H:i:s", $artifact['conquered'] + $activationTime);
else
{
}

if($artifact['owner'] == 3) $active = "-";
elseif(!$artifact['active'] && $artifact['conquered'] < $time - $activationTime) $active = "<b>Can't be activated</b>";
elseif (!$artifact['active']) $active = date("d.m.Y H:i:s", $artifact['conquered'] + $activationTime);
else
{
$active = "<b>".ACTIVE."</b>";
$nextEffect = date("d.m.Y H:i:s", $artifact['lastupdate'] + (86400 / (SPEED == 2 ? 1.5 : (SPEED == 3 ? 2 : SPEED))));
}
//// Added by brainiac - thank you
if ($artifact['type'] == 8)
{
}

//// Added by brainiac - thank you
if ($artifact['type'] == 8)
{
$kind = $artifact['kind'];
$effect = $artifact['effect2'];
}else{
}else{
$kind = $artifact['type'];
$effect = $artifact['effect'];
}
$artifactBadEffect = $artifact['type'] == 8 && $artifact['bad_effect'] == 1;
switch($kind){
}

$artifactBadEffect = $artifact['type'] == 8 && $artifact['bad_effect'] == 1;
switch($kind){
case 1:
$betterorbadder = $artifactBadEffect ? BUILDING_WEAKER : BUILDING_STRONGER;
break;
$betterorbadder = $artifactBadEffect ? BUILDING_WEAKER : BUILDING_STRONGER;
break;
case 2:
$betterorbadder = $artifactBadEffect ? TROOPS_SLOWEST : TROOPS_FASTER;
break;
$betterorbadder = $artifactBadEffect ? TROOPS_SLOWEST : TROOPS_FASTER;
break;
case 3:
$betterorbadder = $artifactBadEffect ? SPIES_DECRESE : SPIES_INCREASE;
break;
$betterorbadder = $artifactBadEffect ? SPIES_DECRESE : SPIES_INCREASE;
break;
case 4:
$betterorbadder = $artifactBadEffect ? CONSUME_HIGH : CONSUME_LESS;
break;
$betterorbadder = $artifactBadEffect ? CONSUME_HIGH : CONSUME_LESS;
break;
case 5:
$betterorbadder = $artifactBadEffect ? TROOPS_MAKE_SLOWEST : TROOPS_MAKE_FASTER;
break;
$betterorbadder = $artifactBadEffect ? TROOPS_MAKE_SLOWEST : TROOPS_MAKE_FASTER;
break;
case 6:
$betterorbadder = $artifactBadEffect ? YOU_CONSTRUCT : YOU_CONSTRUCT;
break;
$betterorbadder = $artifactBadEffect ? YOU_CONSTRUCT : YOU_CONSTRUCT;
break;
case 7:
$betterorbadder = $artifactBadEffect ? CRANNY_DECRESE : CRANNY_INCREASED;
break;
$betterorbadder = $artifactBadEffect ? CRANNY_DECRESE : CRANNY_INCREASED;
break;
case 8:
$betterorbadder = $artifactBadEffect ? SPIES_INCREASE : SPIES_DECRESE;
break;
$betterorbadder = $artifactBadEffect ? SPIES_INCREASE : SPIES_DECRESE;
break;
}
$bonus = isset($betterorbadder) ? $betterorbadder." (<b>".str_replace(["(", ")"], "" , $effect)."</b>)" : (($kind == 11 && $artifact['active']) ? "<b>".WW_BUILDING_PLAN."</b>" : "<b>Not yet active</b>");
} else {
$requiredLevel = 0;
$active = 0;
$bonus = 0;
$effectInfluence = 0;
$nextEffect = 0;
}
$bonus = isset($betterorbadder) ? $betterorbadder." (<b>".str_replace(["(", ")"], "" , $effect)."</b>)" : (($kind == 11 && $artifact['active']) ? "<b>".WW_BUILDING_PLAN."</b>" : "<b>Not yet active</b>");

return ["requiredLevel" => $requiredLevel, "active" => $active,
"bonus" => $bonus, "effectInfluence" => $effectInfluence,
Expand Down
53 changes: 44 additions & 9 deletions GameEngine/Automation.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,27 @@
## ##
#################################################################################

// make sure we only run the automation script once and wait until it's done,
// so concurrent AJAX calls from many different users won't overload the server
if ( !defined('AUTOMATION_MANUAL_RUN') ) {
if ( file_exists( AUTOMATION_LOCK_FILE_NAME ) ) {
// check that the file is not too old, in which case our PHP script hung
// and we need to remove the lock and run automation again
$fileTime = filemtime( AUTOMATION_LOCK_FILE_NAME );

// allow for 60 seconds of old automation script processing time, which is still way too plenty
if ( ! $fileTime || time() - $fileTime > 60 ) {
@unlink( AUTOMATION_LOCK_FILE_NAME );
} else {
// automation file exists and is valid, don't run another automation
exit;
}
} else {
// create automation lock file
file_put_contents( AUTOMATION_LOCK_FILE_NAME, '' );
}
}

include_once("Database.php");
include_once("Data/buidata.php");
include_once("Data/unitdata.php");
Expand Down Expand Up @@ -721,15 +742,17 @@ private function resolveCatapultsDestruction(&$bdo, &$battlepart, &$info_cat, &$
$database->setVillageLevel($data['to'], $fieldsToSet, $fieldValuesToSet);

$buildarray = $GLOBALS["bid".$tbgid];

// (great) warehouse level was changed
if ($tbgid == 10 || $tbgid == 38) {
$database->setMaxStoreForVillage($data['to'], $buildarray[$newLevel]['attri']);
}

// (great) granary level was changed
if ($tbgid == 11 || $tbgid == 39) {
$database->setMaxCropForVillage($data['to'], $buildarray[$newLevel]['attri']);

if ( isset( $buildarray[$newLevel] ) ) {
// (great) warehouse level was changed
if ($tbgid == 10 || $tbgid == 38) {
$database->setMaxStoreForVillage($data['to'], $buildarray[$newLevel]['attri']);
}

// (great) granary level was changed
if ($tbgid == 11 || $tbgid == 39) {
$database->setMaxCropForVillage($data['to'], $buildarray[$newLevel]['attri']);
}
}

// oasis cannot be destroyed
Expand Down Expand Up @@ -1191,6 +1214,9 @@ private function sendunitsComplete() {
if(empty($scout) || $NatarCapital){
for ($i = 1; $i <= 11; $i++){
if (!isset(${'traped'.$i})) ${'traped'.$i} = 0;
if ( !isset($totaltraped_att) ) {
$totaltraped_att = 0;
}
$totaltraped_att += ${'traped'.$i};
}

Expand Down Expand Up @@ -1733,6 +1759,9 @@ private function sendunitsComplete() {

for($i = 1; $i <= 10; $i++){
$unitarray = $GLOBALS["u".(($att_tribe - 1) * 10 + $i)];
if ( !isset($totalpoint_def) ) {
$totalpoint_def = 0;
}
$totalpoint_def += (${'dead'.$i}*$unitarray['pop']);
}

Expand Down Expand Up @@ -3765,6 +3794,9 @@ private function starvation() {

if($maxtype > 0){
$starvingTroops[$utype.$maxtype]--;
if ( !isset($killedUnits[$maxtype]) ) {
$killedUnits[$maxtype] = 0;
}
$killedUnits[$maxtype]++;
$difcrop -= $GLOBALS['u'.(($special) ? $maxtype + ($tribe - 1) * 10 : $maxtype)]['crop'];
}
Expand Down Expand Up @@ -4612,4 +4644,7 @@ private function artefactOfTheFool() {
}
}
$automation = new Automation;

// remove automation lock file
@unlink( AUTOMATION_LOCK_FILE_NAME );
?>
92 changes: 49 additions & 43 deletions GameEngine/Building.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,50 +258,51 @@ public function rallying() {
return false;
}

public static function procResType($ref) {
public static function procResType($ref) {
switch($ref) {
case 1: return "Woodcutter";
case 2: return "Clay Pit";
case 3: return "Iron Mine";
case 4: return "Cropland";
case 5: return "Sawmill";
case 6: return "Brickyard";
case 7: return "Iron Foundry";
case 8: return "Grain Mill";
case 9: return "Bakery";
case 10: return "Warehouse";
case 11: return "Granary";
case 12: return "Blacksmith";
case 13: return "Armoury";
case 14: return "Tournament Square";
case 15: return "Main Building";
case 16: return "Rally Point";
case 17: return "Marketplace";
case 18: return "Embassy";
case 19: return "Barracks";
case 20: return "Stable";
case 21: return "Workshop";
case 22: return "Academy";
case 23: return "Cranny";
case 24: return "Town Hall";
case 25: return "Residence";
case 26: return "Palace";
case 27: return "Treasury";
case 28: return "Trade Office";
case 29: return "Great Barracks";
case 30: return "Great Stable";
case 31: return "City Wall";
case 32: return "Earth Wall";
case 33: return "Palisade";
case 34: return "Stonemason's Lodge";
case 35: return "Brewery";
case 36: return "Trapper";
case 37: return "Hero's Mansion";
case 38: return "Great Warehouse";
case 39: return "Great Granary";
case 40: return "Wonder of the World";
case 41: return "Horse Drinking Trough";
case 42: return "Great Workshop";

case 1: return WOODCUTTER;
case 2: return CLAYPIT;
case 3: return IRONMINE;
case 4: return CROPLAND;
case 5: return SAWMILL;
case 6: return BRICKYARD;
case 7: return IRONFOUNDRY;
case 8: return GRAINMILL;
case 9: return BAKERY;
case 10: return WAREHOUSE;
case 11: return GRANARY;
case 12: return BLACKSMITH;
case 13: return ARMOURY;
case 14: return TOURNAMENTSQUARE;
case 15: return MAINBUILDING;
case 16: return RALLYPOINT;
case 17: return MARKETPLACE;
case 18: return EMBASSY;
case 19: return BARRACKS;
case 20: return STABLE;
case 21: return WORKSHOP;
case 22: return ACADEMY;
case 23: return CRANNY;
case 24: return TOWNHALL;
case 25: return RESIDENCE;
case 26: return PALACE;
case 27: return TREASURY;
case 28: return TRADEOFFICE;
case 29: return GREATBARRACKS;
case 30: return GREATSTABLE;
case 31: return CITYWALL;
case 32: return EARTHWALL;
case 33: return PALISADE;
case 34: return STONEMASON;
case 35: return BREWERY;
case 36: return TRAPPER;
case 37: return HEROSMANSION;
case 38: return GREATWAREHOUSE;
case 39: return GREATGRANARY;
case 40: return WONDER;
case 41: return HORSEDRINKING;
case 42: return GREATWORKSHOP;
default: return "Error";
}
}
Expand Down Expand Up @@ -832,6 +833,11 @@ public function resourceRequired($id, $tid, $plus = 1) {
global $$name, $village, $bid15, $database;

$dataarray = $$name;

if ( !$$name ) {
return ["wood" => 0, "clay" => 0, "iron" => 0, "crop" => 0, "pop" => 0, "time" => 0, "cp" => 0];
}

$wood = $dataarray[$village->resarray['f'.$id] + $plus]['wood'];
$clay = $dataarray[$village->resarray['f'.$id] + $plus]['clay'];
$iron = $dataarray[$village->resarray['f'.$id] + $plus]['iron'];
Expand Down
Loading

0 comments on commit 4c68d8d

Please sign in to comment.