]> git.xonotic.org Git - xonotic/netradiant.git/commitdiff
Handle version constants in a better way
authorMattia Basaglia <mattia.basaglia@gmail.com>
Wed, 29 Jul 2015 12:42:46 +0000 (14:42 +0200)
committerMattia Basaglia <mattia.basaglia@gmail.com>
Wed, 29 Jul 2015 12:42:46 +0000 (14:42 +0200)
29 files changed:
CMakeLists.txt
contrib/camera/camera.cpp
contrib/prtview/AboutDialog.cpp
contrib/ufoaiplug/ufoai.cpp
include/aboutmsg.h
include/stream_version.h
include/version.cpp.in [new file with mode: 0644]
include/version.h
libs/stream/textstream.h
radiant/CMakeLists.txt
radiant/console.cpp
radiant/gtkdlgs.cpp
radiant/main.cpp
radiant/mainframe.cpp
radiant/watchbsp.cpp
tools/CMakeLists.txt
tools/quake2/CMakeLists.txt
tools/quake2/common/inout.c
tools/quake2/qdata_heretic2/common/inout.c
tools/quake3/CMakeLists.txt
tools/quake3/common/inout.c
tools/quake3/q3data/q3data.c
tools/quake3/q3map2/bspfile_abstract.c
tools/quake3/q3map2/bspfile_ibsp.c
tools/quake3/q3map2/bspfile_rbsp.c
tools/quake3/q3map2/main.c
tools/quake3/q3map2/q3map2.h
tools/version.c.in [new file with mode: 0644]
tools/version.h [new file with mode: 0644]

index e4d09aaba7971f77077e3889566c755fec5b53bc..f3fe939548371680dafa84c6c874a232d707546d 100644 (file)
@@ -8,6 +8,7 @@ set(NetRadiant_VERSION_MINOR 5)
 set(NetRadiant_VERSION_PATCH 0)
 set(NetRadiant_VERSION ${NetRadiant_VERSION_MAJOR}.${NetRadiant_VERSION_MINOR}.${NetRadiant_VERSION_PATCH})
 set(Q3MAP_VERSION 2.5.17n)
