From ca89162b06e0b989d79e166213c5c0ce124353d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Wed, 5 Jun 2024 21:04:03 +0200 Subject: [PATCH] Fix wrong file extension being removed in demo cut popup The `.demo` extension is supposed to be removed from the target filename when slicing demos, but anything after the last dot was being removed instead, e.g. `test.abc.def` was incorrectly replaced with `test.abc`. --- src/game/client/components/menus_demo.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index 6aaae19b4..9f75ea3c6 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -830,13 +830,15 @@ void CMenus::RenderDemoPlayerSliceSavePopup(CUIRect MainView) static CButtonContainer s_ButtonOk; if(DoButton_Menu(&s_ButtonOk, Localize("Ok"), 0, &OkButton) || (!Ui()->IsPopupOpen() && Ui()->ConsumeHotkey(CUi::HOTKEY_ENTER))) { + if(str_endswith(m_DemoSliceInput.GetString(), ".demo")) + { + char aNameWithoutExt[IO_MAX_PATH_LENGTH]; + fs_split_file_extension(m_DemoSliceInput.GetString(), aNameWithoutExt, sizeof(aNameWithoutExt)); + m_DemoSliceInput.Set(aNameWithoutExt); + } + char aDemoName[IO_MAX_PATH_LENGTH]; - char aNameWithoutExt[IO_MAX_PATH_LENGTH]; DemoPlayer()->GetDemoName(aDemoName, sizeof(aDemoName)); - - fs_split_file_extension(m_DemoSliceInput.GetString(), aNameWithoutExt, sizeof(aNameWithoutExt)); - m_DemoSliceInput.Set(aNameWithoutExt); - if(str_comp(aDemoName, m_DemoSliceInput.GetString()) == 0) { static CUi::SMessagePopupContext s_MessagePopupContext;