Merge pull request #444 from AL-Kateb/master

Prevent user from illegally founding a new village with 0 settlers
This commit is contained in:
Martin Ambrus
2018-01-01 21:51:12 +01:00
committed by GitHub
2 changed files with 30 additions and 3 deletions
+10
View File
@@ -727,6 +727,16 @@ class Units {
public function Settlers($post) { public function Settlers($post) {
global $form, $database, $village, $session; global $form, $database, $village, $session;
//-- Prevent user from founding a new village if there are not enough settlers
//-- fix by AL-Kateb
$tempunits = $database->getUnit($village->coor['id']);
$settler_key = "u" . $session->userinfo['tribe'] . "0";
$settlers = (int)$tempunits[$settler_key];
if($settlers < 3){
header("location: dorf1.php");
exit;
}
//--
if ( $session->access != BANNED ) { if ( $session->access != BANNED ) {
$mode = CP; $mode = CP;
+19 -2
View File
@@ -32,6 +32,17 @@ $time = round($time);
} }
} }
} }
//-- Prevent user from founding a new village if there are not enough settlers
//-- fix by AL-Kateb
$tempunits = $database->getUnit($village->coor['id']);
$settler_key = "u" . $session->userinfo['tribe'] . "0";
$settlers = (int)$tempunits[$settler_key];
if($settlers < 3){
header("location: dorf1.php");
exit;
}
//--
echo '<pre>'; echo '<pre>';
echo '</pre>'; echo '</pre>';
?> ?>
@@ -59,8 +70,14 @@ echo '</pre>';
<th>Troops</th> <th>Troops</th>
<?php for($i=1;$i<=9;$i++) { <?php for($i=1;$i<=9;$i++) {
echo "<td class=\"none\">0</td>"; echo "<td class=\"none\">0</td>";
} ?> }
<td>3</td>
if($settlers >= 3){
echo "<td>3</td>";
}else{
echo "<td class=\"none\">0</td>";
}
?>
</tr> </tr>
</tbody> </tbody>
<tbody class="infos"> <tbody class="infos">