+set(Q3MAP_STREAM_VERSION 1)
 
 set(RADIANT_VERSION_STRING "${NetRadiant_VERSION}n${GIT_VERSION}")
 execute_process(COMMAND git rev-parse --short HEAD
@@ -55,13 +56,8 @@ endif()
 
 find_package(OpenGL REQUIRED)
 
-add_definitions(
-    -DRADIANT_VERSION="${RADIANT_VERSION_STRING}"
-    -DRADIANT_MAJOR_VERSION="${NetRadiant_VERSION_MINOR}"
-    -DRADIANT_MINOR_VERSION="${NetRadiant_VERSION_PATCH}"
-    -DRADIANT_ABOUTMSG="${RADIANT_ABOUTMSG}"
-    -DRADIANT_EXECUTABLE="${RADIANT_EXECUTABLE}"
-)
+add_definitions(-DRADIANT_EXECUTABLE="${RADIANT_EXECUTABLE}")
+
 if(NOT WIN32)
     add_definitions(
         -DPOSIX=1
@@ -73,6 +69,7 @@ else()
     )
 endif()
 
+configure_file("${CMAKE_SOURCE_DIR}/include/version.cpp.in" "${CMAKE_BINARY_DIR}/version.cpp")
 set(INCLUDELIST
     include/aboutmsg.h
     include/cullable.cpp
index 5647f4c0f082f0bd683368eceb73f271b6c5b196..b49c88d7f1d0d3b477b0beb9cbd0416393fee954 100644 (file)
@@ -170,7 +170,7 @@ class CameraSynapseClient : public CSynapseClient
 public:
 // CSynapseClient API
 bool RequestAPI( APIDescriptor_t *pAPI );
-const char* GetInfo();
+const char* GetInfo() override;
 
 CameraSynapseClient() { }
 virtual ~CameraSynapseClient() { }
index 1baec68defd0b56e6c23fc38a293052c29591263..e9458c0ebc4c37ae8e81391c7b2316618259a0e3 100644 (file)
@@ -66,12 +66,12 @@ void DoAboutDlg(){
        gtk_container_add( GTK_CONTAINER( dlg ), hbox );
        gtk_container_set_border_width( GTK_CONTAINER( hbox ), 10 );
 
-       label = gtk_label_new( "Version 1.000\n\n"
+       std::string label_text = "Version 1.000\n\n"
                                                   "Gtk port by Leonardo Zide\nleo@lokigames.com\n\n"
                                                   "Written by Geoffrey DeWan\ngdewan@prairienet.org\n\n"
-                                                  "Built against NetRadiant " RADIANT_VERSION "\n"
-                                                  __DATE__
-                                                  );
+                                                  "Built against NetRadiant " +radiant::version()+ "\n"
+                                                  __DATE__;
+       label = gtk_label_new( label_text.c_str() );
        gtk_widget_show( label );
        gtk_box_pack_start( GTK_BOX( hbox ), label, TRUE, TRUE, 0 );
        gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT );
index bb11866430e1068f9012759f8703c4aa1eefd881..df6951040b2d8af5c4b1096f7c857f4dbe17b892 100644 (file)
@@ -78,8 +78,12 @@ const char* getCommandTitleList(){
 void dispatch( const char* command, float* vMin, float* vMax, bool bSingleBrush ){
        char *message = NULL;
        if ( string_equal( command, "About" ) ) {
+               std::string version_string = "UFO:AI Plugin (http://ufoai.sf.net)\nBuild: " __DATE__
+                       "\nRadiant version: " +radiant::version()+
+                       "\nPlugin version: " PLUGIN_VERSION
+                       "\nAuthor: Martin Gerhardy (tlh2000/mattn)\n";
                GlobalRadiant().m_pfnMessageBox( GTK_WIDGET( g_mainwnd ),
-                                                                                "UFO:AI Plugin (http://ufoai.sf.net)\nBuild: " __DATE__ "\nRadiant version: " RADIANT_VERSION "\nPlugin version: " PLUGIN_VERSION "\nAuthor: Martin Gerhardy (tlh2000/mattn)\n", "About",
+                                                                                version_string.c_str(), "About",
                                                                                 eMB_OK, eMB_ICONDEFAULT );
        }
        else if ( string_equal( command, "Level 1" ) ) {
index 8b5acc2cc7259cb3c2617ebbee3dffff36593a21..15d67d026ec3dcc1affdcb1023d8c2ec3a1c0339 100644 (file)
@@ -1,4 +1 @@
-// Makefile appends preprocessor flags instead now
-#ifndef RADIANT_ABOUTMSG
-#error no RADIANT_ABOUTMSG defined
-#endif
+#include "version.h"
index 21a26fff35fa5c4f229aae1c957de8ef36b8512a..12a28564ce0792343513751d0f8bfcbf825ea7f7 100644 (file)
@@ -1,2 +1,2 @@
 // version defines for q3map stream
-#define Q3MAP_STREAM_VERSION "1"
+#include "version.h"
diff --git a/include/version.cpp.in b/include/version.cpp.in
new file mode 100644 (file)
index 0000000..d16aa34
--- /dev/null
@@ -0,0 +1,34 @@
+#include "@CMAKE_SOURCE_DIR@/include/version.h"
+namespace radiant {
+
+std::string version()
+{
+       return "@RADIANT_VERSION_STRING@";
+}
+
+int version_major()
+{
+       return @NetRadiant_VERSION_MINOR@;
+}
+
+int version_minor()
+{
+       return @NetRadiant_VERSION_PATCH@;
+}
+
+std::string about_msg()
+{
+       return "@RADIANT_ABOUTMSG@";
+}
+
+
+} // namespace radiant
+
+namespace q3map {
+
+std::string stream_version()
+{
+       return "@Q3MAP_STREAM_VERSION@";
+}
+
+} // namespace q3map
index fd4e5de0cc0f8f0f08f4d0207af37aba524c5a61..c5391ba6d03c6cb40bdf3117ddce62c21c0f8f16 100644 (file)
@@ -1,11 +1,16 @@
-// Makefile appends preprocessor flags instead now
-/// \todo Generate this file from cmake
-#ifndef RADIANT_VERSION
-#error no RADIANT_VERSION defined
-#endif
-#ifndef RADIANT_MAJOR_VERSION
-#error no RADIANT_MAJOR_VERSION defined
-#endif
-#ifndef RADIANT_MINOR_VERSION
-#error no RADIANT_MINOR_VERSION defined
-#endif
+#ifndef INCLUDED_RADIANT_VERSION_H
+#define INCLUDED_RADIANT_VERSION_H
+
+#include <string>
+namespace radiant {
+       std::string version();
+       int version_major();
+       int version_minor();
+       std::string about_msg();
+} // namespace radiant
+
+namespace q3map {
+std::string stream_version();
+} // namespace q3map
+
+#endif // INCLUDED_RADIANT_VERSION_H
index e8de1391075c9c96337a91a1de0902d6ff9cb553..592644488ea21b705acf71d60aab9ad99db2dfe6 100644 (file)
@@ -211,6 +211,13 @@ inline TextOutputStreamType& ostream_write( TextOutputStreamType& ostream, const
        return ostream;
 }
 
+/// \brief Writes a \p string to \p ostream.
+template<typename TextOutputStreamType>
+inline TextOutputStreamType& ostream_write( TextOutputStreamType& ostream, const std::string& string ){
+       ostream.write( string.data(), string.size() );
+       return ostream;
+}
+
 class HexChar
 {
 public:
index 794e0fec83f5d77ef5969105a29826dc8fef3b12..d68bab1ea8579d2a06f6a334bcb1bf514743ec71 100644 (file)
@@ -179,6 +179,7 @@ set(RADIANTLIST
     xmlstuff.h
     xywindow.cpp
     xywindow.h
+    "${CMAKE_BINARY_DIR}/version.cpp"
 )
 
 add_executable(radiant WIN32 radiant.rc ${RADIANTLIST})
index 72a64140fd0ba4af78aa8475cd06bb89551ea87e..11e9b843caaf696277078e85a5963956c021ecdf 100644 (file)
@@ -66,7 +66,9 @@ void Sys_LogFile( bool enable ){
                        time_t localtime;
                        time( &localtime );
                        globalOutputStream() << "Today is: " << ctime( &localtime )
-                                                                << "This is NetRadiant '" RADIANT_VERSION "' compiled " __DATE__ "\n" RADIANT_ABOUTMSG "\n";
+                                                                << "This is NetRadiant '" << radiant::version()
+                                                                << "' compiled " __DATE__ "\n"
+                                                                << radiant::about_msg() << "\n";
                }
                else{
                        gtk_MessageBox( 0, "Failed to create log file, check write permissions in Radiant directory.\n",
index 5a887b293c5242b22891ad7b0ad9028f2e19ba66..16375c5e12558e150aa9e2d1e7875ed8f7f2566c 100644 (file)
@@ -473,16 +473,16 @@ void DoAbout(){
                        }
 
                        {
-                               GtkLabel* label = GTK_LABEL( gtk_label_new( "NetRadiant " RADIANT_VERSION "\n"
-                                                                                                                       __DATE__ "\n\n"
-                                                                                                                       RADIANT_ABOUTMSG "\n\n"
-                                                                                                                                                        "By alientrap.org\n\n"
-                                                                                                                                                        "This program is free software\n"
-                                                                                                                                                        "licensed under the GNU GPL.\n\n"
-                                                                                                                                                        "NetRadiant is unsupported, however\n"
-                                                                                                                                                        "you may report your problems at\n"
-                                                                                                                                                        "http://www.icculus.org/netradiant/"
-                                                                                                                       ) );
+                               std::string label_text = "NetRadiant " + radiant::version() + "\n"
+                                                                               __DATE__ "\n\n"
+                                                                               + radiant::about_msg() + "\n\n"
+                                                                               "This program is free software\n"
+                                                                               "licensed under the GNU GPL.\n\n"
+                                                                               "NetRadiant is unsupported, however\n"
+                                                                               "you may report your problems at\n"
+                                                                               "https://gitlab.com/xonotic/netradiant/issues";
+
+                               GtkLabel* label = GTK_LABEL( gtk_label_new( label_text.c_str() ) );
 
                                gtk_widget_show( GTK_WIDGET( label ) );
                                gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 );
index aa0a1bfd88454146142f3068477566a9367c8f1d..0463944c42320b6f48d019f5746f5c560d06ccae 100644 (file)
@@ -335,7 +335,7 @@ void paths_init(){
 
        {
                StringOutputStream path( 256 );
-               path << home << "1." << RADIANT_MAJOR_VERSION "." << RADIANT_MINOR_VERSION << '/';
+               path << home << "1." << radiant::version_major() << "." << radiant::version_minor() << '/';
                g_strSettingsPath = path.c_str();
        }
 
@@ -375,7 +375,14 @@ bool check_version_file( const char* filename, const char* version ){
 }
 
 bool check_version(){
-       // a safe check to avoid people running broken installations
+       // a safe check to avoid people running broken code
+       // (otherwise, they run it, don't crash it, wait 20 years and blame us for not maintaining this hard enough)
+       // make something idiot proof and someone will make better idiots, this may be overkill
+       // let's leave it disabled in any case
+       /// \todo actually remove this and check if the functions called from here
+       /// are used elsewhere; if not, remove them.
+       return true;
+/*     // a safe check to avoid people running broken installations
        // (otherwise, they run it, crash it, and blame us for not forcing them hard enough to pay attention while installing)
        // make something idiot proof and someone will make better idiots, this may be overkill
        // let's leave it disabled in debug mode in any case
@@ -399,15 +406,17 @@ bool check_version(){
 
        if ( !bVerIsGood ) {
                StringOutputStream msg( 256 );
-               msg << "This editor binary (" RADIANT_VERSION ") doesn't match what the latest setup has configured in this directory\n"
-                                                                                                         "Make sure you run the right/latest editor binary you installed\n"
+               msg << "This editor binary ("
+                       << radiant::version()
+                       << ") doesn't match what the latest setup has configured in this directory\n"
+                               "Make sure you run the right/latest editor binary you installed\n"
                        << AppPath_get();
                gtk_MessageBox( 0, msg.c_str(), "Radiant", eMB_OK, eMB_ICONDEFAULT );
        }
        return bVerIsGood;
 #else
        return true;
-#endif
+#endif*/
 }
 
 void create_global_pid(){
index 14f131f51daa1ad04fe250c4fc7501cc649c0f49..6762360b4cdc08fcb2adba34591f66db5d3ef84d 100644 (file)
@@ -950,7 +950,7 @@ void OpenUpdateURL(){
 #else
        URL << "&OS_dlup=3";
 #endif
-       URL << "&Version_dlup=" RADIANT_VERSION;
+       URL << "&Version_dlup=" << radiant::version();
        g_GamesDialog.AddPacksURL( URL );
        OpenURL( URL.c_str() );
 }
index f3d1ae6f77438bf431f3acaead01255488a17192..cd216afe7ec545a4fccb84d1a05438ba69d78183 100644 (file)
@@ -269,11 +269,13 @@ static void saxStartElement( message_info_t *data, const xmlChar *name, const xm
                                        abortStream( data );
                                        return;
                                }
-                               else if ( strcmp( reinterpret_cast<const char*>( attrs[1] ), Q3MAP_STREAM_VERSION ) != 0 ) {
+                               else if ( q3map::stream_version() !=  reinterpret_cast<const char*>( attrs[1] ) ) {
                                        message_flush( data );
-                                       globalErrorStream() <<
-                                       "This version of Radiant reads version " Q3MAP_STREAM_VERSION " debug streams, I got an incoming connection with version " << reinterpret_cast<const char*>( attrs[1] ) << "\n"
-                                                                                                                                                                                                                                                                                                                                                                                          "Please make sure your versions of Radiant and q3map are matching.\n";
+                                       globalErrorStream() << "This version of Radiant reads version "
+                                               << q3map::stream_version()
+                                               << " debug streams, I got an incoming connection with version "
+                                               << reinterpret_cast<const char*>( attrs[1] )
+                                               << "\nPlease make sure your versions of Radiant and q3map are matching.\n";
                                        abortStream( data );
                                        return;
                                }
index 52c5f18cab8aa5e8cba971591d9758c6ad30b547..22033f1257952535cb1859b9965ee1e6df9ffbb9 100644 (file)
@@ -2,5 +2,7 @@
 
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
 
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/version.c.in" "${CMAKE_BINARY_DIR}/version.c")
+include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
 add_subdirectory(quake3)
 add_subdirectory(quake2)
index 96fe8098d0b74929486745784c6dcab3f3ddb366..8dc03830f5459c11f82052289ea1b98771f1778a 100644 (file)
@@ -54,6 +54,7 @@ add_executable(q2map EXCLUDE_FROM_ALL
    q2map/trace.c
    q2map/tree.c
    q2map/writebsp.c
+       "${CMAKE_BINARY_DIR}/version.c"
 )
 target_link_libraries(q2map
     ${LIBXML2_LIBRARIES}
@@ -91,6 +92,7 @@ add_executable(qdata3 EXCLUDE_FROM_ALL
    qdata/sprites.c
    qdata/tables.c
    qdata/video.c
+       "${CMAKE_BINARY_DIR}/version.c"
 )
 
 target_link_libraries(qdata3
@@ -164,6 +166,7 @@ add_executable(h2data EXCLUDE_FROM_ALL
    qdata_heretic2/tables.c
    qdata_heretic2/tmix.c
    qdata_heretic2/video.c
+       "${CMAKE_BINARY_DIR}/version.c"
 )
 target_include_directories(h2data BEFORE
     PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/qdata_heretic2/common"
index 30ae39df7ee9026ae3cae5d94afff7083691c9de..9200943c6a4e4e5a61ee8e12c503673abbe6e9d4 100644 (file)
@@ -239,7 +239,7 @@ void Broadcast_Setup( const char *dest ){
        brdcst_socket = Net_Connect( &address, 0 );
        if ( brdcst_socket ) {
                // send in a header
-               sprintf( sMsg, "<?xml version=\"1.0\"?><q3map_feedback version=\"" Q3MAP_STREAM_VERSION "\">" );
+               sprintf( sMsg, "<?xml version=\"1.0\"?><q3map_feedback version=\"%s\">", q3map_stream_version() );
                NMSG_Clear( &msg );
                NMSG_WriteString( &msg, sMsg );
                Net_Send( brdcst_socket, &msg );
index 30ae39df7ee9026ae3cae5d94afff7083691c9de..8ccd7a377a28adcd8ea1384bc40ae21af961baa8 100644 (file)
@@ -228,7 +228,7 @@ void xml_Winding( char *msg, vec3_t p[], int numpoints, qboolean die ){
 }
 
 // in include
-#include "stream_version.h"
+#include "version.h"
 
 void Broadcast_Setup( const char *dest ){
        address_t address;
@@ -239,7 +239,7 @@ void Broadcast_Setup( const char *dest ){
        brdcst_socket = Net_Connect( &address, 0 );
        if ( brdcst_socket ) {
                // send in a header
-               sprintf( sMsg, "<?xml version=\"1.0\"?><q3map_feedback version=\"" Q3MAP_STREAM_VERSION "\">" );
+               sprintf( sMsg, "<?xml version=\"1.0\"?><q3map_feedback version=\"%s\">", q3map_stream_version() );
                NMSG_Clear( &msg );
                NMSG_WriteString( &msg, sMsg );
                Net_Send( brdcst_socket, &msg );
index 2bcaf10b4e7742ad597bc4bbf1b67a6697d6defc..29e119adc0bd851c4b1d53f6193eea5ebb678353 100644 (file)
@@ -1,8 +1,5 @@
-add_definitions(-DQ3MAP_VERSION="${Q3MAP_VERSION}")
-
 include_directories(common)
 include_directories("${CMAKE_SOURCE_DIR}/libs")
-include_directories("${CMAKE_SOURCE_DIR}/include")
 
 find_package(GLIB REQUIRED)
 include_directories(${GLIB_INCLUDE_DIRS})
@@ -105,6 +102,7 @@ add_executable(q3map2
     q3map2/vis.c
     q3map2/visflow.c
     q3map2/writebsp.c
+    "${CMAKE_BINARY_DIR}/version.c"
 )
 
 target_link_libraries(q3map2
@@ -157,6 +155,7 @@ add_executable(q3data
     q3data/q3data.h
     q3data/stripper.c
     q3data/video.c
+    "${CMAKE_BINARY_DIR}/version.c"
 )
 
 target_link_libraries(q3data
index 14e9eaafe5ffff974579c5bdd946a7a6ef46d755..6f1c9957131b6fda4fb6c9ec3e6724c7b3db7069 100644 (file)
@@ -231,7 +231,7 @@ void xml_Winding( char *msg, vec3_t p[], int numpoints, qboolean die ){
 }
 
 // in include
-#include "stream_version.h"
+#include "version.h"
 
 void Broadcast_Setup( const char *dest ){
        address_t address;
@@ -242,7 +242,7 @@ void Broadcast_Setup( const char *dest ){
        brdcst_socket = Net_Connect( &address, 0 );
        if ( brdcst_socket ) {
                // send in a header
-               sprintf( sMsg, "<?xml version=\"1.0\"?><q3map_feedback version=\"" Q3MAP_STREAM_VERSION "\">" );
+               sprintf( sMsg, "<?xml version=\"1.0\"?><q3map_feedback version=\"%s\">", q3map_stream_version() );
                NMSG_Clear( &msg );
                NMSG_WriteString( &msg, sMsg );
                Net_Send( brdcst_socket, &msg );
index f517beb0e47afa2a4749b9ff73a553de2d8f70e3..098e78f670e3a22f1961da10024ab12c5458d7f9 100644 (file)
@@ -573,7 +573,7 @@ int main( int argc, char **argv ){
 
        // using GtkRadiant's versioning next to Id's versioning
        printf( "Q3Data      - (c) 1999 Id Software Inc.\n" );
-       printf( "NetRadiant  - v" RADIANT_VERSION " " __DATE__ "\n" );
+       printf( "NetRadiant  - v%s " __DATE__ "\n", radiant_version() );
 
        ExpandWildcards( &argc, &argv );
 
index 1dab66dbda76c4cf7a83b62b9d3816ab0d0e431d..09fec3b676715c874b5f1faf3e449260eb456072 100644 (file)
@@ -619,7 +619,7 @@ void InjectCommandLine( char **argv, int beginArgs, int endArgs ){
 
        *outpos = 0;
        SetKeyValue( &entities[0], "_q3map2_cmdline", newCommandLine );
-       SetKeyValue( &entities[0], "_q3map2_version", Q3MAP_VERSION );
+       SetKeyValue( &entities[0], "_q3map2_version", q3map2_version() );
 }
 
 /*
index f6c1aef0251cb3336823a96437f5dbc2e1fa1f4c..211e5179a75320fa52fbaf6e5517dd154de4aa53 100644 (file)
@@ -550,7 +550,7 @@ void WriteIBSPFile( const char *filename ){
 
        /* add marker lump */
        time( &t );
-       sprintf( marker, "I LOVE MY Q3MAP2 %s on %s)", Q3MAP_VERSION, asctime( localtime( &t ) ) );
+       sprintf( marker, "I LOVE MY Q3MAP2 %s on %s)", q3map2_version(), asctime( localtime( &t ) ) );
        AddLump( file, (bspHeader_t*) header, 0, marker, strlen( marker ) + 1 );
 
        /* add lumps */
index b1ff0304dde7dd4888c53e77b6ae5df054cc12d6..914f69a188a2e775a7f504295b4a06fc3eabe4b9 100644 (file)
@@ -305,7 +305,7 @@ void WriteRBSPFile( const char *filename ){
 
        /* add marker lump */
        time( &t );
-       sprintf( marker, "I LOVE MY Q3MAP2 %s on %s)", Q3MAP_VERSION, asctime( localtime( &t ) ) );
+       sprintf( marker, "I LOVE MY Q3MAP2 %s on %s)", q3map2_version(), asctime( localtime( &t ) ) );
        AddLump( file, (bspHeader_t*) header, 0, marker, strlen( marker ) + 1 );
 
        /* add lumps */
index 8517b0bc6f113618b4489a568e05b29041de70e5..c550b15e4d76055b6ea75d5ad93b41549822dc0f 100644 (file)
@@ -2081,7 +2081,7 @@ int main( int argc, char **argv ){
        start = I_FloatTime();
 
        /* this was changed to emit version number over the network */
-       printf( Q3MAP_VERSION "\n" );
+       printf( "%s\n", q3map2_version() );
 
        /* set exit call */
        atexit( ExitQ3Map );
@@ -2160,8 +2160,8 @@ int main( int argc, char **argv ){
           and we put the GtkRadiant version to make it easy to track with what version of Radiant it was built with */
 
        Sys_Printf( "Q3Map         - v1.0r (c) 1999 Id Software Inc.\n" );
-       Sys_Printf( "Q3Map (ydnar) - v" Q3MAP_VERSION "\n" );
-       Sys_Printf( "NetRadiant    - v" RADIANT_VERSION " " __DATE__ " " __TIME__ "\n" );
+       Sys_Printf( "Q3Map (ydnar) - v%s\n", q3map2_version() );
+       Sys_Printf( "NetRadiant    - v%s " __DATE__ " " __TIME__ "\n", radiant_version() );
        Sys_Printf( "%s\n", Q3MAP_MOTD );
 
        /* ydnar: new path initialization */
index 5f1b3f8240786e9fa055a1be8d7e943876887341..533524ec911cce20d5f4a528260d6a2d15cbaa67 100644 (file)
 
 
 /* version */
-/** \todo Generate a header for Q3MAP_VERSION from cmake  */
-#ifndef Q3MAP_VERSION
-#error no Q3MAP_VERSION defined
-#endif
-#define Q3MAP_MOTD      "Your map saw the pretty lights from q3map2's BFG"
+#include "version.h"
 
 
 
@@ -67,7 +63,6 @@
 
 
 /* general */
-#include "version.h"            /* ttimo: might want to guard that if built outside of the GtkRadiant tree */
 
 #include "cmdlib.h"
 #include "mathlib.h"
diff --git a/tools/version.c.in b/tools/version.c.in
new file mode 100644 (file)
index 0000000..527f6c0
--- /dev/null
@@ -0,0 +1,15 @@
+const char* radiant_version()
+{
+       return "@RADIANT_VERSION_STRING@";
+}
+
+const char* q3map2_version()
+{
+       return "@Q3MAP_VERSION@";
+}
+
+
+const char* q3map_stream_version()
+{
+       return "@Q3MAP_STREAM_VERSION@";
+}
diff --git a/tools/version.h b/tools/version.h
new file mode 100644 (file)
index 0000000..e20211b
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef INCLUDED_TOOLS_VERSION_H
+#define INCLUDED_TOOLS_VERSION_H
+
+const char* radiant_version();
+const char* q3map2_version();
+const char* q3map_stream_version();
+#define Q3MAP_MOTD      "Your map saw the pretty lights from q3map2's BFG"
+
+#endif // INCLUDED_TOOLS_VERSION_H