Browse Source

Merge pull request #3777 from IvanSavenko/fix_autocombat_crash

Fix autocombat crash
Ivan Savenko 1 year ago
parent
commit
3b9bf8626a

+ 0 - 4
AI/BattleAI/BattleAI.cpp

@@ -166,10 +166,6 @@ void CBattleAI::activeStack(const BattleID & battleID, const CStack * stack )
 	{
 		throw;
 	}
-	catch(std::exception &e)
-	{
-		logAi->error("Exception occurred in %s %s",__FUNCTION__, e.what());
-	}
 
 	if(result.actionType == EActionType::DEFEND)
 	{

+ 1 - 1
client/battle/BattleInterface.cpp

@@ -729,7 +729,7 @@ void BattleInterface::requestAutofightingAIToTakeAction()
 			// FIXME: unsafe
 			// Run task in separate thread to avoid UI lock while AI is making turn (which might take some time)
 			// HOWEVER this thread won't atttempt to lock game state, potentially leading to races
-			boost::thread aiThread([this, activeStack]()
+			boost::thread aiThread([battleID = this->battleID, curInt = this->curInt, activeStack]()
 			{
 				setThreadName("autofightingAI");
 				curInt->autofightingAI->activeStack(battleID, activeStack);

+ 1 - 1
lib/modding/IdentifierStorage.cpp

@@ -202,7 +202,7 @@ void CIdentifierStorage::tryRequestIdentifier(const std::string & type, const Js
 
 std::optional<si32> CIdentifierStorage::getIdentifier(const std::string & scope, const std::string & type, const std::string & name, bool silent) const
 {
-	assert(state != ELoadingState::LOADING);
+	//assert(state != ELoadingState::LOADING);
 
 	auto options = ObjectCallback::fromNameAndType(scope, type, name, std::function<void(si32)>(), silent);
 	return getIdentifierImpl(options, silent);