Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some warnings #45

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Sources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,16 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -Os -fno-unsafe-math-optimizations")

# TODO fix these warnings
add_compile_options(-Wno-sign-compare)
add_compile_options(-Wno-switch)
add_compile_options(-Wno-unknown-pragmas)
add_compile_options(-Wno-unused-variable)
add_compile_options(-Wno-unused-value)
add_compile_options(-Wno-reorder)
add_compile_options(-Wno-unused-but-set-variable)
add_compile_options(-Wno-parentheses)
MESSAGE(WARNING, "re-enable some of the warnings some day!")

if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
# !!! FIXME: turn a bunch of these off, this is just for now. I hope. --ryan.
add_compile_options(-Wno-tautological-undefined-compare)
add_compile_options(-Wno-c++11-compat-deprecated-writable-strings)
add_compile_options(-Wno-logical-op-parentheses) # FIXME: this too should be re-enabled
endif()
Expand Down
10 changes: 4 additions & 6 deletions Sources/Engine/Base/Anim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,14 @@ BOOL CAnimData::IsAutoFreed(void)
// Reference counting functions
void CAnimData::AddReference(void)
{
if (this!=NULL) {
MarkUsed();
}
ASSERT(this!=NULL);
MarkUsed();
}

void CAnimData::RemReference(void)
{
if (this!=NULL) {
RemReference_internal();
}
ASSERT(this!=NULL);
RemReference_internal();
}

