diff --git a/src/am_map.cpp b/src/am_map.cpp index 1529b4740..0133a2493 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -1234,16 +1234,9 @@ void AM_initVariables () for (pnum=0;pnum=MAXPLAYERS) - { - m_x=m_y=0; - } - else - { - m_x = (players[pnum].camera->x >> FRACTOMAPBITS) - m_w/2; - m_y = (players[pnum].camera->y >> FRACTOMAPBITS) - m_h/2; - } + assert(pnum >= 0 && pnum < MAXPLAYERS); + m_x = (players[pnum].camera->x >> FRACTOMAPBITS) - m_w/2; + m_y = (players[pnum].camera->y >> FRACTOMAPBITS) - m_h/2; AM_changeWindowLoc(); // for saving & restoring diff --git a/src/b_bot.cpp b/src/b_bot.cpp index 548d10e2e..05cac045b 100644 --- a/src/b_bot.cpp +++ b/src/b_bot.cpp @@ -61,8 +61,8 @@ void DBot::Serialize (FArchive &arc) if (SaveVersion < 4515) { - angle_t savedyaw=0; - int savedpitch=0; + angle_t savedyaw; + int savedpitch; arc << savedyaw << savedpitch; } diff --git a/src/c_cvars.cpp b/src/c_cvars.cpp index c7a71197b..2c6510219 100644 --- a/src/c_cvars.cpp +++ b/src/c_cvars.cpp @@ -439,7 +439,7 @@ static BYTE HexToByte (const char *hex) UCVarValue FBaseCVar::FromString (const char *value, ECVarType type) { UCVarValue ret; - int i=0; + int i; switch (type) { @@ -475,8 +475,11 @@ UCVarValue FBaseCVar::FromString (const char *value, ECVarType type) // 0 1 2 3 ret.pGUID = NULL; - if(value) - for (; i < 38; i++) + if (value == NULL) + { + break; + } + for (i = 0; value[i] != 0 && i < 38; i++) { switch (i) { @@ -1685,7 +1688,7 @@ void FBaseCVar::ListVars (const char *filter, bool plain) flags & CVAR_MOD ? 'M' : ' ', flags & CVAR_IGNORE ? 'X' : ' ', var->GetName(), - var->GetGenericRep (CVAR_String).String); + var->GetGenericRep(CVAR_String).String); } } var = var->m_Next; diff --git a/src/compatibility.h b/src/compatibility.h index d37d25903..cf4dce2f7 100644 --- a/src/compatibility.h +++ b/src/compatibility.h @@ -20,11 +20,11 @@ struct FCompatValues struct FMD5HashTraits { - hash_t Hash(const FMD5Holder &key) + hash_t Hash(const FMD5Holder key) { return key.Hash; } - int Compare(const FMD5Holder &left, const FMD5Holder &right) + int Compare(const FMD5Holder left, const FMD5Holder right) { return left.DWords[0] != right.DWords[0] || left.DWords[1] != right.DWords[1] || diff --git a/src/configfile.cpp b/src/configfile.cpp index 4d642a81d..177c019fb 100644 --- a/src/configfile.cpp +++ b/src/configfile.cpp @@ -50,11 +50,12 @@ static FRandom pr_endtag; // //==================================================================== -FConfigFile::FConfigFile () : PathName(NAME_None) +FConfigFile::FConfigFile () { Sections = CurrentSection = NULL; LastSectionPtr = &Sections; CurrentEntry = NULL; + PathName = ""; OkayToWrite = true; FileExisted = true; } diff --git a/src/decallib.cpp b/src/decallib.cpp index 4da7ba92c..0ea3423c4 100644 --- a/src/decallib.cpp +++ b/src/decallib.cpp @@ -1022,8 +1022,9 @@ FDecalLib::FTranslation *FDecalLib::GenerateTranslation (DWORD start, DWORD end) return trans; } -FDecalBase::FDecalBase () : Name(NAME_None) +FDecalBase::FDecalBase () { + Name = NAME_None; } FDecalBase::~FDecalBase () @@ -1136,8 +1137,9 @@ const FDecalTemplate *FDecalGroup::GetDecal () const return static_cast(remember); } -FDecalAnimator::FDecalAnimator (const char *name) : Name(name) +FDecalAnimator::FDecalAnimator (const char *name) { + Name = name; } FDecalAnimator::~FDecalAnimator () diff --git a/src/dobjtype.h b/src/dobjtype.h index 252287e3e..256e52ad8 100644 --- a/src/dobjtype.h +++ b/src/dobjtype.h @@ -24,7 +24,7 @@ struct PSymbol FName SymbolName; protected: - PSymbol(FName name, ESymbolType type):SymbolName(name) { SymbolType = type; } + PSymbol(FName name, ESymbolType type) { SymbolType = type; SymbolName = name; } }; // A constant value --------------------------------------------------------- diff --git a/src/dsectoreffect.cpp b/src/dsectoreffect.cpp index 82a7deb6f..6732a19dc 100644 --- a/src/dsectoreffect.cpp +++ b/src/dsectoreffect.cpp @@ -78,8 +78,9 @@ DMover::DMover () } DMover::DMover (sector_t *sector) - : DSectorEffect (sector), interpolation(NULL) + : DSectorEffect (sector) { + interpolation = NULL; } void DMover::Destroy() diff --git a/src/g_level.h b/src/g_level.h index aaddfce3c..6e07b0c74 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -241,7 +241,7 @@ struct FOptionalMapinfoData { FOptionalMapinfoData *Next; FName identifier; - FOptionalMapinfoData():identifier(NAME_None) { Next = NULL; } + FOptionalMapinfoData() { Next = NULL; identifier = NAME_None; } virtual ~FOptionalMapinfoData() {} virtual FOptionalMapinfoData *Clone() const = 0; }; diff --git a/src/g_shared/a_pickups.h b/src/g_shared/a_pickups.h index 968de8eac..df0c94b46 100644 --- a/src/g_shared/a_pickups.h +++ b/src/g_shared/a_pickups.h @@ -16,7 +16,7 @@ class FWeaponSlot { public: FWeaponSlot() { Clear(); } - FWeaponSlot(const FWeaponSlot &other):Weapons(other.Weapons) {} + FWeaponSlot(const FWeaponSlot &other) { Weapons = other.Weapons; } FWeaponSlot &operator= (const FWeaponSlot &other) { Weapons = other.Weapons; return *this; } void Clear() { Weapons.Clear(); } bool AddWeapon (const char *type); diff --git a/src/i_net.cpp b/src/i_net.cpp index da1063bc9..d3958e1e1 100644 --- a/src/i_net.cpp +++ b/src/i_net.cpp @@ -238,7 +238,7 @@ void PacketSend (void) else { // Printf("send %d\n", doomcom.datalength); - /*c = */sendto(mysocket, (char *)doomcom.data, doomcom.datalength, + c = sendto(mysocket, (char *)doomcom.data, doomcom.datalength, 0, (sockaddr *)&sendaddress[doomcom.remotenode], sizeof(sendaddress[doomcom.remotenode])); } diff --git a/src/m_argv.cpp b/src/m_argv.cpp index ef3f59fef..004f7857d 100644 --- a/src/m_argv.cpp +++ b/src/m_argv.cpp @@ -55,8 +55,8 @@ DArgs::DArgs() // //=========================================================================== -DArgs::DArgs(const DArgs &other):Argv(other.Argv), - DObject() +DArgs::DArgs(const DArgs &other) +: DObject(), Argv(other.Argv) { } diff --git a/src/menu/menu.h b/src/menu/menu.h index b256ccb2f..3712c9065 100644 --- a/src/menu/menu.h +++ b/src/menu/menu.h @@ -261,10 +261,11 @@ protected: public: bool mEnabled; - FListMenuItem(int xpos = 0, int ypos = 0, FName action = NAME_None):mAction(action) + FListMenuItem(int xpos = 0, int ypos = 0, FName action = NAME_None) { mXpos = xpos; mYpos = ypos; + mAction = action; mEnabled = true; } diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 780495e76..8c6631b5e 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -660,7 +660,10 @@ void ACSStringPool::ReadStrings(PNGHandle *png, DWORD id) i++; j = arc.ReadCount(); } - delete[] str; + if (str != NULL) + { + delete[] str; + } FindFirstFreeEntry(0); } } @@ -5845,7 +5848,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) bool canraiseall = true; while ((actor = iterator.Next())) { - canraiseall = P_Thing_CanRaise(actor) && canraiseall; + canraiseall = P_Thing_CanRaise(actor) & canraiseall; } return canraiseall; diff --git a/src/p_conversation.cpp b/src/p_conversation.cpp index ac59e6a4b..09f2d49d6 100644 --- a/src/p_conversation.cpp +++ b/src/p_conversation.cpp @@ -924,7 +924,7 @@ public: { const char *speakerName; int x, y, linesize; - int width=screen->GetWidth(), height=screen->GetHeight(), fontheight; + int width, fontheight; player_t *cp = &players[consoleplayer]; @@ -949,8 +949,8 @@ public: { screen->DrawTexture (TexMan(CurNode->Backdrop), 0, 0, DTA_320x200, true, TAG_DONE); } - x = 16 * width / 320; - y = 16 * height / 200; + x = 16 * screen->GetWidth() / 320; + y = 16 * screen->GetHeight() / 200; linesize = 10 * CleanYfac; // Who is talking to you? @@ -970,16 +970,16 @@ public: int i; for (i = 0; mDialogueLines[i].Width >= 0; ++i) { } - screen->Dim (0, 0.45f, 14 * width / 320, 13 * height / 200, - 308 * width / 320 - 14 * width / 320, + screen->Dim (0, 0.45f, 14 * screen->GetWidth() / 320, 13 * screen->GetHeight() / 200, + 308 * screen->GetWidth() / 320 - 14 * screen->GetWidth () / 320, speakerName == NULL ? linesize * i + 6 * CleanYfac : linesize * i + 6 * CleanYfac + linesize * 3/2); } // Dim the screen behind the PC's choices. - screen->Dim (0, 0.45f, (24-160) * CleanXfac + width/2, - (mYpos - 2 - 100) * CleanYfac + height/2, + screen->Dim (0, 0.45f, (24-160) * CleanXfac + screen->GetWidth()/2, + (mYpos - 2 - 100) * CleanYfac + screen->GetHeight()/2, 272 * CleanXfac, MIN(mResponseLines.Size() * OptionSettings.mLinespacing + 4, 200 - mYpos) * CleanYfac); @@ -989,7 +989,7 @@ public: DTA_CleanNoMove, true, TAG_DONE); y += linesize * 3 / 2; } - x = 24 * width / 320; + x = 24 * screen->GetWidth() / 320; for (int i = 0; mDialogueLines[i].Width >= 0; ++i) { screen->DrawText (SmallFont, CR_UNTRANSLATED, x, y, mDialogueLines[i].Text, @@ -1019,6 +1019,7 @@ public: int response = 0; for (unsigned i = 0; i < mResponseLines.Size(); i++, y += fontheight) { + width = SmallFont->StringWidth(mResponseLines[i]); x = 64; screen->DrawText (SmallFont, CR_GREEN, x, y, mResponseLines[i], DTA_Clean, true, TAG_DONE); @@ -1036,8 +1037,8 @@ public: { int color = ((DMenu::MenuTime%8) < 4) || DMenu::CurrentMenu != this ? CR_RED:CR_GREY; - x = (50 + 3 - 160) * CleanXfac + width / 2; - int yy = (y + fontheight/2 - 5 - 100) * CleanYfac + height / 2; + x = (50 + 3 - 160) * CleanXfac + screen->GetWidth() / 2; + int yy = (y + fontheight/2 - 5 - 100) * CleanYfac + screen->GetHeight() / 2; screen->DrawText (ConFont, color, x, yy, "\xd", DTA_CellX, 8 * CleanXfac, DTA_CellY, 8 * CleanYfac, diff --git a/src/p_floor.cpp b/src/p_floor.cpp index 9d47729ae..9a5a6eaf8 100644 --- a/src/p_floor.cpp +++ b/src/p_floor.cpp @@ -900,12 +900,12 @@ DElevator::DElevator () } DElevator::DElevator (sector_t *sec) - : m_Interp_Floor(sec->SetInterpolation(sector_t::FloorMove, true)), - m_Interp_Ceiling(sec->SetInterpolation(sector_t::CeilingMove, true)), - Super (sec) + : Super (sec) { sec->floordata = this; sec->ceilingdata = this; + m_Interp_Floor = sec->SetInterpolation(sector_t::FloorMove, true); + m_Interp_Ceiling = sec->SetInterpolation(sector_t::CeilingMove, true); } void DElevator::Serialize (FArchive &arc) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 5cb008bf1..ce9fe722a 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -1977,9 +1977,9 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) { bool tg = (mo->target != NULL); bool blockingtg = (BlockingMobj->target != NULL); - if (BlockingMobj->flags7 & MF7_AIMREFLECT && (tg || blockingtg)) + if ((BlockingMobj->flags7 & MF7_AIMREFLECT) && (tg | blockingtg)) { - AActor *origin=tg ? mo->target : BlockingMobj->target; + AActor *origin = tg ? mo->target : BlockingMobj->target; float speed = (float)(mo->Speed); //dest->x - source->x @@ -1991,7 +1991,7 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) } else { - if (BlockingMobj->flags7 & MF7_MIRRORREFLECT && (tg || blockingtg)) + if ((BlockingMobj->flags7 & MF7_MIRRORREFLECT) && (tg | blockingtg)) { mo->angle += ANGLE_180; mo->velx = -mo->velx / 2; @@ -3498,7 +3498,7 @@ void AActor::Tick () // Check 3D floors as well floorplane = P_FindFloorPlane(floorsector, x, y, floorz); #else - floorplane = floorsector->floorplane; + floorplane = floorsector->floorplane; #endif if (floorplane.c < STEEPSLOPE && @@ -5629,24 +5629,30 @@ static fixed_t GetDefaultSpeed(const PClass *type) AActor *P_SpawnMissile (AActor *source, AActor *dest, const PClass *type, AActor *owner) { - if(!source) + if (source == NULL) + { return NULL; + } return P_SpawnMissileXYZ (source->x, source->y, source->z + 32*FRACUNIT + source->GetBobOffset(), source, dest, type, true, owner); } AActor *P_SpawnMissileZ (AActor *source, fixed_t z, AActor *dest, const PClass *type) { - if(!source) + if (source == NULL) + { return NULL; + } return P_SpawnMissileXYZ (source->x, source->y, z, source, dest, type); } AActor *P_SpawnMissileXYZ (fixed_t x, fixed_t y, fixed_t z, AActor *source, AActor *dest, const PClass *type, bool checkspawn, AActor *owner) { - if(!source) + if (source == NULL) + { return NULL; + } if (dest == NULL) { @@ -5717,8 +5723,10 @@ AActor *P_SpawnMissileXYZ (fixed_t x, fixed_t y, fixed_t z, AActor * P_OldSpawnMissile(AActor * source, AActor * owner, AActor * dest, const PClass *type) { - if(!source) + if (source == NULL) + { return NULL; + } angle_t an; fixed_t dist; AActor *th = Spawn (type, source->x, source->y, source->z + 4*8*FRACUNIT, ALLOW_REPLACE); @@ -5760,8 +5768,10 @@ AActor * P_OldSpawnMissile(AActor * source, AActor * owner, AActor * dest, const AActor *P_SpawnMissileAngle (AActor *source, const PClass *type, angle_t angle, fixed_t velz) { - if(!source) + if (source == NULL) + { return NULL; + } return P_SpawnMissileAngleZSpeed (source, source->z + 32*FRACUNIT + source->GetBobOffset(), type, angle, velz, GetDefaultSpeed (type)); } @@ -5769,16 +5779,16 @@ AActor *P_SpawnMissileAngle (AActor *source, const PClass *type, AActor *P_SpawnMissileAngleZ (AActor *source, fixed_t z, const PClass *type, angle_t angle, fixed_t velz) { - if(!source) - return NULL; return P_SpawnMissileAngleZSpeed (source, z, type, angle, velz, GetDefaultSpeed (type)); } AActor *P_SpawnMissileZAimed (AActor *source, fixed_t z, AActor *dest, const PClass *type) { - if(!source) + if (source == NULL) + { return NULL; + } angle_t an; fixed_t dist; fixed_t speed; @@ -5809,8 +5819,10 @@ AActor *P_SpawnMissileZAimed (AActor *source, fixed_t z, AActor *dest, const PCl AActor *P_SpawnMissileAngleSpeed (AActor *source, const PClass *type, angle_t angle, fixed_t velz, fixed_t speed) { - if(!source) + if (source == NULL) + { return NULL; + } return P_SpawnMissileAngleZSpeed (source, source->z + 32*FRACUNIT + source->GetBobOffset(), type, angle, velz, speed); } @@ -5818,11 +5830,13 @@ AActor *P_SpawnMissileAngleSpeed (AActor *source, const PClass *type, AActor *P_SpawnMissileAngleZSpeed (AActor *source, fixed_t z, const PClass *type, angle_t angle, fixed_t velz, fixed_t speed, AActor *owner, bool checkspawn) { - if(!source) + if (source == NULL) + { return NULL; + } AActor *mo; - if (z != ONFLOORZ && z != ONCEILINGZ && source != NULL) + if (z != ONFLOORZ && z != ONCEILINGZ) { z -= source->floorclip; } @@ -5857,8 +5871,10 @@ AActor *P_SpawnMissileAngleZSpeed (AActor *source, fixed_t z, AActor *P_SpawnPlayerMissile (AActor *source, const PClass *type) { - if(!source) + if (source == NULL) + { return NULL; + } return P_SpawnPlayerMissile (source, 0, 0, 0, type, source->angle); } diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 9da28d9d8..c0810cc29 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -3042,14 +3042,13 @@ void P_LoadBlockMap (MapData * map) blockmap = blockmaplump+4; } -line_t** linebuffer; - // // P_GroupLines // Builds sector line lists and subsector sector numbers. // Finds block bounding boxes for sectors. -// [RH] Handles extra lights. +// [RH] Handles extra lights // +line_t** linebuffer; static void P_GroupLines (bool buildmap) { diff --git a/src/p_teleport.cpp b/src/p_teleport.cpp index e930ffd62..3e3b03c4e 100644 --- a/src/p_teleport.cpp +++ b/src/p_teleport.cpp @@ -188,7 +188,7 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, // Spawn teleport fog at source and destination if (sourceFog && !predicting) { - P_SpawnTeleportFog(thing, oldx, oldy, oldz, true, true); //Passes the actor through then pulls the TeleFog metadata types based on properties. + P_SpawnTeleportFog(thing, oldx, oldy, oldz, true, true); //Passes the actor through which then pulls the TeleFog metadata types based on properties. } if (useFog) { diff --git a/src/p_user.cpp b/src/p_user.cpp index 21ebf00a1..e91766cf0 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -101,10 +101,11 @@ FPlayerClass::FPlayerClass () Flags = 0; } -FPlayerClass::FPlayerClass (const FPlayerClass &other) : Skins(other.Skins) +FPlayerClass::FPlayerClass (const FPlayerClass &other) { Type = other.Type; Flags = other.Flags; + Skins = other.Skins; } FPlayerClass::~FPlayerClass () diff --git a/src/thingdef/thingdef_exp.h b/src/thingdef/thingdef_exp.h index 1c46ab6b2..d3ee57345 100644 --- a/src/thingdef/thingdef_exp.h +++ b/src/thingdef/thingdef_exp.h @@ -152,9 +152,11 @@ struct ExpVal class FxExpression { protected: - FxExpression(const FScriptPosition &pos):ScriptPosition(pos) + FxExpression(const FScriptPosition &pos) + : ScriptPosition(pos) { isresolved = false; + ScriptPosition = pos; } public: virtual ~FxExpression() {}