(svn r12277) [NoAI] -Change: overlay GlobalPointer with local instance access and create sub-node to contain data
[NoAI] -Change: relay PrintFunc to redirect via overlay and supply AIController with Print, in order to establish bypass of the log created by the AI
[/STARTREK VOYAGER]
/* $Id$ */
/** @file squirrel.hpp declarations of the class for squirrel loader */
#ifndef AI_SQUIRREL_HPP
#define AI_SQUIRREL_HPP
class AIControllerSquirrel: public AIController {
private:
Squirrel *engine; ///< The Squirrel engine
HSQOBJECT SQ_instance; ///< The internal instance of squirrel
/**
* Registers all our classes, so it can be used from Squirrel.
*/
void RegisterClasses();
public:
static const char *GetClassName() { return "AIController"; }
AIControllerSquirrel(const char *script_dir, const char *class_name);
~AIControllerSquirrel();
/* virtual */ void Start();
/* virtual */ void Stop();
uint GetTick() { return AIController::GetTick(); }
void Sleep(uint ticks) { return AIController::Sleep(ticks); }
static void PrintFunc(bool error_msg, const char *message) { AIController::Print(error_msg, message); }
};
class FSquirrel: public AIFactory<FSquirrel> {
private:
Squirrel *engine; ///< The Squirrel engine
const char *current_script; ///< Temporary variable to know which script defines which class
/**
* The constructor for when a script makes an instance of the Factory class.
*/
static SQInteger FactoryConstructor(HSQUIRRELVM vm);
/**
* Scans a dir to see if there are dirs in it which have a file called 'main.nut'.
* If found it loads the script.
*/
void ScanDir(const char *dirname);
public:
~FSquirrel();
/* virtual */ const char *GetAuthor() { return "OpenTTD Dev Team"; }
/* virtual */ const char *GetName() { return "Squirrel"; }
/* virtual */ const char *GetDescription() { return "Squirrel Module for loading scripts"; }
/* virtual */ int GetVersion() { return 0; }
/* virtual */ const char *GetDate() { return ""; }
/* virtual */ AIController *CreateInstance() { return NULL; }
/* virtual */ bool AllowStartup() { return false; }
/* virtual */ void Initializer();
};
#endif /* AI_SQUIRREL_HPP */