mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-05 22:04:57 +00:00
(svn r17214) -Add [NoAI]: GetAPIVersion() as optional function in info.nut. Return "0.7" to get an api compatible (as much as possible) with the 0.7 api or "0.8" to get the latest api.
-Change [NoAI]: move all deprecated functions to a separate squirrel script that is only loaded if an AI requests an old API version.
This commit is contained in:
parent
58a0ff945c
commit
67106dc063
71
bin/ai/compat_0.7.nut
Normal file
71
bin/ai/compat_0.7.nut
Normal file
@ -0,0 +1,71 @@
|
||||
/* $Id$ */
|
||||
|
||||
AISign.GetMaxSignID <- function()
|
||||
{
|
||||
AILog.Warning("AISign::GetMaxSignID is deprecated and will be removed soon, please use AISignList instead.");
|
||||
local list = AISignList();
|
||||
local max_id = 0;
|
||||
foreach (id, d in list) {
|
||||
if (id > max_id) max_id = id;
|
||||
}
|
||||
return max_id;
|
||||
}
|
||||
|
||||
AITile.GetHeight <- function(tile)
|
||||
{
|
||||
AILog.Warning("AITile::GetHeight is deprecated and will be removed soon, please use GetMinHeight/GetMaxHeight/GetCornerHeight instead.");
|
||||
if (!AIMap.IsValidTile(tile)) return -1;
|
||||
|
||||
return AITile.GetCornerHeight(tile, AITile.CORNER_N);
|
||||
}
|
||||
|
||||
AIOrder.ChangeOrder <- function(vehicle_id, order_position, order_flags)
|
||||
{
|
||||
AILog.Warning("AIOrder::ChangeOrder is deprecated and will be removed soon, please use AIOrder::SetOrderFlags instead.")
|
||||
|
||||
return AIOrder.SetOrderFlags(vehicle_id, order_position, order_flags);
|
||||
}
|
||||
|
||||
AIWaypoint.WAYPOINT_INVALID <- 0xFFFF;
|
||||
|
||||
AISubsidy.SourceIsTown <- function(subsidy_id)
|
||||
{
|
||||
AILog.Warning("AISubsidy::SourceIsTown is deprecated and will be removed soon, please use AISubsidy::GetSourceType instead.");
|
||||
if (!AISubsidy.IsValidSubsidy(subsidy_id) || AISubsidy.IsAwarded(subsidy_id)) return false;
|
||||
|
||||
return AISubsidy.GetSourceType(subsidy_id) == AISubsidy.SPT_TOWN;
|
||||
}
|
||||
|
||||
AISubsidy.GetSource <- function(subsidy_id)
|
||||
{
|
||||
AILog.Warning("AISubsidy::GetSource is deprecated and will be removed soon, please use AISubsidy::GetSourceIndex instead.");
|
||||
if (!AISubsidy.IsValidSubsidy(subsidy_id)) return AIBaseStation.INVALID_STATION;
|
||||
|
||||
if (AISubsidy.IsAwarded(subsidy_id)) {
|
||||
AILog.Error("AISubsidy::GetSource returned INVALID_STATION due to internal changes in the Subsidy logic.");
|
||||
return AIBaseStation.INVALID_STATION;
|
||||
}
|
||||
|
||||
return AISubsidy.GetSourceIndex(subsidy_id);
|
||||
}
|
||||
|
||||
AISubsidy.DestinationIsTown <- function(subsidy_id)
|
||||
{
|
||||
AILog.Warning("AISubsidy::DestinationIsTown is deprecated and will be removed soon, please use AISubsidy::GetDestinationType instead.");
|
||||
if (!AISubsidy.IsValidSubsidy(subsidy_id) || AISubsidy.IsAwarded(subsidy_id)) return false;
|
||||
|
||||
return AISubsidy.GetDestinationType(subsidy_id) == AISubsidy.SPT_TOWN;
|
||||
}
|
||||
|
||||
AISubsidy.GetDestination <- function(subsidy_id)
|
||||
{
|
||||
AILog.Warning("AISubsidy::GetDestination is deprecated and will be removed soon, please use AISubsidy::GetDestinationIndex instead.");
|
||||
if (!AISubsidy.IsValidSubsidy(subsidy_id)) return AIBaseStation.INVALID_STATION;
|
||||
|
||||
if (AISubsidy.IsAwarded(subsidy_id)) {
|
||||
AILog.Error("AISubsidy::GetDestination returned INVALID_STATION due to internal changes in the Subsidy logic.");
|
||||
return AIBaseStation.INVALID_STATION;
|
||||
}
|
||||
|
||||
return AISubsidy.GetDestinationIndex(subsidy_id);
|
||||
}
|
1
bin/ai/compat_0.8.nut
Normal file
1
bin/ai/compat_0.8.nut
Normal file
@ -0,0 +1 @@
|
||||
/* $Id$ */
|
@ -1204,7 +1204,7 @@ function Regression::TileList()
|
||||
list.AddRectangle(34436, 256 * 2 + 34436 + 8);
|
||||
print(" Count(): " + list.Count());
|
||||
|
||||
list.Valuate(AITile.GetHeight);
|
||||
list.Valuate(AITile.GetCornerHeight, AITile.CORNER_N);
|
||||
print(" Height(): done");
|
||||
print(" Count(): " + list.Count());
|
||||
print(" ListDump:");
|
||||
|
@ -6,6 +6,7 @@ class Regression extends AIInfo {
|
||||
function GetShortName() { return "REGR"; }
|
||||
function GetDescription() { return "This runs regression-tests on all commands. On the same map the result should always be the same."; }
|
||||
function GetVersion() { return 1; }
|
||||
function GetAPIVersion() { return "0.8"; }
|
||||
function GetDate() { return "2007-03-18"; }
|
||||
function CreateInstance() { return "Regression"; }
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "ai_scanner.hpp"
|
||||
#include "../settings_type.h"
|
||||
#include "../openttd.h"
|
||||
#include "../debug.h"
|
||||
|
||||
AIConfigItem _start_date_config = {
|
||||
"start_date",
|
||||
@ -42,6 +43,11 @@ AILibrary::~AILibrary()
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool CheckAPIVersion(const char *api_version)
|
||||
{
|
||||
return strcmp(api_version, "0.7") == 0 || strcmp(api_version, "0.8") == 0;
|
||||
}
|
||||
|
||||
/* static */ SQInteger AIInfo::Constructor(HSQUIRRELVM vm)
|
||||
{
|
||||
/* Get the AIInfo */
|
||||
@ -72,6 +78,16 @@ AILibrary::~AILibrary()
|
||||
} else {
|
||||
info->use_as_random = true;
|
||||
}
|
||||
/* Try to get the API version the AI is written for. */
|
||||
if (info->engine->MethodExists(*info->SQ_instance, "GetAPIVersion")) {
|
||||
if (!info->engine->CallStringMethodStrdup(*info->SQ_instance, "GetAPIVersion", &info->api_version)) return SQ_ERROR;
|
||||
if (!CheckAPIVersion(info->api_version)) {
|
||||
DEBUG(ai, 1, "Loading info.nut from (%s.%d): GetAPIVersion returned invalid version", info->GetName(), info->GetVersion());
|
||||
return SQ_ERROR;
|
||||
}
|
||||
} else {
|
||||
info->api_version = strdup("0.7");
|
||||
}
|
||||
|
||||
/* Remove the link to the real instance, else it might get deleted by RegisterAI() */
|
||||
sq_setinstanceup(vm, 2, NULL);
|
||||
@ -86,6 +102,7 @@ AILibrary::~AILibrary()
|
||||
SQUserPointer instance;
|
||||
sq_getinstanceup(vm, 2, &instance, 0);
|
||||
AIInfo *info = (AIInfo *)instance;
|
||||
info->api_version = NULL;
|
||||
|
||||
SQInteger res = AIFileInfo::Constructor(vm, info);
|
||||
if (res != 0) return res;
|
||||
@ -116,6 +133,7 @@ AIInfo::~AIInfo()
|
||||
}
|
||||
}
|
||||
this->config_list.clear();
|
||||
free((void*)this->api_version);
|
||||
}
|
||||
|
||||
bool AIInfo::CanLoadFromVersion(int version) const
|
||||
|
@ -99,10 +99,16 @@ public:
|
||||
*/
|
||||
bool UseAsRandomAI() const { return this->use_as_random; }
|
||||
|
||||
/**
|
||||
* Get the API version this AI is written for.
|
||||
*/
|
||||
const char *GetAPIVersion() const { return this->api_version; }
|
||||
|
||||
private:
|
||||
AIConfigItemList config_list;
|
||||
int min_loadable_version;
|
||||
bool use_as_random;
|
||||
const char *api_version;
|
||||
};
|
||||
|
||||
class AILibrary : public AIFileInfo {
|
||||
|
@ -80,6 +80,8 @@
|
||||
|
||||
#undef DEFINE_SCRIPT_FILES
|
||||
|
||||
#include "../fileio_func.h"
|
||||
|
||||
AIStorage::~AIStorage()
|
||||
{
|
||||
/* Free our pointers */
|
||||
@ -121,6 +123,11 @@ AIInstance::AIInstance(AIInfo *info) :
|
||||
/* Register the API functions and classes */
|
||||
this->RegisterAPI();
|
||||
|
||||
if (!this->LoadCompatibilityScripts(info->GetAPIVersion())) {
|
||||
this->Died();
|
||||
return;
|
||||
}
|
||||
|
||||
/* Load and execute the script for this AI */
|
||||
const char *main_script = info->GetMainScript();
|
||||
if (strcmp(main_script, "%_dummy") == 0) {
|
||||
@ -239,6 +246,28 @@ void AIInstance::RegisterAPI()
|
||||
this->engine->SetGlobalPointer(this->engine);
|
||||
}
|
||||
|
||||
bool AIInstance::LoadCompatibilityScripts(const char *api_version)
|
||||
{
|
||||
char script_name[32];
|
||||
seprintf(script_name, lastof(script_name), "compat_%s.nut", api_version);
|
||||
char buf[MAX_PATH];
|
||||
Searchpath sp;
|
||||
FOR_ALL_SEARCHPATHS(sp) {
|
||||
FioAppendDirectory(buf, MAX_PATH, sp, AI_DIR);
|
||||
ttd_strlcat(buf, script_name, MAX_PATH);
|
||||
if (!FileExists(buf)) continue;
|
||||
|
||||
if (this->engine->LoadScript(buf)) return true;
|
||||
|
||||
AILog::Error("Failed to load API compatibility script");
|
||||
DEBUG(ai, 0, "Error compiling / running API compatibility script: %s", buf);
|
||||
return false;
|
||||
}
|
||||
|
||||
AILog::Warning("API compatibility script not found");
|
||||
return true;
|
||||
}
|
||||
|
||||
void AIInstance::Continue()
|
||||
{
|
||||
assert(this->suspend < 0);
|
||||
|
@ -130,6 +130,11 @@ private:
|
||||
*/
|
||||
void RegisterAPI();
|
||||
|
||||
/**
|
||||
* Load squirrel scipts to emulate an older API.
|
||||
*/
|
||||
bool LoadCompatibilityScripts(const char *api_version);
|
||||
|
||||
/**
|
||||
* Tell the AI it died.
|
||||
*/
|
||||
|
@ -23,7 +23,6 @@ public:
|
||||
STATION_NEW = 0xFFFD, //!< Build a new station
|
||||
STATION_JOIN_ADJACENT = 0xFFFE, //!< Join an neighbouring station if one exists
|
||||
STATION_INVALID = 0xFFFF, //!< Invalid station id.
|
||||
WAYPOINT_INVALID = 0xFFFF, //!< @deprecated Use STATION_INVALID instead.
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -24,7 +24,6 @@ void SQAIBaseStation_Register(Squirrel *engine) {
|
||||
SQAIBaseStation.DefSQConst(engine, AIBaseStation::STATION_NEW, "STATION_NEW");
|
||||
SQAIBaseStation.DefSQConst(engine, AIBaseStation::STATION_JOIN_ADJACENT, "STATION_JOIN_ADJACENT");
|
||||
SQAIBaseStation.DefSQConst(engine, AIBaseStation::STATION_INVALID, "STATION_INVALID");
|
||||
SQAIBaseStation.DefSQConst(engine, AIBaseStation::WAYPOINT_INVALID, "WAYPOINT_INVALID");
|
||||
|
||||
SQAIBaseStation.DefSQStaticMethod(engine, &AIBaseStation::IsValidBaseStation, "IsValidBaseStation", 2, ".i");
|
||||
SQAIBaseStation.DefSQStaticMethod(engine, &AIBaseStation::GetName, "GetName", 2, ".i");
|
||||
|
@ -476,12 +476,6 @@ static void _DoCommandReturnSetOrderFlags(class AIInstance *instance)
|
||||
return AIOrder::_SetOrderFlags();
|
||||
}
|
||||
|
||||
/* static */ bool AIOrder::ChangeOrder(VehicleID vehicle_id, OrderPosition order_position, AIOrder::AIOrderFlags order_flags)
|
||||
{
|
||||
AILog::Warning("AIOrder::ChangeOrder is deprecated and will be removed soon, please use AIOrder::SetOrderFlags instead.");
|
||||
return SetOrderFlags(vehicle_id, order_position, order_flags);
|
||||
}
|
||||
|
||||
/* static */ bool AIOrder::MoveOrder(VehicleID vehicle_id, OrderPosition order_position_move, OrderPosition order_position_target)
|
||||
{
|
||||
order_position_move = AIOrder::ResolveOrderPosition(vehicle_id, order_position_move);
|
||||
|
@ -403,11 +403,6 @@ public:
|
||||
*/
|
||||
static bool SetOrderFlags(VehicleID vehicle_id, OrderPosition order_position, AIOrderFlags order_flags);
|
||||
|
||||
/**
|
||||
* @Deprecated, use SetOrderFlags instead.
|
||||
*/
|
||||
static bool ChangeOrder(VehicleID vehicle_id, OrderPosition order_position, AIOrderFlags order_flags);
|
||||
|
||||
/**
|
||||
* Move an order inside the orderlist
|
||||
* @param vehicle_id The vehicle to move the orders.
|
||||
|
@ -99,7 +99,6 @@ void SQAIOrder_Register(Squirrel *engine) {
|
||||
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::InsertConditionalOrder, "InsertConditionalOrder", 4, ".iii");
|
||||
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::RemoveOrder, "RemoveOrder", 3, ".ii");
|
||||
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::SetOrderFlags, "SetOrderFlags", 4, ".iii");
|
||||
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::ChangeOrder, "ChangeOrder", 4, ".iii");
|
||||
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::MoveOrder, "MoveOrder", 4, ".iii");
|
||||
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::SkipToOrder, "SkipToOrder", 3, ".ii");
|
||||
SQAIOrder.DefSQStaticMethod(engine, &AIOrder::CopyOrders, "CopyOrders", 3, ".ii");
|
||||
|
@ -14,12 +14,6 @@
|
||||
#include "../../tile_map.h"
|
||||
#include "../../company_func.h"
|
||||
|
||||
/* static */ SignID AISign::GetMaxSignID()
|
||||
{
|
||||
AILog::Warning("AISign::GetMaxSignID is deprecated and will be removed soon, please use AISignList instead.");
|
||||
return (SignID)::Sign::GetPoolSize();
|
||||
}
|
||||
|
||||
/* static */ bool AISign::IsValidSign(SignID sign_id)
|
||||
{
|
||||
const Sign *si = ::Sign::GetIfValid(sign_id);
|
||||
|
@ -28,14 +28,6 @@ public:
|
||||
ERR_SIGN_TOO_MANY_SIGNS, // [STR_ERROR_TOO_MANY_SIGNS]
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the maximum sign index; there are no valid signs with a higher index.
|
||||
* @deprecated This function is deprecated and might be removed in future versions of the API. Use AISignList() instead.
|
||||
* @return The maximum sign index.
|
||||
* @post Return value is always non-negative.
|
||||
*/
|
||||
static SignID GetMaxSignID();
|
||||
|
||||
/**
|
||||
* Checks whether the given sign index is valid.
|
||||
* @param sign_id The index to check.
|
||||
|
@ -28,13 +28,12 @@ void SQAISign_Register(Squirrel *engine) {
|
||||
|
||||
AIError::RegisterErrorMapString(AISign::ERR_SIGN_TOO_MANY_SIGNS, "ERR_SIGN_TOO_MANY_SIGNS");
|
||||
|
||||
SQAISign.DefSQStaticMethod(engine, &AISign::GetMaxSignID, "GetMaxSignID", 1, ".");
|
||||
SQAISign.DefSQStaticMethod(engine, &AISign::IsValidSign, "IsValidSign", 2, ".i");
|
||||
SQAISign.DefSQStaticMethod(engine, &AISign::SetName, "SetName", 3, ".is");
|
||||
SQAISign.DefSQStaticMethod(engine, &AISign::GetName, "GetName", 2, ".i");
|
||||
SQAISign.DefSQStaticMethod(engine, &AISign::GetLocation, "GetLocation", 2, ".i");
|
||||
SQAISign.DefSQStaticMethod(engine, &AISign::BuildSign, "BuildSign", 3, ".is");
|
||||
SQAISign.DefSQStaticMethod(engine, &AISign::RemoveSign, "RemoveSign", 2, ".i");
|
||||
SQAISign.DefSQStaticMethod(engine, &AISign::IsValidSign, "IsValidSign", 2, ".i");
|
||||
SQAISign.DefSQStaticMethod(engine, &AISign::SetName, "SetName", 3, ".is");
|
||||
SQAISign.DefSQStaticMethod(engine, &AISign::GetName, "GetName", 2, ".i");
|
||||
SQAISign.DefSQStaticMethod(engine, &AISign::GetLocation, "GetLocation", 2, ".i");
|
||||
SQAISign.DefSQStaticMethod(engine, &AISign::BuildSign, "BuildSign", 3, ".is");
|
||||
SQAISign.DefSQStaticMethod(engine, &AISign::RemoveSign, "RemoveSign", 2, ".i");
|
||||
|
||||
SQAISign.PostRegister(engine);
|
||||
}
|
||||
|
@ -50,27 +50,6 @@
|
||||
return ::Subsidy::Get(subsidy_id)->cargo_type;
|
||||
}
|
||||
|
||||
/* static */ bool AISubsidy::SourceIsTown(SubsidyID subsidy_id)
|
||||
{
|
||||
AILog::Warning("AISubsidy::SourceIsTown is deprecated and will be removed soon, please use AISubsidy::GetSourceType instead.");
|
||||
if (!IsValidSubsidy(subsidy_id) || IsAwarded(subsidy_id)) return false;
|
||||
|
||||
return ::Subsidy::Get(subsidy_id)->src_type == ST_TOWN;
|
||||
}
|
||||
|
||||
/* static */ int32 AISubsidy::GetSource(SubsidyID subsidy_id)
|
||||
{
|
||||
AILog::Warning("AISubsidy::GetSource is deprecated and will be removed soon, please use AISubsidy::GetSourceIndex instead.");
|
||||
if (!IsValidSubsidy(subsidy_id)) return INVALID_STATION;
|
||||
|
||||
if (IsAwarded(subsidy_id)) {
|
||||
AILog::Error("AISubsidy::GetSource returned INVALID_STATION due to internal changes in the Subsidy logic.");
|
||||
return INVALID_STATION;
|
||||
}
|
||||
|
||||
return ::Subsidy::Get(subsidy_id)->src;
|
||||
}
|
||||
|
||||
/* static */ AISubsidy::SubsidyParticipantType AISubsidy::GetSourceType(SubsidyID subsidy_id)
|
||||
{
|
||||
if (!IsValidSubsidy(subsidy_id)) return SPT_INVALID;
|
||||
@ -85,27 +64,6 @@
|
||||
return ::Subsidy::Get(subsidy_id)->src;
|
||||
}
|
||||
|
||||
/* static */ bool AISubsidy::DestinationIsTown(SubsidyID subsidy_id)
|
||||
{
|
||||
AILog::Warning("AISubsidy::DestinationIsTown is deprecated and will be removed soon, please use AISubsidy::GetDestinationType instead.");
|
||||
if (!IsValidSubsidy(subsidy_id) || IsAwarded(subsidy_id)) return false;
|
||||
|
||||
return ::Subsidy::Get(subsidy_id)->dst_type == ST_TOWN;
|
||||
}
|
||||
|
||||
/* static */ int32 AISubsidy::GetDestination(SubsidyID subsidy_id)
|
||||
{
|
||||
AILog::Warning("AISubsidy::GetDestination is deprecated and will be removed soon, please use AISubsidy::GetDestinationIndex instead.");
|
||||
if (!IsValidSubsidy(subsidy_id)) return INVALID_STATION;
|
||||
|
||||
if (IsAwarded(subsidy_id)) {
|
||||
AILog::Error("AISubsidy::GetDestination returned INVALID_STATION due to internal changes in the Subsidy logic.");
|
||||
return INVALID_STATION;
|
||||
}
|
||||
|
||||
return ::Subsidy::Get(subsidy_id)->dst;
|
||||
}
|
||||
|
||||
/* static */ AISubsidy::SubsidyParticipantType AISubsidy::GetDestinationType(SubsidyID subsidy_id)
|
||||
{
|
||||
if (!IsValidSubsidy(subsidy_id)) return SPT_INVALID;
|
||||
|
@ -69,27 +69,6 @@ public:
|
||||
*/
|
||||
static CargoID GetCargoType(SubsidyID subsidy_id);
|
||||
|
||||
/**
|
||||
* Is the source of the subsidy a town or an industry.
|
||||
* @param subsidy_id The SubsidyID to check.
|
||||
* @pre IsValidSubsidy(subsidy_id) && !IsAwarded(subsidy_id).
|
||||
* @return True if the source is a town, false if it is an industry.
|
||||
* @deprecated Use GetSourceType() instead.
|
||||
*/
|
||||
static bool SourceIsTown(SubsidyID subsidy_id);
|
||||
|
||||
/**
|
||||
* Return the source TownID/IndustryID/StationID the subsidy is for.
|
||||
* \li IsAwarded(subsidy_id) -> return INVALID_STATION.
|
||||
* \li !IsAwarded(subsidy_id) && SourceIsTown(subsidy_id) -> return the TownID.
|
||||
* \li !IsAwarded(subsidy_id) && !SourceIsTown(subsidy_id) -> return the IndustryID.
|
||||
* @param subsidy_id The SubsidyID to check.
|
||||
* @pre IsValidSubsidy(subsidy_id).
|
||||
* @return One of TownID/IndustryID/INVALID_STATION.
|
||||
* @deprecated Use GetSourceIndex() instead.
|
||||
*/
|
||||
static int32 GetSource(SubsidyID subsidy_id);
|
||||
|
||||
/**
|
||||
* Returns the type of source of subsidy.
|
||||
* @param subsidy_id The SubsidyID to check.
|
||||
@ -108,27 +87,6 @@ public:
|
||||
*/
|
||||
static int32 GetSourceIndex(SubsidyID subsidy_id);
|
||||
|
||||
/**
|
||||
* Is the destination of the subsidy a town or an industry.
|
||||
* @param subsidy_id The SubsidyID to check.
|
||||
* @pre IsValidSubsidy(subsidy_id) && !IsAwarded(subsidy_id).
|
||||
* @return True if the destination is a town, false if it is an industry.
|
||||
* @deprecated Use GetDestinationType() instead.
|
||||
*/
|
||||
static bool DestinationIsTown(SubsidyID subsidy_id);
|
||||
|
||||
/**
|
||||
* Return the destination TownID/IndustryID/StationID the subsidy is for.
|
||||
* \li IsAwarded(subsidy_id) -> return INVALID_STATION.
|
||||
* \li !IsAwarded(subsidy_id) && DestinationIsTown(subsidy_id) -> return the TownID.
|
||||
* \li !IsAwarded(subsidy_id) && !DestinationIsTown(subsidy_id) -> return the IndustryID.
|
||||
* @param subsidy_id the SubsidyID to check.
|
||||
* @pre IsValidSubsidy(subsidy_id).
|
||||
* @return One of TownID/IndustryID/INVALID_STATION.
|
||||
* @deprecated Use GetDestinationIndex() instead.
|
||||
*/
|
||||
static int32 GetDestination(SubsidyID subsidy_id);
|
||||
|
||||
/**
|
||||
* Returns the type of destination of subsidy.
|
||||
* @param subsidy_id The SubsidyID to check.
|
||||
|
@ -30,12 +30,8 @@ void SQAISubsidy_Register(Squirrel *engine) {
|
||||
SQAISubsidy.DefSQStaticMethod(engine, &AISubsidy::GetAwardedTo, "GetAwardedTo", 2, ".i");
|
||||
SQAISubsidy.DefSQStaticMethod(engine, &AISubsidy::GetExpireDate, "GetExpireDate", 2, ".i");
|
||||
SQAISubsidy.DefSQStaticMethod(engine, &AISubsidy::GetCargoType, "GetCargoType", 2, ".i");
|
||||
SQAISubsidy.DefSQStaticMethod(engine, &AISubsidy::SourceIsTown, "SourceIsTown", 2, ".i");
|
||||
SQAISubsidy.DefSQStaticMethod(engine, &AISubsidy::GetSource, "GetSource", 2, ".i");
|
||||
SQAISubsidy.DefSQStaticMethod(engine, &AISubsidy::GetSourceType, "GetSourceType", 2, ".i");
|
||||
SQAISubsidy.DefSQStaticMethod(engine, &AISubsidy::GetSourceIndex, "GetSourceIndex", 2, ".i");
|
||||
SQAISubsidy.DefSQStaticMethod(engine, &AISubsidy::DestinationIsTown, "DestinationIsTown", 2, ".i");
|
||||
SQAISubsidy.DefSQStaticMethod(engine, &AISubsidy::GetDestination, "GetDestination", 2, ".i");
|
||||
SQAISubsidy.DefSQStaticMethod(engine, &AISubsidy::GetDestinationType, "GetDestinationType", 2, ".i");
|
||||
SQAISubsidy.DefSQStaticMethod(engine, &AISubsidy::GetDestinationIndex, "GetDestinationIndex", 2, ".i");
|
||||
|
||||
|
@ -130,14 +130,6 @@
|
||||
return (Slope)::ComplementSlope((::Slope)slope);
|
||||
}
|
||||
|
||||
/* static */ int32 AITile::GetHeight(TileIndex tile)
|
||||
{
|
||||
AILog::Warning("AITile::GetHeight is deprecated and will be removed soon, please use GetMinHeight/GetMaxHeight/GetCornerHeight instead.");
|
||||
if (!::IsValidTile(tile)) return -1;
|
||||
|
||||
return ::TileHeight(tile);
|
||||
}
|
||||
|
||||
/* static */ int32 AITile::GetMinHeight(TileIndex tile)
|
||||
{
|
||||
if (!::IsValidTile(tile)) return -1;
|
||||
|
@ -232,16 +232,6 @@ public:
|
||||
*/
|
||||
static Slope GetComplementSlope(Slope slope);
|
||||
|
||||
/**
|
||||
* Get the height of the north corner of a tile.
|
||||
* The returned height is the height of the bare tile. A possible foundation on the tile does not influence this height.
|
||||
* @deprecated This function is deprecated and might be removed in future versions of the API. Use GetMinHeight(), GetMaxHeight() or GetCornerHeight() instead.
|
||||
* @param tile The tile to check on.
|
||||
* @pre AIMap::IsValidTile(tile).
|
||||
* @return The height of the north corner of the tile, ranging from 0 to 15.
|
||||
*/
|
||||
static int32 GetHeight(TileIndex tile);
|
||||
|
||||
/**
|
||||
* Get the minimal height on a tile.
|
||||
* The returned height is the height of the bare tile. A possible foundation on the tile does not influence this height.
|
||||
|
@ -67,7 +67,7 @@ void SQAITile_Register(Squirrel *engine) {
|
||||
|
||||
AIError::RegisterErrorMap(STR_ERROR_ALREADY_AT_SEA_LEVEL, AITile::ERR_TILE_TOO_HIGH);
|
||||
AIError::RegisterErrorMap(STR_ERROR_ALREADY_AT_SEA_LEVEL, AITile::ERR_TILE_TOO_LOW);
|
||||
AIError::RegisterErrorMap(STR_ERROR_ALREADY_LEVELLED, AITile::ERR_AREA_ALREADY_FLAT);
|
||||
AIError::RegisterErrorMap(STR_ERROR_ALREADY_LEVELLED, AITile::ERR_AREA_ALREADY_FLAT);
|
||||
AIError::RegisterErrorMap(STR_ERROR_EXCAVATION_WOULD_DAMAGE, AITile::ERR_EXCAVATION_WOULD_DAMAGE);
|
||||
|
||||
AIError::RegisterErrorMapString(AITile::ERR_TILE_TOO_HIGH, "ERR_TILE_TOO_HIGH");
|
||||
@ -90,7 +90,6 @@ void SQAITile_Register(Squirrel *engine) {
|
||||
SQAITile.DefSQStaticMethod(engine, &AITile::IsDesertTile, "IsDesertTile", 2, ".i");
|
||||
SQAITile.DefSQStaticMethod(engine, &AITile::GetSlope, "GetSlope", 2, ".i");
|
||||
SQAITile.DefSQStaticMethod(engine, &AITile::GetComplementSlope, "GetComplementSlope", 2, ".i");
|
||||
SQAITile.DefSQStaticMethod(engine, &AITile::GetHeight, "GetHeight", 2, ".i");
|
||||
SQAITile.DefSQStaticMethod(engine, &AITile::GetMinHeight, "GetMinHeight", 2, ".i");
|
||||
SQAITile.DefSQStaticMethod(engine, &AITile::GetMaxHeight, "GetMaxHeight", 2, ".i");
|
||||
SQAITile.DefSQStaticMethod(engine, &AITile::GetCornerHeight, "GetCornerHeight", 3, ".ii");
|
||||
|
Loading…
Reference in New Issue
Block a user