mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Remove redundant assignments
According to cppcheck's `redundantInitialization` and `redundantAssignment` errors: ``` src\game\client\ui.cpp:456:5: style: Redundant initialization for 'tw'. The initialized value is overwritten before it is read. [redundantInitialization] tw = TextRender()->TextWidth(0, Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine); ^ src\game\client\ui.cpp:454:11: note: tw is initialized float tw = std::numeric_limits<float>::max(); ^ src\game\client\ui.cpp:456:5: note: tw is overwritten tw = TextRender()->TextWidth(0, Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine); ^ src\game\client\ui.cpp:529:5: style: Redundant initialization for 'tw'. The initialized value is overwritten before it is read. [redundantInitialization] tw = TextRender()->TextWidth(0, Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine); ^ src\game\client\ui.cpp:527:11: note: tw is initialized float tw = std::numeric_limits<float>::max(); ^ src\game\client\ui.cpp:529:5: note: tw is overwritten tw = TextRender()->TextWidth(0, Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine); ^ src\game\editor\editor.cpp:6051:19: style: Variable 'm_Map.m_Modified' is reassigned a value before the old one has been used. [redundantAssignment] m_Map.m_Modified = false; ^ src\game\editor\editor.cpp:6046:19: note: m_Map.m_Modified is assigned m_Map.m_Modified = false; ^ src\game\editor\editor.cpp:6051:19: note: m_Map.m_Modified is overwritten m_Map.m_Modified = false; ^ src\game\client\prediction\entities\character.cpp:1148:36: style: Variable 'm_LatestInput' is reassigned a value before the old one has been used. [redundantAssignment] m_LatestPrevInput = m_LatestInput = m_PrevInput = m_SavedInput = m_Input; ^ src\game\client\prediction\entities\character.cpp:1134:16: note: m_LatestInput is assigned m_LatestInput = m_LatestPrevInput = m_PrevInput = m_Input = m_SavedInput; ^ src\game\client\prediction\entities\character.cpp:1148:36: note: m_LatestInput is overwritten m_LatestPrevInput = m_LatestInput = m_PrevInput = m_SavedInput = m_Input; ^ src\game\client\prediction\entities\character.cpp:1148:20: style: Variable 'm_LatestPrevInput' is reassigned a value before the old one has been used. [redundantAssignment] m_LatestPrevInput = m_LatestInput = m_PrevInput = m_SavedInput = m_Input; ^ src\game\client\prediction\entities\character.cpp:1134:36: note: m_LatestPrevInput is assigned m_LatestInput = m_LatestPrevInput = m_PrevInput = m_Input = m_SavedInput; ^ src\game\client\prediction\entities\character.cpp:1148:20: note: m_LatestPrevInput is overwritten m_LatestPrevInput = m_LatestInput = m_PrevInput = m_SavedInput = m_Input; ^ src\game\client\prediction\entities\character.cpp:1148:50: style: Variable 'm_PrevInput' is reassigned a value before the old one has been used. [redundantAssignment] m_LatestPrevInput = m_LatestInput = m_PrevInput = m_SavedInput = m_Input; ^ src\game\client\prediction\entities\character.cpp:1134:50: note: m_PrevInput is assigned m_LatestInput = m_LatestPrevInput = m_PrevInput = m_Input = m_SavedInput; ^ src\game\client\prediction\entities\character.cpp:1148:50: note: m_PrevInput is overwritten m_LatestPrevInput = m_LatestInput = m_PrevInput = m_SavedInput = m_Input; ^ ```
This commit is contained in:
parent
4197e8d0b0
commit
19bf435d6a
|
@ -1131,8 +1131,6 @@ CCharacter::CCharacter(CGameWorld *pGameWorld, int ID, CNetObj_Character *pChar,
|
||||||
m_Core.Init(&GameWorld()->m_Core, GameWorld()->Collision(), GameWorld()->Teams());
|
m_Core.Init(&GameWorld()->m_Core, GameWorld()->Collision(), GameWorld()->Teams());
|
||||||
m_Core.m_Id = ID;
|
m_Core.m_Id = ID;
|
||||||
mem_zero(&m_Core.m_Ninja, sizeof(m_Core.m_Ninja));
|
mem_zero(&m_Core.m_Ninja, sizeof(m_Core.m_Ninja));
|
||||||
mem_zero(&m_SavedInput, sizeof(m_SavedInput));
|
|
||||||
m_LatestInput = m_LatestPrevInput = m_PrevInput = m_Input = m_SavedInput;
|
|
||||||
m_Core.m_LeftWall = true;
|
m_Core.m_LeftWall = true;
|
||||||
m_ReloadTimer = 0;
|
m_ReloadTimer = 0;
|
||||||
m_NumObjectsHit = 0;
|
m_NumObjectsHit = 0;
|
||||||
|
@ -1142,6 +1140,7 @@ CCharacter::CCharacter(CGameWorld *pGameWorld, int ID, CNetObj_Character *pChar,
|
||||||
m_TeleCheckpoint = 0;
|
m_TeleCheckpoint = 0;
|
||||||
m_StrongWeakID = 0;
|
m_StrongWeakID = 0;
|
||||||
|
|
||||||
|
mem_zero(&m_Input, sizeof(m_Input));
|
||||||
// never initialize both to zero
|
// never initialize both to zero
|
||||||
m_Input.m_TargetX = 0;
|
m_Input.m_TargetX = 0;
|
||||||
m_Input.m_TargetY = -1;
|
m_Input.m_TargetY = -1;
|
||||||
|
|
|
@ -451,9 +451,8 @@ float CUI::DoTextLabel(float x, float y, float w, float h, const char *pText, fl
|
||||||
{
|
{
|
||||||
float AlignedSize = 0;
|
float AlignedSize = 0;
|
||||||
float MaxCharacterHeightInLine = 0;
|
float MaxCharacterHeightInLine = 0;
|
||||||
float tw = std::numeric_limits<float>::max();
|
|
||||||
float MaxTextWidth = LabelProps.m_MaxWidth != -1 ? LabelProps.m_MaxWidth : w;
|
float MaxTextWidth = LabelProps.m_MaxWidth != -1 ? LabelProps.m_MaxWidth : w;
|
||||||
tw = TextRender()->TextWidth(0, Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine);
|
float tw = TextRender()->TextWidth(0, Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine);
|
||||||
while(tw > MaxTextWidth + 0.001f)
|
while(tw > MaxTextWidth + 0.001f)
|
||||||
{
|
{
|
||||||
if(!LabelProps.m_EnableWidthCheck)
|
if(!LabelProps.m_EnableWidthCheck)
|
||||||
|
@ -524,9 +523,8 @@ void CUI::DoLabel(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, cons
|
||||||
{
|
{
|
||||||
float AlignedSize = 0;
|
float AlignedSize = 0;
|
||||||
float MaxCharacterHeightInLine = 0;
|
float MaxCharacterHeightInLine = 0;
|
||||||
float tw = std::numeric_limits<float>::max();
|
|
||||||
float MaxTextWidth = LabelProps.m_MaxWidth != -1 ? LabelProps.m_MaxWidth : pRect->w;
|
float MaxTextWidth = LabelProps.m_MaxWidth != -1 ? LabelProps.m_MaxWidth : pRect->w;
|
||||||
tw = TextRender()->TextWidth(0, Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine);
|
float tw = TextRender()->TextWidth(0, Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine);
|
||||||
while(tw > MaxTextWidth + 0.001f)
|
while(tw > MaxTextWidth + 0.001f)
|
||||||
{
|
{
|
||||||
if(!LabelProps.m_EnableWidthCheck)
|
if(!LabelProps.m_EnableWidthCheck)
|
||||||
|
|
|
@ -6105,8 +6105,6 @@ void CEditor::Reset(bool CreateDefault)
|
||||||
|
|
||||||
m_ShowEnvelopePreview = SHOWENV_NONE;
|
m_ShowEnvelopePreview = SHOWENV_NONE;
|
||||||
m_ShiftBy = 1;
|
m_ShiftBy = 1;
|
||||||
|
|
||||||
m_Map.m_Modified = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int CEditor::GetLineDistance() const
|
int CEditor::GetLineDistance() const
|
||||||
|
|
Loading…
Reference in a new issue