void CAnimData::RemReference_internal(void)
Expand Down
40 changes: 10 additions & 30 deletions Sources/Engine/Base/Console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ CConsole::CConsole(void)
// Destructor.
CConsole::~CConsole(void)
{
if (this==NULL) {
return;
}
ASSERT(this!=NULL);
if (con_fLog!=NULL) {
fclose(con_fLog);
con_fLog = NULL;
Expand Down Expand Up @@ -102,25 +100,19 @@ void CConsole::Initialize(const CTFileName &fnmLog, INDEX ctCharsPerLine, INDEX
// Get current console buffer.
const char *CConsole::GetBuffer(void)
{
if (this==NULL) {
return "";
}
ASSERT(this!=NULL);
return con_strBuffer+(con_ctLines-con_ctLinesPrinted)*(con_ctCharsPerLine+1);
}
INDEX CConsole::GetBufferSize(void)
{
if (this==NULL) {
return 1;
}
ASSERT(this!=NULL);
return (con_ctCharsPerLine+1)*con_ctLines+1;
}

// Discard timing info for last lines
void CConsole::DiscardLastLineTimes(void)
{
if (this==NULL) {
return;
}
ASSERT(this!=NULL);
for(INDEX i=0; i<con_ctLines; i++) {
con_atmLines[i] = -10000.0f;
}
Expand All @@ -129,9 +121,7 @@ void CConsole::DiscardLastLineTimes(void)
// Get number of lines newer than given time
INDEX CConsole::NumberOfLinesAfter(TIME tmLast)
{
if (this==NULL) {
return 0;
}
ASSERT(this!=NULL);
// clamp console variable
con_iLastLines = Clamp( con_iLastLines, 0, (INDEX)CONSOLE_MAXLASTLINES);
// find number of last console lines to be displayed on screen
Expand All @@ -146,9 +136,7 @@ INDEX CConsole::NumberOfLinesAfter(TIME tmLast)
// Get one of last lines
CTString CConsole::GetLastLine(INDEX iLine)
{
if (this==NULL) {
return "";
}
ASSERT(this!=NULL);
if (iLine>=con_ctLinesPrinted) {
return "";
}
Expand All @@ -166,9 +154,7 @@ CTString CConsole::GetLastLine(INDEX iLine)
// clear one given line in buffer
void CConsole::ClearLine(INDEX iLine)
{
if (this==NULL) {
return;
}
ASSERT(this!=NULL);
// line must be valid
ASSERT(iLine>=0 && iLine<con_ctLines);
// get start of line
Expand All @@ -183,9 +169,7 @@ void CConsole::ClearLine(INDEX iLine)
// scroll buffer up, discarding lines at the start
void CConsole::ScrollBufferUp(INDEX ctLines)
{
if (this==NULL) {
return;
}
ASSERT(this!=NULL);
ASSERT(ctLines>0 && ctLines<con_ctLines);
// move buffer up
memmove(
Expand All @@ -207,9 +191,7 @@ void CConsole::ScrollBufferUp(INDEX ctLines)
// Add a line of text to console
void CConsole::PutString(const char *strString)
{
if (this==NULL) {
return;
}
ASSERT(this!=NULL);
// synchronize access to console
CTSingleLock slConsole(&con_csConsole, TRUE);

Expand Down Expand Up @@ -265,9 +247,7 @@ void CConsole::PutString(const char *strString)
// Close console log file buffers (call only when force-exiting!)
void CConsole::CloseLog(void)
{
if (this==NULL) {
return;
}
ASSERT(this!=NULL);
if (con_fLog!=NULL) {
fclose(con_fLog);
}
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
5 changes: 1 addition & 4 deletions Sources/Engine/Entities/Entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2036,10 +2036,7 @@ static CStaticStackArray<CSentEvent> _aseSentEvents; // delayed events
/* Send an event to this entity. */
void CEntity::SendEvent(const CEntityEvent &ee)
{
if (this==NULL) {
ASSERT(FALSE);
return;
}
ASSERT(this!=NULL);
CSentEvent &se = _aseSentEvents.Push();
se.se_penEntity = this;
se.se_peeEvent = ((CEntityEvent&)ee).MakeCopy(); // discard const qualifier
Expand Down
19 changes: 9 additions & 10 deletions Sources/Engine/Entities/Entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -688,24 +688,23 @@ 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; }

/////////////////////////////////////////////////////////////////////
// Reference counting functions
inline void CEntity::AddReference(void) {
if (this!=NULL) {
ASSERT(en_ctReferences>=0);
en_ctReferences++;
}
ASSERT(this!=NULL);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've definitely seen this one come through as NULL before. Are these not asserting for you?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, something went terribly wrong. Do you know what called AddReference on a NULL-pointer?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, something went terribly wrong. Do you know what called AddReference on a NULL-pointer?

I don't; maybe it was something that was fixed later (or it was a run that failed to load the Entities DLL or something...?). If it's not actually a problem, I'm happy. :)

ASSERT(en_ctReferences>=0);
en_ctReferences++;
};
inline void CEntity::RemReference(void) {
if (this!=NULL) {
ASSERT(en_ctReferences>0);
en_ctReferences--;
if(en_ctReferences==0) {
delete this;
}
ASSERT(this!=NULL);
ASSERT(en_ctReferences>0);
en_ctReferences--;
if(en_ctReferences==0) {
delete this;
}
};

Expand Down
10 changes: 4 additions & 6 deletions Sources/Engine/Entities/EntityClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,12 @@ CEntityClass::~CEntityClass(void)
/////////////////////////////////////////////////////////////////////
// Reference counting functions
void CEntityClass::AddReference(void) {
if (this!=NULL) {
MarkUsed();
}
ASSERT(this!=NULL);
MarkUsed();
};
void CEntityClass::RemReference(void) {
if (this!=NULL) {
_pEntityClassStock->Release(this);
}
ASSERT(this!=NULL);
_pEntityClassStock->Release(this);
};

/*
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
4 changes: 2 additions & 2 deletions Sources/Engine/Graphics/Font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void CFontData::Read_t( CTStream *inFile) // throw char *
SetCharSpacing(+1);
SetLineSpacing(+1);
SetSpaceWidth(0.5f);
fd_fcdFontCharData[' '].fcd_pixStart = 0;
fd_fcdFontCharData[(int)' '].fcd_pixStart = 0;
}

void CFontData::Write_t( CTStream *outFile) // throw char *
Expand Down Expand Up @@ -201,7 +201,7 @@ void CFontData::Make_t( const CTFileName &fnTexture, PIX pixCharWidth, PIX pixCh
iLetter++; // skip carriage return
}
// set default space width
fd_fcdFontCharData[' '].fcd_pixStart = 0;
fd_fcdFontCharData[(int)' '].fcd_pixStart = 0;
SetSpaceWidth(0.5f);

// all done
Expand Down
2 changes: 1 addition & 1 deletion Sources/Engine/Graphics/Font.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class ENGINE_API CFontData : public CSerial {
inline void SetFixedWidth(void) { fd_bFixedWidth = TRUE; };
inline void SetVariableWidth(void) { fd_bFixedWidth = FALSE; };
inline void SetSpaceWidth( FLOAT fWidthRatio) { // relative to char cell width (1/2 is default)
fd_fcdFontCharData[' '].fcd_pixEnd = (PIX)(fd_pixCharWidth*fWidthRatio); }
fd_fcdFontCharData[(int)' '].fcd_pixEnd = (PIX)(fd_pixCharWidth*fWidthRatio); }

void Read_t( CTStream *inFile); // throw char *
void Write_t( CTStream *outFile); // throw char *
Expand Down
2 changes: 1 addition & 1 deletion Sources/Engine/Graphics/GfxLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1627,7 +1627,7 @@ void CGfxLibrary::CreateWindowCanvas(void *hWnd, CViewPort **ppvpNew, CDrawPort
*ppvpNew = NULL;
*ppdpNew = NULL;
// create a new viewport
if (*ppvpNew = new CViewPort( pixWidth, pixHeight, (HWND)hWnd)) {
if ((*ppvpNew = new CViewPort( pixWidth, pixHeight, (HWND)hWnd))) {
// and it's drawport
*ppdpNew = &(*ppvpNew)->vp_Raster.ra_MainDrawPort;
} else {
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 @@ -1823,8 +1823,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 @@ -1898,8 +1899,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 @@ -1111,10 +1111,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 @@ -1129,12 +1129,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
2 changes: 1 addition & 1 deletion Sources/Engine/Models/RenderModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ BOOL CModelObject::CreateAttachment( CRenderModel &rmMain, CAttachmentModelObjec
_pfModelProfile.StartTimer( CModelProfile::PTI_CREATEATTACHMENT);
_pfModelProfile.IncrementTimerAveragingCounter( CModelProfile::PTI_CREATEATTACHMENT);
CRenderModel &rmAttached = *amo.amo_prm;
rmAttached.rm_ulFlags = rmMain.rm_ulFlags&(RMF_FOG|RMF_HAZE|RMF_WEAPON) | RMF_ATTACHMENT;
rmAttached.rm_ulFlags = (rmMain.rm_ulFlags&(RMF_FOG|RMF_HAZE|RMF_WEAPON)) | RMF_ATTACHMENT;

// get the position
rmMain.rm_pmdModelData->md_aampAttachedPosition.Lock();
Expand Down
2 changes: 1 addition & 1 deletion Sources/Engine/Network/CommunicationInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ void CCommunicationInterface::Client_OpenNet_t(ULONG ulServerAddress)
if (cm_ciLocalClient.ci_pbReliableInputBuffer.pb_ulNumOfPackets > 0) {
ppaReadPacket = cm_ciLocalClient.ci_pbReliableInputBuffer.GetFirstPacket();
// and it is a connection confirmation
if (ppaReadPacket->pa_ubReliable && UDP_PACKET_CONNECT_RESPONSE) {
if (ppaReadPacket->pa_ubReliable & UDP_PACKET_CONNECT_RESPONSE) {
// the client has succedeed to connect, so read the uwID from the packet
cm_ciLocalClient.ci_adrAddress.adr_ulAddress = ulServerAddress;
cm_ciLocalClient.ci_adrAddress.adr_uwPort = net_iPort;
Expand Down
Loading