From 8510afe23325edef6d8ff5538662acb8c01c990a Mon Sep 17 00:00:00 2001 From: truebrain Date: Fri, 16 Jan 2009 15:01:54 +0000 Subject: (svn r15109) -Add [NoAI]: add AITile::LevelTiles (Yexo) --- src/ai/api/ai_tile.cpp | 8 ++++++++ src/ai/api/ai_tile.hpp | 18 ++++++++++++++++++ src/ai/api/ai_tile.hpp.sq | 1 + 3 files changed, 27 insertions(+) (limited to 'src') diff --git a/src/ai/api/ai_tile.cpp b/src/ai/api/ai_tile.cpp index 29305af8a..a1f16b9bd 100644 --- a/src/ai/api/ai_tile.cpp +++ b/src/ai/api/ai_tile.cpp @@ -202,6 +202,14 @@ return AIObject::DoCommand(tile, slope, 0, CMD_TERRAFORM_LAND); } +/* static */ bool AITile::LevelTiles(TileIndex start_tile, TileIndex end_tile) +{ + EnforcePrecondition(false, ::IsValidTile(start_tile)); + EnforcePrecondition(false, ::IsValidTile(end_tile)); + + return AIObject::DoCommand(end_tile, start_tile, 0, CMD_LEVEL_LAND); +} + /* static */ bool AITile::DemolishTile(TileIndex tile) { EnforcePrecondition(false, ::IsValidTile(tile)); diff --git a/src/ai/api/ai_tile.hpp b/src/ai/api/ai_tile.hpp index 151771cae..9a4df1677 100644 --- a/src/ai/api/ai_tile.hpp +++ b/src/ai/api/ai_tile.hpp @@ -312,6 +312,24 @@ public: */ static bool LowerTile(TileIndex tile, int32 slope); + /** + * Level all tiles in the rectangle between start_tile and end_tile so they + * are at the same height. All tiles will be raised or lowered until + * they are at height AITile::GetHeight(start_tile). + * @param start_tile One corner of the rectangle to level. + * @param end_tile The opposite corner of the rectangle. + * @pre start_tile < AIMap::GetMapSize(). + * @pre end_tile < AIMap::GetMapSize(). + * @exception AIError::ERR_AREA_NOT_CLEAR + * @exception AIError::ERR_TOO_CLOSE_TO_EDGE + * @return True if and only if the area was completely leveled. + * @note Even if leveling some part fails, some other part may have been + * succesfully leveled already. + * @note This function may return true in AITestMode, although it fails in + * AIExecMode. + */ + static bool LevelTiles(TileIndex start_tile, TileIndex end_tile); + /** * Destroy everything on the given tile. * @param tile The tile to demolish. diff --git a/src/ai/api/ai_tile.hpp.sq b/src/ai/api/ai_tile.hpp.sq index 78a888ca8..844c92cf7 100644 --- a/src/ai/api/ai_tile.hpp.sq +++ b/src/ai/api/ai_tile.hpp.sq @@ -87,6 +87,7 @@ void SQAITile_Register(Squirrel *engine) { SQAITile.DefSQStaticMethod(engine, &AITile::GetDistanceSquareToTile, "GetDistanceSquareToTile", 3, "xii"); SQAITile.DefSQStaticMethod(engine, &AITile::RaiseTile, "RaiseTile", 3, "xii"); SQAITile.DefSQStaticMethod(engine, &AITile::LowerTile, "LowerTile", 3, "xii"); + SQAITile.DefSQStaticMethod(engine, &AITile::LevelTiles, "LevelTiles", 3, "xii"); SQAITile.DefSQStaticMethod(engine, &AITile::DemolishTile, "DemolishTile", 2, "xi"); SQAITile.DefSQStaticMethod(engine, &AITile::PlantTree, "PlantTree", 2, "xi"); SQAITile.DefSQStaticMethod(engine, &AITile::PlantTreeRectangle, "PlantTreeRectangle", 4, "xiii"); -- cgit v1.2.3-54-g00ecf