mirror of https://github.com/OpenTTD/OpenTTD
(svn r23368) -Codechange: move FindLibrary down a few layers, so there is no layer violation anymore
parent
880f377fa6
commit
e0d4c75cf4
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include "ai_config.hpp"
|
#include "ai_config.hpp"
|
||||||
#include "ai_gui.hpp"
|
#include "ai_gui.hpp"
|
||||||
|
#include "ai.hpp"
|
||||||
|
|
||||||
#include "../script/script_fatalerror.hpp"
|
#include "../script/script_fatalerror.hpp"
|
||||||
#include "../script/script_suspend.hpp"
|
#include "../script/script_suspend.hpp"
|
||||||
|
@ -240,6 +241,11 @@ int AIInstance::GetSetting(const char *name)
|
||||||
return AIConfig::GetConfig(_current_company)->GetSetting(name);
|
return AIConfig::GetConfig(_current_company)->GetSetting(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScriptInfo *AIInstance::FindLibrary(const char *library, int version)
|
||||||
|
{
|
||||||
|
return (ScriptInfo *)AI::FindLibrary(library, version);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DoCommand callback function for all commands executed by AIs.
|
* DoCommand callback function for all commands executed by AIs.
|
||||||
* @param result The result of the command.
|
* @param result The result of the command.
|
||||||
|
|
|
@ -27,6 +27,7 @@ public:
|
||||||
void Initialize(class AIInfo *info);
|
void Initialize(class AIInfo *info);
|
||||||
|
|
||||||
/* virtual */ int GetSetting(const char *name);
|
/* virtual */ int GetSetting(const char *name);
|
||||||
|
/* virtual */ ScriptInfo *FindLibrary(const char *library, int version);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const char *versionAPI; ///< Current API used by this script.
|
const char *versionAPI; ///< Current API used by this script.
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
#include "script_controller.hpp"
|
#include "script_controller.hpp"
|
||||||
#include "../../ai/ai_instance.hpp"
|
#include "../../ai/ai_instance.hpp"
|
||||||
#include "../../ai/ai.hpp"
|
|
||||||
#include "../script_fatalerror.hpp"
|
#include "../script_fatalerror.hpp"
|
||||||
#include "../script_info.hpp"
|
#include "../script_info.hpp"
|
||||||
#include "../script_suspend.hpp"
|
#include "../script_suspend.hpp"
|
||||||
|
@ -94,7 +93,7 @@ ScriptController::~ScriptController()
|
||||||
snprintf(library_name, sizeof(library_name), "%s.%d", library, version);
|
snprintf(library_name, sizeof(library_name), "%s.%d", library, version);
|
||||||
strtolower(library_name);
|
strtolower(library_name);
|
||||||
|
|
||||||
ScriptInfo *lib = (ScriptInfo *)AI::FindLibrary(library, version);
|
ScriptInfo *lib = ScriptObject::GetActiveInstance()->FindLibrary(library, version);
|
||||||
if (lib == NULL) {
|
if (lib == NULL) {
|
||||||
char error[1024];
|
char error[1024];
|
||||||
snprintf(error, sizeof(error), "couldn't find library '%s' with version %d", library, version);
|
snprintf(error, sizeof(error), "couldn't find library '%s' with version %d", library, version);
|
||||||
|
|
|
@ -43,6 +43,14 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual int GetSetting(const char *name) = 0;
|
virtual int GetSetting(const char *name) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find a library.
|
||||||
|
* @param library The library name to find.
|
||||||
|
* @param version The version the library should have.
|
||||||
|
* @return The library if found, NULL otherwise.
|
||||||
|
*/
|
||||||
|
virtual class ScriptInfo *FindLibrary(const char *library, int version) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A script in multiplayer waits for the server to handle his DoCommand.
|
* A script in multiplayer waits for the server to handle his DoCommand.
|
||||||
* It keeps waiting for this until this function is called.
|
* It keeps waiting for this until this function is called.
|
||||||
|
|
Loading…
Reference in New Issue