Changeset - r26641:01889b29735a
[Not reviewed]
master
0 4 0
Loïc Guilloux - 18 months ago 2022-12-15 20:43:07
glx22@users.noreply.github.com
Fix #10206: Disable scripts in intro game (#10241)
4 files changed with 11 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/ai/ai_instance.cpp
Show inline comments
 
@@ -58,12 +58,15 @@ void AIInstance::RegisterAPI()
 
}
 

	
 
void AIInstance::Died()
 
{
 
	ScriptInstance::Died();
 

	
 
	/* Intro is not supposed to use AI, but it may have 'dummy' AI which instant dies. */
 
	if (_game_mode == GM_MENU) return;
 

	
 
	ShowAIDebugWindow(_current_company);
 

	
 
	const AIInfo *info = AIConfig::GetConfig(_current_company, AIConfig::SSS_FORCE_GAME)->GetInfo();
 
	if (info != nullptr) {
 
		ShowErrorMessage(STR_ERROR_AI_PLEASE_REPORT_CRASH, INVALID_STRING_ID, WL_WARNING);
 

	
src/ai/ai_scanner.cpp
Show inline comments
 
@@ -7,12 +7,13 @@
 

	
 
/** @file ai_scanner.cpp allows scanning AI scripts */
 

	
 
#include "../stdafx.h"
 
#include "../debug.h"
 
#include "../network/network.h"
 
#include "../openttd.h"
 
#include "../core/random_func.hpp"
 

	
 
#include "../script/squirrel_class.hpp"
 
#include "ai_info.hpp"
 
#include "ai_scanner.hpp"
 

	
 
@@ -56,12 +57,17 @@ void AIScannerInfo::RegisterAPI(class Sq
 
{
 
	AIInfo::RegisterAPI(engine);
 
}
 

	
 
AIInfo *AIScannerInfo::SelectRandomAI() const
 
{
 
	if (_game_mode == GM_MENU) {
 
		Debug(script, 0, "The intro game should not use AI, loading 'dummy' AI.");
 
		return this->info_dummy;
 
	}
 

	
 
	uint num_random_ais = 0;
 
	for (const auto &item : info_single_list) {
 
		AIInfo *i = static_cast<AIInfo *>(item.second);
 
		if (i->UseAsRandomAI()) num_random_ais++;
 
	}
 

	
src/saveload/ai_sl.cpp
Show inline comments
 
@@ -74,13 +74,13 @@ struct AIPLChunkHandler : ChunkHandler {
 
			if (index >= MAX_COMPANIES) SlErrorCorrupt("Too many AI configs");
 

	
 
			_ai_saveload_is_random = false;
 
			_ai_saveload_version = -1;
 
			SlObject(nullptr, slt);
 

	
 
			if (_networking && !_network_server) {
 
			if (_game_mode == GM_MENU || (_networking && !_network_server)) {
 
				if (Company::IsValidAiID(index)) AIInstance::LoadEmpty();
 
				continue;
 
			}
 

	
 
			AIConfig *config = AIConfig::GetConfig(index, AIConfig::SSS_FORCE_GAME);
 
			if (_ai_saveload_name.empty()) {
src/saveload/game_sl.cpp
Show inline comments
 
@@ -66,13 +66,13 @@ struct GSDTChunkHandler : ChunkHandler {
 

	
 
		if (SlIterateArray() == -1) return;
 

	
 
		_game_saveload_version = -1;
 
		SlObject(nullptr, slt);
 

	
 
		if (_networking && !_network_server) {
 
		if (_game_mode == GM_MENU || (_networking && !_network_server)) {
 
			GameInstance::LoadEmpty();
 
			if (SlIterateArray() != -1) SlErrorCorrupt("Too many GameScript configs");
 
			return;
 
		}
 

	
 
		GameConfig *config = GameConfig::GetConfig(GameConfig::SSS_FORCE_GAME);
0 comments (0 inline, 0 general)