Fix warning -Wtautological-undefined-compare

Quoting Clang:
"reference cannot be bound to dereferenced null pointer in well-defined
C++ code; comparison may be assumed to always evaluate to false"

Conflicts:
	Sources/CMakeLists.txt
This commit is contained in:
Emil Laine 2016-04-24 00:57:23 +03:00 committed by Daniel Gibson
parent 16a2048a2c
commit 4b0e01145e
9 changed files with 50 additions and 46 deletions

View File

@ -121,7 +121,7 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
MESSAGE(WARNING, "re-enable some of the warnings some day!")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
add_compile_options(-Wno-tautological-undefined-compare) # don't complain about if(this!=NULL)
# !!! FIXME: turn a bunch of these off, this is just for now. I hope. --ryan.
add_compile_options(-Wno-c++11-compat-deprecated-writable-strings)
endif()

View File

@ -562,9 +562,9 @@ void CBrushShadowMap::CheckLayersUpToDate(void)
CBrushShadowLayer &bsl = *itbsl;
if( bsl.bsl_ulFlags&BSLF_ALLDARK) continue;
// light source must be valid
ASSERT( bsl.bsl_plsLightSource!=NULL);
if( bsl.bsl_plsLightSource==NULL) continue;
CLightSource &ls = *bsl.bsl_plsLightSource;
ASSERT( &ls!=NULL);
if( &ls==NULL) continue;
// if the layer is not up to date
if( bsl.bsl_colLastAnim != ls.GetLightColor()) {
// invalidate entire shadow map
@ -581,9 +581,9 @@ BOOL CBrushShadowMap::HasDynamicLayers(void)
// for each layer
FOREACHINLIST( CBrushShadowLayer, bsl_lnInShadowMap, bsm_lhLayers, itbsl)
{ // light source must be valid
ASSERT( itbsl->bsl_plsLightSource!=NULL);
if( itbsl->bsl_plsLightSource==NULL) continue;
CLightSource &ls = *itbsl->bsl_plsLightSource;
ASSERT( &ls!=NULL);
if( &ls==NULL) continue;
// if the layer is dynamic, it has
if( ls.ls_ulFlags&LSF_DYNAMIC) return TRUE;
}

View File

@ -688,6 +688,7 @@ inline const CEntityPointer &CEntityPointer::operator=(const CEntityPointer &pen
return *this;
}
inline CEntity* CEntityPointer::operator->(void) const { return ep_pen; }
inline CEntity* CEntityPointer::get(void) const { return ep_pen; }
inline CEntityPointer::operator CEntity*(void) const { return ep_pen; }
inline CEntity& CEntityPointer::operator*(void) const { return *ep_pen; }

View File

@ -35,6 +35,7 @@ public:
inline const CEntityPointer &operator=(CEntity *pen);
inline const CEntityPointer &operator=(const CEntityPointer &penOther);
inline CEntity* operator->(void) const;
inline CEntity* get(void) const;
inline operator CEntity*(void) const;
inline CEntity& operator*(void) const;
};

View File

