From bfaf672b9a1de8e10c8fe6290ce920644e4b9027 Mon Sep 17 00:00:00 2001 From: mattn Date: Sat, 5 Jul 2008 10:21:36 +0000 Subject: [PATCH] * removed a lot of HACKs for several games by merging the enginepath_win32, enginepath_linux and enginepath_macos from 1.5 to 1.6 (default for everything is quake3) * removed the hacks for q2.game and heretic2.game (just check whether the game config value quake2 is set - TODO: game dialog needs update - quake2 option should be given) git-svn-id: https://zerowing.idsoftware.com/svn/radiant/GtkRadiant/trunk@297 8a3a26a2-13c4-0310-b231-cf6edde360e5 --- radiant/groupdialog.cpp | 2 +- radiant/preferences.cpp | 137 ++++++++++++++++-------- radiant/preferences.h | 1 + radiant/surfaceplugin.cpp | 26 ++--- radiant/watchbsp.cpp | 214 ++++++-------------------------------- 5 files changed, 138 insertions(+), 242 deletions(-) diff --git a/radiant/groupdialog.cpp b/radiant/groupdialog.cpp index acfca286..d9f8c896 100644 --- a/radiant/groupdialog.cpp +++ b/radiant/groupdialog.cpp @@ -1340,7 +1340,7 @@ void GroupDlg::Create () EntWidgets[EntCheck1+i] = check; } - if (g_pGameDescription->quake2 || ( g_pGameDescription->mGameFile == "q2.game" ) || ( g_pGameDescription->mGameFile == "heretic2.game" )) { + if (g_pGameDescription->quake2) { GtkWidget *check = gtk_check_button_new_with_label (_("!Easy")); gtk_widget_show (check); gtk_signal_connect (GTK_OBJECT (check), "toggled", GTK_SIGNAL_FUNC (entity_check), NULL); diff --git a/radiant/preferences.cpp b/radiant/preferences.cpp index d4d0bced..021dc937 100644 --- a/radiant/preferences.cpp +++ b/radiant/preferences.cpp @@ -694,6 +694,31 @@ Games selection dialog ========================================================= */ +#if defined(WIN32) +#define ENGINE_ATTRIBUTE "engine_win32" +#define MP_ENGINE_ATTRIBUTE "mp_engine_win32" +#elif defined(__linux__) || defined (__FreeBSD__) +#define ENGINE_ATTRIBUTE "engine_linux" +#define MP_ENGINE_ATTRIBUTE "mp_engine_linux" +#elif defined(__APPLE__) +#define ENGINE_ATTRIBUTE "engine_macos" +#define MP_ENGINE_ATTRIBUTE "mp_engine_macos" +#else +#error "unsupported platform" +#endif + + +#if defined(WIN32) +#define ENGINEPATH_ATTRIBUTE "enginepath_win32" +#elif defined(__linux__) || defined (__FreeBSD__) +#define ENGINEPATH_ATTRIBUTE "enginepath_linux" +#elif defined(__APPLE__) +#define ENGINEPATH_ATTRIBUTE "enginepath_macos" +#else +#error "unknown platform" +#endif + + CGameDescription::CGameDescription(xmlDocPtr pDoc, const Str &GameFile) { char *p, *prop; @@ -710,7 +735,7 @@ CGameDescription::CGameDescription(xmlDocPtr pDoc, const Str &GameFile) // on win32, game tools path can now be specified relative to the exe's cwd prop = (char*)xmlGetProp( pNode, (xmlChar*)"gametools" ); if ( prop == NULL ) { - Error( "Didn't find 'gametools' node in the game description file '%s'\n", pDoc->URL ); + Error( "Didn't find 'gametools' node in the game description file '%s'\n", pDoc->URL ); } { char full[PATH_MAX]; @@ -784,58 +809,78 @@ CGameDescription::CGameDescription(xmlDocPtr pDoc, const Str &GameFile) xmlFree(prop); } - // on win32, engine path can now be specified relative to the exe's cwd - prop = (char*)xmlGetProp(pNode, (const xmlChar *)"enginepath"); - if ( prop != NULL ) { - char full[PATH_MAX]; + + prop = (char*)xmlGetProp(pNode, (const xmlChar*)ENGINE_ATTRIBUTE); + if (prop == NULL) + { #ifdef _WIN32 - _fullpath( full, prop, PATH_MAX ); -#else - strncpy( full, prop, PATH_MAX ); + mEngine = "quake3.exe"; +#elif __linux__ + mEngine = "quake3"; +#elif __APPLE__ + mEngine = "Quake3.app"; #endif - xmlFree( prop ); - prop = NULL; - // process seperators - for ( p = full; *p != '\0'; p++ ) { - if ( *p == '\\' ) { - *p = '/'; - } } - mEnginePath = full; - if ( p != full && *(p-1) != '/' ) { - mEnginePath += "/"; + else + { + mEngine = prop; + xmlFree(prop); } - } - else - { - // if engine path was not specified in the .game, it implies we can guess it from the gametools path - // on win32, and for most game package, the gametools are installed with the game - char aux_path[PATH_MAX]; // aux - strcpy( aux_path, mGameToolsPath.GetBuffer() ); - if ( ( aux_path[ strlen(aux_path)-1 ] == '/' ) || ( aux_path[ strlen(aux_path)-1 ] == '\\' ) ) { - aux_path[strlen(aux_path)-1] = '\0'; // strip ending '/' if any - } - char up_path[PATH_MAX]; // up one level - ExtractFilePath( aux_path, up_path ); - mEnginePath = up_path; - } - prop = (char*)xmlGetProp(pNode, (xmlChar*)"engine"); - if (prop == NULL) - { + prop = (char*)xmlGetProp(pNode, (const xmlChar*)MP_ENGINE_ATTRIBUTE); + if (prop == NULL) + { #ifdef _WIN32 - mEngine = "quake3.exe"; + mMultiplayerEngine = "quake3.exe"; #elif __linux__ - mEngine = "quake3"; + mMultiplayerEngine = "quake3"; #elif __APPLE__ - mEngine = "Quake3.app"; + mMultiplayerEngine = "Quake3.app"; #endif - } - else - { - mEngine = prop; - xmlFree(prop); - } + } + else + { + mMultiplayerEngine = prop; + xmlFree(prop); + } + + { + // on win32, engine path can now be specified relative to the exe's cwd + prop = (char*)xmlGetProp(pNode, (const xmlChar *)ENGINEPATH_ATTRIBUTE); + if ( prop != NULL ) { + char full[PATH_MAX]; + #ifdef _WIN32 + _fullpath( full, prop, PATH_MAX ); + #else + strncpy( full, prop, PATH_MAX ); + #endif + xmlFree( prop ); + prop = NULL; + // process seperators + for ( p = full; *p != '\0'; p++ ) { + if ( *p == '\\' ) { + *p = '/'; + } + } + mEnginePath = full; + if ( p != full && *(p-1) != '/' ) { + mEnginePath += "/"; + } + } + else + { + // if engine path was not specified in the .game, it implies we can guess it from the gametools path + // on win32, and for most game package, the gametools are installed with the game + char aux_path[PATH_MAX]; // aux + strcpy( aux_path, mGameToolsPath.GetBuffer() ); + if ( ( aux_path[ strlen(aux_path)-1 ] == '/' ) || ( aux_path[ strlen(aux_path)-1 ] == '\\' ) ) { + aux_path[strlen(aux_path)-1] = '\0'; // strip ending '/' if any + } + char up_path[PATH_MAX]; // up one level + ExtractFilePath( aux_path, up_path ); + mEnginePath = up_path; + } + } #if defined (__linux__) || defined (__APPLE__) // *nix specific @@ -2884,7 +2929,7 @@ void PrefsDlg::LoadPrefs () // Texture subset on by default (HL specific really, because of halflife.wad's size) mLocalPrefs.GetPref(TEXTURE_KEY, &m_bTextureWindow, TRUE); } - else if (g_pGameDescription->quake2 || ( g_pGameDescription->mGameFile == "q2.game" ) || ( g_pGameDescription->mGameFile == "heretic2.game" )) + else if (g_pGameDescription->quake2) { // BSP monitoring is implemented in Quake2 and Heretic2 tools mLocalPrefs.GetPref(WATCHBSP_KEY, &m_bWatchBSP, TRUE); @@ -3327,7 +3372,7 @@ void CGameInstall::Run() { } fprintf( fg, "\nquake2 ) || ( g_pGameDescription->mGameFile == "q2.game" ) || ( g_pGameDescription->mGameFile == "heretic2.game" ) ) + if (g_pGameDescription->quake2) b_isQuake2 = true; else b_isQuake2 = false; if (!texdef_face_list) return; - + if (b_SetUndoPoint) { if(g_ptrSelectedFaces.GetSize() > 1) @@ -190,42 +190,42 @@ void SI_SetTexdef_FaceList(texdef_to_face_t* texdef_face_list, bool b_SetUndoPoi SetFaceTexdef(texdef_to_face->face, &texdef_to_face->orig_texdef, NULL); Undo_Start("set facelist texdefs"); - + if( selected_brushes.next != &selected_brushes ) - Undo_AddBrushList(&selected_brushes); + Undo_AddBrushList(&selected_brushes); else Undo_AddBrush(texdef_face_list->brush); - + } - } - + } + for(texdef_to_face = texdef_face_list; texdef_to_face; texdef_to_face = texdef_to_face->next) { if (b_isQuake2) SetFaceTexdef_Q2(texdef_to_face->face, &texdef_to_face->texdef, bFit_to_Scale); else SetFaceTexdef(texdef_to_face->face, &texdef_to_face->texdef, NULL , bFit_to_Scale); - Brush_Build(texdef_to_face->brush); + Brush_Build(texdef_to_face->brush); if(bFit_to_Scale) texdef_to_face->texdef = texdef_to_face->face->texdef; } - + if ( b_SetUndoPoint ) { if( (selected_brushes.next != &selected_brushes) || (g_ptrSelectedFaces.GetSize() == 1) ) { if(selected_brushes.next != &selected_brushes) - Undo_EndBrushList(&selected_brushes); + Undo_EndBrushList(&selected_brushes); else Undo_EndBrush(texdef_face_list->brush); - + Undo_End(); // Over-write the orig_texdef list, cementing the change. for(texdef_to_face = texdef_face_list; texdef_to_face; texdef_to_face = texdef_to_face->next) texdef_to_face->orig_texdef = texdef_to_face->texdef; } } - + Sys_UpdateWindows (W_ALL); } @@ -239,7 +239,7 @@ void SI_FaceList_FitTexture(texdef_to_face_t* si_texdef_face_list, int nHeight, for (temp_texdef_face_list = si_texdef_face_list; temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next) { Face_FitTexture(temp_texdef_face_list->face, nHeight, nWidth); - Brush_Build(temp_texdef_face_list->brush,true,true,false,false); + Brush_Build(temp_texdef_face_list->brush,true,true,false,false); // Write changes to our working Texdef list temp_texdef_face_list->texdef = temp_texdef_face_list->face->texdef; } diff --git a/radiant/watchbsp.cpp b/radiant/watchbsp.cpp index 2c85e57a..1339490d 100644 --- a/radiant/watchbsp.cpp +++ b/radiant/watchbsp.cpp @@ -2,30 +2,30 @@ Copyright (c) 2001, Loki software, inc. All rights reserved. -Redistribution and use in source and binary forms, with or without modification, +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -Redistributions of source code must retain the above copyright notice, this list +Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -Neither the name of Loki software nor the names of its contributors may be used -to endorse or promote products derived from this software without specific prior -written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY -DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +Neither the name of Loki software nor the names of its contributors may be used +to endorse or promote products derived from this software without specific prior +written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ //----------------------------------------------------------------------------- @@ -68,7 +68,7 @@ static void abortStream(message_info_t *data) #include "stream_version.h" -static void saxStartElement(message_info_t *data, const xmlChar *name, const xmlChar **attrs) +static void saxStartElement(message_info_t *data, const xmlChar *name, const xmlChar **attrs) { if (data->ignore_depth == 0) { @@ -93,7 +93,7 @@ static void saxStartElement(message_info_t *data, const xmlChar *name, const xml } else if (strcmp((char*)attrs[1],Q3MAP_STREAM_VERSION) != 0) { - Sys_FPrintf(SYS_ERR, + Sys_FPrintf(SYS_ERR, "This version of Radiant reads version %s debug streams, I got an incoming connection with version %s\n" "Please make sure your versions of Radiant and q3map are matching.\n", Q3MAP_STREAM_VERSION, (char*)attrs[1]); abortStream(data); @@ -105,7 +105,7 @@ static void saxStartElement(message_info_t *data, const xmlChar *name, const xml { data->msg_level = atoi ((char *)attrs[1]); } - else if (strcmp ((char *)name, "polyline") == 0) + else if (strcmp ((char *)name, "polyline") == 0) // polyline has a particular status .. right now we only use it for leakfile .. { data->bGeometry = true; @@ -205,7 +205,7 @@ static void saxWarning(void *ctx, const char *msg, ...) { char saxMsgBuffer[4096]; va_list args; - + va_start(args, msg); vsprintf (saxMsgBuffer, msg, args); va_end(args); @@ -216,7 +216,7 @@ static void saxError(void *ctx, const char *msg, ...) { char saxMsgBuffer[4096]; va_list args; - + va_start(args, msg); vsprintf (saxMsgBuffer, msg, args); va_end(args); @@ -226,9 +226,9 @@ static void saxError(void *ctx, const char *msg, ...) static void saxFatal(void *ctx, const char *msg, ...) { char buffer[4096]; - + va_list args; - + va_start(args, msg); vsprintf (buffer, msg, args); va_end(args); @@ -390,7 +390,7 @@ void CWatchBSP::RoutineProcessing() { Sys_Printf("Connected.\n"); // prepare the message info struct for diving in - memset (&m_message_info, 0, sizeof(message_info_s)); + memset (&m_message_info, 0, sizeof(message_info_s)); // a dumb flag to make sure we init the push parser context when first getting a msg m_bNeedCtxtInit = true; m_eState = EWatching; @@ -503,173 +503,23 @@ void CWatchBSP::RoutineProcessing() // build the command line cmd = g_pGameDescription->mEnginePath.GetBuffer(); // this is game dependant - //!\todo Read the engine binary name from a config file. - if (g_pGameDescription->mGameFile == "wolf.game") + if (!strcmp(ValueForKey(g_qeglobals.d_project_entity, "gamemode"),"mp")) { - if (!strcmp(ValueForKey(g_qeglobals.d_project_entity, "gamemode"),"mp")) - { - // MP -#if defined(WIN32) - cmd += "WolfMP.exe"; -#elif defined(__linux__) - cmd += "wolfmp"; -#elif defined(__APPLE__) - cmd += "wolfmp.app"; -#else -#error "WTF are you compiling on" -#endif - } - else - { - // SP -#if defined(WIN32) - cmd += "WolfSP.exe"; -#elif defined(__linux__) - cmd += "wolfsp"; -#elif defined(__APPLE__) - cmd += "wolfsp.app"; -#else -#error "WTF are you compiling on" -#endif - } - } else if (g_pGameDescription->mGameFile == "et.game") - { -#if defined(WIN32) - cmd += "et.exe"; -#elif defined(__linux__) - cmd += "et"; -#elif defined(__APPLE__) - cmd += "et.app"; -#else -#error "WTF are you compiling on" -#endif - } - // RIANT - // JK2 HACK - else if (g_pGameDescription->mGameFile == "jk2.game") - { - if (!strcmp(ValueForKey(g_qeglobals.d_project_entity, "gamemode"),"mp")) - { - // MP -#if defined(WIN32) - cmd += "jk2MP.exe"; -#elif defined(__linux__) - cmd += "jk2mp"; -#elif defined(__APPLE__) - cmd += "jk2mp.app"; -#else -#error "WTF are you compiling on" -#endif - } - else - { - // SP -#if defined(WIN32) - cmd += "jk2SP.exe"; -#elif defined(__linux__) - cmd += "jk2sp"; -#elif defined(__APPLE__) - cmd += "jk2sp.app"; -#else -#error "WTF are you compiling on" -#endif - } - } - // TTimo - // JA HACK - else if (g_pGameDescription->mGameFile == "ja.game") - { - if (!strcmp(ValueForKey(g_qeglobals.d_project_entity, "gamemode"),"mp")) - { - // MP -#if defined(WIN32) - cmd += "jamp.exe"; -#elif !defined(__linux__) && !defined(__APPLE__) -#error "WTF are you compiling on" -#endif - } - else - { - // SP -#if defined(WIN32) - cmd += "jasp.exe"; -#elif !defined(__linux__) && !defined(__APPLE__) -#error "WTF are you compiling on" -#endif - } - } - // RIANT - // STVEF HACK - else if (g_pGameDescription->mGameFile == "stvef.game") - { - if (!strcmp(ValueForKey(g_qeglobals.d_project_entity, "gamemode"),"mp")) - { - // MP -#if defined(WIN32) - cmd += "stvoyHM.exe"; -#elif defined(__linux__) - cmd += "stvoyHM"; -#elif defined(__APPLE__) - cmd += "stvoyHM.app"; -#else -#error "WTF are you compiling on" -#endif - } - else - { - // SP -#if defined(WIN32) - cmd += "stvoy.exe"; -#elif defined(__linux__) - cmd += "stvoy"; -#elif defined(__APPLE__) - cmd += "stvoy.app"; -#else -#error "WTF are you compiling on" -#endif - } - } - // RIANT - // SOF2 HACK - else if (g_pGameDescription->mGameFile == "sof2.game") - { - if (!strcmp(ValueForKey(g_qeglobals.d_project_entity, "gamemode"),"mp")) - { - // MP -#if defined(WIN32) - cmd += "sof2MP.exe"; -#elif defined(__linux__) - cmd += "b00gus"; -#elif defined(__APPLE__) - cmd += "sof2MP.app"; -#else -#error "WTF are you compiling on" -#endif - } - else - { - // SP -#if defined(WIN32) - cmd += "sof2.exe"; -#elif defined(__linux__) - cmd += "b00gus"; -#elif defined(__APPLE__) - cmd += "sof2.app"; -#else -#error "WTF are you compiling on" -#endif - } + // MP + cmd += g_pGameDescription->mMultiplayerEngine.GetBuffer(); } else { + // SP cmd += g_pGameDescription->mEngine.GetBuffer(); } #ifdef _WIN32 // NOTE: we are using unix pathnames and CreateProcess doesn't like / in the program path + // FIXME: This isn't true anymore, doesn't it? FindReplace( cmd, "/", "\\" ); #endif Str cmdline; - if ( (g_pGameDescription->mGameFile == "q2.game") || (g_pGameDescription->mGameFile == "heretic2.game") ) + if ( g_pGameDescription->quake2 ) { cmdline = ". +exec radiant.cfg +map "; cmdline += m_sBSPName; @@ -696,7 +546,7 @@ void CWatchBSP::RoutineProcessing() } else { - // SP + // SP cmdline += "+set nextmap \"spdevmap "; cmdline += m_sBSPName; cmdline += "\""; @@ -742,7 +592,7 @@ void CWatchBSP::DoMonitoringLoop( GPtrArray *pCmd, char *sBSPName ) { Sys_Printf("WatchBSP got a monitoring request while not idling...\n"); // prompt the user, should we cancel the current process and go ahead? - if (gtk_MessageBox(g_pParentWnd->m_pWidget, "I am already monitoring a BSP process.\nDo you want me to override and start a new compilation?", + if (gtk_MessageBox(g_pParentWnd->m_pWidget, "I am already monitoring a BSP process.\nDo you want me to override and start a new compilation?", "BSP process monitoring", MB_YESNO ) == IDYES) { // disconnect and set EIdle state -- 2.39.2