case ship outside map

This commit is contained in:
Gnieark 2015-12-14 23:19:10 +01:00
parent 254fd4e077
commit deb74b073e
2 changed files with 7 additions and 4 deletions

View File

@ -99,8 +99,8 @@ switch ($_POST['act']){
} }
//init grid //init grid
for($y = 0; $y < $height; $y++){ for($y = 0; $y < $postValues['gridHeight']; $y++){
for($x = 0; $x < $width; $x++){ for($x = 0; $x < $postValues['gridWidth']; $x++){
$grid[$player][$y][$x]=0; $grid[$player][$y][$x]=0;
} }
} }

View File

@ -54,10 +54,13 @@ function get_IA_Response($iaUrl,$postParams){
return htmlentities($output); return htmlentities($output);
} }
function place_ship_on_map($x1,$y1,$x2,$y2,$map){ function place_ship_on_map($x1,$y1,$x2,$y2,$map){
if (($x1 <> $x2) && ($y1 <> $y2)){ if ((($x1 <> $x2) && ($y1 <> $y2))
OR (!isset($map[$y1][$x1]))
OR (!isset($map[$y2][$x2]))){
return false; return false;
} }
if($x1 == $x2){ if($x1 == $x2){
//horizontal ship //horizontal ship
if($y1 <= $y2 ){ if($y1 <= $y2 ){