diff options
Diffstat (limited to 'src/ai/api')
-rw-r--r-- | src/ai/api/ai_changelog.hpp | 1 | ||||
-rw-r--r-- | src/ai/api/ai_controller.cpp | 5 | ||||
-rw-r--r-- | src/ai/api/ai_controller.hpp | 10 | ||||
-rw-r--r-- | src/ai/api/ai_controller.hpp.sq | 13 |
4 files changed, 23 insertions, 6 deletions
diff --git a/src/ai/api/ai_changelog.hpp b/src/ai/api/ai_changelog.hpp index 67875146e..30c524ffa 100644 --- a/src/ai/api/ai_changelog.hpp +++ b/src/ai/api/ai_changelog.hpp @@ -26,6 +26,7 @@ * \li AICompany::GetQuarterlyCargoDelivered * \li AICompany::GetQuarterlyPerformanceRating * \li AICompany::GetQuarterlyCompanyValue + * \li AIController::GetOpsTillSuspend * \li AITown::GetTownAuthority * \li AIVehicle::ERR_VEHICLE_TOO_LONG in case vehicle length limit is reached * diff --git a/src/ai/api/ai_controller.cpp b/src/ai/api/ai_controller.cpp index 9a2c552c0..c6130303d 100644 --- a/src/ai/api/ai_controller.cpp +++ b/src/ai/api/ai_controller.cpp @@ -66,6 +66,11 @@ AIController::~AIController() return ::Company::Get(_current_company)->ai_instance->GetController()->ticks; } +/* static */ int AIController::GetOpsTillSuspend() +{ + return ::Company::Get(_current_company)->ai_instance->GetOpsTillSuspend(); +} + /* static */ int AIController::GetSetting(const char *name) { return AIConfig::GetConfig(_current_company)->GetSetting(name); diff --git a/src/ai/api/ai_controller.hpp b/src/ai/api/ai_controller.hpp index 2ab7c245b..ce74d39c9 100644 --- a/src/ai/api/ai_controller.hpp +++ b/src/ai/api/ai_controller.hpp @@ -52,6 +52,16 @@ public: static uint GetTick(); /** + * Get the number of operations the AI may still execute this tick. + * @return The amount of operations left to execute. + * @note This number can go negative when certain uninteruptable + * operations are executed. The amount of operations that you go + * over the limit will be deducted from the next tick you would + * be allowed to run. + */ + static int GetOpsTillSuspend(); + + /** * Get the value of one of your settings you set via info.nut. * @param name The name of the setting. * @return the value for the setting, or -1 if the setting is not known. diff --git a/src/ai/api/ai_controller.hpp.sq b/src/ai/api/ai_controller.hpp.sq index ec8ddca83..fdfb47788 100644 --- a/src/ai/api/ai_controller.hpp.sq +++ b/src/ai/api/ai_controller.hpp.sq @@ -13,11 +13,12 @@ void SQAIController_Register(Squirrel *engine) { DefSQClass <AIController> SQAIController("AIController"); SQAIController.PreRegister(engine); - SQAIController.DefSQStaticMethod(engine, &AIController::GetTick, "GetTick", 1, "."); - SQAIController.DefSQStaticMethod(engine, &AIController::SetCommandDelay, "SetCommandDelay", 2, ".i"); - SQAIController.DefSQStaticMethod(engine, &AIController::Sleep, "Sleep", 2, ".i"); - SQAIController.DefSQStaticMethod(engine, &AIController::GetSetting, "GetSetting", 2, ".s"); - SQAIController.DefSQStaticMethod(engine, &AIController::GetVersion, "GetVersion", 1, "."); - SQAIController.DefSQStaticMethod(engine, &AIController::Print, "Print", 3, ".bs"); + SQAIController.DefSQStaticMethod(engine, &AIController::GetTick, "GetTick", 1, "."); + SQAIController.DefSQStaticMethod(engine, &AIController::GetOpsTillSuspend, "GetOpsTillSuspend", 1, "."); + SQAIController.DefSQStaticMethod(engine, &AIController::SetCommandDelay, "SetCommandDelay", 2, ".i"); + SQAIController.DefSQStaticMethod(engine, &AIController::Sleep, "Sleep", 2, ".i"); + SQAIController.DefSQStaticMethod(engine, &AIController::GetSetting, "GetSetting", 2, ".s"); + SQAIController.DefSQStaticMethod(engine, &AIController::GetVersion, "GetVersion", 1, "."); + SQAIController.DefSQStaticMethod(engine, &AIController::Print, "Print", 3, ".bs"); SQAIController.PostRegister(engine); } |