Remove extra conditional

Stricter scope on temporary var.
This commit is contained in:
Learath 2018-02-22 20:46:02 +01:00
parent 1f2e398819
commit 4031e15fc8

View file

@ -162,10 +162,10 @@ bool CChat::OnInput(IInput::CEvent Event)
else if(Input()->KeyPress(KEY_RIGHT) || Input()->KeyPress(KEY_DELETE)) else if(Input()->KeyPress(KEY_RIGHT) || Input()->KeyPress(KEY_DELETE))
SearchDirection = 1; SearchDirection = 1;
int OldOffset = m_Input.GetCursorOffset();
if(SearchDirection != 0) if(SearchDirection != 0)
{ {
int OldOffset = m_Input.GetCursorOffset();
int FoundAt = SearchDirection > 0 ? m_Input.GetLength() - 1 : 0; int FoundAt = SearchDirection > 0 ? m_Input.GetLength() - 1 : 0;
for(int i = m_Input.GetCursorOffset() + SearchDirection; SearchDirection > 0 ? i < m_Input.GetLength() - 1 : i > 0; i += SearchDirection) for(int i = m_Input.GetCursorOffset() + SearchDirection; SearchDirection > 0 ? i < m_Input.GetLength() - 1 : i > 0; i += SearchDirection)
{ {
@ -181,6 +181,7 @@ bool CChat::OnInput(IInput::CEvent Event)
break; break;
} }
} }
if(Input()->KeyPress(KEY_BACKSPACE)) if(Input()->KeyPress(KEY_BACKSPACE))
{ {
if(m_Input.GetCursorOffset() != 0) if(m_Input.GetCursorOffset() != 0)
@ -207,9 +208,10 @@ bool CChat::OnInput(IInput::CEvent Event)
str_append(aText, m_Input.GetString() + FoundAt, sizeof(aText)); str_append(aText, m_Input.GetString() + FoundAt, sizeof(aText));
m_Input.Set(aText); m_Input.Set(aText);
FoundAt = OldOffset;
} }
} }
m_Input.SetCursorOffset(Input()->KeyPress(KEY_DELETE) ? OldOffset : FoundAt); m_Input.SetCursorOffset(FoundAt);
} }
} }