Skip to content

Commit

Permalink
Fix warning -Wtautological-undefined-compare
Browse files Browse the repository at this point in the history
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
  • Loading branch information
emlai authored and DanielGibson committed May 29, 2016
1 parent 16a2048 commit 4b0e011
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 46 deletions.
2 changes: 1 addition & 1 deletion Sources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
8 changes: 4 additions & 4 deletions Sources/Engine/Brushes/BrushShadows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions Sources/Engine/Entities/Entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down
1 change: 1 addition & 0 deletions Sources/Engine/Entities/EntityPointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class CEntityPointer {
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;
};
Expand Down
6 changes: 4 additions & 2 deletions Sources/Engine/Light/LayerMixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions Sources/Engine/Math/ObjectSector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
14 changes: 7 additions & 7 deletions Sources/Engine/Rendering/RenCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}

Expand Down
46 changes: 23 additions & 23 deletions Sources/Engine/World/WorldCSG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand All @@ -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,
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -380,34 +380,34 @@ 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;
}

/* 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);
}

/* Split selected sectors with the one sector in the other brush. */

// 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,
Expand All @@ -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) {
Expand All @@ -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));

Expand Down Expand Up @@ -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;
}
Expand All @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions Sources/EntitiesMP/Summoner.es
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ functions:
while (iCount>0)
{
i++;
while (&*pen[i]==NULL) {
while (pen[i].get()==NULL) {
i++;
}
iCount--;
Expand Down Expand Up @@ -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()) {
Expand Down

0 comments on commit 4b0e011

Please sign in to comment.