mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-07-15 09:06:08 +00:00
division by zero error fix
This commit is contained in:
@@ -1229,12 +1229,12 @@ ${dead.$i}=$data['t'.$i];
|
||||
$tblevel = $bdo['f'.$rand];
|
||||
$tbgid = $bdo['f'.$rand.'t'];
|
||||
$tbid = $rand;
|
||||
if($bid34[$stonemason] != 0){
|
||||
if($bid34[$stonemason] == 0){
|
||||
$needed_cata = round((($battlepart[5] * (pow($tblevel,2) + $tblevel + 1)) / (8 * (round(200 * pow(1.0205,$battlepart[6]))/200))) + 0.5);
|
||||
}else{
|
||||
$needed_cata = round((($battlepart[5] * (pow($tblevel,2) + $tblevel + 1)) / (8 * (round(200 * pow(1.0205,$battlepart[6]))/200) / (1 * $bid34[$stonemason]['attri']/100))) + 0.5);
|
||||
}
|
||||
if ($battlepart[4]>$needed_cata)
|
||||
if ($battlepart[4]>$needed_cata and $rand!=0)
|
||||
{
|
||||
$info_cat = "".$catp_pic.", ".$this->procResType($tbgid)." destroyed.";
|
||||
$database->setVillageLevel($data['to'],"f".$tbid."",'0');
|
||||
@@ -1382,12 +1382,12 @@ ${dead.$i}=$data['t'.$i];
|
||||
$tblevel = $bdo['f'.$rand];
|
||||
$tbgid = $bdo['f'.$rand.'t'];
|
||||
$tbid = $rand;
|
||||
if($bid34[$stonemason] != 0){
|
||||
if($bid34[$stonemason] == 0){
|
||||
$needed_cata = round((($battlepart[5] * (pow($tblevel,2) + $tblevel + 1)) / (8 * (round(200 * pow(1.0205,$battlepart[6]))/200))) + 0.5);
|
||||
}else{
|
||||
$needed_cata = round((($battlepart[5] * (pow($tblevel,2) + $tblevel + 1)) / (8 * (round(200 * pow(1.0205,$battlepart[6]))/200) / (1 * $bid34[$stonemason]['attri']/100))) + 0.5);
|
||||
}
|
||||
if (($battlepart[4]/2)>$needed_cata)
|
||||
if (($battlepart[4]/2)>$needed_cata and $rand!=0)
|
||||
{
|
||||
$info_cat = "".$catp_pic.", ".$this->procResType($tbgid)." destroyed.";
|
||||
$database->setVillageLevel($data['to'],"f".$tbid."",'0');
|
||||
@@ -1532,12 +1532,12 @@ ${dead.$i}=$data['t'.$i];
|
||||
$tblevel = $bdo['f'.$rand];
|
||||
$tbgid = $bdo['f'.$rand.'t'];
|
||||
$tbid = $rand;
|
||||
if($bid34[$stonemason] != 0){
|
||||
if($bid34[$stonemason] == 0){
|
||||
$needed_cata = round((($battlepart[5] * (pow($tblevel,2) + $tblevel + 1)) / (8 * (round(200 * pow(1.0205,$battlepart[6]))/200))) + 0.5);
|
||||
}else{
|
||||
$needed_cata = round((($battlepart[5] * (pow($tblevel,2) + $tblevel + 1)) / (8 * (round(200 * pow(1.0205,$battlepart[6]))/200) / (1 * $bid34[$stonemason]['attri']/100))) + 0.5);
|
||||
}
|
||||
if (($battlepart[4]/2)>$needed_cata)
|
||||
if (($battlepart[4]/2)>$needed_cata and $rand!=0)
|
||||
{
|
||||
$info_cat .= "<br><tbody class=\"goods\"><tr><th>Information</th><td colspan=\"11\">
|
||||
<img class=\"unit u".$catp_pic."\" src=\"img/x.gif\" alt=\"Catapult\" title=\"Catapult\" /> ".$this->procResType($tbgid)." destroyed.</td></tr></tbody>";
|
||||
|
||||
@@ -372,8 +372,12 @@ class Battle {
|
||||
$moralbonus = min(1.5, pow($attpop / $defpop, (0.2*($rap/$rdp))));
|
||||
}
|
||||
else {
|
||||
if($defpop==0){
|
||||
$moralbonus = min(1.5, pow($attpop, 0.2));
|
||||
}else{
|
||||
$moralbonus = min(1.5, pow($attpop / $defpop, 0.2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$moralbonus = 1.0;
|
||||
|
||||
Reference in New Issue
Block a user