diff --git a/contrib/bobtoolz/DBrush.cpp b/contrib/bobtoolz/DBrush.cpp index 4a2b9c09..89d80bbb 100644 --- a/contrib/bobtoolz/DBrush.cpp +++ b/contrib/bobtoolz/DBrush.cpp @@ -23,10 +23,6 @@ #include "DBrush.h" -#ifdef WIN32 -#pragma warning(disable : 4786) -#endif - #include #include "str.h" @@ -284,8 +280,12 @@ bool DBrush::BBoxCollision( DBrush* chkBrush ){ vec3_t min1, min2; vec3_t max1, max2; - GetBounds( min1, max1 ); - chkBrush->GetBounds( min2, max2 ); + if( !GetBounds( min1, max1 ) ){ + return false; + } + if( !chkBrush->GetBounds( min2, max2 ) ){ + return false; + } if ( min1[0] >= max2[0] ) { return false; @@ -558,8 +558,12 @@ bool DBrush::BBoxTouch( DBrush *chkBrush ){ vec3_t min1, min2; vec3_t max1, max2; - GetBounds( min1, max1 ); - chkBrush->GetBounds( min2, max2 ); + if( !GetBounds( min1, max1 ) ){ + return false; + } + if( !chkBrush->GetBounds( min2, max2 ) ){ + return false; + } if ( ( min1[0] - max2[0] ) > MAX_ROUND_ERROR ) { return false; @@ -726,7 +730,9 @@ void DBrush::Rotate( vec3_t vOrigin, vec3_t vRotation ){ void DBrush::RotateAboutCentre( vec3_t vRotation ){ vec3_t min, max, centre; - GetBounds( min, max ); + if( !GetBounds( min, max ) ){ + return; + } VectorAdd( min, max, centre ); VectorScale( centre, 0.5f, centre ); diff --git a/contrib/bobtoolz/DEntity.cpp b/contrib/bobtoolz/DEntity.cpp index 38ab47f4..77989327 100644 --- a/contrib/bobtoolz/DEntity.cpp +++ b/contrib/bobtoolz/DEntity.cpp @@ -23,10 +23,6 @@ #include "DEntity.h" -#ifdef WIN32 -#pragma warning(disable : 4786) -#endif - #include #include "str.h" diff --git a/contrib/bobtoolz/DMap.cpp b/contrib/bobtoolz/DMap.cpp index 72356946..18edc3b1 100644 --- a/contrib/bobtoolz/DMap.cpp +++ b/contrib/bobtoolz/DMap.cpp @@ -58,7 +58,7 @@ DMap::~DMap(){ ClearEntities(); } -DEntity* DMap::AddEntity( char *classname, int ID ){ +DEntity* DMap::AddEntity( const char *classname, int ID ){ DEntity* newEntity; if ( ID == -1 ) { newEntity = new DEntity( classname, m_nNextEntity++ ); diff --git a/contrib/bobtoolz/DMap.h b/contrib/bobtoolz/DMap.h index b4a3f79b..f527d04d 100644 --- a/contrib/bobtoolz/DMap.h +++ b/contrib/bobtoolz/DMap.h @@ -45,7 +45,7 @@ DEntity* GetWorldSpawn(); void ClearEntities(); DEntity* GetEntityForID( int ID ); -DEntity* AddEntity( char* classname = "worldspawn", int ID = -1 ); +DEntity* AddEntity( const char* classname = "worldspawn", int ID = -1 ); std::list entityList; diff --git a/contrib/bobtoolz/DPatch.cpp b/contrib/bobtoolz/DPatch.cpp index 71bad58a..7abc7001 100644 --- a/contrib/bobtoolz/DPatch.cpp +++ b/contrib/bobtoolz/DPatch.cpp @@ -483,8 +483,6 @@ std::list DPatch::SplitRows(){ std::list DPatch::Split(){ std::list patchList; - int i; - int x, y; if ( height >= 5 ) { std::list patchColList = SplitCols(); diff --git a/contrib/bobtoolz/bobToolz-GTK.cpp b/contrib/bobtoolz/bobToolz-GTK.cpp index e11a6427..7ef3a727 100644 --- a/contrib/bobtoolz/bobToolz-GTK.cpp +++ b/contrib/bobtoolz/bobToolz-GTK.cpp @@ -59,10 +59,10 @@ void BobToolz_destroy(){ } // plugin name -char* PLUGIN_NAME = "bobToolz"; +const char* PLUGIN_NAME = "bobToolz"; // commands in the menu -static char* PLUGIN_COMMANDS = "About...,-,Reset Textures...,PitOMatic,-,Vis Viewer,Brush Cleanup,Polygon Builder,Caulk Selection,-,Tree Planter,Drop Entity,Plot Splines,-,Merge Patches,Split patches,Split patches cols,Split patches rows,Turn edge"; +static const char* PLUGIN_COMMANDS = "About...,-,Reset Textures...,PitOMatic,-,Vis Viewer,Brush Cleanup,Polygon Builder,Caulk Selection,-,Tree Planter,Drop Entity,Plot Splines,-,Merge Patches,Split patches,Split patches cols,Split patches rows,Turn edge"; // globals GtkWidget *g_pRadiantWnd = NULL; @@ -286,10 +286,10 @@ class BobToolzPluginDependencies : public: BobToolzPluginDependencies() : GlobalEntityModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "entities" ) ), + GlobalEntityClassManagerModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "entityclass" ) ), GlobalShadersModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "shaders" ) ), GlobalBrushModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "brushtypes" ) ), - GlobalPatchModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "patchtypes" ) ), - GlobalEntityClassManagerModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "entityclass" ) ){ + GlobalPatchModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "patchtypes" ) ){ } }; diff --git a/contrib/bobtoolz/dialogs/dialogs-gtk.cpp b/contrib/bobtoolz/dialogs/dialogs-gtk.cpp index a4a08b7a..e4a37cad 100644 --- a/contrib/bobtoolz/dialogs/dialogs-gtk.cpp +++ b/contrib/bobtoolz/dialogs/dialogs-gtk.cpp @@ -117,7 +117,7 @@ static void dialog_button_callback_settex( GtkWidget *widget, gpointer data ){ Data validation Routines ---------------------------------*/ -bool ValidateTextFloat( const char* pData, char* error_title, float* value ){ +bool ValidateTextFloat( const char* pData, const char* error_title, float* value ){ if ( pData ) { float testNum = (float)atof( pData ); @@ -136,7 +136,7 @@ bool ValidateTextFloat( const char* pData, char* error_title, float* value ){ return FALSE; } -bool ValidateTextFloatRange( const char* pData, float min, float max, char* error_title, float* value ){ +bool ValidateTextFloatRange( const char* pData, float min, float max, const char* error_title, float* value ){ char error_buffer[256]; sprintf( error_buffer, "Please Enter A Floating Point Number Between %.3f and %.3f", min, max ); @@ -158,7 +158,7 @@ bool ValidateTextFloatRange( const char* pData, float min, float max, char* erro return FALSE; } -bool ValidateTextIntRange( const char* pData, int min, int max, char* error_title, int* value ){ +bool ValidateTextIntRange( const char* pData, int min, int max, const char* error_title, int* value ){ char error_buffer[256]; sprintf( error_buffer, "Please Enter An Integer Between %i and %i", min, max ); @@ -180,7 +180,7 @@ bool ValidateTextIntRange( const char* pData, int min, int max, char* error_titl return FALSE; } -bool ValidateTextInt( const char* pData, char* error_title, int* value ){ +bool ValidateTextInt( const char* pData, const char* error_title, int* value ){ if ( pData ) { int testNum = atoi( pData ); @@ -603,7 +603,7 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ EMessageBoxReturn ret; int loop = 1; - char *text = "Please set a value in the boxes below and press 'OK' to build the stairs"; + const char *text = "Please set a value in the boxes below and press 'OK' to build the stairs"; window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); @@ -1917,7 +1917,7 @@ EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){ EMessageBoxReturn ret; int loop = 1; - char *text = "Please set a value in the boxes below and press 'OK' to make a chain"; + const char *text = "Please set a value in the boxes below and press 'OK' to make a chain"; window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); diff --git a/contrib/bobtoolz/funchandlers-GTK.cpp b/contrib/bobtoolz/funchandlers-GTK.cpp index d6625365..84a6dda4 100644 --- a/contrib/bobtoolz/funchandlers-GTK.cpp +++ b/contrib/bobtoolz/funchandlers-GTK.cpp @@ -19,10 +19,6 @@ #include "funchandlers.h" -#ifdef WIN32 -#pragma warning(disable : 4786) -#endif - #include "dialogs/dialogs-gtk.h" #include diff --git a/contrib/bobtoolz/lists.cpp b/contrib/bobtoolz/lists.cpp index 81079839..4819b662 100644 --- a/contrib/bobtoolz/lists.cpp +++ b/contrib/bobtoolz/lists.cpp @@ -19,10 +19,6 @@ #include "lists.h" -#ifdef WIN32 -#pragma warning(disable : 4786) -#endif - #include #include "misc.h" diff --git a/contrib/bobtoolz/misc.cpp b/contrib/bobtoolz/misc.cpp index 977879f5..3480efb5 100644 --- a/contrib/bobtoolz/misc.cpp +++ b/contrib/bobtoolz/misc.cpp @@ -129,7 +129,7 @@ char* TranslateString( char *buf ){ std::size_t l = strlen( buf ); char* out = buf2; - for ( int i = 0 ; i < l ; i++ ) + for ( std::size_t i = 0 ; i < l ; i++ ) { if ( buf[i] == '\n' ) { *out++ = '\r'; @@ -182,60 +182,7 @@ extern char* PLUGIN_NAME; return buffer; }*/ -#if defined ( POSIX ) -// the bCreateConsole parameter is ignored on linux .. -bool Q_Exec( const char *pCmd, bool bCreateConsole ){ - switch ( fork() ) - { - case -1: - return false; -// Error ("CreateProcess failed"); - break; - case 0: -#ifdef _DEBUG - printf( "Running system...\n" ); - printf( "Command: %s\n", pCmd ); -#endif - // NOTE: we could use that to detect when a step finishes. But then it - // would not work for remote compiling stuff. -// execlp (pCmd, pCmd, NULL); - system( pCmd ); - printf( "system() returned" ); - _exit( 0 ); - break; - } - return true; -} -#endif - -#ifdef WIN32 - -#include - -bool Q_Exec( const char *pCmd, bool bCreateConsole ){ - // G_DeWan: Don't know if this is needed for linux version - - PROCESS_INFORMATION pi; - STARTUPINFO si = {0}; // Initialize all members to zero - si.cb = sizeof( STARTUPINFO ); // Set byte count - DWORD dwCreationFlags; - - if ( bCreateConsole ) { - dwCreationFlags = CREATE_NEW_CONSOLE | NORMAL_PRIORITY_CLASS; - } - else{ - dwCreationFlags = DETACHED_PROCESS | NORMAL_PRIORITY_CLASS; - } - - for (; *pCmd == ' '; pCmd++ ) ; - - if ( !CreateProcess( NULL, (char *)pCmd, NULL, NULL, false, dwCreationFlags, NULL, NULL, &si, &pi ) ) { - return false; - } - - return true; -} -#endif +#include "cmdlib.h" void StartBSP(){ char exename[256]; @@ -252,7 +199,7 @@ void StartBSP(){ char command[1024]; sprintf( command, "%s -nowater -fulldetail %s", exename, mapname ); - Q_Exec( command, true ); + Q_Exec( NULL, command, NULL, false, true ); } class EntityWriteMiniPrt diff --git a/contrib/bobtoolz/shapes.cpp b/contrib/bobtoolz/shapes.cpp index f466c515..04746469 100644 --- a/contrib/bobtoolz/shapes.cpp +++ b/contrib/bobtoolz/shapes.cpp @@ -58,10 +58,10 @@ / | / | / | / | 4 ----- 6 | - | 2|_|___|8 - | / | / - | / | / ----> WEST, definitely - ||/ | / + | 2|_|___|8 + | / | / + | / | / ----> WEST, definitely + ||/ | / 1|_____|/3 */ diff --git a/contrib/prtview/portals.cpp b/contrib/prtview/portals.cpp index a896fcd4..9bc7c41e 100644 --- a/contrib/prtview/portals.cpp +++ b/contrib/prtview/portals.cpp @@ -37,10 +37,10 @@ CPortalsRender render; int compare( const void *arg1, const void *arg2 ){ - if ( portals.portal[*( (int *)arg1 )].dist > portals.portal[*( (int *)arg2 )].dist ) { + if ( portals.portal[*( (const int *)arg1 )].dist > portals.portal[*( (const int *)arg2 )].dist ) { return -1; } - else if ( portals.portal[*( (int *)arg1 )].dist < portals.portal[*( (int *)arg2 )].dist ) { + else if ( portals.portal[*( (const int *)arg1 )].dist < portals.portal[*( (const int *)arg2 )].dist ) { return 1; } @@ -61,7 +61,7 @@ bool CBspPortal::Build( char *def ){ char *c = def; unsigned int n; int dummy1, dummy2; - int res_cnt, i; + int res_cnt = 0; if ( portals.hint_flags ) { res_cnt = sscanf( def, "%u %d %d %d", &point_count, &dummy1, &dummy2, (int *)&hint ); @@ -96,7 +96,7 @@ bool CBspPortal::Build( char *def ){ center.p[2] += point[n].p[2]; if ( n == 0 ) { - for ( i = 0; i < 3; i++ ) + for ( int i = 0; i < 3; i++ ) { min[i] = point[n].p[i]; max[i] = point[n].p[i]; @@ -104,7 +104,7 @@ bool CBspPortal::Build( char *def ){ } else { - for ( i = 0; i < 3; i++ ) + for ( int i = 0; i < 3; i++ ) { if ( min[i] > point[n].p[i] ) { min[i] = point[n].p[i]; @@ -603,7 +603,7 @@ void CPortalsDrawSolid::render( RenderStateFlags state ) const { } void CPortalsDrawSolidOutline::render( RenderStateFlags state ) const { - for ( int n = 0; n < portals.portal_count; n++ ) + for ( unsigned int n = 0; n < portals.portal_count; n++ ) { if ( portals.lines == 2 && !portals.portal[n].hint ) { continue; @@ -632,7 +632,7 @@ void CPortalsDrawSolidOutline::render( RenderStateFlags state ) const { glBegin( GL_LINE_LOOP ); - for ( int p = 0; p < portals.portal[n].point_count; p++ ) + for ( unsigned int p = 0; p < portals.portal[n].point_count; p++ ) glVertex3fv( portals.portal[n].inner_point[p].p ); glEnd(); diff --git a/contrib/prtview/prtview.cpp b/contrib/prtview/prtview.cpp index 2b3d9c04..7c2a4725 100644 --- a/contrib/prtview/prtview.cpp +++ b/contrib/prtview/prtview.cpp @@ -48,23 +48,23 @@ CopiedString INIfn; ///////////////////////////////////////////////////////////////////////////// // CPrtViewApp construction -#define RENDER_2D "Render2D" -#define WIDTH_2D "Width2D" -#define AA_2D "AntiAlias2D" -#define COLOR_2D "Color2D" +const char RENDER_2D[] = "Render2D"; +const char WIDTH_2D[] = "Width2D"; +const char AA_2D[] = "AntiAlias2D"; +const char COLOR_2D[] = "Color2D"; -#define RENDER_3D "Render3D" -#define WIDTH_3D "Width3D" -#define AA_3D "AntiAlias3D" -#define COLOR_3D "Color3D" -#define COLOR_FOG "ColorFog" -#define FOG "Fog" -#define ZBUFFER "ZBuffer" -#define POLYGON "Polygons" -#define LINE "Lines" -#define TRANS_3D "Transparency" -#define CLIP_RANGE "ClipRange" -#define CLIP "Clip" +const char RENDER_3D[] = "Render3D"; +const char WIDTH_3D[] = "Width3D"; +const char AA_3D[] = "AntiAlias3D"; +const char COLOR_3D[] = "Color3D"; +const char COLOR_FOG[] = "ColorFog"; +const char FOG[] = "Fog"; +const char ZBUFFER[] = "ZBuffer"; +const char POLYGON[] = "Polygons"; +const char LINE[] = "Lines"; +const char TRANS_3D[] = "Transparency"; +const char CLIP_RANGE[] = "ClipRange"; +const char CLIP[] = "Clip"; void PrtView_construct(){ @@ -160,9 +160,9 @@ void SaveConfig(){ } -#define CONFIG_SECTION "Configuration" +const char CONFIG_SECTION[] = "Configuration"; -int INIGetInt( char *key, int def ){ +int INIGetInt( const char *key, int def ){ char value[1024]; if ( read_var( INIfn.c_str(), CONFIG_SECTION, key, value ) ) { @@ -173,7 +173,7 @@ int INIGetInt( char *key, int def ){ } } -void INISetInt( char *key, int val, char *comment /* = NULL */ ){ +void INISetInt( const char *key, int val, const char *comment /* = NULL */ ){ char s[1000]; if ( comment ) { diff --git a/contrib/prtview/prtview.h b/contrib/prtview/prtview.h index 5b3734f5..3dd4e298 100644 --- a/contrib/prtview/prtview.h +++ b/contrib/prtview/prtview.h @@ -25,8 +25,8 @@ void InitInstance(); void SaveConfig(); -int INIGetInt( char *key, int def ); -void INISetInt( char *key, int val, char *comment = 0 ); +int INIGetInt( const char *key, int def ); +void INISetInt( const char *key, int val, const char *comment = 0 ); typedef struct _GtkWidget GtkWidget; extern GtkWidget *g_pRadiantWnd; diff --git a/contrib/shaderplug/shaderplug.cpp b/contrib/shaderplug/shaderplug.cpp index 62e9abe6..0cf2cbd0 100644 --- a/contrib/shaderplug/shaderplug.cpp +++ b/contrib/shaderplug/shaderplug.cpp @@ -118,7 +118,7 @@ void LoadTextureFile( const char* filename ){ typedef FreeCaller1 LoadTextureFileCaller; -void GetTextures( char* extension ){ +void GetTextures( const char* extension ){ GlobalFileSystem().forEachFile( "textures/", extension, LoadTextureFileCaller(), 0 ); } diff --git a/contrib/ufoaiplug/ufoai_gtk.cpp b/contrib/ufoaiplug/ufoai_gtk.cpp index c5470474..e459561b 100644 --- a/contrib/ufoaiplug/ufoai_gtk.cpp +++ b/contrib/ufoaiplug/ufoai_gtk.cpp @@ -36,6 +36,7 @@ UFOAIGtk( void* gtk_window ) : m_gtk_window( ( GtkWindow* )gtk_window ){ } }; +#if 0 /** * @brief If you return FALSE in the "delete_event" signal handler, * GTK will emit the "destroy" signal. Returning TRUE means @@ -60,6 +61,7 @@ static void destroy( GtkWidget *widget, gpointer data ){ static void close_window( GtkWidget *widget, gpointer data ){ gtk_widget_destroy( gtk_widget_get_toplevel( widget ) ); } +#endif /* =============================== */ diff --git a/include/mapfile.h b/include/mapfile.h index df1ab36f..4f5f1a74 100644 --- a/include/mapfile.h +++ b/include/mapfile.h @@ -27,7 +27,13 @@ #include "iscenegraph.h" #include "generic/callbackfwd.h" -const std::size_t MAPFILE_MAX_CHANGES = std::numeric_limits::max(); +#ifdef __GNUC__ +#define VARIABLE_IS_NOT_USED __attribute__ ((unused)) +#else +#define VARIABLE_IS_NOT_USED +#endif + +const std::size_t VARIABLE_IS_NOT_USED MAPFILE_MAX_CHANGES = std::numeric_limits::max(); class MapFile { diff --git a/include/renderable.h b/include/renderable.h index 8b972170..0c0e770b 100644 --- a/include/renderable.h +++ b/include/renderable.h @@ -48,7 +48,7 @@ enum EStyle virtual void PushState() = 0; virtual void PopState() = 0; virtual void SetState( Shader* state, EStyle mode ) = 0; -virtual const EStyle getStyle() const = 0; +virtual EStyle getStyle() const = 0; virtual void Highlight( EHighlightMode mode, bool bEnable = true ) = 0; virtual void setLights( const LightList& lights ){ } diff --git a/libs/cmdlib/cmdlib.cpp b/libs/cmdlib/cmdlib.cpp index 2a9ab55a..8aeba8f4 100644 --- a/libs/cmdlib/cmdlib.cpp +++ b/libs/cmdlib/cmdlib.cpp @@ -92,7 +92,7 @@ bool Q_Exec( const char *cmd, char *cmdline, const char *, bool, bool waitfor ){ // NOTE TTimo windows is VERY nitpicky about the syntax in CreateProcess bool Q_Exec( const char *cmd, char *cmdline, const char *execdir, bool bCreateConsole, bool waitfor ){ PROCESS_INFORMATION ProcessInformation; - STARTUPINFO startupinfo = {0}; + STARTUPINFO startupinfo; DWORD dwCreationFlags; GetStartupInfo( &startupinfo ); if ( bCreateConsole ) { diff --git a/libs/gtkutil/glfont.cpp b/libs/gtkutil/glfont.cpp index 6346ba38..740e5ee4 100644 --- a/libs/gtkutil/glfont.cpp +++ b/libs/gtkutil/glfont.cpp @@ -369,6 +369,17 @@ GLFont *glfont_create( const char* font_string ){ font = gdk_gl_font_use_pango_font( font_desc, 0, 256, font_list_base ); } + if ( font == 0 ) { + pango_font_description_free( font_desc ); + + GtkSettings *settings = gtk_settings_get_default(); + gchar *fontname; + g_object_get( settings, "gtk-font-name", &fontname, NULL ); + + font_desc = pango_font_description_from_string( fontname ); + font = gdk_gl_font_use_pango_font( font_desc, 0, 256, font_list_base ); + } + if ( font != 0 ) { PangoFontMap *fontmap = pango_ft2_font_map_new(); diff --git a/libs/math/aabb.h b/libs/math/aabb.h index 29e3a38e..7d5135af 100644 --- a/libs/math/aabb.h +++ b/libs/math/aabb.h @@ -245,7 +245,13 @@ inline void aabb_planes_oriented( const AABB& aabb, const Matrix4& rotation, Pla planes[5] = Plane3( -vector4_to_vector3( rotation.z() ), -( z - aabb.extents[2] ) ); } -const Vector3 aabb_normals[6] = { +#ifdef __GNUC__ +#define VARIABLE_IS_NOT_USED __attribute__ ((unused)) +#else +#define VARIABLE_IS_NOT_USED +#endif + +const Vector3 VARIABLE_IS_NOT_USED aabb_normals[6] = { Vector3( 1, 0, 0 ), Vector3( 0, 1, 0 ), Vector3( 0, 0, 1 ), diff --git a/libs/math/vector.h b/libs/math/vector.h index 9ec5159f..e5e7f0be 100644 --- a/libs/math/vector.h +++ b/libs/math/vector.h @@ -279,7 +279,13 @@ const Vector3 g_vector3_axis_x( 1, 0, 0 ); const Vector3 g_vector3_axis_y( 0, 1, 0 ); const Vector3 g_vector3_axis_z( 0, 0, 1 ); -const Vector3 g_vector3_axes[3] = { g_vector3_axis_x, g_vector3_axis_y, g_vector3_axis_z }; +#ifdef __GNUC__ +#define VARIABLE_IS_NOT_USED __attribute__ ((unused)) +#else +#define VARIABLE_IS_NOT_USED +#endif + +const Vector3 VARIABLE_IS_NOT_USED g_vector3_axes[3] = { g_vector3_axis_x, g_vector3_axis_y, g_vector3_axis_z }; template inline void vector3_swap( BasicVector3& self, BasicVector3& other ){ diff --git a/libs/picomodel/lwo/lwio.c b/libs/picomodel/lwo/lwio.c index 0964273e..82274256 100644 --- a/libs/picomodel/lwo/lwio.c +++ b/libs/picomodel/lwo/lwio.c @@ -22,7 +22,9 @@ read requests until flen is reset. ====================================================================== */ -#define INT_MIN ( -2147483647 - 1 ) /* minimum (signed) int value */ +#ifndef INT_MIN + #define INT_MIN ( -2147483647 - 1 ) /* minimum (signed) int value */ +#endif #define FLEN_ERROR INT_MIN static int flen; diff --git a/libs/picomodel/lwo/lwo2.c b/libs/picomodel/lwo/lwo2.c index 1bbc7a36..cfa31132 100644 --- a/libs/picomodel/lwo/lwo2.c +++ b/libs/picomodel/lwo/lwo2.c @@ -11,7 +11,7 @@ #include "lwo2.h" /* disable warnings */ -#ifdef WIN32 +#ifdef _MSC_VER #pragma warning( disable:4018 ) /* signed/unsigned mismatch */ #endif diff --git a/libs/picomodel/lwo/lwob.c b/libs/picomodel/lwo/lwob.c index e0256c09..7db04399 100644 --- a/libs/picomodel/lwo/lwob.c +++ b/libs/picomodel/lwo/lwob.c @@ -12,7 +12,7 @@ #include "lwo2.h" /* disable warnings */ -#ifdef WIN32 +#ifdef _MSC_VER #pragma warning( disable:4018 ) /* signed/unsigned mismatch */ #endif diff --git a/libs/picomodel/pm_ms3d.c b/libs/picomodel/pm_ms3d.c index 535b7e22..ce1903b4 100644 --- a/libs/picomodel/pm_ms3d.c +++ b/libs/picomodel/pm_ms3d.c @@ -41,7 +41,7 @@ #include "picointernal.h" /* disable warnings */ -#ifdef WIN32 +#ifdef _MSC_VER #pragma warning( disable:4100 ) /* unref param */ #endif diff --git a/libs/picomodel/pm_obj.c b/libs/picomodel/pm_obj.c index 49d0fe84..4549c3c3 100644 --- a/libs/picomodel/pm_obj.c +++ b/libs/picomodel/pm_obj.c @@ -41,7 +41,7 @@ #include "picointernal.h" /* disable warnings */ -#ifdef WIN32 +#ifdef _MSC_VER #pragma warning( disable:4100 ) /* unref param */ #endif @@ -508,7 +508,7 @@ static picoModel_t *_obj_load( PM_PARAMS_LOAD ){ picoModel_t *model; picoSurface_t *curSurface = NULL; picoParser_t *p; - int allocated; + int allocated = 0; int entries; int numVerts = 0; int numNormals = 0; diff --git a/libs/profile/file.cpp b/libs/profile/file.cpp index ec230964..f8fb6699 100644 --- a/libs/profile/file.cpp +++ b/libs/profile/file.cpp @@ -175,7 +175,7 @@ MemStream::size_type MemStream::write( const byte_type* buffer, size_type length GrowFile( m_nPosition + length ); } - memcpy( (unsigned char*)m_pBuffer + m_nPosition, (unsigned char*)buffer, length ); + memcpy( (unsigned char*)m_pBuffer + m_nPosition, (const unsigned char*)buffer, length ); m_nPosition += size_type( length ); @@ -271,7 +271,7 @@ int MemStream::Seek( offset_type lOff, int nFrom ){ lNewPos = m_nFileSize + lOff; } else{ - return ( position_type ) - 1; + return -1; } m_nPosition = lNewPos; diff --git a/libs/profile/profile.cpp b/libs/profile/profile.cpp index 71d2ae1b..c1505e07 100644 --- a/libs/profile/profile.cpp +++ b/libs/profile/profile.cpp @@ -252,7 +252,7 @@ bool profile_load_buffer( const char * rc_path, const char *name, void *buffer, fclose( f ); } - return true; + return ret; } int profile_load_int( const char *filename, const char *section, const char *key, int default_value ){ diff --git a/libs/render.h b/libs/render.h index 6bc9410c..b2e6c5e9 100644 --- a/libs/render.h +++ b/libs/render.h @@ -171,7 +171,7 @@ RenderIndex m_prev0; RenderIndex m_prev1; RenderIndex m_prev2; -const RenderIndex find_or_insert( const Vertex& vertex ){ +RenderIndex find_or_insert( const Vertex& vertex ){ RenderIndex index = 0; while ( 1 ) diff --git a/libs/str.h b/libs/str.h index 9090bf2d..6996e64b 100644 --- a/libs/str.h +++ b/libs/str.h @@ -254,7 +254,7 @@ const char* Left( std::size_t n ){ } else { - g_pStrWork = ""; + //g_pStrWork = ""; g_pStrWork = new char[1]; g_pStrWork[0] = '\0'; } @@ -290,7 +290,7 @@ const char* Mid( std::size_t first, std::size_t n ) const { } else { - g_pStrWork = ""; + //g_pStrWork = ""; g_pStrWork = new char[1]; g_pStrWork[0] = '\0'; } @@ -429,7 +429,7 @@ bool operator >( char* pStr ) const { return ( m_bIgnoreCase ) ? stricmp( m_pStr bool operator >( const char* pStr ) const { return ( m_bIgnoreCase ) ? stricmp( m_pStr, pStr ) > 0 : strcmp( m_pStr, pStr ) > 0; } char& operator []( std::size_t nIndex ) { return m_pStr[nIndex]; } const char& operator []( std::size_t nIndex ) const { return m_pStr[nIndex]; } -const char GetAt( std::size_t nIndex ) { return m_pStr[nIndex]; } +char GetAt( std::size_t nIndex ) { return m_pStr[nIndex]; } }; diff --git a/libs/xml/xmlparser.h b/libs/xml/xmlparser.h index b11d355b..1c1bdb01 100644 --- a/libs/xml/xmlparser.h +++ b/libs/xml/xmlparser.h @@ -187,7 +187,7 @@ XMLStreamParser( TextInputStream& istream ) : m_istream( istream ){ } virtual void exportXML( XMLImporter& importer ){ - bool wellFormed = false; + //bool wellFormed = false; char chars[BUFSIZE]; std::size_t res = m_istream.read( chars, 4 ); @@ -203,7 +203,7 @@ virtual void exportXML( XMLImporter& importer ){ } xmlParseChunk( ctxt, chars, 0, 1 ); - wellFormed = ( ctxt->wellFormed == 1 ); + //wellFormed = ( ctxt->wellFormed == 1 ); xmlFreeParserCtxt( ctxt ); } diff --git a/libs/xml/xmltextags.cpp b/libs/xml/xmltextags.cpp index c9d2b06b..b9985737 100644 --- a/libs/xml/xmltextags.cpp +++ b/libs/xml/xmltextags.cpp @@ -49,16 +49,16 @@ bool XmlTagBuilder::CreateXmlDocument(){ xmlTextWriterStartDocument( writer, NULL, "UTF-8", NULL ); // create the root node with stock and custom elements - xmlTextWriterStartElement( writer, (xmlChar*)"root" ); - xmlTextWriterWriteString( writer, (xmlChar*)"\n " ); - xmlTextWriterStartElement( writer, (xmlChar*)"stock" ); - xmlTextWriterWriteString( writer, (xmlChar*)"\n " ); + xmlTextWriterStartElement( writer, (const xmlChar*)"root" ); + xmlTextWriterWriteString( writer, (const xmlChar*)"\n " ); + xmlTextWriterStartElement( writer, (const xmlChar*)"stock" ); + xmlTextWriterWriteString( writer, (const xmlChar*)"\n " ); xmlTextWriterEndElement( writer ); - xmlTextWriterWriteString( writer, (xmlChar*)"\n " ); - xmlTextWriterStartElement( writer, (xmlChar*)"custom" ); - xmlTextWriterWriteString( writer, (xmlChar*)"\n " ); + xmlTextWriterWriteString( writer, (const xmlChar*)"\n " ); + xmlTextWriterStartElement( writer, (const xmlChar*)"custom" ); + xmlTextWriterWriteString( writer, (const xmlChar*)"\n " ); xmlTextWriterEndElement( writer ); - xmlTextWriterWriteString( writer, (xmlChar*)"\n" ); + xmlTextWriterWriteString( writer, (const xmlChar*)"\n" ); xmlTextWriterEndElement( writer ); // end of the xml document @@ -151,26 +151,28 @@ bool XmlTagBuilder::AddShaderNode( const char* shader, TextureType textureType, switch ( nodeShaderType ) { case SHADER: - newnode = xmlNewNode( NULL, (xmlChar*)"shader" ); + newnode = xmlNewNode( NULL, (const xmlChar*)"shader" ); break; case TEXTURE: - newnode = xmlNewNode( NULL, (xmlChar*)"texture" ); + default: + newnode = xmlNewNode( NULL, (const xmlChar*)"texture" ); + break; }; newnode = xmlDocCopyNode( newnode, doc, 1 ); - xmlSetProp( newnode, (xmlChar*)"path", (xmlChar*)shader ); - xmlNodeSetContent( newnode, (xmlChar*)"\n " ); + xmlSetProp( newnode, (const xmlChar*)"path", (const xmlChar*)shader ); + xmlNodeSetContent( newnode, (const xmlChar*)"\n " ); if ( nodePtr->nodeTab[0]->children->next == NULL ) { // there are no shaders yet // add spaces - newtext = xmlNewText( (xmlChar*)" " ); + newtext = xmlNewText( (const xmlChar*)" " ); xmlAddChild( nodeParent->children, newtext ); // add the new node xmlAddNextSibling( nodeParent->children, newnode ); // append a new line - newtext = xmlNewText( (xmlChar*)"\n " ); + newtext = xmlNewText( (const xmlChar*)"\n " ); xmlAddNextSibling( nodeParent->children->next, newtext ); } else { @@ -178,7 +180,7 @@ bool XmlTagBuilder::AddShaderNode( const char* shader, TextureType textureType, xmlAddNextSibling( nodeParent->children, newnode ); // append a new line and spaces - newtext = xmlNewText( (xmlChar*)"\n " ); + newtext = xmlNewText( (const xmlChar*)"\n " ); xmlAddNextSibling( nodeParent->children->next, newtext ); } @@ -327,26 +329,26 @@ bool XmlTagBuilder::AddShaderTag( const char* shader, const char* content, NodeT } if ( !xmlXPathNodeSetIsEmpty( nodePtr ) ) { // node was found - xmlNodePtr newnode = xmlNewNode( NULL, (xmlChar*)"tag" ); + xmlNodePtr newnode = xmlNewNode( NULL, (const xmlChar*)"tag" ); xmlNodePtr nodeParent = nodePtr->nodeTab[0]; newnode = xmlDocCopyNode( newnode, doc, 1 ); - xmlNodeSetContent( newnode, (xmlChar*)content ); + xmlNodeSetContent( newnode, (const xmlChar*)content ); if ( nodePtr->nodeTab[0]->children->next == NULL ) { // shader node has NO children // add spaces - xmlNodePtr newtext = xmlNewText( (xmlChar*)" " ); + xmlNodePtr newtext = xmlNewText( (const xmlChar*)" " ); xmlAddChild( nodeParent->children, newtext ); // add new node xmlAddNextSibling( nodeParent->children, newnode ); // append a new line + spaces - newtext = xmlNewText( (xmlChar*)"\n " ); + newtext = xmlNewText( (const xmlChar*)"\n " ); xmlAddNextSibling( nodeParent->children->next, newtext ); } else { // shader node has children already - the new node will be the first sibling xmlAddNextSibling( nodeParent->children, newnode ); - xmlNodePtr newtext = xmlNewText( (xmlChar*)"\n " ); + xmlNodePtr newtext = xmlNewText( (const xmlChar*)"\n " ); xmlAddNextSibling( nodeParent->children->next, newtext ); } xmlXPathFreeObject( xpathPtr ); @@ -376,7 +378,7 @@ int XmlTagBuilder::RenameShaderTag( const char* oldtag, CopiedString newtag ){ strcat( expression, oldtag ); strcat( expression, "']/*" ); - xmlXPathObjectPtr result = xmlXPathEvalExpression( (xmlChar*)expression, context ); + xmlXPathObjectPtr result = xmlXPathEvalExpression( (const xmlChar*)expression, context ); if ( !result ) { return 0; } @@ -388,7 +390,7 @@ int XmlTagBuilder::RenameShaderTag( const char* oldtag, CopiedString newtag ){ char* content = (char*)xmlNodeGetContent( ptrContent ); if ( strcmp( content, oldtag ) == 0 ) { // found a node with old content? - xmlNodeSetContent( ptrContent, (xmlChar*)newtag.c_str() ); + xmlNodeSetContent( ptrContent, (const xmlChar*)newtag.c_str() ); num++; } } @@ -476,7 +478,7 @@ void XmlTagBuilder::GetShaderTags( const char* shader, std::vector returns a vector containing the tags */ - char* expression; + const char* expression; if ( shader == NULL ) { // get all tags from all shaders expression = "/root/*/*/tag"; @@ -510,7 +512,7 @@ void XmlTagBuilder::GetUntagged( std::set& shaders ){ returns a set containing the shaders (with path) */ - char* expression = "/root/*/*[not(child::tag)]"; + const char* expression = "/root/*/*[not(child::tag)]"; xmlXPathObjectPtr xpathPtr = XpathEval( expression ); xmlNodeSetPtr nodePtr; @@ -527,7 +529,7 @@ void XmlTagBuilder::GetUntagged( std::set& shaders ){ for ( int i = 0; i < nodePtr->nodeNr; i++ ) { ptr = nodePtr->nodeTab[i]; - shaders.insert( (char*)xmlGetProp( ptr, (xmlChar*)"path" ) ); + shaders.insert( (char*)xmlGetProp( ptr, (const xmlChar*)"path" ) ); } } @@ -540,7 +542,7 @@ void XmlTagBuilder::GetAllTags( std::set& tags ){ returns a set containing all used tags */ - char* expression = "/root/*/*/tag"; + const char* expression = "/root/*/*/tag"; xmlXPathObjectPtr xpathPtr = XpathEval( expression ); xmlNodeSetPtr nodePtr; @@ -584,7 +586,7 @@ void XmlTagBuilder::TagSearch( const char* expression, std::set& p for ( int i = 0; i < nodePtr->nodeNr; i++ ) { ptr = nodePtr->nodeTab[i]; - xmlattrib = xmlGetProp( ptr, (xmlChar*)"path" ); + xmlattrib = xmlGetProp( ptr, (const xmlChar*)"path" ); paths.insert( (CopiedString)(char*)xmlattrib ); } } diff --git a/libs/xml/xmltextags.h b/libs/xml/xmltextags.h index 7a1bae6d..dbad5f56 100644 --- a/libs/xml/xmltextags.h +++ b/libs/xml/xmltextags.h @@ -58,7 +58,7 @@ xmlXPathContextPtr context; xmlNodeSetPtr nodePtr; xmlXPathObjectPtr XpathEval( const char* queryString ){ - xmlChar* expression = (xmlChar*)queryString; + const xmlChar* expression = (const xmlChar*)queryString; xmlXPathObjectPtr result = xmlXPathEvalExpression( expression, context ); return result; }; diff --git a/plugins/entity/light.cpp b/plugins/entity/light.cpp index f0261cc5..db625fa6 100644 --- a/plugins/entity/light.cpp +++ b/plugins/entity/light.cpp @@ -650,8 +650,8 @@ void render( RenderStateFlags state ) const { points[5] = vector4_projected( matrix4_transformed_vector4( unproject, Vector4( points[5], 1 ) ) ); points[6] = vector4_projected( matrix4_transformed_vector4( unproject, Vector4( points[6], 1 ) ) ); points[7] = vector4_projected( matrix4_transformed_vector4( unproject, Vector4( points[7], 1 ) ) ); - Vector4 test1 = matrix4_transformed_vector4( unproject, Vector4( 0.5f, 0.5f, 0.5f, 1 ) ); - Vector3 test2 = vector4_projected( test1 ); + //Vector4 test1 = matrix4_transformed_vector4( unproject, Vector4( 0.5f, 0.5f, 0.5f, 1 ) ); + //Vector3 test2 = vector4_projected( test1 ); aabb_draw_wire( points ); } }; diff --git a/plugins/imagehl/hlw.cpp b/plugins/imagehl/hlw.cpp index 2731e15a..73275547 100644 --- a/plugins/imagehl/hlw.cpp +++ b/plugins/imagehl/hlw.cpp @@ -91,7 +91,7 @@ typedef struct Image* LoadHLWBuff( byte* buffer ){ byte *buf_p; unsigned long mipdatasize; - int columns, rows, numPixels; + int columns, rows; byte *pixbuf; int row, column; byte *palette; @@ -108,7 +108,6 @@ Image* LoadHLWBuff( byte* buffer ){ columns = lpMip->width; rows = lpMip->height; - numPixels = columns * rows; RGBAImage* image = new RGBAImage( columns, rows ); diff --git a/plugins/imagehl/mip.cpp b/plugins/imagehl/mip.cpp index 51dbfd7e..94332ff5 100644 --- a/plugins/imagehl/mip.cpp +++ b/plugins/imagehl/mip.cpp @@ -138,7 +138,6 @@ static const byte quakepalette[768] = Image* LoadMIPBuff( byte* buffer ){ byte *buf_p; int palettelength; - unsigned long mipdatasize; int columns, rows, numPixels; byte *pixbuf; int i; @@ -158,7 +157,7 @@ Image* LoadMIPBuff( byte* buffer ){ return 0; } - mipdatasize = GET_MIP_DATA_SIZE( columns, rows ); + //unsigned long mipdatasize = GET_MIP_DATA_SIZE( columns, rows ); palettelength = vfsLoadFile( "gfx/palette.lmp", (void **) &loadedpalette ); if ( palettelength == 768 ) { diff --git a/plugins/imagehl/sprite.cpp b/plugins/imagehl/sprite.cpp index b6347ec4..6e469562 100644 --- a/plugins/imagehl/sprite.cpp +++ b/plugins/imagehl/sprite.cpp @@ -102,7 +102,7 @@ typedef struct { Image* LoadIDSPBuff( byte *buffer ){ byte *buf_p; - int columns, rows, numPixels; + int columns, rows; byte *pixbuf; int row, column; @@ -159,8 +159,6 @@ Image* LoadIDSPBuff( byte *buffer ){ // palette = buffer+mipdatasize+2; // buf_p = buffer+lpMip->offsets[0]; - numPixels = columns * rows; - RGBAImage* image = new RGBAImage( columns, rows ); #ifdef DEBUG diff --git a/plugins/mapq3/plugin.cpp b/plugins/mapq3/plugin.cpp index 2c3d99c5..3317830b 100644 --- a/plugins/mapq3/plugin.cpp +++ b/plugins/mapq3/plugin.cpp @@ -106,12 +106,12 @@ void readGraph( scene::Node& root, TextInputStream& inputStream, EntityCreator& if ( !Tokeniser_parseToken( tokeniser, "Version" ) ) { return; } - std::size_t version; - if ( !Tokeniser_getSize( tokeniser, version ) ) { + int version; + if ( !Tokeniser_getInteger( tokeniser, version ) ) { return; } if ( version != MapVersion() ) { - globalErrorStream() << "Doom 3 map version " << MapVersion() << " supported, version is " << Unsigned( version ) << "\n"; + globalErrorStream() << "Doom 3 map version " << MapVersion() << " supported, version is " << version << "\n"; return; } tokeniser.nextLine(); @@ -177,12 +177,12 @@ void readGraph( scene::Node& root, TextInputStream& inputStream, EntityCreator& if ( !Tokeniser_parseToken( tokeniser, "Version" ) ) { return; } - std::size_t version; - if ( !Tokeniser_getSize( tokeniser, version ) ) { + int version; + if ( !Tokeniser_getInteger( tokeniser, version ) ) { return; } if ( version != MapVersion() ) { - globalErrorStream() << "Quake 4 map version " << MapVersion() << " supported, version is " << Unsigned( version ) << "\n"; + globalErrorStream() << "Quake 4 map version " << MapVersion() << " supported, version is " << version << "\n"; return; } tokeniser.nextLine(); diff --git a/plugins/shaders/shaders.cpp b/plugins/shaders/shaders.cpp index eda91d4f..f1c140e5 100644 --- a/plugins/shaders/shaders.cpp +++ b/plugins/shaders/shaders.cpp @@ -785,6 +785,7 @@ float evaluateFloat( const ShaderValue& value, const ShaderParameters& params, c float f; if ( !string_parse_float( result, f ) ) { globalErrorStream() << "parsing float value failed: " << makeQuoted( result ) << "\n"; + return 1.f; } return f; } diff --git a/plugins/textool/TexTool.cpp b/plugins/textool/TexTool.cpp index 50fbf125..64e8b77f 100644 --- a/plugins/textool/TexTool.cpp +++ b/plugins/textool/TexTool.cpp @@ -261,12 +261,10 @@ const char* QERPlug_GetCommandList(){ char *TranslateString( char *buf ){ static char buf2[32768]; - int i, l; - char *out; - l = strlen( buf ); - out = buf2; - for ( i = 0 ; i < l ; i++ ) + std::size_t l = strlen( buf ); + char* out = buf2; + for ( std::size_t i = 0 ; i < l ; i++ ) { if ( buf[i] == '\n' ) { *out++ = '\r'; diff --git a/plugins/vfspk3/vfs.cpp b/plugins/vfspk3/vfs.cpp index 893f002b..e738e218 100644 --- a/plugins/vfspk3/vfs.cpp +++ b/plugins/vfspk3/vfs.cpp @@ -473,8 +473,8 @@ int GetFileCount( const char *filename, int flag ){ for ( archives_t::iterator i = g_archives.begin(); i != g_archives.end(); ++i ) { - if ( ( *i ).is_pakfile && ( flag & VFS_SEARCH_PAK ) != 0 - || !( *i ).is_pakfile && ( flag & VFS_SEARCH_DIR ) != 0 ) { + if ( ( ( *i ).is_pakfile && ( flag & VFS_SEARCH_PAK ) != 0 ) + || ( !( *i ).is_pakfile && ( flag & VFS_SEARCH_DIR ) != 0 ) ) { if ( ( *i ).archive->containsFile( fixed ) ) { ++count; } diff --git a/radiant/brush_primit.cpp b/radiant/brush_primit.cpp index 3e7e4775..0434f4e2 100644 --- a/radiant/brush_primit.cpp +++ b/radiant/brush_primit.cpp @@ -1255,7 +1255,7 @@ inline Matrix4 matrix4_reflection_for_plane45( const Plane3& plane, const Vector Vector3 first = from; Vector3 second = to; - if ( vector3_dot( from, plane.normal() ) > 0 == vector3_dot( to, plane.normal() ) > 0 ) { + if ( ( vector3_dot( from, plane.normal() ) > 0 ) == ( vector3_dot( to, plane.normal() ) > 0 ) ) { first = vector3_negated( first ); second = vector3_negated( second ); } @@ -1273,7 +1273,7 @@ inline Matrix4 matrix4_reflection_for_plane45( const Plane3& plane, const Vector Matrix4 swap = matrix4_swap_axes( first, second ); - Matrix4 tmp = matrix4_reflection_for_plane( plane ); + //Matrix4 tmp = matrix4_reflection_for_plane( plane ); swap.tx() = -static_cast( -2 * plane.a * plane.d ); swap.ty() = -static_cast( -2 * plane.b * plane.d ); diff --git a/radiant/brushmanip.cpp b/radiant/brushmanip.cpp index 520af385..83202140 100644 --- a/radiant/brushmanip.cpp +++ b/radiant/brushmanip.cpp @@ -1330,13 +1330,13 @@ BrushPrefab g_brushcone( eBrushCone ); BrushPrefab g_brushsphere( eBrushSphere ); BrushPrefab g_brushrock( eBrushRock ); - +/* void FlipClip(); void SplitClip(); void Clip(); void OnClipMode( bool enable ); bool ClipMode(); - +*/ void ClipSelected(){ if ( ClipMode() ) { diff --git a/radiant/build.cpp b/radiant/build.cpp index 31801e90..75c10da8 100644 --- a/radiant/build.cpp +++ b/radiant/build.cpp @@ -55,6 +55,7 @@ const char* build_get_variable( const char* name ){ class Evaluatable { public: +virtual ~Evaluatable(){} virtual void evaluate( StringBuffer& output ) = 0; virtual void exportXML( XMLImporter& importer ) = 0; }; @@ -896,7 +897,7 @@ GtkWindow* BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectLi object_set_boolean_property( G_OBJECT( renderer ), "editable", TRUE ); g_signal_connect( renderer, "edited", G_CALLBACK( project_cell_edited ), &projectList ); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", 0, 0 ); + GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", 0, NULL ); gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column ); GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) ); @@ -937,7 +938,7 @@ GtkWindow* BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectLi object_set_int_property( G_OBJECT( renderer ), "wrap-width", 640 ); g_signal_connect( renderer, "edited", G_CALLBACK( commands_cell_edited ), store ); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", 0, 0 ); + GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", 0, NULL ); gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column ); GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) ); diff --git a/radiant/camwindow.cpp b/radiant/camwindow.cpp index 43da650e..1746dd77 100644 --- a/radiant/camwindow.cpp +++ b/radiant/camwindow.cpp @@ -193,12 +193,13 @@ inline Matrix4 projection_for_camera( float near_z, float far_z, float fieldOfVi } float Camera_getFarClipPlane( camera_t& camera ){ - return ( g_camwindow_globals_private.m_bCubicClipping ) ? pow( 2.0, ( g_camwindow_globals.m_nCubicScale + 7 ) / 2.0 ) : 32768.0f; + return ( g_camwindow_globals_private.m_bCubicClipping ) ? pow( 2.0, ( g_camwindow_globals.m_nCubicScale + 7 ) / 2.0 ) : ( ( g_MaxWorldCoord - g_MinWorldCoord ) * sqrt( 3 ) ); } void Camera_updateProjection( camera_t& camera ){ float farClip = Camera_getFarClipPlane( camera ); - camera.projection = projection_for_camera( farClip / 4096.0f, farClip, camera_t::fieldOfView, camera.width, camera.height ); + + camera.projection = projection_for_camera( 1.f, farClip, camera_t::fieldOfView, camera.width, camera.height ); camera.m_view->Construct( camera.projection, camera.modelview, camera.width, camera.height ); } @@ -750,7 +751,7 @@ CameraView& getCameraView(){ return m_cameraview; } -guint32 m_rightClickTime; +Timer m_rightClickTimer; private: void Cam_Draw(); @@ -826,39 +827,39 @@ void Camera_setAngles( CamWnd& camwnd, const Vector3& angles ){ // ============================================================================= // CamWnd class -void context_menu(){ +void context_menu_show(){ if( g_pParentWnd->ActiveXY() ){ g_pParentWnd->ActiveXY()->OnContextMenu(); g_bCamEntityMenu = true; } } +void context_menu(){ + //need this hack, otherwise button wont be released = global accels broken, until correct button pressed again... + GdkEvent* event_ = gtk_get_current_event(); + if( event_ ){ + event_->type = GDK_BUTTON_RELEASE; + gtk_main_do_event( event_ ); + gdk_event_free( event_ ); + context_menu_show(); + } +} + /* GDK_2BUTTON_PRESS doesn't always work in this case, so... */ -bool context_menu_try( GdkEventButton* event, CamWnd* camwnd ){ - if( ( event->time - camwnd->m_rightClickTime ) < 200 ){ - camwnd->m_rightClickTime = event->time; - return true; - } - else{ - camwnd->m_rightClickTime = event->time; - return false; - } +bool context_menu_try( CamWnd* camwnd ){ + //globalOutputStream() << camwnd->m_rightClickTimer.elapsed_msec() << "\n"; + return camwnd->m_rightClickTimer.elapsed_msec() < 200; + //doesn't work if cam redraw > 200msec (3x click works): gtk_widget_queue_draw proceeds after timer.start() } gboolean enable_freelook_button_press( GtkWidget* widget, GdkEventButton* event, CamWnd* camwnd ){ if ( event->type == GDK_BUTTON_PRESS && event->button == 3 && modifiers_for_state( event->state ) == c_modifierNone ) { - if( context_menu_try( event, camwnd ) ){ - //need this hack, otherwise button wont be released = global accels broken, until correct button pressed again... - GdkEvent* event_ = gtk_get_current_event(); - if( event_ ){ - event_->type = GDK_BUTTON_RELEASE; - gtk_main_do_event( event_ ); - gdk_event_free( event_ ); - context_menu(); - } + if( context_menu_try( camwnd ) ){ + context_menu(); } else{ camwnd->EnableFreeMove(); + camwnd->m_rightClickTimer.start(); } return TRUE; } @@ -867,16 +868,13 @@ gboolean enable_freelook_button_press( GtkWidget* widget, GdkEventButton* event, gboolean disable_freelook_button_press( GtkWidget* widget, GdkEventButton* event, CamWnd* camwnd ){ if ( event->type == GDK_BUTTON_PRESS && event->button == 3 && modifiers_for_state( event->state ) == c_modifierNone ) { + bool doubleclicked = context_menu_try( camwnd ); camwnd->DisableFreeMove(); - if( context_menu_try( event, camwnd ) ){ - //need this hack, otherwise button wont be released = global accels broken, until correct button pressed again... - GdkEvent* event_ = gtk_get_current_event(); - if( event_ ){ - event_->type = GDK_BUTTON_RELEASE; - gtk_main_do_event( event_ ); - gdk_event_free( event_ ); - context_menu(); - } + if( doubleclicked ){ + context_menu(); + } + else{ + camwnd->m_rightClickTimer.start(); } return TRUE; } @@ -973,7 +971,7 @@ gboolean wheelmove_scroll( GtkWidget* widget, GdkEventScroll* event, CamWnd* cam normalized[1] *= -1.f; normalized[2] = 0.f; - normalized *= 16.0f; + normalized *= 2.0f; //*= 2 * nearplane //globalOutputStream() << normalized << " normalized "; matrix4_transform_point( maa, normalized ); //globalOutputStream() << normalized << "\n"; @@ -1297,8 +1295,7 @@ CamWnd::CamWnd() : m_selection_button_release_handler( 0 ), m_selection_motion_handler( 0 ), m_freelook_button_press_handler( 0 ), - m_drawing( false ), - m_rightClickTime( 0 ){ + m_drawing( false ){ m_bFreeMove = false; GlobalWindowObservers_add( m_window_observer ); @@ -1503,7 +1500,7 @@ void SetState( Shader* state, EStyle style ){ m_state_stack.back().m_state = state; } } -const EStyle getStyle() const { +EStyle getStyle() const { return eFullMaterials; } void PushState(){ diff --git a/radiant/console.cpp b/radiant/console.cpp index 94060a45..0192f4e4 100644 --- a/radiant/console.cpp +++ b/radiant/console.cpp @@ -147,8 +147,12 @@ GtkTextTag* tag; public: GtkTextBufferOutputStream( GtkTextBuffer* textBuffer, GtkTextIter* iter, GtkTextTag* tag ) : textBuffer( textBuffer ), iter( iter ), tag( tag ){ } -std::size_t __attribute__((optimize("O0"))) write( const char* buffer, std::size_t length ){ - gtk_text_buffer_insert_with_tags( textBuffer, iter, buffer, gint( length ), tag, 0 ); +std::size_t +#ifdef __GNUC__ +__attribute__((optimize("O0"))) +#endif +write( const char* buffer, std::size_t length ){ + gtk_text_buffer_insert_with_tags( textBuffer, iter, buffer, gint( length ), tag, NULL ); return length; } }; diff --git a/radiant/eclass.cpp b/radiant/eclass.cpp index db65063a..c74c7b72 100644 --- a/radiant/eclass.cpp +++ b/radiant/eclass.cpp @@ -45,7 +45,7 @@ namespace typedef std::map EntityClasses; EntityClasses g_entityClasses; EntityClass *eclass_bad = 0; -char eclass_directory[1024]; +//char eclass_directory[1024]; typedef std::map ListAttributeTypes; ListAttributeTypes g_listTypes; } diff --git a/radiant/entityinspector.cpp b/radiant/entityinspector.cpp index 60113063..d63b1804 100644 --- a/radiant/entityinspector.cpp +++ b/radiant/entityinspector.cpp @@ -1485,7 +1485,7 @@ GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){ { GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "Key", renderer, "text", 0, 0 ); + GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "Key", renderer, "text", 0, NULL ); gtk_tree_view_append_column( view, column ); } @@ -1575,13 +1575,13 @@ GtkWidget* EntityInspector_constructWindow( GtkWindow* toplevel ){ { GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", 0, 0 ); + GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", 0, NULL ); gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column ); } { GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", 1, 0 ); + GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "", renderer, "text", 1, NULL ); gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column ); } diff --git a/radiant/entitylist.cpp b/radiant/entitylist.cpp index 7f93b44f..acb7eaa0 100644 --- a/radiant/entitylist.cpp +++ b/radiant/entitylist.cpp @@ -123,22 +123,22 @@ void entitylist_treeviewcolumn_celldatafunc( GtkTreeViewColumn* column, GtkCellR if ( node != 0 ) { gtk_cell_renderer_set_fixed_size( renderer, -1, -1 ); char* name = const_cast( node_get_name( *node ) ); - g_object_set( G_OBJECT( renderer ), "text", name, "visible", TRUE, 0 ); + g_object_set( G_OBJECT( renderer ), "text", name, "visible", TRUE, NULL ); //globalOutputStream() << "rendering cell " << makeQuoted(name) << "\n"; GtkStyle* style = gtk_widget_get_style( GTK_WIDGET( getEntityList().m_tree_view ) ); if ( instance->childSelected() ) { - g_object_set( G_OBJECT( renderer ), "cell-background-gdk", &style->base[GTK_STATE_ACTIVE], 0 ); + g_object_set( G_OBJECT( renderer ), "cell-background-gdk", &style->base[GTK_STATE_ACTIVE], NULL ); } else { - g_object_set( G_OBJECT( renderer ), "cell-background-gdk", &style->base[GTK_STATE_NORMAL], 0 ); + g_object_set( G_OBJECT( renderer ), "cell-background-gdk", &style->base[GTK_STATE_NORMAL], NULL ); } } else { gtk_cell_renderer_set_fixed_size( renderer, -1, 0 ); - g_object_set( G_OBJECT( renderer ), "text", "", "visible", FALSE, 0 ); + g_object_set( G_OBJECT( renderer ), "text", "", "visible", FALSE, NULL ); } } diff --git a/radiant/environment.cpp b/radiant/environment.cpp index ad0edd77..a5f5e2dc 100644 --- a/radiant/environment.cpp +++ b/radiant/environment.cpp @@ -30,7 +30,7 @@ #include "cmdlib.h" int g_argc; -char** g_argv; +const char** g_argv; void args_init( int argc, char* argv[] ){ int i, j, k; @@ -51,11 +51,11 @@ void args_init( int argc, char* argv[] ){ } g_argc = argc; - g_argv = argv; + g_argv = const_cast( argv ); } -char *gamedetect_argv_buffer[1024]; -void gamedetect_found_game( char *game, char *path ){ +const char *gamedetect_argv_buffer[1024]; +void gamedetect_found_game( const char *game, char *path ){ int argc; static char buf[128]; @@ -79,7 +79,7 @@ void gamedetect_found_game( char *game, char *path ){ g_argv = gamedetect_argv_buffer; } -bool gamedetect_check_game( char *gamefile, const char *checkfile1, const char *checkfile2, char *buf /* must have 64 bytes free after bufpos */, int bufpos ){ +bool gamedetect_check_game( const char *gamefile, const char *checkfile1, const char *checkfile2, char *buf /* must have 64 bytes free after bufpos */, int bufpos ){ buf[bufpos] = '/'; strcpy( buf + bufpos + 1, checkfile1 ); @@ -181,15 +181,15 @@ bool portable_app_setup(){ } -char* openCmdMap; +const char* g_openCmdMap; void cmdMap(){ - openCmdMap = NULL; + g_openCmdMap = NULL; for ( int i = 1; i < g_argc; ++i ) { //if ( !stricmp( g_argv[i] + strlen(g_argv[i]) - 4, ".map" ) ){ if( string_equal_suffix_nocase( g_argv[i], ".map" ) ){ - openCmdMap = g_argv[i]; + g_openCmdMap = g_argv[i]; } } } @@ -211,7 +211,7 @@ const char* LINK_NAME = ; /// brief Returns the filename of the executable belonging to the current process, or 0 if not found. -char* getexename( char *buf ){ +const char* getexename( char *buf ){ /* Now read the symbolic link */ int ret = readlink( LINK_NAME, buf, PATH_MAX ); diff --git a/radiant/environment.h b/radiant/environment.h index b5dc6c15..e42c9fde 100644 --- a/radiant/environment.h +++ b/radiant/environment.h @@ -27,9 +27,9 @@ const char* environment_get_home_path(); const char* environment_get_app_path(); extern int g_argc; -extern char** g_argv; +extern const char** g_argv; -extern char* openCmdMap; +extern const char* g_openCmdMap; #endif diff --git a/radiant/filetypes.cpp b/radiant/filetypes.cpp index 87cb205c..9cf4c08b 100644 --- a/radiant/filetypes.cpp +++ b/radiant/filetypes.cpp @@ -43,13 +43,14 @@ struct filetype_copy_t filetype_t getType() const { return filetype_t( m_name.c_str(), m_pattern.c_str(), m_can_load, m_can_save, m_can_import ); } - bool m_can_load; - bool m_can_import; - bool m_can_save; private: CopiedString m_moduleName; CopiedString m_name; CopiedString m_pattern; +public: + bool m_can_load; + bool m_can_import; + bool m_can_save; }; typedef std::vector filetype_list_t; std::map m_typelists; diff --git a/radiant/findtexturedialog.cpp b/radiant/findtexturedialog.cpp index 88d28320..14998574 100644 --- a/radiant/findtexturedialog.cpp +++ b/radiant/findtexturedialog.cpp @@ -100,7 +100,7 @@ static void OnApply( GtkWidget* widget, gpointer data ){ g_FindTextureDialog.exportData(); FindTextureDialog_apply(); } - +#if 0 static void OnFind( GtkWidget* widget, gpointer data ){ g_FindTextureDialog.exportData(); FindTextureDialog_apply(); @@ -111,7 +111,7 @@ static void OnOK( GtkWidget* widget, gpointer data ){ FindTextureDialog_apply(); g_FindTextureDialog.HideDlg(); } - +#endif static void OnClose( GtkWidget* widget, gpointer data ){ g_FindTextureDialog.HideDlg(); } diff --git a/radiant/gtkmisc.cpp b/radiant/gtkmisc.cpp index 59dab2a9..dc9bfd04 100644 --- a/radiant/gtkmisc.cpp +++ b/radiant/gtkmisc.cpp @@ -134,6 +134,34 @@ bool color_dialog( GtkWidget *parent, Vector3& color, const char* title ){ return ok; } +bool OpenGLFont_dialog( GtkWidget *parent, const char* font, CopiedString &newfont ){ + GtkWidget* dlg; + ModalDialog dialog; + + + dlg = gtk_font_selection_dialog_new( "OpenGLFont" ); + gtk_font_selection_dialog_set_font_name( GTK_FONT_SELECTION_DIALOG( dlg ), font ); + + g_signal_connect( G_OBJECT( dlg ), "delete_event", G_CALLBACK( dialog_delete_callback ), &dialog ); + g_signal_connect( G_OBJECT( gtk_font_selection_dialog_get_ok_button( GTK_FONT_SELECTION_DIALOG( dlg ) ) ), "clicked", G_CALLBACK( dialog_button_ok ), &dialog ); + g_signal_connect( G_OBJECT( gtk_font_selection_dialog_get_cancel_button( GTK_FONT_SELECTION_DIALOG( dlg ) ) ), "clicked", G_CALLBACK( dialog_button_cancel ), &dialog ); + + if ( parent != 0 ) { + gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( parent ) ); + } + + bool ok = modal_dialog_show( GTK_WINDOW( dlg ), dialog ) == eIDOK; + if ( ok ) { + gchar* selectedfont = gtk_font_selection_dialog_get_font_name( GTK_FONT_SELECTION_DIALOG( dlg ) ); + newfont = selectedfont; + g_free( selectedfont ); + } + + gtk_widget_destroy( dlg ); + + return ok; +} + void button_clicked_entry_browse_file( GtkWidget* widget, GtkEntry* entry ){ const char *filename = file_dialog( gtk_widget_get_toplevel( widget ), TRUE, "Choose File", gtk_entry_get_text( entry ) ); diff --git a/radiant/gtkmisc.h b/radiant/gtkmisc.h index 14cdd816..3ea7363e 100644 --- a/radiant/gtkmisc.h +++ b/radiant/gtkmisc.h @@ -68,6 +68,9 @@ template class BasicVector3; typedef BasicVector3 Vector3; bool color_dialog( GtkWidget *parent, Vector3& color, const char* title = "Choose Color" ); +#include "string/stringfwd.h" +bool OpenGLFont_dialog( GtkWidget *parent, const char* font, CopiedString &newfont ); + typedef struct _GtkEntry GtkEntry; void button_clicked_entry_browse_file( GtkWidget* widget, GtkEntry* entry ); void button_clicked_entry_browse_directory( GtkWidget* widget, GtkEntry* entry ); diff --git a/radiant/main.cpp b/radiant/main.cpp index d17db3d6..7d3a5a79 100644 --- a/radiant/main.cpp +++ b/radiant/main.cpp @@ -652,8 +652,8 @@ int main( int argc, char* argv[] ){ hide_splash(); - if( openCmdMap && *openCmdMap ){ - Map_LoadFile( openCmdMap ); + if( g_openCmdMap && *g_openCmdMap ){ + Map_LoadFile( g_openCmdMap ); } else if ( g_bLoadLastMap && !g_strLastMap.empty() ) { Map_LoadFile( g_strLastMap.c_str() ); diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index 8a5d3bec..8687cbf8 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -923,6 +923,7 @@ GtkMenuItem* create_colours_menu(){ create_menu_item_with_mnemonic( menu_3, "Maya/Max/Lightwave Emulation", "ColorSchemeYdnar" ); create_menu_item_with_mnemonic( menu_in_menu, "GTK Theme...", "gtkThemeDlg" ); + create_menu_item_with_mnemonic( menu_in_menu, "OpenGL Font...", "OpenGLFont" ); menu_separator( menu_in_menu ); @@ -3344,9 +3345,23 @@ void GridStatus_onTextureLockEnabledChanged(){ } } -void GlobalGL_sharedContextCreated(){ - GLFont *g_font = NULL; +CopiedString g_strOpenGLFont = "arial 8"; +void OpenGLFont_select(){ + CopiedString newfont; + if( OpenGLFont_dialog( GTK_WIDGET( MainFrame_getWindow() ), g_strOpenGLFont.c_str(), newfont ) ){ + { + ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Changing OpenGL Font" ); + delete GlobalOpenGL().m_font; + g_strOpenGLFont = newfont; + GlobalOpenGL().m_font = glfont_create( g_strOpenGLFont.c_str() ); + } + UpdateAllWindows(); + } +} + + +void GlobalGL_sharedContextCreated(){ // report OpenGL information globalOutputStream() << "GL_VENDOR: " << reinterpret_cast( glGetString( GL_VENDOR ) ) << "\n"; globalOutputStream() << "GL_RENDERER: " << reinterpret_cast( glGetString( GL_RENDERER ) ) << "\n"; @@ -3360,17 +3375,7 @@ void GlobalGL_sharedContextCreated(){ GlobalShaderCache().realise(); Textures_Realise(); -#ifdef WIN32 - /* win32 is dodgy here, just use courier new then */ - g_font = glfont_create( "arial 8" ); -#else - GtkSettings *settings = gtk_settings_get_default(); - gchar *fontname; - g_object_get( settings, "gtk-font-name", &fontname, NULL ); - g_font = glfont_create( fontname ); -#endif - - GlobalOpenGL().m_font = g_font; + GlobalOpenGL().m_font = glfont_create( g_strOpenGLFont.c_str() ); } void GlobalGL_sharedContextDestroyed(){ @@ -3509,6 +3514,7 @@ void MainFrame_Construct(){ GlobalCommands_insert( "MouseDragOrScale", FreeCaller(), Accelerator( 'Q' ) ); GlobalCommands_insert( "gtkThemeDlg", FreeCaller() ); + GlobalCommands_insert( "OpenGLFont", FreeCaller() ); GlobalCommands_insert( "ColorSchemeOriginal", FreeCaller() ); GlobalCommands_insert( "ColorSchemeQER", FreeCaller() ); GlobalCommands_insert( "ColorSchemeBlackAndGreen", FreeCaller() ); @@ -3591,6 +3597,7 @@ void MainFrame_Construct(){ GlobalPreferenceSystem().registerPreference( "EnginePath", CopiedStringImportStringCaller( g_strEnginePath ), CopiedStringExportStringCaller( g_strEnginePath ) ); GlobalPreferenceSystem().registerPreference( "NudgeAfterClone", BoolImportStringCaller( g_bNudgeAfterClone ), BoolExportStringCaller( g_bNudgeAfterClone ) ); + GlobalPreferenceSystem().registerPreference( "OpenGLFont", CopiedStringImportStringCaller( g_strOpenGLFont ), CopiedStringExportStringCaller( g_strOpenGLFont ) ); if ( g_strEnginePath.empty() ) { g_strEnginePath_was_empty_1st_start = true; diff --git a/radiant/map.cpp b/radiant/map.cpp index 01d9a271..cba9fad9 100644 --- a/radiant/map.cpp +++ b/radiant/map.cpp @@ -1006,14 +1006,14 @@ void DoMapInfo(){ { GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "Entity", renderer, "text", 0, 0 ); + GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "Entity", renderer, "text", 0, NULL ); gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column ); gtk_tree_view_column_set_sort_column_id( column, 0 ); } { GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); - GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "Count", renderer, "text", 1, 0 ); + GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "Count", renderer, "text", 1, NULL ); gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column ); gtk_tree_view_column_set_sort_column_id( column, 1 ); } diff --git a/radiant/multimon.cpp b/radiant/multimon.cpp index 33ae89f1..cab6d7ab 100644 --- a/radiant/multimon.cpp +++ b/radiant/multimon.cpp @@ -32,7 +32,8 @@ multimon_globals_t g_multimon_globals; //LatchedBool g_Multimon_enableSysMenuPopups( false, "Floating windows sysmenu icons" ); void MultiMonitor_constructPreferences( PreferencesPage& page ){ - GtkWidget* primary_monitor = page.appendCheckBox( "Multi Monitor", "Start on Primary Monitor", g_multimon_globals.m_bStartOnPrimMon ); + //GtkWidget* primary_monitor = + page.appendCheckBox( "Multi Monitor", "Start on Primary Monitor", g_multimon_globals.m_bStartOnPrimMon ); // GtkWidget* popup = page.appendCheckBox( // "", "Disable system menu on popup windows", // LatchedBoolImportCaller( g_Multimon_enableSysMenuPopups ), diff --git a/radiant/patch.cpp b/radiant/patch.cpp index 8148a716..066e66ca 100644 --- a/radiant/patch.cpp +++ b/radiant/patch.cpp @@ -1357,7 +1357,7 @@ void Patch::ConstructPrefab( const AABB& aabb, EPatchPrefab eType, int axis, std // vPos[1] = aabb.origin; // vPos[2] = vector3_added(aabb.origin, aabb.extents); - int i, j; + unsigned int i, j; float f = 1 / cos( M_PI / n ); for ( i = 0; i < width; ++i ) { @@ -1383,7 +1383,7 @@ void Patch::ConstructPrefab( const AABB& aabb, EPatchPrefab eType, int axis, std // vPos[1] = aabb.origin; // vPos[2] = vector3_added(aabb.origin, aabb.extents); - int i, j; + unsigned int i, j; float f = 1 / cos( M_PI / n ); for ( i = 0; i < width; ++i ) { @@ -1410,7 +1410,7 @@ void Patch::ConstructPrefab( const AABB& aabb, EPatchPrefab eType, int axis, std // vPos[1] = aabb.origin; // vPos[2] = vector3_added(aabb.origin, aabb.extents); - int i, j; + unsigned int i, j; float f = 1 / cos( M_PI / n ); float g = 1 / cos( M_PI / ( 2 * m ) ); for ( i = 0; i < width; ++i ) diff --git a/radiant/texmanip.cpp b/radiant/texmanip.cpp index 03196c3c..bd25d58f 100644 --- a/radiant/texmanip.cpp +++ b/radiant/texmanip.cpp @@ -118,12 +118,13 @@ void R_ResampleTexture( const void *indata, int inwidth, int inheight, void *out if ( bytesperpixel == 4 ) { int i, j, yi, oldy, f, fstep, lerp, endy = ( inheight - 1 ), inwidth4 = inwidth * 4, outwidth4 = outwidth * 4; - byte *inrow, *out; + const byte *inrow; + byte *out; out = (byte *)outdata; fstep = (int) ( inheight * 65536.0f / outheight ); #define LERPBYTE( i ) out[i] = (byte) ( ( ( ( row2[i] - row1[i] ) * lerp ) >> 16 ) + row1[i] ) - inrow = (byte *)indata; + inrow = (const byte *)indata; oldy = 0; R_ResampleTextureLerpLine( inrow, row1, inwidth, outwidth, bytesperpixel ); R_ResampleTextureLerpLine( inrow + inwidth4, row2, inwidth, outwidth, bytesperpixel ); @@ -134,7 +135,7 @@ void R_ResampleTexture( const void *indata, int inwidth, int inheight, void *out if ( yi < endy ) { lerp = f & 0xFFFF; if ( yi != oldy ) { - inrow = (byte *)indata + inwidth4 * yi; + inrow = (const byte *)indata + inwidth4 * yi; if ( yi == oldy + 1 ) { memcpy( row1, row2, outwidth4 ); } @@ -197,7 +198,7 @@ void R_ResampleTexture( const void *indata, int inwidth, int inheight, void *out else { if ( yi != oldy ) { - inrow = (byte *)indata + inwidth4 * yi; + inrow = (const byte *)indata + inwidth4 * yi; if ( yi == oldy + 1 ) { memcpy( row1, row2, outwidth4 ); } @@ -213,12 +214,13 @@ void R_ResampleTexture( const void *indata, int inwidth, int inheight, void *out } else if ( bytesperpixel == 3 ) { int i, j, yi, oldy, f, fstep, lerp, endy = ( inheight - 1 ), inwidth3 = inwidth * 3, outwidth3 = outwidth * 3; - byte *inrow, *out; + const byte *inrow; + byte *out; out = (byte *)outdata; fstep = (int) ( inheight * 65536.0f / outheight ); #define LERPBYTE( i ) out[i] = (byte) ( ( ( ( row2[i] - row1[i] ) * lerp ) >> 16 ) + row1[i] ) - inrow = (byte *)indata; + inrow = (const byte *)indata; oldy = 0; R_ResampleTextureLerpLine( inrow, row1, inwidth, outwidth, bytesperpixel ); R_ResampleTextureLerpLine( inrow + inwidth3, row2, inwidth, outwidth, bytesperpixel ); @@ -228,7 +230,7 @@ void R_ResampleTexture( const void *indata, int inwidth, int inheight, void *out if ( yi < endy ) { lerp = f & 0xFFFF; if ( yi != oldy ) { - inrow = (byte *)indata + inwidth3 * yi; + inrow = (const byte *)indata + inwidth3 * yi; if ( yi == oldy + 1 ) { memcpy( row1, row2, outwidth3 ); } @@ -284,7 +286,7 @@ void R_ResampleTexture( const void *indata, int inwidth, int inheight, void *out else { if ( yi != oldy ) { - inrow = (byte *)indata + inwidth3 * yi; + inrow = (const byte *)indata + inwidth3 * yi; if ( yi == oldy + 1 ) { memcpy( row1, row2, outwidth3 ); } diff --git a/radiant/undo.cpp b/radiant/undo.cpp index 9910fb98..0bcfc856 100644 --- a/radiant/undo.cpp +++ b/radiant/undo.cpp @@ -254,7 +254,7 @@ void release( Undoable* undoable ){ m_undoables.erase( undoable ); } void setLevels( std::size_t levels ){ - if ( levels > MAX_UNDO_LEVELS() ) { + if ( levels > static_cast( MAX_UNDO_LEVELS() ) ) { levels = MAX_UNDO_LEVELS(); } diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index 52929bdf..c1a0b22d 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -89,7 +89,7 @@ ClipPoint(){ Reset(); }; void Reset(){ - m_ptClip[0] = m_ptClip[1] = m_ptClip[2] = 0.0; + m_ptClip[0] = m_ptClip[1] = m_ptClip[2] = 0.f; m_bSet = false; } bool Set(){ @@ -198,7 +198,7 @@ inline bool GlobalClipPoints_valid(){ return g_Clip1.Set() && g_Clip2.Set(); } -void PlanePointsFromClipPoints( Vector3 planepts[3], const AABB& bounds, int viewtype ){ +void PlanePointsFromClipPoints( Vector3 planepts[3], const AABB& bounds, VIEWTYPE viewtype ){ ASSERT_MESSAGE( GlobalClipPoints_valid(), "clipper points not initialised" ); planepts[0] = g_Clip1.m_ptClip; planepts[1] = g_Clip2.m_ptClip; @@ -231,9 +231,6 @@ void PlanePointsFromClipPoints( Vector3 planepts[3], const AABB& bounds, int vie void Clip_Update(){ Vector3 planepts[3]; if ( !GlobalClipPoints_valid() ) { - planepts[0] = Vector3( 0, 0, 0 ); - planepts[1] = Vector3( 0, 0, 0 ); - planepts[2] = Vector3( 0, 0, 0 ); Scene_BrushSetClipPlane( GlobalSceneGraph(), Plane3( 0, 0, 0, 0 ) ); } else @@ -264,7 +261,6 @@ void Clip(){ g_Clip2.Reset(); g_Clip3.Reset(); Clip_Update(); - ClipperChangeNotify(); if( g_quick_clipper ){ g_quick_clipper = false; ClipperMode(); @@ -282,7 +278,6 @@ void SplitClip(){ g_Clip2.Reset(); g_Clip3.Reset(); Clip_Update(); - ClipperChangeNotify(); if( g_quick_clipper ){ g_quick_clipper = false; ClipperMode(); @@ -293,7 +288,6 @@ void SplitClip(){ void FlipClip(){ g_bSwitch = !g_bSwitch; Clip_Update(); - ClipperChangeNotify(); } void OnClipMode( bool enabled ){ @@ -306,7 +300,6 @@ void OnClipMode( bool enabled ){ } Clip_Update(); - ClipperChangeNotify(); } bool ClipMode(){ @@ -336,7 +329,6 @@ void NewClipPoint( const Vector3& point ){ } Clip_Update(); - ClipperChangeNotify(); } @@ -428,6 +420,7 @@ inline unsigned int buttons_for_button_and_modifiers( ButtonIdentifier button, M case ButtonEnumeration::LEFT: buttons |= RAD_LBUTTON; break; case ButtonEnumeration::MIDDLE: buttons |= RAD_MBUTTON; break; case ButtonEnumeration::RIGHT: buttons |= RAD_RBUTTON; break; + default: break; } if ( bitfield_enabled( flags, c_modifierControl ) ) { @@ -978,20 +971,31 @@ void XYWnd::DropClipPoint( int pointx, int pointy ){ Vector3 mid; Select_GetMid( mid ); - g_clip_viewtype = static_cast( GetViewType() ); + g_clip_viewtype = GetViewType(); const int nDim = ( g_clip_viewtype == YZ ) ? 0 : ( ( g_clip_viewtype == XZ ) ? 1 : 2 ); point[nDim] = mid[nDim]; vector3_snap( point, GetSnapGridSize() ); NewClipPoint( point ); } +Timer g_clipper_timer; +bool g_clipper_doubleclicked = false; + void XYWnd::Clipper_OnLButtonDown( int x, int y ){ + bool doubleclick = g_clipper_timer.elapsed_msec() < 200; + Vector3 mousePosition; XY_ToPoint( x, y, mousePosition ); - g_pMovingClip = GlobalClipPoints_Find( mousePosition, (VIEWTYPE)m_viewType, m_fScale ); + g_pMovingClip = GlobalClipPoints_Find( mousePosition, m_viewType, m_fScale ); if ( !g_pMovingClip ) { DropClipPoint( x, y ); } + else if( doubleclick ){ + UndoableCommand undo( "clipperClip" ); + Clip(); + g_clipper_doubleclicked = true; + } + g_clipper_timer.start(); } void XYWnd::Clipper_OnLButtonUp( int x, int y ){ @@ -1005,7 +1009,6 @@ void XYWnd::Clipper_OnMouseMoved( int x, int y ){ XY_ToPoint( x, y, g_pMovingClip->m_ptClip ); XY_SnapToGrid( g_pMovingClip->m_ptClip ); Clip_Update(); - ClipperChangeNotify(); } } @@ -1016,7 +1019,7 @@ void XYWnd::Clipper_Crosshair_OnMouseMoved( int x, int y ){ Vector3 mousePosition; XY_ToPoint( x, y, mousePosition ); if ( ClipMode() ) { - if( GlobalClipPoints_Find( mousePosition, (VIEWTYPE)m_viewType, m_fScale ) != 0 ){ + if( GlobalClipPoints_Find( mousePosition, m_viewType, m_fScale ) != 0 ){ GdkCursor *cursor; cursor = gdk_cursor_new( GDK_CROSSHAIR ); //cursor = gdk_cursor_new( GDK_FLEUR ); @@ -1031,7 +1034,6 @@ void XYWnd::Clipper_Crosshair_OnMouseMoved( int x, int y ){ // g_object_unref( pixbuf ); gdk_window_set_cursor( m_gl_widget->window, cursor ); gdk_cursor_unref( cursor ); - } } else @@ -1518,8 +1520,10 @@ void XYWnd::XY_MouseUp( int x, int y, unsigned int buttons ){ else if ( m_zoom_started ) { Zoom_End(); } - else if ( ClipMode() && ( buttons == Clipper_buttons() || buttons == Clipper_quick_buttons() ) ) { + else if ( ( ClipMode() && ( buttons == Clipper_buttons() || buttons == Clipper_quick_buttons() ) ) || + g_clipper_doubleclicked ){ Clipper_OnLButtonUp( x, y ); + g_clipper_doubleclicked = false; } else if ( m_bNewBrushDrag ) { m_bNewBrushDrag = false; @@ -2455,7 +2459,7 @@ void SetState( Shader* state, EStyle style ){ m_state_stack.back().m_state = state; } } -const EStyle getStyle() const { +EStyle getStyle() const { return eWireframeOnly; } void PushState(){ diff --git a/tools/quake3/common/cmdlib.h b/tools/quake3/common/cmdlib.h index 701b3016..45611b2d 100644 --- a/tools/quake3/common/cmdlib.h +++ b/tools/quake3/common/cmdlib.h @@ -26,7 +26,7 @@ #include "bytebool.h" -#ifdef _WIN32 +#ifdef _MSC_VER #pragma warning(disable : 4244) // MIPS #pragma warning(disable : 4136) // X86 #pragma warning(disable : 4051) // ALPHA @@ -46,7 +46,7 @@ #include #include -#ifdef _WIN32 +#ifdef _MSC_VER #pragma intrinsic( memset, memcpy ) diff --git a/tools/quake3/common/vfs.h b/tools/quake3/common/vfs.h index eb6abe75..5b6e604c 100644 --- a/tools/quake3/common/vfs.h +++ b/tools/quake3/common/vfs.h @@ -44,7 +44,7 @@ #define R_OK 04 #endif -#define S_ISDIR( mode ) ( mode & _S_IFDIR ) +//#define S_ISDIR( mode ) ( mode & _S_IFDIR ) #define PATH_MAX 260 #endif #include diff --git a/tools/quake3/q3map2/convert_map.c b/tools/quake3/q3map2/convert_map.c index 3081ef77..8f62d1fe 100644 --- a/tools/quake3/q3map2/convert_map.c +++ b/tools/quake3/q3map2/convert_map.c @@ -674,11 +674,13 @@ static void ConvertBrush( FILE *f, int num, bspBrush_t *brush, vec3_t origin, qb vert[2]->xyz[sv], vert[2]->xyz[tv], stK[i] ); VectorSet( sts[i], D0 / D, D1 / D, D2 / D ); + //Sys_Printf( "%.3f %.3f %.3f \n", sts[i][0], sts[i][1], sts[i][2] ); } } else{ fprintf( stderr, "degenerate triangle found when solving texDef equations\n" ); // FIXME add stuff here - + VectorSet( sts[0], 2.f, 0.f, 0.f ); + VectorSet( sts[1], 0.f, -2.f, 0.f ); } // now we must solve: // // now we must invert: diff --git a/tools/quake3/q3map2/light_ydnar.c b/tools/quake3/q3map2/light_ydnar.c index f655fb03..b4b7841c 100644 --- a/tools/quake3/q3map2/light_ydnar.c +++ b/tools/quake3/q3map2/light_ydnar.c @@ -3221,7 +3221,7 @@ void IlluminateVertexes( int num ){ void SetupBrushesFlags( int mask_any, int test_any, int mask_all, int test_all ){ int i, j, b; - unsigned int compileFlags, allCompileFlags; + int compileFlags, allCompileFlags; bspBrush_t *brush; bspBrushSide_t *side; bspShader_t *shader; @@ -3249,7 +3249,7 @@ void SetupBrushesFlags( int mask_any, int test_any, int mask_all, int test_all ) /* check all sides */ compileFlags = 0; - allCompileFlags = ~( 0u ); + allCompileFlags = ~( 0 ); for ( j = 0; j < brush->numSides; j++ ) { /* do bsp shader calculations */