From 3dedc963f7d6ebd1b23c70aebf5c307d2b0e47d4 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sat, 8 Apr 2023 18:53:28 +0300 Subject: [PATCH 1/4] Fix double-playing of battle effects --- client/CPlayerInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 91e6516fe..5c4c0aa7a 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -941,7 +941,7 @@ void CPlayerInterface::battleStacksEffectsSet( const SetStackEffect & sse ) void CPlayerInterface::battleTriggerEffect (const BattleTriggerEffect & bte) { EVENT_HANDLER_CALLED_BY_CLIENT; - //TODO why is this different (no return on LOPLINT != this) ? + BATTLE_EVENT_POSSIBLE_RETURN; RETURN_IF_QUICK_COMBAT; battleInt->effectsController->battleTriggerEffect(bte); From 0abc00f82e99e1f7ef3512cfcaf4df9efddab727 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sat, 8 Apr 2023 18:53:47 +0300 Subject: [PATCH 2/4] Fix assertion failure in in-game console --- client/adventureMap/CInGameConsole.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/client/adventureMap/CInGameConsole.cpp b/client/adventureMap/CInGameConsole.cpp index ed4588ea4..3af427e9f 100644 --- a/client/adventureMap/CInGameConsole.cpp +++ b/client/adventureMap/CInGameConsole.cpp @@ -38,6 +38,9 @@ void CInGameConsole::showAll(SDL_Surface * to) void CInGameConsole::show(SDL_Surface * to) { + if (LOCPLINT->cingconsole != this) + return; + int number = 0; boost::unique_lock lock(texts_mx); @@ -107,7 +110,11 @@ void CInGameConsole::print(const std::string & txt) void CInGameConsole::keyPressed (const SDL_Keycode & key) { - if(!captureAllKeys && key != SDLK_TAB) return; //because user is not entering any text + if (LOCPLINT->cingconsole != this) + return; + + if(!captureAllKeys && key != SDLK_TAB) + return; //because user is not entering any text switch(key) { @@ -192,6 +199,9 @@ void CInGameConsole::keyPressed (const SDL_Keycode & key) void CInGameConsole::textInputed(const std::string & inputtedText) { + if (LOCPLINT->cingconsole != this) + return; + if(!captureAllKeys || enteredText.empty()) return; enteredText.resize(enteredText.size()-1); From 71ddaeea6ef9042731d01ad06167cc8761027a96 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sat, 8 Apr 2023 19:47:16 +0300 Subject: [PATCH 3/4] Fix crash on missing music file --- client/CMusicHandler.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/client/CMusicHandler.cpp b/client/CMusicHandler.cpp index f15ad9c3f..1649339c4 100644 --- a/client/CMusicHandler.cpp +++ b/client/CMusicHandler.cpp @@ -446,15 +446,7 @@ void CMusicHandler::queueNext(std::unique_ptr queued) void CMusicHandler::queueNext(CMusicHandler *owner, const std::string & setName, const std::string & musicURI, bool looped, bool fromStart) { - try - { - queueNext(std::make_unique(owner, setName, musicURI, looped, fromStart)); - } - catch(std::exception &e) - { - logGlobal->error("Failed to queue music. setName=%s\tmusicURI=%s", setName, musicURI); - logGlobal->error("Exception: %s", e.what()); - } + queueNext(std::make_unique(owner, setName, musicURI, looped, fromStart)); } void CMusicHandler::stopMusic(int fade_ms) @@ -563,12 +555,20 @@ void MusicEntry::load(std::string musicURI) } currentName = musicURI; + music = nullptr; logGlobal->trace("Loading music file %s", musicURI); - auto musicFile = MakeSDLRWops(CResourceHandler::get()->load(ResourceID(std::move(musicURI), EResType::MUSIC))); - - music = Mix_LoadMUS_RW(musicFile, SDL_TRUE); + try + { + auto musicFile = MakeSDLRWops(CResourceHandler::get()->load(ResourceID(std::move(musicURI), EResType::MUSIC))); + music = Mix_LoadMUS_RW(musicFile, SDL_TRUE); + } + catch(std::exception &e) + { + logGlobal->error("Failed to load music. setName=%s\tmusicURI=%s", setName, musicURI); + logGlobal->error("Exception: %s", e.what()); + } if(!music) { From 454168897e2fe85051483101ab88dbebd664df15 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sat, 8 Apr 2023 19:47:38 +0300 Subject: [PATCH 4/4] Fix handling of invalid hotkeys in configurable UI --- client/gui/InterfaceObjectConfigurable.cpp | 14 +++++++++++--- config/widgets/settings/settingsMainContainer.json | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/client/gui/InterfaceObjectConfigurable.cpp b/client/gui/InterfaceObjectConfigurable.cpp index 79b7de24c..340c0e21b 100644 --- a/client/gui/InterfaceObjectConfigurable.cpp +++ b/client/gui/InterfaceObjectConfigurable.cpp @@ -31,6 +31,8 @@ static std::map KeycodeMap{ {"left", SDLK_LEFT}, {"right", SDLK_RIGHT}, {"space", SDLK_SPACE}, + {"escape", SDLK_ESCAPE}, + {"backspace", SDLK_BACKSPACE}, {"enter", SDLK_RETURN} }; @@ -220,10 +222,16 @@ int InterfaceObjectConfigurable::readKeycode(const JsonNode & config) const auto s = config.String(); if(s.size() == 1) //keyboard symbol return s[0]; - return KeycodeMap[s]; + + if (KeycodeMap.count(s)) + return KeycodeMap[s]; + + logGlobal->error("Invalid keycode '%s' in interface configuration!", config.String()); + return SDLK_UNKNOWN; } - - return 0; + + logGlobal->error("Invalid keycode format in interface configuration! Expected string or integer!", config.String()); + return SDLK_UNKNOWN; } std::shared_ptr InterfaceObjectConfigurable::buildPicture(const JsonNode & config) const diff --git a/config/widgets/settings/settingsMainContainer.json b/config/widgets/settings/settingsMainContainer.json index 8e7d78f8f..014fc1d96 100644 --- a/config/widgets/settings/settingsMainContainer.json +++ b/config/widgets/settings/settingsMainContainer.json @@ -153,7 +153,7 @@ "imageOrder": [1, 0, 2, 3], "help": "core.help.325", "callback": "closeWindow", - "hotkey": ["esc", "backspace"] + "hotkey": ["escape", "backspace"] } ] }