@@ -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);
@@ -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++;
@@ -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()) {
@@ -66,13 +66,13 @@ struct GSDTChunkHandler : ChunkHandler {
if (SlIterateArray() == -1) return;
_game_saveload_version = -1;
GameInstance::LoadEmpty();
if (SlIterateArray() != -1) SlErrorCorrupt("Too many GameScript configs");
return;
GameConfig *config = GameConfig::GetConfig(GameConfig::SSS_FORCE_GAME);
Status change: