diff --git a/source/gui/ObjectTypes/CInput.cpp b/source/gui/ObjectTypes/CInput.cpp index c6dc7745f9..662f31ecb2 100644 --- a/source/gui/ObjectTypes/CInput.cpp +++ b/source/gui/ObjectTypes/CInput.cpp @@ -295,9 +295,7 @@ void CInput::ManuallyMutableHandleKeyDownEvent(const SDL_Keycode keyCode) if (m_iBufferPos == static_cast(caption.length())) caption = caption.substr(0, static_cast(caption.length()) - 1); else - caption = - caption.substr(0, m_iBufferPos - 1) + - caption.Right(static_cast(caption.length()) - m_iBufferPos); + caption = caption.substr(0, m_iBufferPos - 1) + caption.substr(m_iBufferPos); --m_iBufferPos; @@ -319,10 +317,7 @@ void CInput::ManuallyMutableHandleKeyDownEvent(const SDL_Keycode keyCode) if (caption.empty() || m_iBufferPos == static_cast(caption.length())) break; - caption = - caption.substr(0, m_iBufferPos) + - caption.Right(static_cast(caption.length()) - (m_iBufferPos + 1)); - + caption = caption.substr(0, m_iBufferPos) + caption.substr(m_iBufferPos + 1); UpdateText(m_iBufferPos, m_iBufferPos + 1, m_iBufferPos); } @@ -363,9 +358,7 @@ void CInput::ManuallyMutableHandleKeyDownEvent(const SDL_Keycode keyCode) if (m_iBufferPos == static_cast(caption.length())) caption += cooked; else - caption = - caption.substr(0, m_iBufferPos) + cooked + - caption.Right(static_cast(caption.length()) - m_iBufferPos); + caption = caption.substr(0, m_iBufferPos) + cooked + caption.substr(m_iBufferPos); UpdateText(m_iBufferPos, m_iBufferPos, m_iBufferPos + 1); @@ -654,9 +647,7 @@ Input::Reaction CInput::ManuallyHandleHotkeyEvent(const SDL_Event& ev) if (m_iBufferPos == static_cast(caption.length())) caption += text; else - caption = - caption.substr(0, m_iBufferPos) + text + - caption.Right(static_cast(caption.length()) - m_iBufferPos); + caption = caption.substr(0, m_iBufferPos) + text + caption.substr(m_iBufferPos); UpdateText(m_iBufferPos, m_iBufferPos, m_iBufferPos+1); @@ -2009,8 +2000,7 @@ void CInput::DeleteCurSelection() } // Silently change. - m_Caption.Set(m_Caption->substr(0, virtualFrom) + - m_Caption->Right(static_cast(m_Caption->length()) - virtualTo), false); + m_Caption.Set(m_Caption->substr(0, virtualFrom) + m_Caption->substr(virtualTo), false); UpdateText(virtualFrom, virtualTo, virtualFrom); diff --git a/source/ps/CStr.cpp b/source/ps/CStr.cpp index 737f12ba4a..d9f58656f5 100644 --- a/source/ps/CStr.cpp +++ b/source/ps/CStr.cpp @@ -293,13 +293,6 @@ CStr CStr::UpperCase() const return newStr; } -// Retrieve the substring of the last n characters -CStr CStr::Right(size_t len) const -{ - ENSURE(len <= length()); - return substr(length()-len, len); -} - // Retrieve the substring following the last occurrence of Str // (or the whole string if it doesn't contain Str) CStr CStr::AfterLast(const CStr& str, size_t startPos) const diff --git a/source/ps/CStr.h b/source/ps/CStr.h index c5b820b132..5de107a287 100644 --- a/source/ps/CStr.h +++ b/source/ps/CStr.h @@ -161,14 +161,6 @@ public: **/ CStr UpperCase() const; - /** - * Retrieve last n characters of the CStr. - * - * @param size_t len the number of characters to retrieve. - * @return CStr retrieved substring. - **/ - CStr Right(size_t len) const; - /** * Retrieve substring of the CStr after last occurrence of a string. * Return substring of the CStr after the last occurrence of the search string. diff --git a/source/ps/scripting/JSInterface_VFS.cpp b/source/ps/scripting/JSInterface_VFS.cpp index c104d494ae..77cd517a88 100644 --- a/source/ps/scripting/JSInterface_VFS.cpp +++ b/source/ps/scripting/JSInterface_VFS.cpp @@ -288,7 +288,7 @@ void WriteJSONFile(const Script::Interface& scriptInterface, const std::wstring& bool DeleteCampaignSave(const CStrW& filePath) { OsPath realPath; - if (!filePath.starts_with(L"saves/campaigns/") || filePath.Right(12) != L".0adcampaign") + if (!filePath.starts_with(L"saves/campaigns/") || !filePath.ends_with(L".0adcampaign")) return false; if (!VfsFileExists(filePath)) return false;