2009-01-12 17:11:45 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
|
|
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2009-01-12 17:11:45 +00:00
|
|
|
/** @file ai_core.cpp Implementation of AI. */
|
|
|
|
|
|
|
|
#include "../stdafx.h"
|
2010-05-31 20:22:57 +00:00
|
|
|
#include "../core/backup_type.hpp"
|
2009-02-03 22:42:42 +00:00
|
|
|
#include "../core/bitmath_func.hpp"
|
2009-01-12 17:11:45 +00:00
|
|
|
#include "../company_base.h"
|
|
|
|
#include "../company_func.h"
|
|
|
|
#include "../network/network.h"
|
|
|
|
#include "../window_func.h"
|
|
|
|
#include "ai_scanner.hpp"
|
|
|
|
#include "ai_instance.hpp"
|
|
|
|
#include "ai_config.hpp"
|
2011-11-29 23:26:35 +00:00
|
|
|
#include "ai_info.hpp"
|
2011-11-29 23:21:52 +00:00
|
|
|
#include "ai.hpp"
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/* static */ uint AI::frame_counter = 0;
|
2011-11-29 23:21:52 +00:00
|
|
|
/* static */ AIScannerInfo *AI::scanner_info = NULL;
|
|
|
|
/* static */ AIScannerLibrary *AI::scanner_library = NULL;
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/* static */ bool AI::CanStartNew()
|
|
|
|
{
|
|
|
|
/* Only allow new AIs on the server and only when that is allowed in multiplayer */
|
|
|
|
return !_networking || (_network_server && _settings_game.ai.ai_in_multiplayer);
|
|
|
|
}
|
|
|
|
|
2010-01-09 14:41:22 +00:00
|
|
|
/* static */ void AI::StartNew(CompanyID company, bool rerandomise_ai)
|
2009-01-12 17:11:45 +00:00
|
|
|
{
|
2009-05-17 01:00:56 +00:00
|
|
|
assert(Company::IsValidID(company));
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/* Clients shouldn't start AIs */
|
|
|
|
if (_networking && !_network_server) return;
|
|
|
|
|
2012-04-09 12:35:01 +00:00
|
|
|
AIConfig *config = AIConfig::GetConfig(company, AIConfig::SSS_FORCE_GAME);
|
2010-01-09 14:41:22 +00:00
|
|
|
AIInfo *info = config->GetInfo();
|
2011-11-29 23:26:35 +00:00
|
|
|
if (info == NULL || (rerandomise_ai && config->IsRandom())) {
|
2011-11-29 23:21:52 +00:00
|
|
|
info = AI::scanner_info->SelectRandomAI();
|
2009-01-12 17:11:45 +00:00
|
|
|
assert(info != NULL);
|
|
|
|
/* Load default data and store the name in the settings */
|
2011-11-29 23:26:35 +00:00
|
|
|
config->Change(info->GetName(), -1, false, true);
|
2009-01-12 17:11:45 +00:00
|
|
|
}
|
|
|
|
|
2010-06-05 13:29:48 +00:00
|
|
|
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
|
2009-05-16 23:34:14 +00:00
|
|
|
Company *c = Company::Get(company);
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
c->ai_info = info;
|
2009-01-17 15:14:13 +00:00
|
|
|
assert(c->ai_instance == NULL);
|
2011-11-13 20:43:48 +00:00
|
|
|
c->ai_instance = new AIInstance();
|
|
|
|
c->ai_instance->Initialize(info);
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2010-06-05 13:29:48 +00:00
|
|
|
cur_company.Restore();
|
|
|
|
|
2009-01-12 17:11:45 +00:00
|
|
|
InvalidateWindowData(WC_AI_DEBUG, 0, -1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ void AI::GameLoop()
|
|
|
|
{
|
|
|
|
/* If we are in networking, only servers run this function, and that only if it is allowed */
|
|
|
|
if (_networking && (!_network_server || !_settings_game.ai.ai_in_multiplayer)) return;
|
|
|
|
|
|
|
|
/* The speed with which AIs go, is limited by the 'competitor_speed' */
|
|
|
|
AI::frame_counter++;
|
|
|
|
assert(_settings_game.difficulty.competitor_speed <= 4);
|
|
|
|
if ((AI::frame_counter & ((1 << (4 - _settings_game.difficulty.competitor_speed)) - 1)) != 0) return;
|
|
|
|
|
2010-06-05 12:16:12 +00:00
|
|
|
Backup<CompanyByte> cur_company(_current_company, FILE_LINE);
|
2009-01-12 17:11:45 +00:00
|
|
|
const Company *c;
|
|
|
|
FOR_ALL_COMPANIES(c) {
|
2009-06-10 22:05:01 +00:00
|
|
|
if (c->is_ai) {
|
2010-05-31 20:22:57 +00:00
|
|
|
cur_company.Change(c->index);
|
2009-01-12 17:11:45 +00:00
|
|
|
c->ai_instance->GameLoop();
|
|
|
|
}
|
|
|
|
}
|
2010-05-31 20:22:57 +00:00
|
|
|
cur_company.Restore();
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2009-02-03 22:42:42 +00:00
|
|
|
/* Occasionally collect garbage; every 255 ticks do one company.
|
|
|
|
* Effectively collecting garbage once every two months per AI. */
|
|
|
|
if ((AI::frame_counter & 255) == 0) {
|
|
|
|
CompanyID cid = (CompanyID)GB(AI::frame_counter, 8, 4);
|
2009-06-10 22:05:01 +00:00
|
|
|
if (Company::IsValidAiID(cid)) Company::Get(cid)->ai_instance->CollectGarbage();
|
2009-02-03 22:42:42 +00:00
|
|
|
}
|
2009-01-12 17:11:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ uint AI::GetTick()
|
|
|
|
{
|
|
|
|
return AI::frame_counter;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ void AI::Stop(CompanyID company)
|
|
|
|
{
|
|
|
|
if (_networking && !_network_server) return;
|
|
|
|
|
2010-06-05 12:16:12 +00:00
|
|
|
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
|
2009-05-16 23:34:14 +00:00
|
|
|
Company *c = Company::Get(company);
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
delete c->ai_instance;
|
|
|
|
c->ai_instance = NULL;
|
2012-01-03 23:09:48 +00:00
|
|
|
c->ai_info = NULL;
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2010-05-31 20:22:57 +00:00
|
|
|
cur_company.Restore();
|
2009-02-07 17:01:44 +00:00
|
|
|
|
2009-01-12 17:11:45 +00:00
|
|
|
InvalidateWindowData(WC_AI_DEBUG, 0, -1);
|
2010-01-29 21:38:55 +00:00
|
|
|
DeleteWindowById(WC_AI_SETTINGS, company);
|
2009-01-12 17:11:45 +00:00
|
|
|
}
|
|
|
|
|
2012-09-21 19:58:18 +00:00
|
|
|
/* static */ void AI::Pause(CompanyID company)
|
2010-04-02 17:35:20 +00:00
|
|
|
{
|
2012-09-21 19:58:18 +00:00
|
|
|
/* The reason why dedicated servers are forbidden to execute this
|
|
|
|
* command is not because it is unsafe, but because there is no way
|
|
|
|
* for the server owner to unpause the script again. */
|
|
|
|
if (_network_dedicated) return;
|
|
|
|
|
|
|
|
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
|
|
|
|
Company::Get(company)->ai_instance->Pause();
|
|
|
|
|
|
|
|
cur_company.Restore();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ void AI::Unpause(CompanyID company)
|
|
|
|
{
|
|
|
|
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
|
|
|
|
Company::Get(company)->ai_instance->Unpause();
|
2010-04-02 17:35:20 +00:00
|
|
|
|
2012-09-21 19:58:18 +00:00
|
|
|
cur_company.Restore();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ bool AI::IsPaused(CompanyID company)
|
|
|
|
{
|
2010-06-05 12:16:12 +00:00
|
|
|
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
|
2012-09-21 19:58:18 +00:00
|
|
|
bool paused = Company::Get(company)->ai_instance->IsPaused();
|
2010-04-02 17:35:20 +00:00
|
|
|
|
2010-05-31 20:22:57 +00:00
|
|
|
cur_company.Restore();
|
2012-09-21 19:58:18 +00:00
|
|
|
|
|
|
|
return paused;
|
2010-04-02 17:35:20 +00:00
|
|
|
}
|
|
|
|
|
2009-01-12 17:11:45 +00:00
|
|
|
/* static */ void AI::KillAll()
|
|
|
|
{
|
|
|
|
/* It might happen there are no companies .. than we have nothing to loop */
|
2009-05-16 23:44:36 +00:00
|
|
|
if (Company::GetPoolSize() == 0) return;
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
const Company *c;
|
|
|
|
FOR_ALL_COMPANIES(c) {
|
2009-06-10 22:05:01 +00:00
|
|
|
if (c->is_ai) AI::Stop(c->index);
|
2009-01-12 17:11:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ void AI::Initialize()
|
|
|
|
{
|
2011-11-29 23:21:52 +00:00
|
|
|
if (AI::scanner_info != NULL) AI::Uninitialize(true);
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
AI::frame_counter = 0;
|
2011-11-29 23:21:52 +00:00
|
|
|
if (AI::scanner_info == NULL) {
|
2011-11-14 21:40:39 +00:00
|
|
|
TarScanner::DoScan(TarScanner::AI);
|
2011-11-29 23:21:52 +00:00
|
|
|
AI::scanner_info = new AIScannerInfo();
|
2011-12-15 19:52:44 +00:00
|
|
|
AI::scanner_info->Initialize();
|
2011-11-29 23:21:52 +00:00
|
|
|
AI::scanner_library = new AIScannerLibrary();
|
2011-12-15 19:52:44 +00:00
|
|
|
AI::scanner_library->Initialize();
|
2011-11-14 21:40:39 +00:00
|
|
|
}
|
2009-01-12 17:11:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ void AI::Uninitialize(bool keepConfig)
|
|
|
|
{
|
|
|
|
AI::KillAll();
|
|
|
|
|
|
|
|
if (keepConfig) {
|
|
|
|
/* Run a rescan, which indexes all AIInfos again, and check if we can
|
|
|
|
* still load all the AIS, while keeping the configs in place */
|
|
|
|
Rescan();
|
|
|
|
} else {
|
2011-11-29 23:21:52 +00:00
|
|
|
delete AI::scanner_info;
|
|
|
|
delete AI::scanner_library;
|
|
|
|
AI::scanner_info = NULL;
|
|
|
|
AI::scanner_library = NULL;
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
|
|
|
|
if (_settings_game.ai_config[c] != NULL) {
|
|
|
|
delete _settings_game.ai_config[c];
|
|
|
|
_settings_game.ai_config[c] = NULL;
|
|
|
|
}
|
|
|
|
if (_settings_newgame.ai_config[c] != NULL) {
|
|
|
|
delete _settings_newgame.ai_config[c];
|
|
|
|
_settings_newgame.ai_config[c] = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ void AI::ResetConfig()
|
|
|
|
{
|
2013-01-08 22:46:42 +00:00
|
|
|
/* Check for both newgame as current game if we can reload the AIInfo inside
|
2009-01-12 17:11:45 +00:00
|
|
|
* the AIConfig. If not, remove the AI from the list (which will assign
|
|
|
|
* a random new AI on reload). */
|
|
|
|
for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
|
2011-11-29 23:26:35 +00:00
|
|
|
if (_settings_game.ai_config[c] != NULL && _settings_game.ai_config[c]->HasScript()) {
|
2011-06-03 19:18:39 +00:00
|
|
|
if (!_settings_game.ai_config[c]->ResetInfo(true)) {
|
2011-12-01 12:04:10 +00:00
|
|
|
DEBUG(script, 0, "After a reload, the AI by the name '%s' was no longer found, and removed from the list.", _settings_game.ai_config[c]->GetName());
|
2011-11-29 23:26:35 +00:00
|
|
|
_settings_game.ai_config[c]->Change(NULL);
|
2011-06-03 19:18:39 +00:00
|
|
|
if (Company::IsValidAiID(c)) {
|
|
|
|
/* The code belonging to an already running AI was deleted. We can only do
|
|
|
|
* one thing here to keep everything sane and that is kill the AI. After
|
|
|
|
* killing the offending AI we start a random other one in it's place, just
|
|
|
|
* like what would happen if the AI was missing during loading. */
|
|
|
|
AI::Stop(c);
|
|
|
|
AI::StartNew(c, false);
|
|
|
|
}
|
|
|
|
} else if (Company::IsValidAiID(c)) {
|
|
|
|
/* Update the reference in the Company struct. */
|
|
|
|
Company::Get(c)->ai_info = _settings_game.ai_config[c]->GetInfo();
|
2009-01-12 17:11:45 +00:00
|
|
|
}
|
|
|
|
}
|
2011-11-29 23:26:35 +00:00
|
|
|
if (_settings_newgame.ai_config[c] != NULL && _settings_newgame.ai_config[c]->HasScript()) {
|
2011-06-03 19:18:39 +00:00
|
|
|
if (!_settings_newgame.ai_config[c]->ResetInfo(false)) {
|
2011-12-01 12:04:10 +00:00
|
|
|
DEBUG(script, 0, "After a reload, the AI by the name '%s' was no longer found, and removed from the list.", _settings_newgame.ai_config[c]->GetName());
|
2011-11-29 23:26:35 +00:00
|
|
|
_settings_newgame.ai_config[c]->Change(NULL);
|
2009-01-12 17:11:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
/* static */ void AI::NewEvent(CompanyID company, ScriptEvent *event)
|
2009-01-12 17:11:45 +00:00
|
|
|
{
|
2009-01-24 21:38:30 +00:00
|
|
|
/* AddRef() and Release() need to be called at least once, so do it here */
|
|
|
|
event->AddRef();
|
|
|
|
|
2009-01-12 17:11:45 +00:00
|
|
|
/* Clients should ignore events */
|
2009-01-24 21:38:30 +00:00
|
|
|
if (_networking && !_network_server) {
|
|
|
|
event->Release();
|
|
|
|
return;
|
|
|
|
}
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/* Only AIs can have an event-queue */
|
2009-06-10 22:05:01 +00:00
|
|
|
if (!Company::IsValidAiID(company)) {
|
2009-01-24 21:38:30 +00:00
|
|
|
event->Release();
|
|
|
|
return;
|
|
|
|
}
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/* Queue the event */
|
2010-06-05 12:16:12 +00:00
|
|
|
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
|
2011-11-13 20:43:48 +00:00
|
|
|
Company::Get(_current_company)->ai_instance->InsertEvent(event);
|
2010-05-31 20:22:57 +00:00
|
|
|
cur_company.Restore();
|
2009-01-24 21:38:30 +00:00
|
|
|
|
|
|
|
event->Release();
|
2009-01-12 17:11:45 +00:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
/* static */ void AI::BroadcastNewEvent(ScriptEvent *event, CompanyID skip_company)
|
2009-01-12 17:11:45 +00:00
|
|
|
{
|
2009-01-24 21:38:30 +00:00
|
|
|
/* AddRef() and Release() need to be called at least once, so do it here */
|
|
|
|
event->AddRef();
|
|
|
|
|
2009-01-12 17:11:45 +00:00
|
|
|
/* Clients should ignore events */
|
2009-01-24 21:38:30 +00:00
|
|
|
if (_networking && !_network_server) {
|
|
|
|
event->Release();
|
|
|
|
return;
|
|
|
|
}
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/* Try to send the event to all AIs */
|
|
|
|
for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
|
|
|
|
if (c != skip_company) AI::NewEvent(c, event);
|
|
|
|
}
|
2009-01-24 21:38:30 +00:00
|
|
|
|
|
|
|
event->Release();
|
2009-01-12 17:11:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ void AI::Save(CompanyID company)
|
|
|
|
{
|
|
|
|
if (!_networking || _network_server) {
|
2009-05-18 16:21:28 +00:00
|
|
|
Company *c = Company::GetIfValid(company);
|
|
|
|
assert(c != NULL && c->ai_instance != NULL);
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2010-06-05 12:16:12 +00:00
|
|
|
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
|
2009-05-18 16:21:28 +00:00
|
|
|
c->ai_instance->Save();
|
2010-05-31 20:22:57 +00:00
|
|
|
cur_company.Restore();
|
2009-01-12 17:11:45 +00:00
|
|
|
} else {
|
|
|
|
AIInstance::SaveEmpty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-13 01:46:46 +00:00
|
|
|
/* static */ void AI::Load(CompanyID company, int version)
|
2009-01-12 17:11:45 +00:00
|
|
|
{
|
|
|
|
if (!_networking || _network_server) {
|
2009-05-18 16:21:28 +00:00
|
|
|
Company *c = Company::GetIfValid(company);
|
|
|
|
assert(c != NULL && c->ai_instance != NULL);
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2010-06-05 12:16:12 +00:00
|
|
|
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
|
2009-05-18 16:21:28 +00:00
|
|
|
c->ai_instance->Load(version);
|
2010-05-31 20:22:57 +00:00
|
|
|
cur_company.Restore();
|
2009-01-12 17:11:45 +00:00
|
|
|
} else {
|
|
|
|
/* Read, but ignore, the load data */
|
|
|
|
AIInstance::LoadEmpty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-13 14:00:26 +00:00
|
|
|
/* static */ int AI::GetStartNextTime()
|
|
|
|
{
|
2009-01-13 16:53:03 +00:00
|
|
|
/* Find the first company which doesn't exist yet */
|
2009-01-13 14:00:26 +00:00
|
|
|
for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
|
2012-04-09 12:35:01 +00:00
|
|
|
if (!Company::IsValidID(c)) return AIConfig::GetConfig(c, AIConfig::SSS_FORCE_GAME)->GetSetting("start_date");
|
2009-01-13 14:00:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Currently no AI can be started, check again in a year. */
|
2009-01-13 22:58:03 +00:00
|
|
|
return DAYS_IN_YEAR;
|
2009-01-13 14:00:26 +00:00
|
|
|
}
|
|
|
|
|
2011-02-07 09:51:16 +00:00
|
|
|
/* static */ char *AI::GetConsoleList(char *p, const char *last, bool newest_only)
|
2009-01-12 17:11:45 +00:00
|
|
|
{
|
2011-11-29 23:21:52 +00:00
|
|
|
return AI::scanner_info->GetConsoleList(p, last, newest_only);
|
2009-01-12 17:11:45 +00:00
|
|
|
}
|
|
|
|
|
2011-01-03 14:52:30 +00:00
|
|
|
/* static */ char *AI::GetConsoleLibraryList(char *p, const char *last)
|
|
|
|
{
|
2011-11-29 23:21:52 +00:00
|
|
|
return AI::scanner_library->GetConsoleList(p, last, true);
|
2011-01-03 14:52:30 +00:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:21:52 +00:00
|
|
|
/* static */ const ScriptInfoList *AI::GetInfoList()
|
2009-01-12 17:11:45 +00:00
|
|
|
{
|
2011-11-29 23:21:52 +00:00
|
|
|
return AI::scanner_info->GetInfoList();
|
2009-01-12 17:11:45 +00:00
|
|
|
}
|
|
|
|
|
2011-11-29 23:21:52 +00:00
|
|
|
/* static */ const ScriptInfoList *AI::GetUniqueInfoList()
|
2009-01-20 16:49:10 +00:00
|
|
|
{
|
2011-11-29 23:21:52 +00:00
|
|
|
return AI::scanner_info->GetUniqueInfoList();
|
2009-01-20 16:49:10 +00:00
|
|
|
}
|
|
|
|
|
2010-01-29 00:03:31 +00:00
|
|
|
/* static */ AIInfo *AI::FindInfo(const char *name, int version, bool force_exact_match)
|
2009-01-12 17:11:45 +00:00
|
|
|
{
|
2011-11-29 23:21:52 +00:00
|
|
|
return AI::scanner_info->FindInfo(name, version, force_exact_match);
|
2009-01-12 17:11:45 +00:00
|
|
|
}
|
|
|
|
|
2011-11-23 13:39:36 +00:00
|
|
|
/* static */ AILibrary *AI::FindLibrary(const char *library, int version)
|
2009-01-12 17:11:45 +00:00
|
|
|
{
|
2011-11-29 23:21:52 +00:00
|
|
|
return AI::scanner_library->FindLibrary(library, version);
|
2009-01-12 17:11:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ void AI::Rescan()
|
|
|
|
{
|
2011-11-14 21:40:39 +00:00
|
|
|
TarScanner::DoScan(TarScanner::AI);
|
|
|
|
|
2011-11-29 23:21:52 +00:00
|
|
|
AI::scanner_info->RescanDir();
|
|
|
|
AI::scanner_library->RescanDir();
|
2009-01-12 17:11:45 +00:00
|
|
|
ResetConfig();
|
2011-08-24 16:38:09 +00:00
|
|
|
|
|
|
|
InvalidateWindowData(WC_AI_LIST, 0, 1);
|
|
|
|
SetWindowClassesDirty(WC_AI_DEBUG);
|
2012-01-02 20:39:50 +00:00
|
|
|
InvalidateWindowClassesData(WC_AI_SETTINGS);
|
2009-01-12 17:11:45 +00:00
|
|
|
}
|
2011-11-29 23:21:52 +00:00
|
|
|
|
2011-11-30 06:20:14 +00:00
|
|
|
#if defined(ENABLE_NETWORK)
|
|
|
|
|
2011-11-29 23:21:52 +00:00
|
|
|
/**
|
|
|
|
* Check whether we have an AI (library) with the exact characteristics as ci.
|
|
|
|
* @param ci the characteristics to search on (shortname and md5sum)
|
|
|
|
* @param md5sum whether to check the MD5 checksum
|
|
|
|
* @return true iff we have an AI (library) matching.
|
|
|
|
*/
|
|
|
|
/* static */ bool AI::HasAI(const ContentInfo *ci, bool md5sum)
|
|
|
|
{
|
|
|
|
return AI::scanner_info->HasScript(ci, md5sum);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ bool AI::HasAILibrary(const ContentInfo *ci, bool md5sum)
|
|
|
|
{
|
|
|
|
return AI::scanner_library->HasScript(ci, md5sum);
|
|
|
|
}
|
2011-11-30 06:20:14 +00:00
|
|
|
|
|
|
|
#endif /* defined(ENABLE_NETWORK) */
|
2012-08-20 21:01:40 +00:00
|
|
|
|
|
|
|
/* static */ AIScannerInfo *AI::GetScannerInfo()
|
|
|
|
{
|
|
|
|
return AI::scanner_info;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ AIScannerLibrary *AI::GetScannerLibrary()
|
|
|
|
{
|
|
|
|
return AI::scanner_library;
|
|
|
|
}
|
|
|
|
|