mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-20 10:11:00 +00:00
Fixed two population bugs
Automation.php: Fixed the attacker population and defender population before a battle, now the account population will be considered instead of the single village population. Fixed the attacker population and defender population while chiefing a village, now the account population will be considered instead of the single village population. Database: Added a function to get the total population of the account.
This commit is contained in:
@@ -1434,8 +1434,8 @@ class Automation {
|
|||||||
$att_tribe = $owntribe;
|
$att_tribe = $owntribe;
|
||||||
$def_tribe = $targettribe;
|
$def_tribe = $targettribe;
|
||||||
$residence = "0";
|
$residence = "0";
|
||||||
$attpop = $fromF['pop'];
|
$attpop = 0;
|
||||||
$defpop = $toF['pop'];
|
$defpop = 0;
|
||||||
$def_ab=array();
|
$def_ab=array();
|
||||||
//get level of palace or residence
|
//get level of palace or residence
|
||||||
$residence = $database->getFieldLevelInVillage($data['to'], '25, 26', false);
|
$residence = $database->getFieldLevelInVillage($data['to'], '25, 26', false);
|
||||||
@@ -1574,7 +1574,7 @@ class Automation {
|
|||||||
$att_tribe = $owntribe;
|
$att_tribe = $owntribe;
|
||||||
$def_tribe = $targettribe;
|
$def_tribe = $targettribe;
|
||||||
$residence = 0;
|
$residence = 0;
|
||||||
$attpop = $fromF['pop'];
|
$attpop = 0;
|
||||||
$defpop = 100;
|
$defpop = 100;
|
||||||
|
|
||||||
//type of attack
|
//type of attack
|
||||||
@@ -1607,6 +1607,18 @@ class Automation {
|
|||||||
} else {
|
} else {
|
||||||
$varray1 = $database->getProfileVillages($from['owner'], 0, false);
|
$varray1 = $database->getProfileVillages($from['owner'], 0, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// total population of the defender
|
||||||
|
if($isoasis == 0){
|
||||||
|
foreach($varray as $defenderVillage){
|
||||||
|
$defpop += $defenderVillage['pop'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// total population of the attacker
|
||||||
|
foreach($varray1 as $attackerVillage){
|
||||||
|
$attpop += $attackerVillage['pop'];
|
||||||
|
}
|
||||||
|
|
||||||
//fix by ronix
|
//fix by ronix
|
||||||
for ($i=1;$i<=50;$i++) {
|
for ($i=1;$i<=50;$i++) {
|
||||||
@@ -2603,8 +2615,8 @@ class Automation {
|
|||||||
$newLevels_fieldNames = [];
|
$newLevels_fieldNames = [];
|
||||||
$newLevels_fieldValues = [];
|
$newLevels_fieldValues = [];
|
||||||
|
|
||||||
$pop1 = $database->getVillageField($data['from'],"pop");
|
$pop1 = $database->getTotalPopulation($AttackerID);
|
||||||
$pop2 = $database->getVillageField($data['to'],"pop");
|
$pop2 = $database->getTotalPopulation($DefenderID);
|
||||||
if($pop1 > $pop2){
|
if($pop1 > $pop2){
|
||||||
$buildlevel = $database->getResourceLevel($data['to']);
|
$buildlevel = $database->getResourceLevel($data['to']);
|
||||||
|
|
||||||
|
|||||||
@@ -1870,6 +1870,22 @@ class MYSQLi_DB implements IDbConnection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to get the population of the whole account
|
||||||
|
*
|
||||||
|
* @param int $uid the user id
|
||||||
|
* @return int Returns the total population of the account
|
||||||
|
*/
|
||||||
|
|
||||||
|
function getTotalPopulation($uid){
|
||||||
|
list($uid) = $this->escape_input((int) $uid);
|
||||||
|
|
||||||
|
$q = "SELECT Sum(pop) FROM " . TB_PREFIX . "vdata WHERE owner = ".$uid."";
|
||||||
|
$result = mysqli_query($this->dblink, $q);
|
||||||
|
$row = mysqli_fetch_row($result);
|
||||||
|
return $row[0];
|
||||||
|
}
|
||||||
|
|
||||||
function getVillageByWorldID($vid, $use_cache = true) {
|
function getVillageByWorldID($vid, $use_cache = true) {
|
||||||
$array_passed = is_array($vid);
|
$array_passed = is_array($vid);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user