From 88a616da7585f317ce7b1a4651dffc1b2a36e1c6 Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Sat, 23 Jan 2016 19:33:26 -0500 Subject: [PATCH 1/5] - Removed what appears to be a debug breakpoint. - Cleared some GCC and Clang warnings. Mostly static analysis false positives, but one of them generated a pretty massive warning in a release build. - Use -Wno-unused-result since I doubt we're going to address those unless they actually prove to be a problem (and they only appear in release builds). --- dumb/CMakeLists.txt | 2 +- src/CMakeLists.txt | 3 +- src/p_mobj.cpp | 2 +- src/p_pspr.cpp | 2 +- src/p_spec.cpp | 2 +- src/p_teleport.cpp | 2 +- src/r_data/r_interpolate.cpp | 2 - src/s_sound.cpp | 83 +++++++++++++++++++----------------- src/v_font.cpp | 4 +- 9 files changed, 53 insertions(+), 49 deletions(-) diff --git a/dumb/CMakeLists.txt b/dumb/CMakeLists.txt index b590aa165..fd8cdd968 100644 --- a/dumb/CMakeLists.txt +++ b/dumb/CMakeLists.txt @@ -8,7 +8,7 @@ include( CheckCXXCompilerFlag ) set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG -DDEBUGMODE=1" ) if( ZD_CMAKE_COMPILER_IS_GNUC_COMPATIBLE ) - set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-pointer-sign -Wno-uninitialized" ) + set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-pointer-sign -Wno-uninitialized -Wno-unused-but-set-variable" ) endif( ZD_CMAKE_COMPILER_IS_GNUC_COMPATIBLE ) CHECK_FUNCTION_EXISTS( itoa ITOA_EXISTS ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e161a85dd..70890c5fc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -456,7 +456,8 @@ if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) set( CMAKE_CXX_FLAGS_MINSIZEREL "${REL_CXX_FLAGS} ${CMAKE_CXX_FLAGS_MINSIZEREL}" ) set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${REL_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" ) - set( CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-unused -Wno-unused-parameter -Wno-missing-field-initializers ${CMAKE_CXX_FLAGS}" ) + set( CMAKE_C_FLAGS "-Wall -Wextra -Wno-unused -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unused-result ${CMAKE_C_FLAGS}" ) + set( CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-unused -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unused-result ${CMAKE_CXX_FLAGS}" ) # Remove extra warnings when using the official DirectX headers. # Also, TDM-GCC 4.4.0 no longer accepts glibc-style printf formats as valid, diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 32a20e321..67f7d1685 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -5939,7 +5939,7 @@ AActor *P_SpawnPlayerMissile (AActor *source, fixed_t x, fixed_t y, fixed_t z, const PClass *type, angle_t angle, AActor **pLineTarget, AActor **pMissileActor, bool nofreeaim, bool noautoaim) { - static const int angdiff[3] = { -1<<26, 1<<26, 0 }; + static const int angdiff[3] = { -(1<<26), 1<<26, 0 }; angle_t an = angle; angle_t pitch; AActor *linetarget; diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index 7cdef059c..0ced8f004 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -891,7 +891,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AInventory, A_GunFlash) angle_t P_BulletSlope (AActor *mo, AActor **pLineTarget) { - static const int angdiff[3] = { -1<<26, 1<<26, 0 }; + static const int angdiff[3] = { -(1<<26), 1<<26, 0 }; int i; angle_t an; angle_t pitch; diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 2cb322278..0dcf5124a 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -1223,7 +1223,7 @@ void P_InitSectorSpecial(sector_t *sector, int special, bool nothinkers) if (!nothinkers) { new DStrobe(sector, STROBEBRIGHT, FASTDARK, false); - new DScroller(DScroller::sc_floor, (-FRACUNIT / 2) << 3, + new DScroller(DScroller::sc_floor, -((FRACUNIT / 2) << 3), 0, -1, int(sector - sectors), 0); } keepspecial = true; diff --git a/src/p_teleport.cpp b/src/p_teleport.cpp index ab860bfe9..85b668bf0 100644 --- a/src/p_teleport.cpp +++ b/src/p_teleport.cpp @@ -108,7 +108,7 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, sector_t *destsect; bool resetpitch = false; fixed_t floorheight, ceilingheight; - fixed_t missilespeed; + fixed_t missilespeed = 0; old = thing->Pos(); aboveFloor = thing->Z() - thing->floorz; diff --git a/src/r_data/r_interpolate.cpp b/src/r_data/r_interpolate.cpp index 82e27abb4..4ce3a3c7b 100644 --- a/src/r_data/r_interpolate.cpp +++ b/src/r_data/r_interpolate.cpp @@ -447,8 +447,6 @@ void DSectorPlaneInterpolation::UpdateInterpolation() oldheight = sector->ceilingplane.d; oldtexz = sector->GetPlaneTexZ(sector_t::ceiling); } - if (oldtexz <-128*FRACUNIT) - __asm nop } //========================================================================== diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 2a9703ae4..c05ef1036 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -676,52 +676,55 @@ static void CalcPosVel(int type, const AActor *actor, const sector_t *sector, z = y = x = 0; } - switch (type) + // [BL] Moved this case out of the switch statement to make code easier + // on static analysis. + if(type == SOURCE_Unattached) { - case SOURCE_None: - default: - break; - - case SOURCE_Actor: -// assert(actor != NULL); - if (actor != NULL) - { - x = actor->SoundX(); - y = actor->SoundZ(); - z = actor->SoundY(); - } - break; - - case SOURCE_Sector: - assert(sector != NULL); - if (sector != NULL) - { - if (chanflags & CHAN_AREA) - { - CalcSectorSoundOrg(sector, channum, &x, &z, &y); - } - else - { - x = sector->soundorg[0]; - z = sector->soundorg[1]; - chanflags |= CHAN_LISTENERZ; - } - } - break; - - case SOURCE_Polyobj: - assert(poly != NULL); - CalcPolyobjSoundOrg(poly, &x, &z, &y); - break; - - case SOURCE_Unattached: pos->X = pt[0]; pos->Y = !(chanflags & CHAN_LISTENERZ) ? pt[1] : FIXED2FLOAT(y); pos->Z = pt[2]; - break; } - if (type != SOURCE_Unattached) + else { + switch (type) + { + case SOURCE_None: + default: + break; + + case SOURCE_Actor: + //assert(actor != NULL); + if (actor != NULL) + { + x = actor->SoundX(); + y = actor->SoundZ(); + z = actor->SoundY(); + } + break; + + case SOURCE_Sector: + assert(sector != NULL); + if (sector != NULL) + { + if (chanflags & CHAN_AREA) + { + CalcSectorSoundOrg(sector, channum, &x, &z, &y); + } + else + { + x = sector->soundorg[0]; + z = sector->soundorg[1]; + chanflags |= CHAN_LISTENERZ; + } + } + break; + + case SOURCE_Polyobj: + assert(poly != NULL); + CalcPolyobjSoundOrg(poly, &x, &z, &y); + break; + } + if ((chanflags & CHAN_LISTENERZ) && players[consoleplayer].camera != NULL) { y = players[consoleplayer].camera != NULL ? players[consoleplayer].camera->SoundZ() : 0; diff --git a/src/v_font.cpp b/src/v_font.cpp index 5fc2994fb..e30f8352d 100644 --- a/src/v_font.cpp +++ b/src/v_font.cpp @@ -1059,7 +1059,9 @@ void FSingleLumpFont::LoadTranslations() break; default: - break; + // Should be unreachable. + I_Error("Unknown font type in FSingleLumpFont::LoadTranslation."); + return; } for(unsigned int i = 0;i < count;++i) From 20f7f524ca3d5d447bc9e2e78cada93244ee0dd8 Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Sat, 23 Jan 2016 20:09:39 -0500 Subject: [PATCH 2/5] - Don't link against sndfile and mpg123 if not compiling with OpenAL support. --- src/CMakeLists.txt | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 70890c5fc..40503f8e9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -286,16 +286,19 @@ if( NO_FMOD ) endif( NO_FMOD ) if( NO_OPENAL ) add_definitions( -DNO_OPENAL=1 ) + + set(MPG123_FOUND NO) + set(SNDFILE_FOUND NO) +else( NO_OPENAL ) + # Search for libSndFile + + find_package( SndFile ) + + # Search for libmpg123 + + find_package( MPG123 ) endif( NO_OPENAL ) -# Search for libSndFile - -find_package( SndFile ) - -# Search for libmpg123 - -find_package( MPG123 ) - # Search for FluidSynth find_package( FluidSynth ) From 5abacf0b2f322b505625eb731bfd554a8ee1aa9e Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Sat, 23 Jan 2016 21:40:19 -0500 Subject: [PATCH 3/5] - Fixed: Uninitialized variable on DrawSelectedInventory. --- src/g_shared/sbarinfo_commands.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_shared/sbarinfo_commands.cpp b/src/g_shared/sbarinfo_commands.cpp index 2f7739a4f..7a874328f 100644 --- a/src/g_shared/sbarinfo_commands.cpp +++ b/src/g_shared/sbarinfo_commands.cpp @@ -1595,7 +1595,7 @@ class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDra public: CommandDrawSelectedInventory(SBarInfo *script) : CommandDrawImage(script), CommandDrawNumber(script), alternateOnEmpty(false), - artiflash(false), alwaysShowCounter(false) + artiflash(false), alwaysShowCounter(false), itemflash(false) { length = INT_MAX; // Counter size } From fc15be8689d3648d40199e4b4a3f50ebe7790a42 Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Sat, 23 Jan 2016 21:47:20 -0500 Subject: [PATCH 4/5] - Improved DrawSwitchableImage keyslot condition to include key species. - Fixed: currentpos command would crash if not in game. --- src/c_cmds.cpp | 11 +++++++-- src/g_shared/sbarinfo_commands.cpp | 39 ++++++++++++++++++++++++++---- 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/src/c_cmds.cpp b/src/c_cmds.cpp index 3cfbf1c65..233c31d29 100644 --- a/src/c_cmds.cpp +++ b/src/c_cmds.cpp @@ -1083,8 +1083,15 @@ CCMD(nextsecret) CCMD(currentpos) { AActor *mo = players[consoleplayer].mo; - Printf("Current player position: (%1.3f,%1.3f,%1.3f), angle: %1.3f, floorheight: %1.3f, sector:%d, lightlevel: %d\n", - FIXED2FLOAT(mo->X()), FIXED2FLOAT(mo->Y()), FIXED2FLOAT(mo->Z()), mo->angle/float(ANGLE_1), FIXED2FLOAT(mo->floorz), mo->Sector->sectornum, mo->Sector->lightlevel); + if(mo) + { + Printf("Current player position: (%1.3f,%1.3f,%1.3f), angle: %1.3f, floorheight: %1.3f, sector:%d, lightlevel: %d\n", + FIXED2FLOAT(mo->X()), FIXED2FLOAT(mo->Y()), FIXED2FLOAT(mo->Z()), mo->angle/float(ANGLE_1), FIXED2FLOAT(mo->floorz), mo->Sector->sectornum, mo->Sector->lightlevel); + } + else + { + Printf("You are not in game!"); + } } //----------------------------------------------------------------------------- diff --git a/src/g_shared/sbarinfo_commands.cpp b/src/g_shared/sbarinfo_commands.cpp index 7a874328f..f91d5841c 100644 --- a/src/g_shared/sbarinfo_commands.cpp +++ b/src/g_shared/sbarinfo_commands.cpp @@ -412,6 +412,21 @@ class CommandDrawSwitchableImage : public CommandDrawImage return compare != value; } } + // Key species are used to allow altnerates for existing key slots. + static FName LookupKeySpecies(int keynum) + { + for(unsigned int i = 0;i < PClass::m_Types.Size();++i) + { + const PClass *cls = PClass::m_Types[i]; + if(cls->IsDescendantOf(RUNTIME_CLASS(AKey))) + { + AKey *key = (AKey *)GetDefaultByType(cls); + if(key->KeyNumber == keynum) + return cls->TypeName; + } + } + return FName(); + } public: CommandDrawSwitchableImage(SBarInfo *script) : CommandDrawImage(script), @@ -442,6 +457,7 @@ class CommandDrawSwitchableImage : public CommandDrawImage condition = KEYSLOT; sc.MustGetToken(TK_IntConst); conditionalValue[0] = sc.Number; + keySpecies[0] = LookupKeySpecies(conditionalValue[0]); } else if(sc.Compare("armortype")) { @@ -468,6 +484,8 @@ class CommandDrawSwitchableImage : public CommandDrawImage { sc.MustGetToken(TK_IntConst); conditionalValue[1] = sc.Number; + if(condition == KEYSLOT) + keySpecies[1] = LookupKeySpecies(conditionalValue[1]); } else if(condition == ARMORTYPE) { @@ -541,11 +559,21 @@ class CommandDrawSwitchableImage : public CommandDrawImage if(item->IsKindOf(RUNTIME_CLASS(AKey))) { int keynum = static_cast(item)->KeyNumber; - - if(keynum == conditionalValue[0]) - found1 = true; - if(conditionAnd && keynum == conditionalValue[1]) // two keys - found2 = true; + if(keynum) + { + if(keynum == conditionalValue[0]) + found1 = true; + if(conditionAnd && keynum == conditionalValue[1]) // two keys + found2 = true; + } + else + { + FName species = item->GetSpecies(); + if(species == keySpecies[0]) + found1 = true; + if(conditionAnd && species == keySpecies[1]) + found2 = true; + } } } @@ -639,6 +667,7 @@ class CommandDrawSwitchableImage : public CommandDrawImage Operator conditionalOperator[2]; FString inventoryItem[2]; int armorType[2]; + FName keySpecies[2]; }; //////////////////////////////////////////////////////////////////////////////// From fd4440cfe4288f4e3b3f1610d8ce1ad981844169 Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Sat, 23 Jan 2016 23:34:07 -0500 Subject: [PATCH 5/5] - Fixed: Intermissions with no screens (such as EndTitle) would result in a double wipe. --- src/intermission/intermission.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/intermission/intermission.cpp b/src/intermission/intermission.cpp index a19d0a479..44f52485c 100644 --- a/src/intermission/intermission.cpp +++ b/src/intermission/intermission.cpp @@ -722,7 +722,10 @@ DIntermissionController::DIntermissionController(FIntermissionDescriptor *Desc, mScreen = NULL; mFirst = true; mGameState = state; - NextPage(); + + // If the intermission finishes straight away then cancel the wipe. + if(!NextPage()) + wipegamestate = GS_FINALE; } bool DIntermissionController::NextPage ()