From 757b41143d0a2f3df459300febd2efa807bc8fdd Mon Sep 17 00:00:00 2001 From: Pietro Date: Tue, 3 Apr 2018 15:39:48 +0200 Subject: [PATCH] Fixed some building bugs Fixed an error that could have shown if you had tried to build a not buildable building. Buildings can no longer be built if in demolition. Buildings can no longer be built above the max level (the previous fix was still hackable, through the waiting loop). --- GameEngine/Building.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/GameEngine/Building.php b/GameEngine/Building.php index 37c7204f..81254cd5 100755 --- a/GameEngine/Building.php +++ b/GameEngine/Building.php @@ -494,6 +494,13 @@ class Building { $uprequire = $this->resourceRequired($id,$village->resarray['f'.$id.'t']); $time = time() + $uprequire['time']; $bindicate = $this->canBuild($id,$village->resarray['f'.$id.'t']); + + // don't allow building above max levels and don't allow building if it's in demolition + if ($bindicate == 1 || $bindicate == 10 || $bindicate == 11) { + header("Location: dorf2.php"); + exit; + } + $loop = ($bindicate == 9 ? 1 : 0); $loopsame = 0; if($loop == 1) { @@ -525,11 +532,6 @@ class Building { } $level = $database->getResourceLevel($village->wid); - // don't allow building above max levels - if ($level['f'.$id] + 1 > count(${'bid'.$village->resarray['f'.$id.'t']})) { - return; - } - if($session->access!=BANNED){ if($database->addBuilding($village->wid,$id,$village->resarray['f'.$id.'t'],$loop,$time+($loop==1?ceil(60/SPEED):0),0,$level['f'.$id] + 1 + count($database->getBuildingByField($village->wid,$id)))) { $database->modifyResource($village->wid,$uprequire['wood'],$uprequire['clay'],$uprequire['iron'],$uprequire['crop'],0); @@ -607,7 +609,7 @@ class Building { } $uprequire = $this->resourceRequired( $id, $tid ); $time = time() + $uprequire['time']; - $bindicate = $this->canBuild( $id, $village->resarray[ 'f' . $id . 't' ] ); + $bindicate = $this->canBuild( $id, $tid ); $loop = ( $bindicate == 9 ? 1 : 0 ); if ( $loop == 1 ) { foreach ( $this->buildArray as $build ) { @@ -629,6 +631,9 @@ class Building { header( "Location: banned.php" ); exit; } + } else { + header("location: dorf2.php"); + exit; } } else { header( "Location: dorf2.php" );