From 4cb289fc91dca09866cc4642a500812350a05d80 Mon Sep 17 00:00:00 2001 From: cutealien Date: Sat, 14 Nov 2020 16:56:16 +0000 Subject: [PATCH] Code cleanup Prefer static_cast to reinterpret_cast. Declare variables later with init values to avoid having uninitialized variables around. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6161 dfc29bdd-3216-0410-991c-e03cc46cb475 --- source/Irrlicht/CGUIFont.cpp | 4 +--- source/Irrlicht/CGUITreeView.cpp | 11 ++++------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/source/Irrlicht/CGUIFont.cpp b/source/Irrlicht/CGUIFont.cpp index 08579244..0fa82981 100644 --- a/source/Irrlicht/CGUIFont.cpp +++ b/source/Irrlicht/CGUIFont.cpp @@ -203,17 +203,15 @@ void CGUIFont::setMaxHeight() return; MaxHeight = 0; - s32 t; core::array< core::rect >& p = SpriteBank->getPositions(); for (u32 i=0; iMaxHeight) MaxHeight = t; } - } void CGUIFont::pushTextureCreationFlags(bool(&flags)[3]) diff --git a/source/Irrlicht/CGUITreeView.cpp b/source/Irrlicht/CGUITreeView.cpp index 2614cadc..b348a791 100644 --- a/source/Irrlicht/CGUITreeView.cpp +++ b/source/Irrlicht/CGUITreeView.cpp @@ -754,10 +754,7 @@ bool CGUITreeView::OnEvent( const SEvent &event ) void CGUITreeView::mouseAction( s32 xpos, s32 ypos, bool onlyHover /*= false*/ ) { IGUITreeViewNode* oldSelected = Selected; - IGUITreeViewNode* hitNode = 0; s32 selIdx=-1; - s32 n; - IGUITreeViewNode* node; SEvent event; event.EventType = EET_GUI_EVENT; @@ -774,9 +771,9 @@ void CGUITreeView::mouseAction( s32 xpos, s32 ypos, bool onlyHover /*= false*/ ) selIdx = ( ( ypos - 1 ) + scrollBarVPos ) / ItemHeight; } - hitNode = 0; - node = Root->getFirstChild(); - n = 0; + IGUITreeViewNode* hitNode = 0; + IGUITreeViewNode* node = Root->getFirstChild(); + s32 n = 0; while( node ) { if( selIdx == n ) @@ -1024,7 +1021,7 @@ void CGUITreeView::draw() iconWidth += ImageList->getImageSize().Width + 3; textRect.UpperLeftCorner.X += ImageList->getImageSize().Width + 3; } - else if( ( IconFont && reinterpret_cast( node )->Icon.size() ) + else if( ( IconFont && static_cast( node )->Icon.size() ) && ( ( ImageLeftOfIcon && n == 1 ) || ( !ImageLeftOfIcon && n == 0 ) ) ) {