mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 06:15:04 +00:00
(svn r23357) -Codechange: move AIStorage to ScriptStorage
This commit is contained in:
parent
c2398c0fe1
commit
99cb93ef6f
@ -792,6 +792,7 @@
|
||||
<ClInclude Include="..\src\script\script_info.hpp" />
|
||||
<ClCompile Include="..\src\script\script_scanner.cpp" />
|
||||
<ClInclude Include="..\src\script\script_scanner.hpp" />
|
||||
<ClInclude Include="..\src\script\script_storage.hpp" />
|
||||
<ClCompile Include="..\src\script\squirrel.cpp" />
|
||||
<ClInclude Include="..\src\script\squirrel.hpp" />
|
||||
<ClInclude Include="..\src\script\squirrel_class.hpp" />
|
||||
@ -851,7 +852,6 @@
|
||||
<ClInclude Include="..\src\ai\ai_instance.hpp" />
|
||||
<ClCompile Include="..\src\ai\ai_scanner.cpp" />
|
||||
<ClInclude Include="..\src\ai\ai_scanner.hpp" />
|
||||
<ClInclude Include="..\src\ai\ai_storage.hpp" />
|
||||
<ClInclude Include="..\src\ai\api\ai_changelog.hpp" />
|
||||
<ClInclude Include="..\src\ai\api\ai_info_docs.hpp" />
|
||||
<ClInclude Include="..\src\script\api\script_accounting.hpp" />
|
||||
|
@ -1599,6 +1599,9 @@
|
||||
<ClInclude Include="..\src\script\script_scanner.hpp">
|
||||
<Filter>Script</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\script\script_storage.hpp">
|
||||
<Filter>Script</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="..\src\script\squirrel.cpp">
|
||||
<Filter>Script</Filter>
|
||||
</ClCompile>
|
||||
@ -1776,9 +1779,6 @@
|
||||
<ClInclude Include="..\src\ai\ai_scanner.hpp">
|
||||
<Filter>AI Core</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\ai\ai_storage.hpp">
|
||||
<Filter>AI Core</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\ai\api\ai_changelog.hpp">
|
||||
<Filter>AI API</Filter>
|
||||
</ClInclude>
|
||||
|
@ -2474,6 +2474,10 @@
|
||||
RelativePath=".\..\src\script\script_scanner.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\script\script_storage.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\script\squirrel.cpp"
|
||||
>
|
||||
@ -2722,10 +2726,6 @@
|
||||
RelativePath=".\..\src\ai\ai_scanner.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\ai\ai_storage.hpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="AI API"
|
||||
|
@ -2471,6 +2471,10 @@
|
||||
RelativePath=".\..\src\script\script_scanner.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\script\script_storage.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\script\squirrel.cpp"
|
||||
>
|
||||
@ -2719,10 +2723,6 @@
|
||||
RelativePath=".\..\src\ai\ai_scanner.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\ai\ai_storage.hpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="AI API"
|
||||
|
@ -557,6 +557,7 @@ script/script_info.cpp
|
||||
script/script_info.hpp
|
||||
script/script_scanner.cpp
|
||||
script/script_scanner.hpp
|
||||
script/script_storage.hpp
|
||||
script/squirrel.cpp
|
||||
script/squirrel.hpp
|
||||
script/squirrel_class.hpp
|
||||
@ -622,7 +623,6 @@ ai/ai_instance.cpp
|
||||
ai/ai_instance.hpp
|
||||
ai/ai_scanner.cpp
|
||||
ai/ai_scanner.hpp
|
||||
ai/ai_storage.hpp
|
||||
|
||||
# AI API
|
||||
ai/api/ai_changelog.hpp
|
||||
|
@ -17,10 +17,11 @@
|
||||
#include "../script/squirrel_class.hpp"
|
||||
|
||||
#include "ai_config.hpp"
|
||||
#include "ai_storage.hpp"
|
||||
#include "ai_instance.hpp"
|
||||
#include "ai_gui.hpp"
|
||||
|
||||
#include "../script/script_storage.hpp"
|
||||
#include "ai_instance.hpp"
|
||||
|
||||
/* Convert all AI related classes to Squirrel data.
|
||||
* Note: this line is a marker in squirrel_export.sh. Do not change! */
|
||||
#include "api/ai_accounting.hpp.sq"
|
||||
@ -82,7 +83,7 @@ static const int MAX_SL_OPS = 100000;
|
||||
/** The maximum number of operations for initial start of an AI. */
|
||||
static const int MAX_CONSTRUCTOR_OPS = 100000;
|
||||
|
||||
AIStorage::~AIStorage()
|
||||
ScriptStorage::~ScriptStorage()
|
||||
{
|
||||
/* Free our pointers */
|
||||
if (event_data != NULL) ScriptEventController::FreeEventPointer();
|
||||
@ -111,7 +112,7 @@ AIInstance::AIInstance() :
|
||||
suspend(0),
|
||||
callback(NULL)
|
||||
{
|
||||
this->storage = new AIStorage();
|
||||
this->storage = new ScriptStorage();
|
||||
this->engine = new Squirrel("AI");
|
||||
this->engine->SetPrintFunction(&PrintFunc);
|
||||
}
|
||||
@ -428,7 +429,7 @@ void AIInstance::CollectGarbage() const
|
||||
instance->engine->InsertResult(ScriptObject::GetNewGroupID());
|
||||
}
|
||||
|
||||
AIStorage *AIInstance::GetStorage()
|
||||
ScriptStorage *AIInstance::GetStorage()
|
||||
{
|
||||
return this->storage;
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ public:
|
||||
/**
|
||||
* Get the storage of this AI.
|
||||
*/
|
||||
class AIStorage *GetStorage();
|
||||
class ScriptStorage *GetStorage();
|
||||
|
||||
/**
|
||||
* Get the log pointer of this AI.
|
||||
@ -202,7 +202,7 @@ public:
|
||||
|
||||
private:
|
||||
class ScriptController *controller; ///< The AI main class.
|
||||
class AIStorage *storage; ///< Some global information for each running AI.
|
||||
class ScriptStorage *storage; ///< Some global information for each running AI.
|
||||
class Squirrel *engine; ///< A wrapper around the squirrel vm.
|
||||
SQObject *instance; ///< Squirrel-pointer to the AI main class.
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
class ScriptExecMode : public ScriptObject {
|
||||
private:
|
||||
AIModeProc *last_mode; ///< The previous mode we were in.
|
||||
ScriptModeProc *last_mode; ///< The previous mode we were in.
|
||||
ScriptObject *last_instance; ///< The previous instace of the mode.
|
||||
|
||||
protected:
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "../../network/network.h"
|
||||
#include "../../tunnelbridge.h"
|
||||
|
||||
#include "../../ai/ai_storage.hpp"
|
||||
#include "../script_storage.hpp"
|
||||
#include "../../ai/ai_instance.hpp"
|
||||
#include "script_error.hpp"
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
* Get the storage associated with the current AIInstance.
|
||||
* @return The storage.
|
||||
*/
|
||||
static AIStorage *GetStorage()
|
||||
static ScriptStorage *GetStorage()
|
||||
{
|
||||
return ScriptObject::GetActiveInstance()->GetStorage();
|
||||
}
|
||||
@ -60,13 +60,13 @@ ScriptObject::ActiveInstance::~ActiveInstance()
|
||||
return GetStorage()->delay;
|
||||
}
|
||||
|
||||
/* static */ void ScriptObject::SetDoCommandMode(AIModeProc *proc, ScriptObject *instance)
|
||||
/* static */ void ScriptObject::SetDoCommandMode(ScriptModeProc *proc, ScriptObject *instance)
|
||||
{
|
||||
GetStorage()->mode = proc;
|
||||
GetStorage()->mode_instance = instance;
|
||||
}
|
||||
|
||||
/* static */ AIModeProc *ScriptObject::GetDoCommandMode()
|
||||
/* static */ ScriptModeProc *ScriptObject::GetDoCommandMode()
|
||||
{
|
||||
return GetStorage()->mode;
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ typedef void (AISuspendCallbackProc)(class AIInstance *instance);
|
||||
/**
|
||||
* The callback function for Mode-classes.
|
||||
*/
|
||||
typedef bool (AIModeProc)();
|
||||
typedef bool (ScriptModeProc)();
|
||||
|
||||
/**
|
||||
* Uper-parent object of all API classes. You should never use this class in
|
||||
@ -122,12 +122,12 @@ protected:
|
||||
/**
|
||||
* Set the current mode of your AI to this proc.
|
||||
*/
|
||||
static void SetDoCommandMode(AIModeProc *proc, ScriptObject *instance);
|
||||
static void SetDoCommandMode(ScriptModeProc *proc, ScriptObject *instance);
|
||||
|
||||
/**
|
||||
* Get the current mode your AI is currently under.
|
||||
*/
|
||||
static AIModeProc *GetDoCommandMode();
|
||||
static ScriptModeProc *GetDoCommandMode();
|
||||
|
||||
/**
|
||||
* Get the instance of the current mode your AI is currently under.
|
||||
|
@ -25,7 +25,7 @@
|
||||
*/
|
||||
class ScriptTestMode : public ScriptObject {
|
||||
private:
|
||||
AIModeProc *last_mode; ///< The previous mode we were in.
|
||||
ScriptModeProc *last_mode; ///< The previous mode we were in.
|
||||
ScriptObject *last_instance; ///< The previous instace of the mode.
|
||||
|
||||
protected:
|
||||
|
@ -7,10 +7,10 @@
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/** @file ai_storage.hpp Defines AIStorage and includes all files required for it. */
|
||||
/** @file script_storage.hpp Defines ScriptStorage and includes all files required for it. */
|
||||
|
||||
#ifndef AI_STORAGE_HPP
|
||||
#define AI_STORAGE_HPP
|
||||
#ifndef SCRIPT_STORAGE_HPP
|
||||
#define SCRIPT_STORAGE_HPP
|
||||
|
||||
#include "../signs_func.h"
|
||||
#include "../vehicle_func.h"
|
||||
@ -23,21 +23,21 @@
|
||||
/**
|
||||
* The callback function for Mode-classes.
|
||||
*/
|
||||
typedef bool (AIModeProc)();
|
||||
typedef bool (ScriptModeProc)();
|
||||
|
||||
/**
|
||||
* The storage for each AI. It keeps track of important information.
|
||||
* The storage for each script. It keeps track of important information.
|
||||
*/
|
||||
class AIStorage {
|
||||
class ScriptStorage {
|
||||
friend class ScriptObject;
|
||||
private:
|
||||
AIModeProc *mode; ///< The current build mode we are int.
|
||||
ScriptModeProc *mode; ///< The current build mode we are int.
|
||||
class ScriptObject *mode_instance; ///< The instance belonging to the current build mode.
|
||||
|
||||
uint delay; ///< The ticks of delay each DoCommand has.
|
||||
bool allow_do_command; ///< Is the usage of DoCommands restricted?
|
||||
|
||||
CommandCost costs; ///< The costs the AI is tracking.
|
||||
CommandCost costs; ///< The costs the script is tracking.
|
||||
Money last_cost; ///< The last cost of the command.
|
||||
uint last_error; ///< The last error of the command.
|
||||
bool last_command_res; ///< The last result of the command.
|
||||
@ -56,7 +56,7 @@ private:
|
||||
void *log_data; ///< Pointer to the log data storage.
|
||||
|
||||
public:
|
||||
AIStorage() :
|
||||
ScriptStorage() :
|
||||
mode (NULL),
|
||||
mode_instance (NULL),
|
||||
delay (1),
|
||||
@ -76,7 +76,7 @@ public:
|
||||
log_data (NULL)
|
||||
{ }
|
||||
|
||||
~AIStorage();
|
||||
~ScriptStorage();
|
||||
};
|
||||
|
||||
#endif /* AI_STORAGE_HPP */
|
||||
#endif /* SCRIPT_STORAGE_HPP */
|
Loading…
Reference in New Issue
Block a user