From 6d419a245f8eb266c1a3521ad0540a7b6e3ae6f6 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sun, 11 Aug 2013 13:20:37 +0200 Subject: [PATCH 1/7] Fix vbsp missing skybox error case when building cubemaps. The code previoused checked the address of a stack array that would always evaluate non-zero, which wasn't what was intended. --- mp/src/utils/vbsp/cubemap.cpp | 11 ++++++----- sp/src/utils/vbsp/cubemap.cpp | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/mp/src/utils/vbsp/cubemap.cpp b/mp/src/utils/vbsp/cubemap.cpp index fda41703..2415115b 100644 --- a/mp/src/utils/vbsp/cubemap.cpp +++ b/mp/src/utils/vbsp/cubemap.cpp @@ -286,12 +286,8 @@ void CreateDefaultCubemaps( bool bHDR ) // NOTE: This implementation depends on the fact that all VTF files contain // all mipmap levels const char *pSkyboxBaseName = FindSkyboxMaterialName(); - char skyboxMaterialName[MAX_PATH]; - Q_snprintf( skyboxMaterialName, MAX_PATH, "skybox/%s", pSkyboxBaseName ); - IVTFTexture *pSrcVTFTextures[6]; - - if( !skyboxMaterialName ) + if( !pSkyboxBaseName ) { if( s_DefaultCubemapNames.Count() ) { @@ -300,6 +296,11 @@ void CreateDefaultCubemaps( bool bHDR ) return; } + char skyboxMaterialName[MAX_PATH]; + Q_snprintf( skyboxMaterialName, MAX_PATH, "skybox/%s", pSkyboxBaseName ); + + IVTFTexture *pSrcVTFTextures[6]; + int unionTextureFlags = 0; if( !LoadSrcVTFFiles( pSrcVTFTextures, skyboxMaterialName, &unionTextureFlags, bHDR ) ) { diff --git a/sp/src/utils/vbsp/cubemap.cpp b/sp/src/utils/vbsp/cubemap.cpp index fda41703..2415115b 100644 --- a/sp/src/utils/vbsp/cubemap.cpp +++ b/sp/src/utils/vbsp/cubemap.cpp @@ -286,12 +286,8 @@ void CreateDefaultCubemaps( bool bHDR ) // NOTE: This implementation depends on the fact that all VTF files contain // all mipmap levels const char *pSkyboxBaseName = FindSkyboxMaterialName(); - char skyboxMaterialName[MAX_PATH]; - Q_snprintf( skyboxMaterialName, MAX_PATH, "skybox/%s", pSkyboxBaseName ); - IVTFTexture *pSrcVTFTextures[6]; - - if( !skyboxMaterialName ) + if( !pSkyboxBaseName ) { if( s_DefaultCubemapNames.Count() ) { @@ -300,6 +296,11 @@ void CreateDefaultCubemaps( bool bHDR ) return; } + char skyboxMaterialName[MAX_PATH]; + Q_snprintf( skyboxMaterialName, MAX_PATH, "skybox/%s", pSkyboxBaseName ); + + IVTFTexture *pSrcVTFTextures[6]; + int unionTextureFlags = 0; if( !LoadSrcVTFFiles( pSrcVTFTextures, skyboxMaterialName, &unionTextureFlags, bHDR ) ) { From 53ac2580ac9a515f8cb4ee6a1213ef253e8941f4 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sun, 11 Aug 2013 11:02:54 +0200 Subject: [PATCH 2/7] Fix SortEntry operator< not being const. This solves a problem where the standard library expects it to be const, which causes compilation problems on GNU/Linux. --- mp/src/utils/common/mstristrip.cpp | 2 +- sp/src/utils/common/mstristrip.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mp/src/utils/common/mstristrip.cpp b/mp/src/utils/common/mstristrip.cpp index 6a66de2f..9e611f94 100644 --- a/mp/src/utils/common/mstristrip.cpp +++ b/mp/src/utils/common/mstristrip.cpp @@ -867,7 +867,7 @@ public: int iFirstUsed; int iOrigIndex; - bool operator<(const SortEntry& rhs) + bool operator<(const SortEntry& rhs) const { return iFirstUsed < rhs.iFirstUsed; } diff --git a/sp/src/utils/common/mstristrip.cpp b/sp/src/utils/common/mstristrip.cpp index 6a66de2f..9e611f94 100644 --- a/sp/src/utils/common/mstristrip.cpp +++ b/sp/src/utils/common/mstristrip.cpp @@ -867,7 +867,7 @@ public: int iFirstUsed; int iOrigIndex; - bool operator<(const SortEntry& rhs) + bool operator<(const SortEntry& rhs) const { return iFirstUsed < rhs.iFirstUsed; } From 324b4f93dcdda1d4e50497d8ec69a6372a6817bd Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sun, 11 Aug 2013 11:43:19 +0200 Subject: [PATCH 3/7] Fix bad class declaration in utils/vbsp/ivp. The duplicated namespace in the member declaration causes the class to not compile using gcc. --- mp/src/utils/vbsp/ivp.cpp | 2 +- sp/src/utils/vbsp/ivp.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mp/src/utils/vbsp/ivp.cpp b/mp/src/utils/vbsp/ivp.cpp index 421b1b2e..585f0904 100644 --- a/mp/src/utils/vbsp/ivp.cpp +++ b/mp/src/utils/vbsp/ivp.cpp @@ -432,7 +432,7 @@ public: private: - CPhysConvex *CPlaneList::BuildConvexForBrush( int brushnumber, float shrink, CPhysCollide *pCollideTest, float shrinkMinimum ); + CPhysConvex *BuildConvexForBrush( int brushnumber, float shrink, CPhysCollide *pCollideTest, float shrinkMinimum ); public: CUtlVector m_convex; diff --git a/sp/src/utils/vbsp/ivp.cpp b/sp/src/utils/vbsp/ivp.cpp index 421b1b2e..585f0904 100644 --- a/sp/src/utils/vbsp/ivp.cpp +++ b/sp/src/utils/vbsp/ivp.cpp @@ -432,7 +432,7 @@ public: private: - CPhysConvex *CPlaneList::BuildConvexForBrush( int brushnumber, float shrink, CPhysCollide *pCollideTest, float shrinkMinimum ); + CPhysConvex *BuildConvexForBrush( int brushnumber, float shrink, CPhysCollide *pCollideTest, float shrinkMinimum ); public: CUtlVector m_convex; From c5fb3851bb7650e3d83857f89555134acc36283f Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Mon, 12 Aug 2013 14:55:24 +0200 Subject: [PATCH 4/7] Fix use of temporary vector in utils/vrad/vraddetailprops.cpp. This fixes a gcc compile error. --- mp/src/utils/vrad/vraddetailprops.cpp | 3 ++- sp/src/utils/vrad/vraddetailprops.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mp/src/utils/vrad/vraddetailprops.cpp b/mp/src/utils/vrad/vraddetailprops.cpp index 6712beb1..822bc78c 100644 --- a/mp/src/utils/vrad/vraddetailprops.cpp +++ b/mp/src/utils/vrad/vraddetailprops.cpp @@ -524,7 +524,8 @@ private: bool TestPointAgainstSkySurface( Vector const &pt, dface_t *pFace ) { // Create sky face winding. - winding_t *pWinding = WindingFromFace( pFace, Vector( 0.0f, 0.0f, 0.0f ) ); + Vector v( 0.0f, 0.0f, 0.0f ); + winding_t *pWinding = WindingFromFace( pFace, v ); // Test point in winding. (Since it is at the node, it is in the plane.) bool bRet = PointInWinding( pt, pWinding ); diff --git a/sp/src/utils/vrad/vraddetailprops.cpp b/sp/src/utils/vrad/vraddetailprops.cpp index 6712beb1..822bc78c 100644 --- a/sp/src/utils/vrad/vraddetailprops.cpp +++ b/sp/src/utils/vrad/vraddetailprops.cpp @@ -524,7 +524,8 @@ private: bool TestPointAgainstSkySurface( Vector const &pt, dface_t *pFace ) { // Create sky face winding. - winding_t *pWinding = WindingFromFace( pFace, Vector( 0.0f, 0.0f, 0.0f ) ); + Vector v( 0.0f, 0.0f, 0.0f ); + winding_t *pWinding = WindingFromFace( pFace, v ); // Test point in winding. (Since it is at the node, it is in the plane.) bool bRet = PointInWinding( pt, pWinding ); From b64d2e878c93977ae5c155ec574c00c20cf821f9 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Mon, 12 Aug 2013 14:37:24 +0200 Subject: [PATCH 5/7] Avoid conflict with gamma(3) in utils/vrad/vrad.h. The name of the global variable conflicts with the deprecated gamma function from on some systems. Additionally the variable appears to be unused - should it rather just be deleted from the codebase? --- mp/src/utils/vrad/vrad.cpp | 2 +- mp/src/utils/vrad/vrad.h | 2 +- sp/src/utils/vrad/vrad.cpp | 2 +- sp/src/utils/vrad/vrad.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mp/src/utils/vrad/vrad.cpp b/mp/src/utils/vrad/vrad.cpp index 854956ec..8100dc3f 100644 --- a/mp/src/utils/vrad/vrad.cpp +++ b/mp/src/utils/vrad/vrad.cpp @@ -93,7 +93,7 @@ bool g_bOnlyStaticProps = false; bool g_bShowStaticPropNormals = false; -float gamma = 0.5; +float gamma_value = 0.5; float indirect_sun = 1.0; float reflectivityScale = 1.0; qboolean do_extra = true; diff --git a/mp/src/utils/vrad/vrad.h b/mp/src/utils/vrad/vrad.h index b9dc0a3f..b39d66c8 100644 --- a/mp/src/utils/vrad/vrad.h +++ b/mp/src/utils/vrad/vrad.h @@ -336,7 +336,7 @@ extern dface_t *g_pFaces; extern bool g_bMPIProps; extern byte nodehit[MAX_MAP_NODES]; -extern float gamma; +extern float gamma_value; extern float indirect_sun; extern float smoothing_threshold; extern int dlight_map; diff --git a/sp/src/utils/vrad/vrad.cpp b/sp/src/utils/vrad/vrad.cpp index 854956ec..8100dc3f 100644 --- a/sp/src/utils/vrad/vrad.cpp +++ b/sp/src/utils/vrad/vrad.cpp @@ -93,7 +93,7 @@ bool g_bOnlyStaticProps = false; bool g_bShowStaticPropNormals = false; -float gamma = 0.5; +float gamma_value = 0.5; float indirect_sun = 1.0; float reflectivityScale = 1.0; qboolean do_extra = true; diff --git a/sp/src/utils/vrad/vrad.h b/sp/src/utils/vrad/vrad.h index b9dc0a3f..b39d66c8 100644 --- a/sp/src/utils/vrad/vrad.h +++ b/sp/src/utils/vrad/vrad.h @@ -336,7 +336,7 @@ extern dface_t *g_pFaces; extern bool g_bMPIProps; extern byte nodehit[MAX_MAP_NODES]; -extern float gamma; +extern float gamma_value; extern float indirect_sun; extern float smoothing_threshold; extern int dlight_map; From 63325a7174ebae9766c1ede2d961208b07554641 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sun, 11 Aug 2013 12:13:27 +0200 Subject: [PATCH 6/7] Use Q_strncpy in utils/vbsp/detailobjects.cpp. --- mp/src/utils/vbsp/detailobjects.cpp | 2 +- sp/src/utils/vbsp/detailobjects.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mp/src/utils/vbsp/detailobjects.cpp b/mp/src/utils/vbsp/detailobjects.cpp index 22595781..b110534c 100644 --- a/mp/src/utils/vbsp/detailobjects.cpp +++ b/mp/src/utils/vbsp/detailobjects.cpp @@ -379,7 +379,7 @@ static int SelectDetail( DetailObjectGroup_t const& group ) static int AddDetailDictLump( const char* pModelName ) { DetailObjectDictLump_t dictLump; - strncpy( dictLump.m_Name, pModelName, DETAIL_NAME_LENGTH ); + Q_strncpy( dictLump.m_Name, pModelName, DETAIL_NAME_LENGTH ); for (int i = s_DetailObjectDictLump.Count(); --i >= 0; ) { diff --git a/sp/src/utils/vbsp/detailobjects.cpp b/sp/src/utils/vbsp/detailobjects.cpp index 22595781..b110534c 100644 --- a/sp/src/utils/vbsp/detailobjects.cpp +++ b/sp/src/utils/vbsp/detailobjects.cpp @@ -379,7 +379,7 @@ static int SelectDetail( DetailObjectGroup_t const& group ) static int AddDetailDictLump( const char* pModelName ) { DetailObjectDictLump_t dictLump; - strncpy( dictLump.m_Name, pModelName, DETAIL_NAME_LENGTH ); + Q_strncpy( dictLump.m_Name, pModelName, DETAIL_NAME_LENGTH ); for (int i = s_DetailObjectDictLump.Count(); --i >= 0; ) { From 82fe37f0e65202c46a4bfb786ee7b679885f4df5 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sun, 11 Aug 2013 10:47:17 +0200 Subject: [PATCH 7/7] Fix bsp lump names being declared non-portably. gcc issues warnings when encountering multicharacter constants, so we'll simply emulate them in a manner works portably. The code assumes we are using a little-endian machine - the real solution would be using using four chars instead of an enum. --- mp/src/public/gamebspfile.h | 10 ++++++---- sp/src/public/gamebspfile.h | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/mp/src/public/gamebspfile.h b/mp/src/public/gamebspfile.h index 242d6ca9..786e0671 100644 --- a/mp/src/public/gamebspfile.h +++ b/mp/src/public/gamebspfile.h @@ -21,12 +21,14 @@ //----------------------------------------------------------------------------- // This enumerations defines all the four-CC codes for the client lump names //----------------------------------------------------------------------------- +// TODO: We may have some endian considerations here! +#define GAMELUMP_MAKE_CODE(a, b, c, d) ((a) << 24 | (b) << 16 | (c) << 8 | (d) << 0) enum { - GAMELUMP_DETAIL_PROPS = 'dprp', - GAMELUMP_DETAIL_PROP_LIGHTING = 'dplt', - GAMELUMP_STATIC_PROPS = 'sprp', - GAMELUMP_DETAIL_PROP_LIGHTING_HDR = 'dplh', + GAMELUMP_DETAIL_PROPS = GAMELUMP_MAKE_CODE('d', 'p', 'r', 'p'), + GAMELUMP_DETAIL_PROP_LIGHTING = GAMELUMP_MAKE_CODE('d', 'p', 'l', 't'), + GAMELUMP_STATIC_PROPS = GAMELUMP_MAKE_CODE('s', 'p', 'r', 'p'), + GAMELUMP_DETAIL_PROP_LIGHTING_HDR = GAMELUMP_MAKE_CODE('d', 'p', 'l', 'h'), }; // Versions... diff --git a/sp/src/public/gamebspfile.h b/sp/src/public/gamebspfile.h index 242d6ca9..786e0671 100644 --- a/sp/src/public/gamebspfile.h +++ b/sp/src/public/gamebspfile.h @@ -21,12 +21,14 @@ //----------------------------------------------------------------------------- // This enumerations defines all the four-CC codes for the client lump names //----------------------------------------------------------------------------- +// TODO: We may have some endian considerations here! +#define GAMELUMP_MAKE_CODE(a, b, c, d) ((a) << 24 | (b) << 16 | (c) << 8 | (d) << 0) enum { - GAMELUMP_DETAIL_PROPS = 'dprp', - GAMELUMP_DETAIL_PROP_LIGHTING = 'dplt', - GAMELUMP_STATIC_PROPS = 'sprp', - GAMELUMP_DETAIL_PROP_LIGHTING_HDR = 'dplh', + GAMELUMP_DETAIL_PROPS = GAMELUMP_MAKE_CODE('d', 'p', 'r', 'p'), + GAMELUMP_DETAIL_PROP_LIGHTING = GAMELUMP_MAKE_CODE('d', 'p', 'l', 't'), + GAMELUMP_STATIC_PROPS = GAMELUMP_MAKE_CODE('s', 'p', 'r', 'p'), + GAMELUMP_DETAIL_PROP_LIGHTING_HDR = GAMELUMP_MAKE_CODE('d', 'p', 'l', 'h'), }; // Versions...