Fixed issue #432

+Added an error which warns you if you enter an invalid attack type (a
number greater tha 4 or less than 2)
+Fixed the possibility to spy with attacking troops by hacking the
attack type
+Some clean-up
This commit is contained in:
iopietro
2018-04-16 15:59:05 +02:00
parent bd38ac7fd8
commit e6449d20c6
3 changed files with 28 additions and 24 deletions
+16 -9
View File
@@ -89,7 +89,7 @@ class Units {
$vid = $database->getVillageByName(stripslashes($post['dname']));
}
if (!empty($vid)) {
if($database->isVillageOases($vid) != 0){
if($database->isVillageOases($vid)){
$too = $database->getOasisField($vid,"conqured");
if($too == 0){
$disabledr ="disabled=disabled"; $disabled ="disabled=disabled";
@@ -122,12 +122,16 @@ class Units {
$disabled ="disabled=disabled";
}
}
if($disabledr != "" && $post['c'] == 2){
$form->addError("error","You can't reinforce this village/oasis");
if(!empty($disabledr) && $post['c'] == 2){
$form->addError("error","You can't reinforce this village/oasis");
}
if($disabled != "" && $post['c'] == 3){
$form->addError("error","You can't attack this village/oasis with normal attack");
if(!empty($disabled) && $post['c'] == 3){
$form->addError("error","You can't attack this village/oasis with normal attack");
}
if($post['c'] < 2 || $post['c'] > 4) $form->addError("error", "Invalid attack type.");
if(empty($post['t1']) && empty($post['t2']) && empty($post['t3']) && empty($post['t4']) && empty($post['t5']) &&
empty($post['t6']) && empty($post['t7']) && empty($post['t8']) && empty($post['t9']) && empty($post['t10']) && empty($post['t11'])){
$form->addError("error","You need to mark min. one troop");
@@ -364,6 +368,10 @@ class Units {
$form->addError( "error", "You can't send negative units." );
}
if($data['type'] < 1 || $data['type'] > 4) $form->addError("error", "Invalid attack type.");
if($data['type'] != 1 && $post['spy'] != 0) $post['spy'] = 0;
if ( $form->returnErrors() > 0 ) {
$_SESSION['errorarray'] = $form->getErrors();
$_SESSION['valuearray'] = $_POST;
@@ -415,11 +423,10 @@ class Units {
);
$fromcoor = $database->getCoor( $village->wid );
$from = array('x' => $fromcoor['x'], 'y' => $fromcoor['y']);
$from = ['x' => $fromcoor['x'], 'y' => $fromcoor['y']];
$tocoor = $database->getCoor( $data['to_vid'] );
$to = array('x' => $tocoor['x'], 'y' => $tocoor['y']);
$speeds = array();
$scout = 1;
$to = ['x' => $tocoor['x'], 'y' => $tocoor['y']];
$speeds = [];
//find slowest unit.
for ( $i = 1; $i <= 10; $i ++ ) {
+7 -10
View File
@@ -72,10 +72,8 @@ $ckey= $generator->generateRandStr(6);
(!empty($process['t10']) ? $process['t10'] : 0) +
(!empty($process['t11']) ? $process['t11'] : 0);
}
if (isset($scout) && $scout==1 && isset($totalunits) && $totalunits==0) {
if ($process['c'] != 2){
$process['c'] = 1;
}
if (isset($scout) && $scout == 1 && isset($totalunits) && $totalunits == 0 && $process['c'] != 2) {
$process['c'] = 1;
}
$id = $database->addA2b($ckey,time(),$process['0'],$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11,$process['c']);
@@ -332,16 +330,15 @@ $end = ($tribe*10);
}
else if($process['c']=='4')
{
?><tbody class="infos">
<th>Destination:</th>
<td colspan="<?php if(!empty($process['t11'])){ echo"11"; }else{ echo"10"; } ?>">
?><tbody class="infos">
<tr>
<th>Destination:</th>
<td> colspan="<?php if(!empty($process['t11'])){ echo"11"; }else{ echo"10"; } ?>">
<?PHP
echo"Warning: Catapult will <b>ONLY</b> shoot with a normal attack (they dont shoot with raids!)";
?>
</td>
</td>
</tr>
<?PHP
}
+5 -5
View File
@@ -134,7 +134,7 @@ $actionType = "Raid";
<td><img src="img/x.gif" class="unit u42" title="Thorned Warrior" alt="Thorned Warrior"></td>
<td><img src="img/x.gif" class="unit u43" title="Guardsman" alt="Guardsman></td>
<td><img src="img/x.gif" class="unit u43" title="Guardsman" alt="Guardsman"></td>
<td><img src="img/x.gif" class="unit u44" title="Bird of Prey" alt="Bird of Prey"></td>
@@ -315,14 +315,14 @@ $actionType = "Raid";
else if($process['c']=='4')
{
?><tbody class="infos">
<th>Destination:</th>
<td colspan="<?php if($process['t11'] != ''){ echo"11"; }else{ echo"10"; } ?>">
<tr>
<th>Destination:</th>
<td> colspan="<?php if($process['t11'] != ''){ echo"11"; }else{ echo"10"; } ?>">
<?PHP
echo"Warning: Catapult will <b>ONLY</b> shoot with a normal attack (they dont shoot with raids!)";
?>
</td>
</td>
</tr>
<?PHP