Переглянути джерело

Merge pull request #1910 from IvanSavenko/beta_fixes

Fixes for 1.2 branch
Ivan Savenko 2 роки тому
батько
коміт
e2d0cd37e4

+ 12 - 12
client/CMusicHandler.cpp

@@ -446,15 +446,7 @@ void CMusicHandler::queueNext(std::unique_ptr<MusicEntry> queued)
 
 
 void CMusicHandler::queueNext(CMusicHandler *owner, const std::string & setName, const std::string & musicURI, bool looped, bool fromStart)
 void CMusicHandler::queueNext(CMusicHandler *owner, const std::string & setName, const std::string & musicURI, bool looped, bool fromStart)
 {
 {
-	try
-	{
-		queueNext(std::make_unique<MusicEntry>(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<MusicEntry>(owner, setName, musicURI, looped, fromStart));
 }
 }
 
 
 void CMusicHandler::stopMusic(int fade_ms)
 void CMusicHandler::stopMusic(int fade_ms)
@@ -563,12 +555,20 @@ void MusicEntry::load(std::string musicURI)
 	}
 	}
 
 
 	currentName = musicURI;
 	currentName = musicURI;
+	music = nullptr;
 
 
 	logGlobal->trace("Loading music file %s", musicURI);
 	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)
 	if(!music)
 	{
 	{

+ 1 - 1
client/CPlayerInterface.cpp

@@ -941,7 +941,7 @@ void CPlayerInterface::battleStacksEffectsSet( const SetStackEffect & sse )
 void CPlayerInterface::battleTriggerEffect (const BattleTriggerEffect & bte)
 void CPlayerInterface::battleTriggerEffect (const BattleTriggerEffect & bte)
 {
 {
 	EVENT_HANDLER_CALLED_BY_CLIENT;
 	EVENT_HANDLER_CALLED_BY_CLIENT;
-	//TODO why is this different (no return on LOPLINT != this) ?
+	BATTLE_EVENT_POSSIBLE_RETURN;
 
 
 	RETURN_IF_QUICK_COMBAT;
 	RETURN_IF_QUICK_COMBAT;
 	battleInt->effectsController->battleTriggerEffect(bte);
 	battleInt->effectsController->battleTriggerEffect(bte);

+ 11 - 1
client/adventureMap/CInGameConsole.cpp

@@ -38,6 +38,9 @@ void CInGameConsole::showAll(SDL_Surface * to)
 
 
 void CInGameConsole::show(SDL_Surface * to)
 void CInGameConsole::show(SDL_Surface * to)
 {
 {
+	if (LOCPLINT->cingconsole != this)
+		return;
+
 	int number = 0;
 	int number = 0;
 
 
 	boost::unique_lock<boost::mutex> lock(texts_mx);
 	boost::unique_lock<boost::mutex> lock(texts_mx);
@@ -107,7 +110,11 @@ void CInGameConsole::print(const std::string & txt)
 
 
 void CInGameConsole::keyPressed (const SDL_Keycode & key)
 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)
 	switch(key)
 	{
 	{
@@ -192,6 +199,9 @@ void CInGameConsole::keyPressed (const SDL_Keycode & key)
 
 
 void CInGameConsole::textInputed(const std::string & inputtedText)
 void CInGameConsole::textInputed(const std::string & inputtedText)
 {
 {
+	if (LOCPLINT->cingconsole != this)
+		return;
+
 	if(!captureAllKeys || enteredText.empty())
 	if(!captureAllKeys || enteredText.empty())
 		return;
 		return;
 	enteredText.resize(enteredText.size()-1);
 	enteredText.resize(enteredText.size()-1);

+ 11 - 3
client/gui/InterfaceObjectConfigurable.cpp

@@ -31,6 +31,8 @@ static std::map<std::string, int> KeycodeMap{
 	{"left", SDLK_LEFT},
 	{"left", SDLK_LEFT},
 	{"right", SDLK_RIGHT},
 	{"right", SDLK_RIGHT},
 	{"space", SDLK_SPACE},
 	{"space", SDLK_SPACE},
+	{"escape", SDLK_ESCAPE},
+	{"backspace", SDLK_BACKSPACE},
 	{"enter", SDLK_RETURN}
 	{"enter", SDLK_RETURN}
 };
 };
 
 
@@ -220,10 +222,16 @@ int InterfaceObjectConfigurable::readKeycode(const JsonNode & config) const
 		auto s = config.String();
 		auto s = config.String();
 		if(s.size() == 1) //keyboard symbol
 		if(s.size() == 1) //keyboard symbol
 			return s[0];
 			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<CPicture> InterfaceObjectConfigurable::buildPicture(const JsonNode & config) const
 std::shared_ptr<CPicture> InterfaceObjectConfigurable::buildPicture(const JsonNode & config) const

+ 1 - 1
config/widgets/settings/settingsMainContainer.json

@@ -153,7 +153,7 @@
 			"imageOrder": [1, 0, 2, 3],
 			"imageOrder": [1, 0, 2, 3],
 			"help": "core.help.325",
 			"help": "core.help.325",
 			"callback": "closeWindow",
 			"callback": "closeWindow",
-			"hotkey": ["esc", "backspace"]
+			"hotkey": ["escape", "backspace"]
 		}
 		}
 	]
 	]
 }
 }