From a646f7db94ed0cac0c62aa3adb1c6f748ea62e97 Mon Sep 17 00:00:00 2001 From: Mattia Basaglia Date: Wed, 29 Jul 2015 14:42:46 +0200 Subject: [PATCH] Handle version constants in a better way --- CMakeLists.txt | 11 +++---- contrib/camera/camera.cpp | 2 +- contrib/prtview/AboutDialog.cpp | 8 ++--- contrib/ufoaiplug/ufoai.cpp | 6 +++- include/aboutmsg.h | 5 +--- include/stream_version.h | 2 +- include/version.cpp.in | 34 ++++++++++++++++++++++ include/version.h | 27 ++++++++++------- libs/stream/textstream.h | 7 +++++ radiant/CMakeLists.txt | 1 + radiant/console.cpp | 4 ++- radiant/gtkdlgs.cpp | 20 ++++++------- radiant/main.cpp | 19 ++++++++---- radiant/mainframe.cpp | 2 +- radiant/watchbsp.cpp | 10 ++++--- tools/CMakeLists.txt | 2 ++ tools/quake2/CMakeLists.txt | 3 ++ tools/quake2/common/inout.c | 2 +- tools/quake2/qdata_heretic2/common/inout.c | 4 +-- tools/quake3/CMakeLists.txt | 5 ++-- tools/quake3/common/inout.c | 4 +-- tools/quake3/q3data/q3data.c | 2 +- tools/quake3/q3map2/bspfile_abstract.c | 2 +- tools/quake3/q3map2/bspfile_ibsp.c | 2 +- tools/quake3/q3map2/bspfile_rbsp.c | 2 +- tools/quake3/q3map2/main.c | 6 ++-- tools/quake3/q3map2/q3map2.h | 7 +---- tools/version.c.in | 15 ++++++++++ tools/version.h | 9 ++++++ 29 files changed, 152 insertions(+), 71 deletions(-) create mode 100644 include/version.cpp.in create mode 100644 tools/version.c.in create mode 100644 tools/version.h diff --git a/CMakeLists.txt b/CMakeLists.txt index e4d09aab..f3fe9395 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/contrib/camera/camera.cpp b/contrib/camera/camera.cpp index 5647f4c0..b49c88d7 100644 --- a/contrib/camera/camera.cpp +++ b/contrib/camera/camera.cpp @@ -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() { } diff --git a/contrib/prtview/AboutDialog.cpp b/contrib/prtview/AboutDialog.cpp index 1baec68d..e9458c0e 100644 --- a/contrib/prtview/AboutDialog.cpp +++ b/contrib/prtview/AboutDialog.cpp @@ -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 ); diff --git a/contrib/ufoaiplug/ufoai.cpp b/contrib/ufoaiplug/ufoai.cpp index bb118664..df695104 100644 --- a/contrib/ufoaiplug/ufoai.cpp +++ b/contrib/ufoaiplug/ufoai.cpp @@ -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" ) ) { diff --git a/include/aboutmsg.h b/include/aboutmsg.h index 8b5acc2c..15d67d02 100644 --- a/include/aboutmsg.h +++ b/include/aboutmsg.h @@ -1,4 +1 @@ -// Makefile appends preprocessor flags instead now -#ifndef RADIANT_ABOUTMSG -#error no RADIANT_ABOUTMSG defined -#endif +#include "version.h" diff --git a/include/stream_version.h b/include/stream_version.h index 21a26fff..12a28564 100644 --- a/include/stream_version.h +++ b/include/stream_version.h @@ -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 index 00000000..d16aa348 --- /dev/null +++ b/include/version.cpp.in @@ -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 diff --git a/include/version.h b/include/version.h index fd4e5de0..c5391ba6 100644 --- a/include/version.h +++ b/include/version.h @@ -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 +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 diff --git a/libs/stream/textstream.h b/libs/stream/textstream.h index e8de1391..59264448 100644 --- a/libs/stream/textstream.h +++ b/libs/stream/textstream.h @@ -211,6 +211,13 @@ inline TextOutputStreamType& ostream_write( TextOutputStreamType& ostream, const return ostream; } +/// \brief Writes a \p string to \p ostream. +template +inline TextOutputStreamType& ostream_write( TextOutputStreamType& ostream, const std::string& string ){ + ostream.write( string.data(), string.size() ); + return ostream; +} + class HexChar { public: diff --git a/radiant/CMakeLists.txt b/radiant/CMakeLists.txt index 794e0fec..d68bab1e 100644 --- a/radiant/CMakeLists.txt +++ b/radiant/CMakeLists.txt @@ -179,6 +179,7 @@ set(RADIANTLIST xmlstuff.h xywindow.cpp xywindow.h + "${CMAKE_BINARY_DIR}/version.cpp" ) add_executable(radiant WIN32 radiant.rc ${RADIANTLIST}) diff --git a/radiant/console.cpp b/radiant/console.cpp index 72a64140..11e9b843 100644 --- a/radiant/console.cpp +++ b/radiant/console.cpp @@ -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", diff --git a/radiant/gtkdlgs.cpp b/radiant/gtkdlgs.cpp index 5a887b29..16375c5e 100644 --- a/radiant/gtkdlgs.cpp +++ b/radiant/gtkdlgs.cpp @@ -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 ); diff --git a/radiant/main.cpp b/radiant/main.cpp index aa0a1bfd..0463944c 100644 --- a/radiant/main.cpp +++ b/radiant/main.cpp @@ -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(){ diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index 14f131f5..6762360b 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -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() ); } diff --git a/radiant/watchbsp.cpp b/radiant/watchbsp.cpp index f3d1ae6f..cd216afe 100644 --- a/radiant/watchbsp.cpp +++ b/radiant/watchbsp.cpp @@ -269,11 +269,13 @@ static void saxStartElement( message_info_t *data, const xmlChar *name, const xm abortStream( data ); return; } - else if ( strcmp( reinterpret_cast( attrs[1] ), Q3MAP_STREAM_VERSION ) != 0 ) { + else if ( q3map::stream_version() != reinterpret_cast( 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( 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( attrs[1] ) + << "\nPlease make sure your versions of Radiant and q3map are matching.\n"; abortStream( data ); return; } diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 52c5f18c..22033f12 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -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) diff --git a/tools/quake2/CMakeLists.txt b/tools/quake2/CMakeLists.txt index 96fe8098..8dc03830 100644 --- a/tools/quake2/CMakeLists.txt +++ b/tools/quake2/CMakeLists.txt @@ -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" diff --git a/tools/quake2/common/inout.c b/tools/quake2/common/inout.c index 30ae39df..9200943c 100644 --- a/tools/quake2/common/inout.c +++ b/tools/quake2/common/inout.c @@ -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, "" ); + sprintf( sMsg, "", q3map_stream_version() ); NMSG_Clear( &msg ); NMSG_WriteString( &msg, sMsg ); Net_Send( brdcst_socket, &msg ); diff --git a/tools/quake2/qdata_heretic2/common/inout.c b/tools/quake2/qdata_heretic2/common/inout.c index 30ae39df..8ccd7a37 100644 --- a/tools/quake2/qdata_heretic2/common/inout.c +++ b/tools/quake2/qdata_heretic2/common/inout.c @@ -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, "" ); + sprintf( sMsg, "", q3map_stream_version() ); NMSG_Clear( &msg ); NMSG_WriteString( &msg, sMsg ); Net_Send( brdcst_socket, &msg ); diff --git a/tools/quake3/CMakeLists.txt b/tools/quake3/CMakeLists.txt index 2bcaf10b..29e119ad 100644 --- a/tools/quake3/CMakeLists.txt +++ b/tools/quake3/CMakeLists.txt @@ -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 diff --git a/tools/quake3/common/inout.c b/tools/quake3/common/inout.c index 14e9eaaf..6f1c9957 100644 --- a/tools/quake3/common/inout.c +++ b/tools/quake3/common/inout.c @@ -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, "" ); + sprintf( sMsg, "", q3map_stream_version() ); NMSG_Clear( &msg ); NMSG_WriteString( &msg, sMsg ); Net_Send( brdcst_socket, &msg ); diff --git a/tools/quake3/q3data/q3data.c b/tools/quake3/q3data/q3data.c index f517beb0..098e78f6 100644 --- a/tools/quake3/q3data/q3data.c +++ b/tools/quake3/q3data/q3data.c @@ -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 ); diff --git a/tools/quake3/q3map2/bspfile_abstract.c b/tools/quake3/q3map2/bspfile_abstract.c index 1dab66db..09fec3b6 100644 --- a/tools/quake3/q3map2/bspfile_abstract.c +++ b/tools/quake3/q3map2/bspfile_abstract.c @@ -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() ); } /* diff --git a/tools/quake3/q3map2/bspfile_ibsp.c b/tools/quake3/q3map2/bspfile_ibsp.c index f6c1aef0..211e5179 100644 --- a/tools/quake3/q3map2/bspfile_ibsp.c +++ b/tools/quake3/q3map2/bspfile_ibsp.c @@ -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 */ diff --git a/tools/quake3/q3map2/bspfile_rbsp.c b/tools/quake3/q3map2/bspfile_rbsp.c index b1ff0304..914f69a1 100644 --- a/tools/quake3/q3map2/bspfile_rbsp.c +++ b/tools/quake3/q3map2/bspfile_rbsp.c @@ -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 */ diff --git a/tools/quake3/q3map2/main.c b/tools/quake3/q3map2/main.c index 8517b0bc..c550b15e 100644 --- a/tools/quake3/q3map2/main.c +++ b/tools/quake3/q3map2/main.c @@ -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 */ diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index 5f1b3f82..533524ec 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -35,11 +35,7 @@ /* 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 index 00000000..527f6c07 --- /dev/null +++ b/tools/version.c.in @@ -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 index 00000000..e20211b4 --- /dev/null +++ b/tools/version.h @@ -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 -- 2.39.2