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 tons of compiler warnings #44

Merged
merged 12 commits into from
May 24, 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
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
Build/
Debug/

# custom user build dirs
/*build*
/Sources/*build*

# Visual Studio
*.vs
*.opendb
Expand Down Expand Up @@ -70,20 +74,22 @@ Sources/Entities/*.cpp
# Other generated files:
Sources/Engine/Ska/smcScan.cpp
Sources/Engine/Ska/smcPars.h
Sources/Engine/Ska/smcPars.hpp
Sources/Engine/Ska/smcPars.cpp
Sources/Engine/Base/Parser.cpp
Sources/Engine/Base/Parser.h
Sources/Engine/Base/Parser.hpp
Sources/Engine/Base/Scanner.cpp
Sources/Ecc/Parser.cpp
Sources/Ecc/Parser.h
Sources/Ecc/Parser.hpp
Sources/Ecc/Scanner.cpp
Sources/SeriousSkaStudio/Parser.cpp
Sources/SeriousSkaStudio/Parser.h
Sources/SeriousSkaStudio/Parser.hpp
Sources/SeriousSkaStudio/Scanner.cpp

# vim swap files
*.swp
*.swo



16 changes: 8 additions & 8 deletions Sources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,21 @@ 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)
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)
add_compile_options(-Wno-unused-variable) # TODO: maybe only enable this for Entities
add_compile_options(-Wno-unused-value) # same here (the Scripts generate tons of unused variables and values)
add_compile_options(-Wno-missing-braces)
add_compile_options(-Wno-overloaded-virtual)
add_compile_options(-Wno-invalid-offsetof)
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-tautological-undefined-compare) # don't complain about if(this!=NULL)
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()

if(MACOSX)
Expand Down
8 changes: 4 additions & 4 deletions Sources/Engine/Base/Anim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,13 +296,13 @@ void CAnimData::LoadFromScript_t( CTStream *File, CListHead *pFrameFileList) //
char ld_line[ 128];
CTmpListHead TempAnimationList;
SLONG lc;
BOOL ret_val;
//BOOL ret_val;

//ASSERT( ad_Anims == NULL);
// clears possible animations
CAnimData::Clear();

ret_val = TRUE;
//ret_val = TRUE;
FOREVER
{
// Repeat reading of one line of script file until it is not empty or comment
Expand Down Expand Up @@ -904,14 +904,14 @@ void CAnimObject::PlayAnim(INDEX iNew, ULONG ulFlags)
class COneAnim *pCOA = &ao_AnimData->ad_Anims[ao_iCurrentAnim];
TIME tmNow = _pTimer->CurrentTick();
TIME tmLength = GetCurrentAnimLength();
FLOAT fFrame = ((_pTimer->CurrentTick() - ao_tmAnimStart)/pCOA->oa_SecsPerFrame);
FLOAT fFrame = ((tmNow - ao_tmAnimStart)/pCOA->oa_SecsPerFrame);
INDEX iFrame = INDEX(fFrame);
FLOAT fFract = fFrame-iFrame;
iFrame = ClipFrame(iFrame);
TIME tmPassed = (iFrame+fFract)*pCOA->oa_SecsPerFrame;
TIME tmLeft = tmLength-tmPassed;
// set time ahead to end of the current animation
ao_tmAnimStart = _pTimer->CurrentTick()+tmLeft;
ao_tmAnimStart = tmNow+tmLeft;
// remember last animation
ao_iLastAnim = ao_iCurrentAnim;
// set new animation number
Expand Down
6 changes: 3 additions & 3 deletions Sources/Engine/Base/Lists.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ BOOL CListHead::IsValid(void) const
{
ASSERT(this!=NULL);
ASSERT(lh_NULL == NULL);
ASSERT((lh_Head == (CListNode *) &lh_NULL) && (lh_Tail == (CListNode *) &lh_Head)
|| lh_Tail->IsValid() && lh_Head->IsValid() );
ASSERT(((lh_Head == (CListNode *) &lh_NULL) && (lh_Tail == (CListNode *) &lh_Head))
|| (lh_Tail->IsValid() && lh_Head->IsValid()) );
return TRUE;
}

Expand Down Expand Up @@ -211,7 +211,7 @@ BOOL CListNode::IsValid(void) const
ASSERT((ln_Pred==NULL && ln_Succ==NULL) || (ln_Pred!=NULL && ln_Succ!=NULL));
// it is valid if it is cleared or if it is linked
return (ln_Pred==NULL && ln_Succ==NULL)
|| (ln_Pred->ln_Succ == this) && (ln_Succ->ln_Pred == this);
|| ((ln_Pred->ln_Succ == this) && (ln_Succ->ln_Pred == this));
}

/*
Expand Down
2 changes: 1 addition & 1 deletion Sources/Engine/Base/Shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ CDynamicStackArray<CTString> _shell_astrTempStrings;
CDynamicStackArray<CTString> _shell_astrExtStrings;
CDynamicStackArray<FLOAT> _shell_afExtFloats;

static const char *strCommandLine = "";
//static const char *strCommandLine = "";

FLOAT tmp_af[10] = { 0 };
INDEX tmp_ai[10] = { 0 };
Expand Down
6 changes: 3 additions & 3 deletions Sources/Engine/Base/Stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ void CTFileStream::Create_t(const CTFileName &fnFileName,
}

CTFileName fnmFullFileName;
INDEX iFile = ExpandFilePath(EFP_WRITE, fnFileNameAbsolute, fnmFullFileName);
/* INDEX iFile = */ ExpandFilePath(EFP_WRITE, fnFileNameAbsolute, fnmFullFileName);

