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
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
)
endif()
+configure_file("${CMAKE_SOURCE_DIR}/include/version.cpp.in" "${CMAKE_BINARY_DIR}/version.cpp")
set(INCLUDELIST
include/aboutmsg.h
include/cullable.cpp
public:
// CSynapseClient API
bool RequestAPI( APIDescriptor_t *pAPI );
-const char* GetInfo();
+const char* GetInfo() override;
CameraSynapseClient() { }
virtual ~CameraSynapseClient() { }
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 );
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" ) ) {
-// Makefile appends preprocessor flags instead now
-#ifndef RADIANT_ABOUTMSG
-#error no RADIANT_ABOUTMSG defined
-#endif
+#include "version.h"
// version defines for q3map stream
-#define Q3MAP_STREAM_VERSION "1"
+#include "version.h"
--- /dev/null
+#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
-// 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
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:
xmlstuff.h
xywindow.cpp
xywindow.h
+ "${CMAKE_BINARY_DIR}/version.cpp"
)
add_executable(radiant WIN32 radiant.rc ${RADIANTLIST})
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",
}
{
- 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 );
{
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();
}
}
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
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(){
#else
URL << "&OS_dlup=3";
#endif
- URL << "&Version_dlup=" RADIANT_VERSION;
+ URL << "&Version_dlup=" << radiant::version();
g_GamesDialog.AddPacksURL( URL );
OpenURL( URL.c_str() );
}
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;
}
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)
q2map/trace.c
q2map/tree.c
q2map/writebsp.c
+ "${CMAKE_BINARY_DIR}/version.c"
)
target_link_libraries(q2map
${LIBXML2_LIBRARIES}
qdata/sprites.c
qdata/tables.c
qdata/video.c
+ "${CMAKE_BINARY_DIR}/version.c"
)
target_link_libraries(qdata3
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"
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 );
}
// in include
-#include "stream_version.h"
+#include "version.h"
void Broadcast_Setup( const char *dest ){
address_t address;
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 );
-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})
q3map2/vis.c
q3map2/visflow.c
q3map2/writebsp.c
+ "${CMAKE_BINARY_DIR}/version.c"
)
target_link_libraries(q3map2
q3data/q3data.h
q3data/stripper.c
q3data/video.c
+ "${CMAKE_BINARY_DIR}/version.c"
)
target_link_libraries(q3data
}
// in include
-#include "stream_version.h"
+#include "version.h"
void Broadcast_Setup( const char *dest ){
address_t address;
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 );
// 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 );
*outpos = 0;
SetKeyValue( &entities[0], "_q3map2_cmdline", newCommandLine );
- SetKeyValue( &entities[0], "_q3map2_version", Q3MAP_VERSION );
+ SetKeyValue( &entities[0], "_q3map2_version", q3map2_version() );
}
/*
/* 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 */
/* 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 */
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 );
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 */
/* 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"
/* general */
-#include "version.h" /* ttimo: might want to guard that if built outside of the GtkRadiant tree */
#include "cmdlib.h"
#include "mathlib.h"
--- /dev/null
+const char* radiant_version()
+{
+ return "@RADIANT_VERSION_STRING@";
+}
+
+const char* q3map2_version()
+{
+ return "@Q3MAP_VERSION@";
+}
+
+
+const char* q3map_stream_version()
+{
+ return "@Q3MAP_STREAM_VERSION@";
+}
--- /dev/null
+#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