mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Remove redundant null-checks
According to cppcheck's `nullPointerRedundantCheck` check: ``` src\game\client\components\menus_settings.cpp:729:8: warning: Either the condition 'pSkinToBeSelected==0' is redundant or there is possible null pointer dereference: pSkinToBeSelected. [nullPointerRedundantCheck] if((pSkinToBeSelected->GetName()[0] == 'x' && pSkinToBeSelected->GetName()[1] == '_')) ^ src\game\client\components\menus_settings.cpp:732:25: note: Assuming that condition 'pSkinToBeSelected==0' is not redundant if(pSkinToBeSelected == 0) ^ src\game\client\components\menus_settings.cpp:729:8: note: Null pointer dereference if((pSkinToBeSelected->GetName()[0] == 'x' && pSkinToBeSelected->GetName()[1] == '_')) ^ src\game\editor\editor.cpp:5034:19: warning: Either the condition 'pEnvelope' is redundant or there is possible null pointer dereference: pEnvelope. [nullPointerRedundantCheck] float EndTime = pEnvelope->EndTime(); ^ src\game\editor\editor.cpp:5056:7: note: Assuming that condition 'pEnvelope' is not redundant if(pEnvelope) ^ src\game\editor\editor.cpp:5034:19: note: Null pointer dereference float EndTime = pEnvelope->EndTime(); ^ src\game\editor\editor.cpp:5038:3: warning: Either the condition 'pEnvelope' is redundant or there is possible null pointer dereference: pEnvelope. [nullPointerRedundantCheck] pEnvelope->FindTopBottom(s_ActiveChannels); ^ src\game\editor\editor.cpp:5056:7: note: Assuming that condition 'pEnvelope' is not redundant if(pEnvelope) ^ src\game\editor\editor.cpp:5038:3: note: Null pointer dereference pEnvelope->FindTopBottom(s_ActiveChannels); ^ src\game\editor\editor.cpp:5039:15: warning: Either the condition 'pEnvelope' is redundant or there is possible null pointer dereference: pEnvelope. [nullPointerRedundantCheck] float Top = pEnvelope->m_Top; ^ src\game\editor\editor.cpp:5056:7: note: Assuming that condition 'pEnvelope' is not redundant if(pEnvelope) ^ src\game\editor\editor.cpp:5039:15: note: Null pointer dereference float Top = pEnvelope->m_Top; ^ src\game\editor\editor.cpp:5040:18: warning: Either the condition 'pEnvelope' is redundant or there is possible null pointer dereference: pEnvelope. [nullPointerRedundantCheck] float Bottom = pEnvelope->m_Bottom; ^ src\game\editor\editor.cpp:5056:7: note: Assuming that condition 'pEnvelope' is not redundant if(pEnvelope) ^ src\game\editor\editor.cpp:5040:18: note: Null pointer dereference float Bottom = pEnvelope->m_Bottom; ^ src\game\editor\editor.cpp:5081:23: warning: Either the condition 'pEnvelope' is redundant or there is possible null pointer dereference: pEnvelope. [nullPointerRedundantCheck] for(int c = 0; c < pEnvelope->m_Channels; c++) ^ src\game\editor\editor.cpp:5056:7: note: Assuming that condition 'pEnvelope' is not redundant if(pEnvelope) ^ src\game\editor\editor.cpp:5081:23: note: Null pointer dereference for(int c = 0; c < pEnvelope->m_Channels; c++) ^ ```
This commit is contained in:
parent
e134e4e488
commit
8e675878b0
|
@ -729,9 +729,6 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
|
|||
if((pSkinToBeSelected->GetName()[0] == 'x' && pSkinToBeSelected->GetName()[1] == '_'))
|
||||
return false;
|
||||
|
||||
if(pSkinToBeSelected == 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
|
|
|
@ -5119,24 +5119,21 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
|
|||
if(UI()->HotItem() == &s_EnvelopeEditorID)
|
||||
{
|
||||
// do stuff
|
||||
if(pEnvelope)
|
||||
if(UI()->MouseButtonClicked(1))
|
||||
{
|
||||
if(UI()->MouseButtonClicked(1))
|
||||
{
|
||||
// add point
|
||||
int Time = (int)(((UI()->MouseX() - View.x) * TimeScale) * 1000.0f);
|
||||
//float env_y = (UI()->MouseY()-view.y)/TimeScale;
|
||||
ColorRGBA Channels;
|
||||
pEnvelope->Eval(Time / 1000.0f, Channels);
|
||||
pEnvelope->AddPoint(Time,
|
||||
f2fx(Channels.r), f2fx(Channels.g),
|
||||
f2fx(Channels.b), f2fx(Channels.a));
|
||||
m_Map.m_Modified = true;
|
||||
}
|
||||
|
||||
m_ShowEnvelopePreview = SHOWENV_SELECTED;
|
||||
m_pTooltip = "Press right mouse button to create a new point";
|
||||
// add point
|
||||
int Time = (int)(((UI()->MouseX() - View.x) * TimeScale) * 1000.0f);
|
||||
//float env_y = (UI()->MouseY()-view.y)/TimeScale;
|
||||
ColorRGBA Channels;
|
||||
pEnvelope->Eval(Time / 1000.0f, Channels);
|
||||
pEnvelope->AddPoint(Time,
|
||||
f2fx(Channels.r), f2fx(Channels.g),
|
||||
f2fx(Channels.b), f2fx(Channels.a));
|
||||
m_Map.m_Modified = true;
|
||||
}
|
||||
|
||||
m_ShowEnvelopePreview = SHOWENV_SELECTED;
|
||||
m_pTooltip = "Press right mouse button to create a new point";
|
||||
}
|
||||
|
||||
// render lines
|
||||
|
|
Loading…
Reference in a new issue