// check parameters
ASSERT(strlen(fnFileNameAbsolute)>0);
Expand Down Expand Up @@ -1317,7 +1317,7 @@ BOOL FileExistsForWriting(const CTFileName &fnmFile)
}
// expand the filename to full path for writing
CTFileName fnmFullFileName;
INDEX iFile = ExpandFilePath(EFP_WRITE, fnmFile, fnmFullFileName);
/* INDEX iFile = */ ExpandFilePath(EFP_WRITE, fnmFile, fnmFullFileName);

// check if it exists
FILE *f = fopen(fnmFullFileName, "rb");
Expand Down Expand Up @@ -1433,7 +1433,7 @@ static INDEX ExpandFilePath_read(ULONG ulType, const CTFileName &fnmFile, CTFile
{
// search for the file in zips
INDEX iFileInZip = UNZIPGetFileIndex(fnmFile);
const BOOL userdir_not_basedir = (_fnmUserDir != _fnmApplicationPath);
//const BOOL userdir_not_basedir = (_fnmUserDir != _fnmApplicationPath);

// if a mod is active
if (_fnmMod!="") {
Expand Down
15 changes: 5 additions & 10 deletions Sources/Engine/Base/Timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ void CTimer_TimerFunc_internal(void)
CTimerValue tvTimeNow = _pTimer->GetHighPrecisionTimer();
TIME tmTickNow = _pTimer->tm_RealTimeTimer;
// calculate how long has passed since we have last been on time
TIME tmTimeDelay = (TIME)(tvTimeNow - _pTimer->tm_tvLastTimeOnTime).GetSeconds();
TIME tmTickDelay = (tmTickNow - _pTimer->tm_tmLastTickOnTime);
//TIME tmTimeDelay = (TIME)(tvTimeNow - _pTimer->tm_tvLastTimeOnTime).GetSeconds();
//TIME tmTickDelay = (tmTickNow - _pTimer->tm_tmLastTickOnTime);

_sfStats.StartTimer(CStatForm::STI_TIMER);
// if we are keeping up to time (more or less)
Expand Down Expand Up @@ -209,13 +209,14 @@ Uint32 CTimer_TimerFunc_SDL(Uint32 interval, void* param)

#pragma inline_depth()


#ifdef PLATFORM_WIN32 // DG: not used on other platforms
#define MAX_MEASURE_TRIES 5
static INDEX _aiTries[MAX_MEASURE_TRIES];

// Get processor speed in Hertz
static __int64 GetCPUSpeedHz(void)
{
#ifdef PLATFORM_WIN32
// get the frequency of the 'high' precision timer
__int64 llTimerFrequency;
BOOL bPerformanceCounterPresent = QueryPerformanceFrequency((LARGE_INTEGER*)&llTimerFrequency);
Expand Down Expand Up @@ -296,14 +297,8 @@ static __int64 GetCPUSpeedHz(void)
// use measured value
return (__int64)slSpeedRead*1000000;
}
#else

STUBBED("I hope this isn't critical...");
return(1);

#endif

}
#endif // PLATFORM_WIN32


#if PLATFORM_MACOSX
Expand Down
36 changes: 33 additions & 3 deletions Sources/Engine/Base/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -679,15 +679,45 @@ inline void Clear(float i) {};
inline void Clear(double i) {};
inline void Clear(void *pv) {};

// These macros are not safe to use unless data is UNSIGNED!
#define BYTESWAP16_unsigned(x) ((((x)>>8)&0xff)+ (((x)<<8)&0xff00))
#define BYTESWAP32_unsigned(x) (((x)>>24) + (((x)>>8)&0xff00) + (((x)<<8)&0xff0000) + ((x)<<24))
// DG: screw macros, use inline functions instead - they're even safe for signed values
inline UWORD BYTESWAP16_unsigned(UWORD x)
{
#ifdef __GNUC__ // GCC and clang have a builtin that hopefully does the most efficient thing
return __builtin_bswap16(x);
#else
return (((x)>>8)&0xff)+ (((x)<<8)&0xff00);
#endif
}

inline ULONG BYTESWAP32_unsigned(ULONG x)
{
#ifdef __GNUC__ // GCC and clang have a builtin that hopefully does the most efficient thing
return __builtin_bswap32(x);
#else
return ((x)>>24) + (((x)>>8)&0xff00) + (((x)<<8)&0xff0000) + ((x)<<24);
#endif
}

inline __uint64 BYTESWAP64_unsigned(__uint64 x)
{
#ifdef __GNUC__ // GCC and clang have a builtin that hopefully does the most efficient thing
return __builtin_bswap64(x);
#else
ULONG l = BYTESWAP32_unsigned((ULONG)(val & 0xFFFFFFFF));
ULONG h = BYTESWAP32_unsigned((ULONG)((val >> 32) & 0xFFFFFFFF));
return (((__uint64)l) << 32) | ((__uint64)h);
#endif
}

// rcg03242004
#if PLATFORM_LITTLEENDIAN
#define BYTESWAP(x)
#else

// TODO: DG: the following stuff could probably be updated to use the functions above properly,
// which should make lots of cases easier. As I don't have a big endian machine I can't test,
// so I won't touch this for now.

static inline void BYTESWAP(UWORD &val)
{
#if __POWERPC__
Expand Down
2 changes: 1 addition & 1 deletion Sources/Engine/Brushes/BrushPolygon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ CBrushPolygon &CBrushPolygon::CopyPolygon(CBrushPolygon &bp)
bpo_boxBoundingBox=bp.bpo_boxBoundingBox;
bpo_pbscSector=bp.bpo_pbscSector;
bpo_rsOtherSideSectors.Clear();
bpo_lhShadingInfos;
//bpo_lhShadingInfos; // don't copy or anything, it's a CListHead which must not be copied
bpo_iInWorld=bp.bpo_iInWorld;
return *this;
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/Engine/Brushes/BrushSector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ CBrushSector::CBrushSector(void)
, bsc_ulFlags2(0)
, bsc_ulTempFlags(0)
, bsc_ulVisFlags(0)
, bsc_strName("")
, bsc_bspBSPTree(*new DOUBLEbsptree3D)
, bsc_strName("")
{

};
Expand Down Expand Up @@ -622,9 +622,9 @@ void CBrushSector::TriangularizeMarkedPolygons( void)
bpoNew.bpo_abpePolygonEdges[2].bpe_pbedEdge = &abedEdgesNew[iEdge+2];
bpoNew.bpo_abpePolygonEdges[2].bpe_bReverse = FALSE;

CBrushEdge &edg0 = *bpoNew.bpo_abpePolygonEdges[0].bpe_pbedEdge;
CBrushEdge &edg1 = *bpoNew.bpo_abpePolygonEdges[1].bpe_pbedEdge;
CBrushEdge &edg2 = *bpoNew.bpo_abpePolygonEdges[2].bpe_pbedEdge;
//CBrushEdge &edg0 = *bpoNew.bpo_abpePolygonEdges[0].bpe_pbedEdge;
//CBrushEdge &edg1 = *bpoNew.bpo_abpePolygonEdges[1].bpe_pbedEdge;
//CBrushEdge &edg2 = *bpoNew.bpo_abpePolygonEdges[2].bpe_pbedEdge;

// set brush vertex ptrs
bpoNew.bpo_apbvxTriangleVertices.New(3);
Expand Down
2 changes: 1 addition & 1 deletion Sources/Engine/Brushes/BrushShadows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ BOOL CBrushShadowMap::IsShadowFlat( COLOR &colFlat)
COLOR col;
UBYTE ubR,ubG,ubB, ubR1,ubG1,ubB1;
SLONG slR=0,slG=0,slB=0;
INDEX ctPointLights=0;
//INDEX ctPointLights=0;
CBrushPolygon *pbpo = GetBrushPolygon();

// if the shadowmap is not using the shading mode
Expand Down
6 changes: 3 additions & 3 deletions Sources/Engine/Brushes/BrushTriangularize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ void CTriangularizer::MakeEdgesForTriangularization(void)
// get number of edges in polygon
INDEX ctEdges = tr_abpeOriginalEdges.Count();
// create that much edges in the array
CBrushEdge *pbedEdges = tr_abedEdges.New(ctEdges);
/* CBrushEdge *pbedEdges = */ tr_abedEdges.New(ctEdges);

tr_abedEdges.Lock();

Expand Down Expand Up @@ -480,7 +480,7 @@ void CTriangularizer::FindExistingTriangleEdges(void)

// for each edge
FOREACHINDYNAMICARRAY(tr_abedEdges, CBrushEdge, itbed) {
CBrushEdge *pbed = itbed;
//CBrushEdge *pbed = itbed;

// if it is the bottom edge of the triangle
if (tr_pbedBottom == itbed) {
Expand Down Expand Up @@ -517,7 +517,7 @@ BOOL CTriangularizer::CheckTriangleAgainstEdges(void)
{
// for each edge
FOREACHINDYNAMICARRAY(tr_abedEdges, CBrushEdge, itbed) {
CBrushEdge *pbed = itbed;
//CBrushEdge *pbed = itbed;

// if it is the bottom edge of the triangle
if (tr_pbedBottom == itbed) {
Expand Down
26 changes: 13 additions & 13 deletions Sources/Engine/Classes/MovableEntity.es
Original file line number Diff line number Diff line change
Expand Up @@ -1009,8 +1009,8 @@ functions:
}
// find current breathing parameters
BOOL bCanBreathe =
(ctUp.ct_ulFlags&CTF_BREATHABLE_LUNGS) && (en_ulPhysicsFlags&EPF_HASLUNGS) ||
(ctUp.ct_ulFlags&CTF_BREATHABLE_GILLS) && (en_ulPhysicsFlags&EPF_HASGILLS);
((ctUp.ct_ulFlags&CTF_BREATHABLE_LUNGS) && (en_ulPhysicsFlags&EPF_HASLUNGS)) ||
((ctUp.ct_ulFlags&CTF_BREATHABLE_GILLS) && (en_ulPhysicsFlags&EPF_HASGILLS));
TIME tmNow = _pTimer->CurrentTick();
TIME tmBreathDelay = tmNow-en_tmLastBreathed;
// if entity can breathe now
Expand Down Expand Up @@ -1207,8 +1207,8 @@ functions:

// if polygon's steepness is too high
CSurfaceType &stReference = en_pwoWorld->wo_astSurfaceTypes[pbpo->bpo_bppProperties.bpp_ubSurfaceType];
if (fCos>=-stReference.st_fClimbSlopeCos&&fCos<0
||stReference.st_ulFlags&STF_SLIDEDOWNSLOPE) {
if ((fCos >= -stReference.st_fClimbSlopeCos && fCos<0)
|| stReference.st_ulFlags&STF_SLIDEDOWNSLOPE) {
// it cannot be below
_pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_ISSTANDINGONPOLYGON);
return FALSE;
Expand Down Expand Up @@ -1529,11 +1529,11 @@ out:;
// going up or
iStep==0 ||
// going forward and hit stairs or
iStep==1 && bHitStairsNow ||
(iStep==1 && bHitStairsNow) ||
// going down and ends on something that is not high slope
iStep==2 &&
(iStep==2 &&
(vHitPlane%en_vGravityDir<-stHit.st_fClimbSlopeCos ||
bHitStairsNow);
bHitStairsNow));

// if early clip is allowed
if (bEarlyClipAllowed || bSlidingAllowed) {
Expand Down Expand Up @@ -2322,8 +2322,8 @@ out:;
FLOAT fPlaneYAbs = Abs(fPlaneY);
FLOAT fFriction = stReference.st_fFriction;
// if on a steep slope
if (fPlaneY>=-stReference.st_fClimbSlopeCos&&fPlaneY<0
||(stReference.st_ulFlags&STF_SLIDEDOWNSLOPE)&&fPlaneY>-0.99f) {
if ((fPlaneY>=-stReference.st_fClimbSlopeCos&&fPlaneY<0)
||((stReference.st_ulFlags&STF_SLIDEDOWNSLOPE)&&fPlaneY>-0.99f)) {
en_ulPhysicsFlags|=EPF_ONSTEEPSLOPE;
// accellerate horizontaly towards desired absolute translation
AddAccelerationOnPlane2(
Expand Down Expand Up @@ -2737,8 +2737,8 @@ out:;
/* old */ FLOAT fPlaneYAbs = Abs(fPlaneY);
/* old */ FLOAT fFriction = stReference.st_fFriction;
/* old */ // if on a steep slope
/* old */ if (fPlaneY>=-stReference.st_fClimbSlopeCos&&fPlaneY<0
/* old */ ||(stReference.st_ulFlags&STF_SLIDEDOWNSLOPE)&&fPlaneY>-0.99f) {
/* old */ if ((fPlaneY>=-stReference.st_fClimbSlopeCos&&fPlaneY<0)
/* old */ ||((stReference.st_ulFlags&STF_SLIDEDOWNSLOPE)&&fPlaneY>-0.99f)) {
/* old */ en_ulPhysicsFlags|=EPF_ONSTEEPSLOPE;
/* old */ // accellerate horizontaly towards desired absolute translation
/* old */ AddAccelerationOnPlane2(
Expand Down Expand Up @@ -2863,7 +2863,7 @@ out:;

_pfPhysicsProfile.IncrementCounter((INDEX) CPhysicsProfile::PCI_DOMOVING);

FLOAT fTickQuantum=_pTimer->TickQuantum; // used for normalizing from SI units to game ticks
//FLOAT fTickQuantum=_pTimer->TickQuantum; // used for normalizing from SI units to game ticks

// if rotation and translation are synchronized
if (en_ulPhysicsFlags&EPF_RT_SYNCHRONIZED) {
Expand All @@ -2878,7 +2878,7 @@ out:;
if ((en_ulPhysicsFlags&EPF_ONBLOCK_MASK)==EPF_ONBLOCK_PUSH) {
penPusher = this;
}
BOOL bMoveSuccessfull = TryToMove(penPusher, TRUE, TRUE);
/* BOOL bMoveSuccessfull = */ TryToMove(penPusher, TRUE, TRUE);

// if rotation and translation are asynchronious
} else {
Expand Down
Loading