From 3c8cbe8e84985f3cb047b294504b5c5b44ce4cd0 Mon Sep 17 00:00:00 2001
From: joris <joris.dauphin@gmail.com>
Date: Wed, 3 Apr 2013 18:24:22 +0200
Subject: [PATCH] Add a simple main.cpp to ease the use of unitTest.

---
 CMakeLists.txt              |  1 +
 src/include/stratagus.h     |  3 ++-
 src/stratagus/main.cpp      | 40 +++++++++++++++++++++++++++++++++++++
 src/stratagus/stratagus.cpp |  2 +-
 4 files changed, 44 insertions(+), 2 deletions(-)
 create mode 100644 src/stratagus/main.cpp

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2ca0f31c0..7e8815b8f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -283,6 +283,7 @@ set(stratagusmain_SRCS
 	src/stratagus/groups.cpp
 	src/stratagus/iolib.cpp
 	src/stratagus/luacallback.cpp
+	src/stratagus/main.cpp
 	src/stratagus/mainloop.cpp
 	src/stratagus/parameters.cpp
 	src/stratagus/player.cpp
diff --git a/src/include/stratagus.h b/src/include/stratagus.h
index b6e2616c4..7e731a34f 100644
--- a/src/include/stratagus.h
+++ b/src/include/stratagus.h
@@ -179,7 +179,7 @@ extern const char NameLine[];
 #define CYCLES_PER_SECOND  30  // 1/30s 0.33ms
 
 /*----------------------------------------------------------------------------
---  stratagus.c
+--  stratagus.cpp
 ----------------------------------------------------------------------------*/
 
 extern std::string StratagusLibPath;        /// Location of stratagus data
@@ -194,6 +194,7 @@ extern void ExitFatal(int err);             /// Exit with fatal error
 extern void UpdateDisplay();            /// Game display update
 extern void DrawMapArea();              /// Draw the map area
 extern void GameMainLoop();             /// Game main loop
+extern int stratagusMain(int argc, char **argv); /// main entry
 
 //@}
 
diff --git a/src/stratagus/main.cpp b/src/stratagus/main.cpp
new file mode 100644
index 000000000..99d607c8a
--- /dev/null
+++ b/src/stratagus/main.cpp
@@ -0,0 +1,40 @@
+//       _________ __                 __
+//      /   _____//  |_____________ _/  |______     ____  __ __  ______
+//      \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
+//      /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ |
+//     /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
+//             \/                  \/          \//_____/            \/
+//  ______________________                           ______________________
+//                        T H E   W A R   B E G I N S
+//         Stratagus - A free fantasy real time strategy game engine
+//
+/**@name main.cpp - The main file. */
+//
+//      (c) Copyright 2013 by Joris Dauphin
+//
+//      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; only 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 "stratagus.h"
+#include "SDL.h"
+
+int main(int argc, char **argv)
+{
+	return stratagusMain(argc, argv);
+}
+
+//@}
diff --git a/src/stratagus/stratagus.cpp b/src/stratagus/stratagus.cpp
index 224e49dcc..024325a43 100644
--- a/src/stratagus/stratagus.cpp
+++ b/src/stratagus/stratagus.cpp
@@ -616,7 +616,7 @@ void ParseCommandLine(int argc, char **argv, Parameters &parameters)
 **  @param argc  Number of arguments.
 **  @param argv  Vector of arguments.
 */
-int main(int argc, char **argv)
+int stratagusMain(int argc, char **argv)
 {
 #ifdef REDIRECT_OUTPUT
 	RedirectOutput();