Refactor(Units): collapse the duplicated procUnits() cases 1-4 [#219] (#281)

Cases 1 to 4 of the procUnits() switch had a byte-identical body (send troops
when the rally-point form is submitted, otherwise load the unit form). Stack the
four case labels and keep a single shared body via switch fall-through.
Behaviour-preserving.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Ferywir
2026-06-25 11:37:54 +02:00
committed by GitHub
parent 06089df64c
commit 1e661b7a03
+1 -25
View File
@@ -24,32 +24,8 @@ class Units {
switch($post['c']) {
case 1:
if (isset($post['a']) && $post['a'] == 533374 && empty($post['disabled'])) $this->sendTroops($post);
else
{
$post = $this->loadUnits($post);
return $post;
}
break;
case 2:
if (isset($post['a']) && $post['a'] == 533374 && empty($post['disabled'])) $this->sendTroops($post);
else
{
$post = $this->loadUnits($post);
return $post;
}
break;
case 3:
if (isset($post['a']) && $post['a'] == 533374 && empty($post['disabled'])) $this->sendTroops($post);
else
{
$post = $this->loadUnits($post);
return $post;
}
break;
case 4:
if (isset($post['a']) && $post['a'] == 533374 && empty($post['disabled'])) $this->sendTroops($post);
else
@@ -58,7 +34,7 @@ class Units {
return $post;
}
break;
case 5:
if (isset($post['a']) && $post['a'] == "new") $this->Settlers($post);
else