Changeset - r28792:5622964c1375
[Not reviewed]
master
0 1 0
Loïc Guilloux - 2 months ago 2024-02-20 17:55:18
glx22@users.noreply.github.com
Fix #12133: [Script] Don't crash when emergency saving (#12138)
1 file changed with 10 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/ai/ai_core.cpp
Show inline comments
 
@@ -285,14 +285,18 @@
 
{
 
	if (!_networking || _network_server) {
 
		Company *c = Company::GetIfValid(company);
 
		assert(c != nullptr && c->ai_instance != nullptr);
 
		assert(c != nullptr);
 

	
 
		Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
 
		c->ai_instance->Save();
 
		cur_company.Restore();
 
	} else {
 
		AIInstance::SaveEmpty();
 
		/* When doing emergency saving, an AI can be not fully initialised. */
 
		if (c->ai_instance != nullptr) {
 
			Backup<CompanyID> cur_company(_current_company, company, FILE_LINE);
 
			c->ai_instance->Save();
 
			cur_company.Restore();
 
			return;
 
		}
 
	}
 

	
 
	AIInstance::SaveEmpty();
 
}
 

	
 
/* static */ void AI::GetConsoleList(std::back_insert_iterator<std::string> &output_iterator, bool newest_only)
0 comments (0 inline, 0 general)