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

cherry-picked fixes by emlai, fix compilation again #54

Merged
merged 7 commits into from
May 29, 2016
Merged
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
4 changes: 1 addition & 3 deletions Sources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ 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
# !!! FIXME: turn a bunch of these off, this is just for now. I hope. --ryan.
add_compile_options(-Wno-sign-compare)
add_compile_options(-Wno-switch)
add_compile_options(-Wno-char-subscripts)
add_compile_options(-Wno-unknown-pragmas)
Expand All @@ -123,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
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);
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
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
18 changes: 12 additions & 6 deletions Sources/Engine/Network/Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,8 @@ extern void FreeUnusedStock(void)
*/
void CNetworkTimerHandler::HandleTimer(void)
{
if (this==NULL || _bTempNetwork) {
ASSERT(this!=NULL);
if (_bTempNetwork) {
return; // this can happen during NET_MakeDefaultState_t()!
}
// enable stream handling during timer
Expand Down Expand Up @@ -902,7 +903,8 @@ void CNetworkLibrary::Init(const CTString &strGameID)
*/
void CNetworkLibrary::AddTimerHandler(void)
{
if (this==NULL || _bTempNetwork) {
ASSERT(this!=NULL);
if (_bTempNetwork) {
return; // this can happen during NET_MakeDefaultState_t()!
}
_pTimer->AddHandler(&ga_thTimerHandler);
Expand All @@ -912,7 +914,8 @@ void CNetworkLibrary::AddTimerHandler(void)
*/
void CNetworkLibrary::RemoveTimerHandler(void)
{
if (this==NULL || _bTempNetwork) {
ASSERT(this!=NULL);
if (_bTempNetwork) {
return; // this can happen during NET_MakeDefaultState_t()!
}
_pTimer->RemHandler(&ga_thTimerHandler);
Expand Down Expand Up @@ -1390,7 +1393,8 @@ void CNetworkLibrary::TogglePause(void)
// test if game is paused
BOOL CNetworkLibrary::IsPaused(void)
{
if (this==NULL || _bTempNetwork) {
ASSERT(this!=NULL);
if (_bTempNetwork) {
return TRUE; // this can happen during NET_MakeDefaultState_t()!
}
return ga_sesSessionState.ses_bPause;
Expand Down Expand Up @@ -1427,7 +1431,8 @@ void CNetworkLibrary::SetLocalPause(BOOL bPause)

BOOL CNetworkLibrary::GetLocalPause(void)
{
if (this==NULL || _bTempNetwork) {
ASSERT(this!=NULL);
if (_bTempNetwork) {
return TRUE; // this can happen during NET_MakeDefaultState_t()!
}
return ga_bLocalPause;
Expand Down Expand Up @@ -2033,7 +2038,8 @@ void CNetworkLibrary::SendActionsToServer(void)
*/
void CNetworkLibrary::TimerLoop(void)
{
if (this==NULL || _bTempNetwork) {
ASSERT(this!=NULL);
if (_bTempNetwork) {
return; // this can happen during NET_MakeDefaultState_t()!
}
_pfNetworkProfile.StartTimer(CNetworkProfile::PTI_TIMERLOOP);
Expand Down
Loading