OpenTTD Source 20241224-master-gf74b0cf984
AIScannerInfo Class Reference
Inheritance diagram for AIScannerInfo:
ScriptScanner FileScanner

Public Member Functions

void Initialize () override
 
class AIInfoSelectRandomAI () const
 Select a random AI.
 
class AIInfoFindInfo (const std::string &name, int version, bool force_exact_match)
 Check if we have an AI by name and version available in our list.
 
void SetDummyAI (class AIInfo *info)
 Set the Dummy AI.
 
- Public Member Functions inherited from ScriptScanner
class SquirrelGetEngine ()
 Get the engine of the main squirrel handler (it indexes all available scripts).
 
std::string GetMainScript ()
 Get the current main script the ScanDir is currently tracking.
 
std::string GetTarFile ()
 Get the current tar file the ScanDir is currently tracking.
 
const ScriptInfoListGetInfoList ()
 Get the list of all registered scripts.
 
const ScriptInfoListGetUniqueInfoList ()
 Get the list of the latest version of all registered scripts.
 
void RegisterScript (class ScriptInfo *info)
 Register a ScriptInfo to the scanner.
 
void GetConsoleList (std::back_insert_iterator< std::string > &output_iterator, bool newest_only) const
 Get the list of registered scripts to print on the console.
 
bool HasScript (const struct ContentInfo *ci, bool md5sum)
 Check whether we have a script with the exact characteristics as ci.
 
const char * FindMainScript (const ContentInfo *ci, bool md5sum)
 Find a script of a ContentInfo.
 
bool AddFile (const std::string &filename, size_t basepath_length, const std::string &tar_filename) override
 Add a file with the given filename.
 
void RescanDir ()
 Rescan the script dir.
 
- Public Member Functions inherited from FileScanner
virtual ~FileScanner ()=default
 Destruct the proper one...
 
uint Scan (std::string_view extension, Subdirectory sd, bool tars=true, bool recursive=true)
 Scan for files with the given extension in the given search path.
 
uint Scan (std::string_view extension, const std::string &directory, bool recursive=true)
 Scan for files with the given extension in the given search path.
 

Protected Member Functions

std::string GetScriptName (ScriptInfo *info) override
 Get the script name how to store the script in memory.
 
const char * GetFileName () const override
 Get the filename to scan for this type of script.
 
Subdirectory GetDirectory () const override
 Get the directory to scan in.
 
const char * GetScannerName () const override
 Get the type of the script, in plural.
 
void RegisterAPI (class Squirrel *engine) override
 Register the API for this ScriptInfo.
 
- Protected Member Functions inherited from ScriptScanner
void Initialize (const char *name)
 Initialize the scanner.
 
void Reset ()
 Reset all allocated lists.
 
void ResetEngine ()
 Reset the engine to ensure a clean environment for further steps.
 

Private Attributes

AIInfoinfo_dummy
 The dummy AI.
 

Additional Inherited Members

- Protected Attributes inherited from ScriptScanner
class Squirrelengine
 The engine we're scanning with.
 
std::string main_script
 The full path of the script.
 
std::string tar_file
 If, which tar file the script was in.
 
ScriptInfoList info_list
 The list of all script.
 
ScriptInfoList info_single_list
 The list of all unique script. The best script (highest version) is shown.
 
- Protected Attributes inherited from FileScanner
Subdirectory subdir
 The current sub directory we are searching through.
 

Detailed Description

Definition at line 15 of file ai_scanner.hpp.

Constructor & Destructor Documentation

◆ AIScannerInfo()

AIScannerInfo::AIScannerInfo ( )

Definition at line 24 of file ai_scanner.cpp.

◆ ~AIScannerInfo()

AIScannerInfo::~AIScannerInfo ( )

Definition at line 46 of file ai_scanner.cpp.

Member Function Documentation

◆ FindInfo()

AIInfo * AIScannerInfo::FindInfo ( const std::string &  name,
int  version,
bool  force_exact_match 
)

Check if we have an AI by name and version available in our list.

Parameters
nameThe name of the AI.
versionThe version of the AI, or -1 if you want the latest.
force_exact_matchOnly match name+version, never latest.
Returns
nullptr if no match found, otherwise the AI that matched.

Definition at line 95 of file ai_scanner.cpp.

References AIInfo::CanLoadFromVersion(), ScriptInfo::GetName(), ScriptInfo::GetVersion(), ScriptScanner::info_list, ScriptScanner::info_single_list, and StrEqualsIgnoreCase().

Referenced by AI::FindInfo().

◆ GetDirectory()

Subdirectory AIScannerInfo::GetDirectory ( ) const
inlineoverrideprotectedvirtual

Get the directory to scan in.

Implements ScriptScanner.

Definition at line 45 of file ai_scanner.hpp.

References AI_DIR.

◆ GetFileName()

const char * AIScannerInfo::GetFileName ( ) const
inlineoverrideprotectedvirtual

Get the filename to scan for this type of script.

Implements ScriptScanner.

Definition at line 44 of file ai_scanner.hpp.

◆ GetScannerName()

const char * AIScannerInfo::GetScannerName ( ) const
inlineoverrideprotectedvirtual

Get the type of the script, in plural.

Implements ScriptScanner.

Definition at line 46 of file ai_scanner.hpp.

◆ GetScriptName()

std::string AIScannerInfo::GetScriptName ( ScriptInfo info)
overrideprotectedvirtual

Get the script name how to store the script in memory.

Implements ScriptScanner.

Definition at line 51 of file ai_scanner.cpp.

References ScriptInfo::GetName().

◆ Initialize()

void AIScannerInfo::Initialize ( )
overridevirtual

Implements ScriptScanner.

Definition at line 30 of file ai_scanner.cpp.

◆ RegisterAPI()

void AIScannerInfo::RegisterAPI ( class Squirrel engine)
overrideprotectedvirtual

Register the API for this ScriptInfo.

Implements ScriptScanner.

Definition at line 56 of file ai_scanner.cpp.

References ScriptScanner::engine, and AIInfo::RegisterAPI().

◆ SelectRandomAI()

AIInfo * AIScannerInfo::SelectRandomAI ( ) const

Select a random AI.

Returns
A random AI from the pool.

Definition at line 61 of file ai_scanner.cpp.

References Debug, info_dummy, ScriptScanner::info_single_list, OWNER_NONE, and AIInfo::UseAsRandomAI().

Referenced by AI::StartNew().

◆ SetDummyAI()

void AIScannerInfo::SetDummyAI ( class AIInfo info)

Set the Dummy AI.

Definition at line 41 of file ai_scanner.cpp.

References info_dummy.

Field Documentation

◆ info_dummy

AIInfo* AIScannerInfo::info_dummy
private

The dummy AI.

Definition at line 50 of file ai_scanner.hpp.

Referenced by SelectRandomAI(), and SetDummyAI().


The documentation for this class was generated from the following files: