General fixes

+Fixed a bug that didn't permit to attack with catapults with the new
automation system
+Fixed a warning that could have been displayed in certain cases
This commit is contained in:
iopietro
2018-05-23 17:36:16 +02:00
parent e70d0ff619
commit fca22ac98b
4 changed files with 45 additions and 23 deletions
+1
View File
@@ -26,6 +26,7 @@ include_once("Technology.php");
include_once("Ranking.php");
include_once("Generator.php");
include_once("Multisort.php");
include_once("Building.php");
$autoprefix = '';
for ($i = 0; $i < 5; $i++) {
+6 -15
View File
@@ -479,8 +479,8 @@ class Building {
}
}
private function constructBuilding($id,$tid) {
global $database,$village,$session,$logging;
private function constructBuilding($id, $tid) {
global $database, $village, $session, $logging;
if($session->access == BANNED) {
header("Location: banned.php");
@@ -890,7 +890,7 @@ class Building {
public function resourceRequired($id, $tid, $plus = 1) {
$name = "bid".$tid;
global $$name, $village, $bid15;
global $$name, $village, $bid15, $database;
$dataarray = $$name;
$wood = $dataarray[$village->resarray['f'.$id] + $plus]['wood'];
@@ -898,19 +898,10 @@ class Building {
$iron = $dataarray[$village->resarray['f'.$id] + $plus]['iron'];
$crop = $dataarray[$village->resarray['f'.$id] + $plus]['crop'];
$pop = $dataarray[$village->resarray['f'.$id] + $plus]['pop'];
if($tid == 15){
if($this->getTypeLevel(15) == 0) $time = round($dataarray[$village->resarray['f'.$id] + $plus]['time'] / SPEED * 5);
else $time = round($dataarray[$village->resarray['f'.$id] + $plus]['time'] / SPEED);
}else{
if($this->getTypeLevel(15) > 0) {
$time = round($dataarray[$village->resarray['f'.$id] + $plus]['time'] * ($bid15[$this->getTypeLevel(15)]['attri'] /100) / SPEED);
}
else $time = round($dataarray[$village->resarray['f'.$id] + $plus]['time'] * 5 / SPEED);
}
$time = $database->getBuildingTime($id, $tid, $plus, $village->wid, $village->resarray);
$cp = $dataarray[$village->resarray['f'.$id] + $plus]['cp'];
return ["wood" => $wood, "clay" => $clay, "iron" => $iron, "crop" => $crop, "pop" => $pop, "time" => $time,"cp" => $cp];
return ["wood" => $wood, "clay" => $clay, "iron" => $iron, "crop" => $crop, "pop" => $pop, "time" => $time, "cp" => $cp];
}
public function getTypeField($type) {
+35 -3
View File
@@ -4476,6 +4476,36 @@ References: User ID/Message ID, Mode
return mysqli_query($this->dblink,$q);
}
/**
* Get the time required to build a specified building
*
* @param int $id The ID where the building is located
* @param int $tid The type of the building
* @param int $plus The construction queue count
* @param int $wref The village ID
* @param array $buildingArray The array containing the buildings in the village
* @return int Returns the building time
*/
function getBuildingTime($id, $tid, $plus, $wref, $buildingArray) {
list($id, $tid, $plus, $wref, $buildingArray) = $this->escape_input((int) $id, (int) $tid, (int) $plus, (int) $wref, $buildingArray);
global ${'bid'.$tid}, $bid15;
$dataArray = ${'bid'.$tid};
//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);
}else{
if($mainBuilding > 0) {
return round($dataArray[$buildingArray['f'.$id] + $plus]['time'] * ($bid15[$mainBuilding]['attri'] / 100) / SPEED);
}
else return round($dataArray[$buildingArray['f'.$id] + $plus]['time'] * 5 / SPEED);
}
}
/**
* Called when removing a queued building by a player or because destroyed by catapults
*
@@ -4488,7 +4518,6 @@ References: User ID/Message ID, Mode
function removeBuilding($d, $tribe, $wid, $fieldsArray = []) {
list($d, $tribe, $wid, $fieldsArray) = $this->escape_input((int) $d, (int) $tribe, (int) $wid, $fieldsArray);
global $building;
//Variables initialization
$jobToDelete = [];
@@ -4510,9 +4539,12 @@ References: User ID/Message ID, Mode
if($sameBuilding && $canBeRemoved) $canBeRemoved = !$sameBuilding;
//Get the time required to upgrade the building at the given level
$newTime = $building->resourceRequired($job['field'],
$newTime = $this->getBuildingTime(
$job['field'],
$job['type'],
$job['level'] - $fieldsArray['f'.$job['field']] - $sameBuilding)['time'];
$job['level'] - $fieldsArray['f'.$job['field']] - $sameBuilding,
$wid,
$fieldsArray);
//Increase the looptime
$loopTime += $newTime;
+3 -5
View File
@@ -502,17 +502,15 @@ class Message {
$user = $database->getUserField($recieve, "id", 1);
// Vulnerability closed by Shadow
if ($security_check) {
$q = "SELECT Count(*) as Total FROM ".TB_PREFIX."mdata WHERE owner='".$session->uid."' AND time > ".(time() - 60);
$res = mysqli_fetch_array(mysqli_query($database->dblink,$q) or die(mysqli_error($database->dblink). " query ".$q), MYSQLI_ASSOC);
$res = mysqli_fetch_array(mysqli_query($database->dblink,$q), MYSQLI_ASSOC);
$flood = $res['Total'];
if($flood > 5)
return; //flood
if($flood > 5) return; //flood
}
// Vulnerability closed by Shadow
if(WORD_CENSOR) {
$topic = $this->wordCensor($topic);
$text = $this->wordCensor($text);