@ -1770,8 +1770,9 @@ void CLayerMixer::MixOneMipmap(CBrushShadowMap *pbsm, INDEX iMipmap)
if( lm_pbpoPolygon->bpo_ulFlags&BPOF_HASDIRECTIONALAMBIENT) {
{FOREACHINLIST( CBrushShadowLayer, bsl_lnInShadowMap, lm_pbsmShadowMap->bsm_lhLayers, itbsl) {
CBrushShadowLayer &bsl = *itbsl;
ASSERT( bsl.bsl_plsLightSource!=NULL);
if( bsl.bsl_plsLightSource==NULL) continue; // safety check
CLightSource &ls = *bsl.bsl_plsLightSource;
ASSERT( &ls!=NULL); if( &ls==NULL) continue; // safety check
if( !(ls.ls_ulFlags&LSF_DIRECTIONAL)) continue; // skip non-directional layers
COLOR col = AdjustColor( ls.GetLightAmbient(), _slShdHueShift, _slShdSaturation);
colAmbient = AddColors( colAmbient, col);
@ -1843,8 +1844,9 @@ void CLayerMixer::MixOneMipmap(CBrushShadowMap *pbsm, INDEX iMipmap)
{FORDELETELIST( CBrushShadowLayer, bsl_lnInShadowMap, lm_pbsmShadowMap->bsm_lhLayers, itbsl)
{
CBrushShadowLayer &bsl = *itbsl;
ASSERT( bsl.bsl_plsLightSource!=NULL);
if( bsl.bsl_plsLightSource==NULL) continue; // safety check
CLightSource &ls = *bsl.bsl_plsLightSource;
ASSERT( &ls!=NULL); if( &ls==NULL) continue; // safety check
// skip if should not be applied
if( (bDynamicOnly && !(ls.ls_ulFlags&LSF_NONPERSISTENT)) || (ls.ls_ulFlags & LSF_DYNAMIC)) continue;

View File

@ -1115,10 +1115,10 @@ void CObjectPolygon::JoinContinuingEdges(CDynamicArray<CObjectEdge> &oedEdges)
// for each edge
{FOREACHINDYNAMICARRAY(opo_PolygonEdges, CObjectPolygonEdge, itope) {
CObjectEdge &oedThis = *itope->ope_Edge;
CObjectEdge *poedThis = itope->ope_Edge;
// if not already marked for removal
if (&oedThis != NULL) {
if (poedThis != NULL) {
CObjectVertex *povxStartThis, *povxEndThis;
// get start and end vertices
itope->GetVertices(povxStartThis, povxEndThis);
@ -1133,12 +1133,12 @@ void CObjectPolygon::JoinContinuingEdges(CDynamicArray<CObjectEdge> &oedEdges)
// for each edge
{FOREACHINDYNAMICARRAY(opo_PolygonEdges, CObjectPolygonEdge, itope2) {
CObjectEdge &oedOther = *itope2->ope_Edge;
CObjectEdge *poedOther = itope2->ope_Edge;
// if not already marked for removal
if (&oedOther != NULL) {
if (poedOther != NULL) {
// if the two edges are collinear
if ( CompareEdgeLines(*oedThis.colinear2.oed_pedxLine, *oedOther.colinear2.oed_pedxLine)==0) {
if ( CompareEdgeLines(*poedThis->colinear2.oed_pedxLine, *poedOther->colinear2.oed_pedxLine)==0) {
CObjectVertex *povxStartOther, *povxEndOther;
// get start and end vertices
itope2->GetVertices(povxStartOther, povxEndOther);

View File

@ -779,23 +779,23 @@ CScreenPolygon *CRenderer::MakeScreenPolygon(CBrushPolygon &bpo)
void CRenderer::AddPolygonToScene( CScreenPolygon *pspo)
{
// if the polygon is not falid or occluder and not selected
CBrushPolygon &bpo = *pspo->spo_pbpoBrushPolygon;
if( &bpo==NULL || ((bpo.bpo_ulFlags&BPOF_OCCLUDER) && (!(bpo.bpo_ulFlags&BPOF_SELECTED) ||
CBrushPolygon *pbpo = pspo->spo_pbpoBrushPolygon;
if(pbpo==NULL || ((pbpo->bpo_ulFlags&BPOF_OCCLUDER) && (!(pbpo->bpo_ulFlags&BPOF_SELECTED) ||
_wrpWorldRenderPrefs.GetSelectionType()!=CWorldRenderPrefs::ST_POLYGONS))) {
// do not add it to rendering
return;
}
CBrushSector &bsc = *bpo.bpo_pbscSector;
CBrushSector &bsc = *pbpo->bpo_pbscSector;
ScenePolygon &sppo = pspo->spo_spoScenePolygon;
const CViewVertex *pvvx0 = &re_avvxViewVertices[bsc.bsc_ivvx0];
const INDEX ctVtx = bpo.bpo_apbvxTriangleVertices.Count();
const INDEX ctVtx = pbpo->bpo_apbvxTriangleVertices.Count();
sppo.spo_iVtx0 = _avtxScene.Count();
GFXVertex3 *pvtx = _avtxScene.Push(ctVtx);
// find vertex with nearest Z distance while copying vertices
FLOAT fNearestZ = 123456789.0f;
for( INDEX i=0; i<ctVtx; i++) {
CBrushVertex *pbvx = bpo.bpo_apbvxTriangleVertices[i];
CBrushVertex *pbvx = pbpo->bpo_apbvxTriangleVertices[i];
const INDEX iVtx = bsc.bsc_abvxVertices.Index(pbvx);
const FLOAT3D &v = pvvx0[iVtx].vvx_vView;
if( -v(3)<fNearestZ) fNearestZ = -v(3); // inverted because of negative sign
@ -809,8 +809,8 @@ void CRenderer::AddPolygonToScene( CScreenPolygon *pspo)
// all done
sppo.spo_ctVtx = ctVtx;
sppo.spo_ctElements = bpo.bpo_aiTriangleElements.Count();
sppo.spo_piElements = sppo.spo_ctElements ? &bpo.bpo_aiTriangleElements[0] : NULL;
sppo.spo_ctElements = pbpo->bpo_aiTriangleElements.Count();
sppo.spo_piElements = sppo.spo_ctElements ? &pbpo->bpo_aiTriangleElements[0] : NULL;
_sfStats.IncrementCounter(CStatForm::SCI_SCENE_TRIANGLES, sppo.spo_ctElements/3);
}

View File

@ -172,15 +172,15 @@ void CWorld::DoCSGOperation(
AssureFPT_53();
// get relevant brush mips in each brush
CBrushMip &bmThis = *GetBrushMip(enThis);
CBrushMip &bmOther = *GetBrushMip(enOther);
if (&bmThis==NULL || &bmOther==NULL) {
CBrushMip *pbmThis = GetBrushMip(enThis);
CBrushMip *pbmOther = GetBrushMip(enOther);
if (pbmThis==NULL || pbmOther==NULL) {
return;
}
// get open sector of the other brush to object
CBrushSectorSelectionForCSG selbscOtherOpen;
bmOther.SelectOpenSector(selbscOtherOpen);
pbmOther->SelectOpenSector(selbscOtherOpen);
CObject3D obOtherOpen;
DOUBLEaabbox3D boxOtherOpen;
woOther.CopySourceBrushSectorsToObject(enOther, selbscOtherOpen, plOther,
@ -193,7 +193,7 @@ void CWorld::DoCSGOperation(
obOtherOpen.TurnPortalsToWalls();
// if there are any sectors in this brush
if (bmThis.bm_abscSectors.Count()>0) {
if (pbmThis->bm_abscSectors.Count()>0) {
// move affected part of this brush to an object3d object
CObject3D obThis;
MoveTargetBrushPartToObject(enThis, boxOtherOpen, obThis);
@ -213,7 +213,7 @@ void CWorld::DoCSGOperation(
// get closed sectors of the other brush to object
CBrushSectorSelectionForCSG selbscOtherClosed;
bmOther.SelectClosedSectors(selbscOtherClosed);
pbmOther->SelectClosedSectors(selbscOtherClosed);
CObject3D obOtherClosed;
DOUBLEaabbox3D boxOtherClosed;
woOther.CopySourceBrushSectorsToObject(enOther, selbscOtherClosed, plOther,
@ -224,7 +224,7 @@ void CWorld::DoCSGOperation(
CObject3D obResult;
// if there are any sectors in this brush
if (bmThis.bm_abscSectors.Count()>0) {
if (pbmThis->bm_abscSectors.Count()>0) {
// move affected part of this brush to an object3d object
CObject3D obThis;
MoveTargetBrushPartToObject(enThis, boxOtherClosed, obThis);
@ -304,16 +304,16 @@ void CWorld::CSGRemove(CEntity &enThis, CWorld &woOther, CEntity &enOther,
AssureFPT_53();
// get relevant brush mip in other brush
CBrushMip &bmOther = *GetBrushMip(enOther);
if (&bmOther==NULL) {
CBrushMip *pbmOther = GetBrushMip(enOther);
if (pbmOther==NULL) {
return;
}
// if other brush has more than one sector
if (bmOther.bm_abscSectors.Count()>1) {
if (pbmOther->bm_abscSectors.Count()>1) {
// join all sectors of the other brush together
CBrushSectorSelection selbscOtherAll;
bmOther.SelectAllSectors(selbscOtherAll);
pbmOther->SelectAllSectors(selbscOtherAll);
woOther.JoinSectors(selbscOtherAll);
}
@ -380,15 +380,15 @@ void CWorld::SplitSectors(CEntity &enThis, CBrushSectorSelection &selbscSectorsT
AssureFPT_53();
// get relevant brush mip in this brush
CBrushMip &bmThis = *GetBrushMip(enThis);
if (&bmThis==NULL) {
CBrushMip *pbmThis = GetBrushMip(enThis);
if (pbmThis==NULL) {
_pfWorldEditingProfile.StopTimer(CWorldEditingProfile::PTI_CSGTOTAL);
return;
}
// get relevant brush mip in other brush
CBrushMip &bmOther = *GetBrushMip(enOther);
if (&bmOther==NULL) {
CBrushMip *pbmOther = GetBrushMip(enOther);
if (pbmOther==NULL) {
_pfWorldEditingProfile.StopTimer(CWorldEditingProfile::PTI_CSGTOTAL);
return;
}
@ -396,10 +396,10 @@ void CWorld::SplitSectors(CEntity &enThis, CBrushSectorSelection &selbscSectorsT
/* Assure that the other brush has only one sector. */
// if other brush has more than one sector
if (bmOther.bm_abscSectors.Count()>1) {
if (pbmOther->bm_abscSectors.Count()>1) {
// join all sectors of the other brush together
CBrushSectorSelection selbscOtherAll;
bmOther.SelectAllSectors(selbscOtherAll);
pbmOther->SelectAllSectors(selbscOtherAll);
woOther.JoinSectors(selbscOtherAll);
}
@ -407,7 +407,7 @@ void CWorld::SplitSectors(CEntity &enThis, CBrushSectorSelection &selbscSectorsT
// get the sector of the other brush to object
CBrushSectorSelectionForCSG selbscOther;
bmOther.SelectAllSectors(selbscOther);
pbmOther->SelectAllSectors(selbscOther);
CObject3D obOther;
DOUBLEaabbox3D boxOther;
woOther.CopySourceBrushSectorsToObject(enOther, selbscOther, plOther,
@ -416,7 +416,7 @@ void CWorld::SplitSectors(CEntity &enThis, CBrushSectorSelection &selbscSectorsT
// if the selection is empty
if (selbscSectorsToSplit.Count()==0) {
// select all sectors near the splitting tool
bmThis.SelectSectorsInRange(selbscSectorsToSplit, DOUBLEtoFLOAT(boxOther));
pbmThis->SelectSectorsInRange(selbscSectorsToSplit, DOUBLEtoFLOAT(boxOther));
}
// for all sectors in the selection
FOREACHINDYNAMICCONTAINER(selbscSectorsToSplit, CBrushSector, itbsc) {
@ -426,7 +426,7 @@ void CWorld::SplitSectors(CEntity &enThis, CBrushSectorSelection &selbscSectorsT
}
// update the bounding boxes of this brush
bmThis.bm_pbrBrush->CalculateBoundingBoxes();
pbmThis->bm_pbrBrush->CalculateBoundingBoxes();
// find possible shadow layers near affected area
FindShadowLayers(DOUBLEtoFLOAT(boxOther));
@ -574,8 +574,8 @@ void CWorld::SplitPolygons(CEntity &enThis, CBrushPolygonSelection &selbpoPolygo
_pfWorldEditingProfile.IncrementAveragingCounter();
// get relevant brush mip in other brush
CBrushMip &bmOther = *GetBrushMip(enOther);
if (&bmOther==NULL) {
CBrushMip *pbmOther = GetBrushMip(enOther);
if (pbmOther==NULL) {
_pfWorldEditingProfile.StopTimer(CWorldEditingProfile::PTI_CSGTOTAL);
return;
}
@ -596,7 +596,7 @@ void CWorld::SplitPolygons(CEntity &enThis, CBrushPolygonSelection &selbpoPolygo
// get the sector of the other brush to object
CBrushSectorSelectionForCSG selbscOther;
bmOther.SelectAllSectors(selbscOther);
pbmOther->SelectAllSectors(selbscOther);
CObject3D obOther;
DOUBLEaabbox3D boxOther;
woOther.CopySourceBrushSectorsToObject(enOther, selbscOther, plOther,

View File

@ -627,7 +627,7 @@ functions:
while (iCount>0)
{
i++;
while (&*pen[i]==NULL) {
while (pen[i].get()==NULL) {
i++;
}
iCount--;
@ -1337,17 +1337,17 @@ procedures:
m_iGroup01Count = 0;
pen = &m_penGroup01Template01;
for (i=0; i<SUMMONER_TEMP_PER_GROUP; i++) {
if (&*pen[i]!=NULL) { m_iGroup01Count++; }
if (pen[i].get()!=NULL) { m_iGroup01Count++; }
}
m_iGroup02Count = 0;
pen = &m_penGroup02Template01;
for (i=0; i<SUMMONER_TEMP_PER_GROUP; i++) {
if (&*pen[i]!=NULL) { m_iGroup02Count++; }
if (pen[i].get()!=NULL) { m_iGroup02Count++; }
}
m_iGroup03Count = 0;
pen = &m_penGroup03Template01;
for (i=0; i<SUMMONER_TEMP_PER_GROUP; i++) {
if (&*pen[i]!=NULL) { m_iGroup03Count++; }
if (pen[i].get()!=NULL) { m_iGroup03Count++; }
}
if (!DoSafetyChecks()) {