Clean up cMaxHHs and cMaxTeams a bit, get rid of hardcoded numbers
authorWuzzy <Wuzzy2@mail.ru>
Sun, 15 Jul 2018 14:21:06 +0200
changeset 13491 4ef83bcb850b
parent 13490 c85b324c4c2d
child 13492 d23731fe84d4
Clean up cMaxHHs and cMaxTeams a bit, get rid of hardcoded numbers
QTfrontend/hwconsts.cpp.in
QTfrontend/hwconsts.h
QTfrontend/hwform.cpp
QTfrontend/ui/widget/frameTeam.cpp
--- a/QTfrontend/hwconsts.cpp.in	Thu Jul 12 14:46:16 2018 +0200
+++ b/QTfrontend/hwconsts.cpp.in	Sun Jul 15 14:21:06 2018 +0200
@@ -16,6 +16,12 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+/*
+ * PLEASE NOTE: hwconsts.cpp is automatically generated from hwconsts.cpp.in.
+ * Do not edit hwconsts.cpp manually, it will be overwritten when building.
+ * Edit hwconsts.cpp.in to change the code.
+ */
+
 #include <QStandardItemModel>
 
 #include "hwconsts.h"
@@ -37,6 +43,7 @@
 bool custom_data = false;
 
 int cMaxTeams = 8;
+int cMaxHHs = 48;
 int cMinServerVersion = 3;
 
 QString * cDefaultAmmoStore = new QString( AMMOLINE_DEFAULT_QT AMMOLINE_DEFAULT_PROB
--- a/QTfrontend/hwconsts.h	Thu Jul 12 14:46:16 2018 +0200
+++ b/QTfrontend/hwconsts.h	Sun Jul 15 14:21:06 2018 +0200
@@ -37,6 +37,7 @@
 extern bool custom_data;
 
 extern int cMaxTeams;
+extern int cMaxHHs;
 extern int cMinServerVersion;
 
 class QStandardItemModel;
--- a/QTfrontend/hwform.cpp	Thu Jul 12 14:46:16 2018 +0200
+++ b/QTfrontend/hwform.cpp	Sun Jul 15 14:21:06 2018 +0200
@@ -1708,11 +1708,11 @@
 void HWForm::StartMPGame()
 {
     int numHogs = ui.pageMultiplayer->teamsSelect->getNumHedgehogs();
-    /* Don't allow to start game with >48 hogs.
-    TODO: Remove this as soon the engine supports more hogs. */
-    if(numHogs > 48)
+    /* Don't allow to start game with more than cMaxHHs hedgehogs.
+    TODO: Remove this as soon the engine supports more hedgehogs. */
+    if(numHogs > cMaxHHs)
     {
-        MessageDialog::ShowErrorMessage(QMessageBox::tr("Sorry, Hedgewars can't be played with more than 48 hedgehogs. Please try again with fewer hedgehogs.\n\nCurrent number of hedgehogs: %1").arg(numHogs), this);
+        MessageDialog::ShowErrorMessage(QMessageBox::tr("Sorry, there are too many hedgehogs! Please try again with fewer hedgehogs.\n\nMaximum number of hedgehogs: %1\nCurrent number of hedgehogs: %2").arg(cMaxHHs).arg(numHogs), this);
         return;
     }
     QString ammo;
--- a/QTfrontend/ui/widget/frameTeam.cpp	Thu Jul 12 14:46:16 2018 +0200
+++ b/QTfrontend/ui/widget/frameTeam.cpp	Sun Jul 15 14:21:06 2018 +0200
@@ -126,7 +126,7 @@
 
 bool FrameTeams::isFullTeams() const
 {
-    return teamToWidget.size() >= 8;
+    return teamToWidget.size() >= cMaxTeams;
 }
 
 void FrameTeams::emitTeamColorChanged(const HWTeam& team)