summaryrefslogtreecommitdiff
path: root/src/script/api/script_tile.cpp
diff options
context:
space:
mode:
authortruebrain <truebrain@openttd.org>2011-11-29 23:15:35 +0000
committertruebrain <truebrain@openttd.org>2011-11-29 23:15:35 +0000
commit98103121d4f2ed1f1581919b7b1f343ccd410c12 (patch)
tree1e760dd6517a6b0f9fb669ec277139a8e3f9a4a3 /src/script/api/script_tile.cpp
parentafdb67a3534f85b4efbd3327ece8137211042d7b (diff)
downloadopenttd-98103121d4f2ed1f1581919b7b1f343ccd410c12.tar.xz
(svn r23355) -Codechange: rename all AI* to Script* (Rubidium)
Diffstat (limited to 'src/script/api/script_tile.cpp')
-rw-r--r--src/script/api/script_tile.cpp106
1 files changed, 53 insertions, 53 deletions
diff --git a/src/script/api/script_tile.cpp b/src/script/api/script_tile.cpp
index c395aa516..b898b9c15 100644
--- a/src/script/api/script_tile.cpp
+++ b/src/script/api/script_tile.cpp
@@ -7,7 +7,7 @@
* 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 script_tile.cpp Implementation of AITile. */
+/** @file script_tile.cpp Implementation of ScriptTile. */
#include "../../stdafx.h"
#include "script_tile.hpp"
@@ -23,7 +23,7 @@
#include "../../landscape.h"
#include "../../economy_func.h"
-/* static */ bool AITile::IsBuildable(TileIndex tile)
+/* static */ bool ScriptTile::IsBuildable(TileIndex tile)
{
if (!::IsValidTile(tile)) return false;
@@ -44,30 +44,30 @@
}
}
-/* static */ bool AITile::IsBuildableRectangle(TileIndex tile, uint width, uint height)
+/* static */ bool ScriptTile::IsBuildableRectangle(TileIndex tile, uint width, uint height)
{
uint tx, ty;
- tx = AIMap::GetTileX(tile);
- ty = AIMap::GetTileY(tile);
+ tx = ScriptMap::GetTileX(tile);
+ ty = ScriptMap::GetTileY(tile);
for (uint x = tx; x < width + tx; x++) {
for (uint y = ty; y < height + ty; y++) {
- if (!IsBuildable(AIMap::GetTileIndex(x, y))) return false;
+ if (!IsBuildable(ScriptMap::GetTileIndex(x, y))) return false;
}
}
return true;
}
-/* static */ bool AITile::IsWaterTile(TileIndex tile)
+/* static */ bool ScriptTile::IsWaterTile(TileIndex tile)
{
if (!::IsValidTile(tile)) return false;
return ::IsTileType(tile, MP_WATER) && !::IsCoast(tile);
}
-/* static */ bool AITile::IsCoastTile(TileIndex tile)
+/* static */ bool ScriptTile::IsCoastTile(TileIndex tile)
{
if (!::IsValidTile(tile)) return false;
@@ -75,98 +75,98 @@
(::IsTileType(tile, MP_TREES) && ::GetTreeGround(tile) == TREE_GROUND_SHORE);
}
-/* static */ bool AITile::IsStationTile(TileIndex tile)
+/* static */ bool ScriptTile::IsStationTile(TileIndex tile)
{
if (!::IsValidTile(tile)) return false;
return ::IsTileType(tile, MP_STATION);
}
-/* static */ bool AITile::IsSteepSlope(Slope slope)
+/* static */ bool ScriptTile::IsSteepSlope(Slope slope)
{
if ((slope & ~(SLOPE_ELEVATED | SLOPE_STEEP | SLOPE_HALFTILE_MASK)) != 0) return false;
return ::IsSteepSlope((::Slope)slope);
}
-/* static */ bool AITile::IsHalftileSlope(Slope slope)
+/* static */ bool ScriptTile::IsHalftileSlope(Slope slope)
{
if ((slope & ~(SLOPE_ELEVATED | SLOPE_STEEP | SLOPE_HALFTILE_MASK)) != 0) return false;
return ::IsHalftileSlope((::Slope)slope);
}
-/* static */ bool AITile::HasTreeOnTile(TileIndex tile)
+/* static */ bool ScriptTile::HasTreeOnTile(TileIndex tile)
{
if (!::IsValidTile(tile)) return false;
return ::IsTileType(tile, MP_TREES);
}
-/* static */ bool AITile::IsFarmTile(TileIndex tile)
+/* static */ bool ScriptTile::IsFarmTile(TileIndex tile)
{
if (!::IsValidTile(tile)) return false;
return (::IsTileType(tile, MP_CLEAR) && ::IsClearGround(tile, CLEAR_FIELDS));
}
-/* static */ bool AITile::IsRockTile(TileIndex tile)
+/* static */ bool ScriptTile::IsRockTile(TileIndex tile)
{
if (!::IsValidTile(tile)) return false;
return (::IsTileType(tile, MP_CLEAR) && ::GetRawClearGround(tile) == ::CLEAR_ROCKS);
}
-/* static */ bool AITile::IsRoughTile(TileIndex tile)
+/* static */ bool ScriptTile::IsRoughTile(TileIndex tile)
{
if (!::IsValidTile(tile)) return false;
return (::IsTileType(tile, MP_CLEAR) && ::GetRawClearGround(tile) == ::CLEAR_ROUGH);
}
-/* static */ bool AITile::IsSnowTile(TileIndex tile)
+/* static */ bool ScriptTile::IsSnowTile(TileIndex tile)
{
if (!::IsValidTile(tile)) return false;
return (::IsTileType(tile, MP_CLEAR) && ::IsSnowTile(tile));
}
-/* static */ bool AITile::IsDesertTile(TileIndex tile)
+/* static */ bool ScriptTile::IsDesertTile(TileIndex tile)
{
if (!::IsValidTile(tile)) return false;
return (::IsTileType(tile, MP_CLEAR) && ::IsClearGround(tile, CLEAR_DESERT));
}
-/* static */ AITile::Slope AITile::GetSlope(TileIndex tile)
+/* static */ ScriptTile::Slope ScriptTile::GetSlope(TileIndex tile)
{
if (!::IsValidTile(tile)) return SLOPE_INVALID;
return (Slope)::GetTileSlope(tile);
}
-/* static */ AITile::Slope AITile::GetComplementSlope(Slope slope)
+/* static */ ScriptTile::Slope ScriptTile::GetComplementSlope(Slope slope)
{
if ((slope & ~SLOPE_ELEVATED) != 0) return SLOPE_INVALID;
return (Slope)::ComplementSlope((::Slope)slope);
}
-/* static */ int32 AITile::GetMinHeight(TileIndex tile)
+/* static */ int32 ScriptTile::GetMinHeight(TileIndex tile)
{
if (!::IsValidTile(tile)) return -1;
return ::GetTileZ(tile);
}
-/* static */ int32 AITile::GetMaxHeight(TileIndex tile)
+/* static */ int32 ScriptTile::GetMaxHeight(TileIndex tile)
{
if (!::IsValidTile(tile)) return -1;
return ::GetTileMaxZ(tile);
}
-/* static */ int32 AITile::GetCornerHeight(TileIndex tile, Corner corner)
+/* static */ int32 ScriptTile::GetCornerHeight(TileIndex tile, Corner corner)
{
if (!::IsValidTile(tile) || !::IsValidCorner((::Corner)corner)) return -1;
@@ -175,114 +175,114 @@
return (z + ::GetSlopeZInCorner(slope, (::Corner)corner));
}
-/* static */ AICompany::CompanyID AITile::GetOwner(TileIndex tile)
+/* static */ ScriptCompany::CompanyID ScriptTile::GetOwner(TileIndex tile)
{
- if (!::IsValidTile(tile)) return AICompany::COMPANY_INVALID;
- if (::IsTileType(tile, MP_HOUSE)) return AICompany::COMPANY_INVALID;
- if (::IsTileType(tile, MP_INDUSTRY)) return AICompany::COMPANY_INVALID;
+ if (!::IsValidTile(tile)) return ScriptCompany::COMPANY_INVALID;
+ if (::IsTileType(tile, MP_HOUSE)) return ScriptCompany::COMPANY_INVALID;
+ if (::IsTileType(tile, MP_INDUSTRY)) return ScriptCompany::COMPANY_INVALID;
- return AICompany::ResolveCompanyID((AICompany::CompanyID)(byte)::GetTileOwner(tile));
+ return ScriptCompany::ResolveCompanyID((ScriptCompany::CompanyID)(byte)::GetTileOwner(tile));
}
-/* static */ bool AITile::HasTransportType(TileIndex tile, TransportType transport_type)
+/* static */ bool ScriptTile::HasTransportType(TileIndex tile, TransportType transport_type)
{
if (!::IsValidTile(tile)) return false;
return ::TrackStatusToTrackdirBits(::GetTileTrackStatus(tile, (::TransportType)transport_type, UINT32_MAX)) != TRACKDIR_BIT_NONE;
}
-/* static */ int32 AITile::GetCargoAcceptance(TileIndex tile, CargoID cargo_type, int width, int height, int radius)
+/* static */ int32 ScriptTile::GetCargoAcceptance(TileIndex tile, CargoID cargo_type, int width, int height, int radius)
{
- if (!::IsValidTile(tile) || width <= 0 || height <= 0 || radius < 0 || !AICargo::IsValidCargo(cargo_type)) return -1;
+ if (!::IsValidTile(tile) || width <= 0 || height <= 0 || radius < 0 || !ScriptCargo::IsValidCargo(cargo_type)) return -1;
CargoArray acceptance = ::GetAcceptanceAroundTiles(tile, width, height, _settings_game.station.modified_catchment ? radius : (int)CA_UNMODIFIED);
return acceptance[cargo_type];
}
-/* static */ int32 AITile::GetCargoProduction(TileIndex tile, CargoID cargo_type, int width, int height, int radius)
+/* static */ int32 ScriptTile::GetCargoProduction(TileIndex tile, CargoID cargo_type, int width, int height, int radius)
{
- if (!::IsValidTile(tile) || width <= 0 || height <= 0 || radius < 0 || !AICargo::IsValidCargo(cargo_type)) return -1;
+ if (!::IsValidTile(tile) || width <= 0 || height <= 0 || radius < 0 || !ScriptCargo::IsValidCargo(cargo_type)) return -1;
CargoArray produced = ::GetProductionAroundTiles(tile, width, height, _settings_game.station.modified_catchment ? radius : (int)CA_UNMODIFIED);
return produced[cargo_type];
}
-/* static */ int32 AITile::GetDistanceManhattanToTile(TileIndex tile_from, TileIndex tile_to)
+/* static */ int32 ScriptTile::GetDistanceManhattanToTile(TileIndex tile_from, TileIndex tile_to)
{
- return AIMap::DistanceManhattan(tile_from, tile_to);
+ return ScriptMap::DistanceManhattan(tile_from, tile_to);
}
-/* static */ int32 AITile::GetDistanceSquareToTile(TileIndex tile_from, TileIndex tile_to)
+/* static */ int32 ScriptTile::GetDistanceSquareToTile(TileIndex tile_from, TileIndex tile_to)
{
- return AIMap::DistanceSquare(tile_from, tile_to);
+ return ScriptMap::DistanceSquare(tile_from, tile_to);
}
-/* static */ bool AITile::RaiseTile(TileIndex tile, int32 slope)
+/* static */ bool ScriptTile::RaiseTile(TileIndex tile, int32 slope)
{
EnforcePrecondition(false, tile < ::MapSize());
- return AIObject::DoCommand(tile, slope, 1, CMD_TERRAFORM_LAND);
+ return ScriptObject::DoCommand(tile, slope, 1, CMD_TERRAFORM_LAND);
}
-/* static */ bool AITile::LowerTile(TileIndex tile, int32 slope)
+/* static */ bool ScriptTile::LowerTile(TileIndex tile, int32 slope)
{
EnforcePrecondition(false, tile < ::MapSize());
- return AIObject::DoCommand(tile, slope, 0, CMD_TERRAFORM_LAND);
+ return ScriptObject::DoCommand(tile, slope, 0, CMD_TERRAFORM_LAND);
}
-/* static */ bool AITile::LevelTiles(TileIndex start_tile, TileIndex end_tile)
+/* static */ bool ScriptTile::LevelTiles(TileIndex start_tile, TileIndex end_tile)
{
EnforcePrecondition(false, start_tile < ::MapSize());
EnforcePrecondition(false, end_tile < ::MapSize());
- return AIObject::DoCommand(end_tile, start_tile, LM_LEVEL << 1, CMD_LEVEL_LAND);
+ return ScriptObject::DoCommand(end_tile, start_tile, LM_LEVEL << 1, CMD_LEVEL_LAND);
}
-/* static */ bool AITile::DemolishTile(TileIndex tile)
+/* static */ bool ScriptTile::DemolishTile(TileIndex tile)
{
EnforcePrecondition(false, ::IsValidTile(tile));
- return AIObject::DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR);
+ return ScriptObject::DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR);
}
-/* static */ bool AITile::PlantTree(TileIndex tile)
+/* static */ bool ScriptTile::PlantTree(TileIndex tile)
{
EnforcePrecondition(false, ::IsValidTile(tile));
- return AIObject::DoCommand(tile, TREE_INVALID, tile, CMD_PLANT_TREE);
+ return ScriptObject::DoCommand(tile, TREE_INVALID, tile, CMD_PLANT_TREE);
}
-/* static */ bool AITile::PlantTreeRectangle(TileIndex tile, uint width, uint height)
+/* static */ bool ScriptTile::PlantTreeRectangle(TileIndex tile, uint width, uint height)
{
EnforcePrecondition(false, ::IsValidTile(tile));
EnforcePrecondition(false, width >= 1 && width <= 20);
EnforcePrecondition(false, height >= 1 && height <= 20);
TileIndex end_tile = tile + ::TileDiffXY(width - 1, height - 1);
- return AIObject::DoCommand(tile, TREE_INVALID, end_tile, CMD_PLANT_TREE);
+ return ScriptObject::DoCommand(tile, TREE_INVALID, end_tile, CMD_PLANT_TREE);
}
-/* static */ bool AITile::IsWithinTownInfluence(TileIndex tile, TownID town_id)
+/* static */ bool ScriptTile::IsWithinTownInfluence(TileIndex tile, TownID town_id)
{
- return AITown::IsWithinTownInfluence(town_id, tile);
+ return ScriptTown::IsWithinTownInfluence(town_id, tile);
}
-/* static */ TownID AITile::GetTownAuthority(TileIndex tile)
+/* static */ TownID ScriptTile::GetTownAuthority(TileIndex tile)
{
if (!::IsValidTile(tile)) return false;
return ::ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority)->index;
}
-/* static */ TownID AITile::GetClosestTown(TileIndex tile)
+/* static */ TownID ScriptTile::GetClosestTown(TileIndex tile)
{
if (!::IsValidTile(tile)) return INVALID_TOWN;
return ::ClosestTownFromTile(tile, UINT_MAX)->index;
}
-/* static */ Money AITile::GetBuildCost(BuildType build_type)
+/* static */ Money ScriptTile::GetBuildCost(BuildType build_type)
{
switch (build_type) {
case BT_FOUNDATION: return ::GetPrice(PR_BUILD_FOUNDATION, 1, NULL);