Protocol version sets in CMake
authorunc0rr
Fri, 24 Nov 2006 19:33:43 +0000
changeset 271 f2f9a3d5b441
parent 270 bb56f0682655
child 272 bf5240469cd1
Protocol version sets in CMake
CMakeLists.txt
QTfrontend/CMakeLists.txt
QTfrontend/game.cpp
QTfrontend/hwconsts.h
QTfrontend/hwconsts.h.in
QTfrontend/hwform.cpp
hedgewars/CMakeLists.txt
hedgewars/hwengine.dpr
hedgewars/proto.inc.in
hedgewars/uConsts.pas
--- a/CMakeLists.txt	Thu Nov 23 22:27:47 2006 +0000
+++ b/CMakeLists.txt	Fri Nov 24 19:33:43 2006 +0000
@@ -9,6 +9,8 @@
 endif(DEFINED DATA_INSTALL_DIR)
 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
 
+set(HEDGEWARS_PROTO_VER 3)
+
 add_subdirectory(bin)
 add_subdirectory(QTfrontend)
 add_subdirectory(hedgewars)
--- a/QTfrontend/CMakeLists.txt	Thu Nov 23 22:27:47 2006 +0000
+++ b/QTfrontend/CMakeLists.txt	Fri Nov 24 19:33:43 2006 +0000
@@ -18,6 +18,8 @@
 
 configure_file(${hedgewars_SOURCE_DIR}/QTfrontend/main.cpp.in 
 	${hedgewars_SOURCE_DIR}/QTfrontend/main.cpp)
+configure_file(${hedgewars_SOURCE_DIR}/QTfrontend/hwconsts.h.in 
+	${hedgewars_SOURCE_DIR}/QTfrontend/hwconsts.h)
 
 set(hwfr_src 
 	game.cpp
--- a/QTfrontend/game.cpp	Thu Nov 23 22:27:47 2006 +0000
+++ b/QTfrontend/game.cpp	Fri Nov 24 19:33:43 2006 +0000
@@ -43,7 +43,7 @@
 
 void HWGame::onClientDisconnect()
 {
-	SaveDemo(cfgdir->absolutePath() + "/Demos/LastRound.hwd_1");
+	SaveDemo(cfgdir->absolutePath() + "/Demos/LastRound.hwd_" + cProtoVer);
 }
 
 void HWGame::SendTeamConfig(int index)
--- a/QTfrontend/hwconsts.h	Thu Nov 23 22:27:47 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- * Hedgewars, a worms-like game
- * Copyright (c) 2005, 2006 Andrey Korotaev <unC0Rr@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <QDir>
-
-const char resolutions[2][4][5] =
-{
-	{"640", "800", "1024", "1280"},
-	{"480", "600",  "768", "1024"}
-};
-
-extern QDir * cfgdir;
-extern QDir * datadir;
-extern QDir * bindir;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/hwconsts.h.in	Fri Nov 24 19:33:43 2006 +0000
@@ -0,0 +1,32 @@
+/*
+ * Hedgewars, a worms-like game
+ * Copyright (c) 2005, 2006 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <QDir>
+#include <QString>
+
+const char resolutions[2][4][5] =
+{
+	{"640", "800", "1024", "1280"},
+	{"480", "600",  "768", "1024"}
+};
+
+extern QDir * cfgdir;
+extern QDir * datadir;
+extern QDir * bindir;
+
+const QString cProtoVer("${HEDGEWARS_PROTO_VER}");
--- a/QTfrontend/hwform.cpp	Thu Nov 23 22:27:47 2006 +0000
+++ b/QTfrontend/hwform.cpp	Fri Nov 24 19:33:43 2006 +0000
@@ -140,7 +140,8 @@
 	tmpdir.cd("Demos");
 	tmpdir.setFilter(QDir::Files);
 	ui.pagePlayDemo->DemosList->clear();
-	ui.pagePlayDemo->DemosList->addItems(tmpdir.entryList(QStringList("*.hwd_1")).replaceInStrings(QRegExp("^(.*).hwd_1"), "\\1"));
+	ui.pagePlayDemo->DemosList->addItems(tmpdir.entryList(QStringList("*.hwd_" + cProtoVer))
+			.replaceInStrings(QRegExp("^(.*).hwd_" + cProtoVer), "\\1"));
 	ui.Pages->setCurrentIndex(ID_PAGE_DEMOS);
 }
 
@@ -202,7 +203,7 @@
 		return ;
 	}
 	game = new HWGame(config, 0);
-	game->PlayDemo(cfgdir->absolutePath() + "/Demos/" + curritem->text() + ".hwd_1");
+	game->PlayDemo(cfgdir->absolutePath() + "/Demos/" + curritem->text() + ".hwd_" + cProtoVer);
 }
 
 void HWForm::NetConnect()
--- a/hedgewars/CMakeLists.txt	Thu Nov 23 22:27:47 2006 +0000
+++ b/hedgewars/CMakeLists.txt	Fri Nov 24 19:33:43 2006 +0000
@@ -1,3 +1,6 @@
+configure_file(${hedgewars_SOURCE_DIR}/hedgewars/proto.inc.in 
+	${hedgewars_SOURCE_DIR}/hedgewars/proto.inc) 
+
 set(dcc32_tryexe dcc32.exe)
 set(fpc_tryexe fpc)
 set(hwengine_project "hwengine.dpr")
@@ -32,6 +35,7 @@
 	GSHandlers.inc
 	HHHandlers.inc
 	options.inc
+	proto.inc
 	tunsetborder.inc
 	)
 
--- a/hedgewars/hwengine.dpr	Thu Nov 23 22:27:47 2006 +0000
+++ b/hedgewars/hwengine.dpr	Fri Nov 24 19:33:43 2006 +0000
@@ -48,6 +48,7 @@
 // also: GSHandlers.inc
 //       CCHandlers.inc
 //       HHHandlers.inc
+//       proto.inc
 
 
 procedure OnDestroy; forward;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hedgewars/proto.inc.in	Fri Nov 24 19:33:43 2006 +0000
@@ -0,0 +1,19 @@
+(*
+ * Hedgewars, a worms-like game
+ * Copyright (c) 2006 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *)
+
+const cNetProtoVersion = ${HEDGEWARS_PROTO_VER};
--- a/hedgewars/uConsts.pas	Thu Nov 23 22:27:47 2006 +0000
+++ b/hedgewars/uConsts.pas	Fri Nov 24 19:33:43 2006 +0000
@@ -20,6 +20,7 @@
 interface
 uses SDLh, uLocale;
 {$INCLUDE options.inc}
+{$INCLUDE proto.inc}
 type TStuff     = (sConsoleBG, sPowerBar, sQuestion, sWindBar,
                    sWindL, sWindR, sRopeNode);
      TGameState = (gsLandGen, gsStart, gsGame, gsConsole, gsExit);
@@ -77,8 +78,6 @@
       msgGettingConfig     = 'Getting game config...';
 
 const
-      cNetProtoVersion = 2;
-
       MAXNAMELEN = 32;
 
       COLOR_LAND = $00FFFFFF;