(svn r10568) [NoAI] -Add: {Build|Remove}RoadFull(). These functions have the same behaviour as {Build|Remove}Road(), except road is built/removed on both halves of ending tiles (ie build a sloped road on sloped tile instead half road with fundations)
--- a/src/ai/api/ai_road.cpp Sat Jul 14 22:06:38 2007 +0000
+++ b/src/ai/api/ai_road.cpp Sat Jul 14 23:35:46 2007 +0000
@@ -104,6 +104,17 @@
return this->DoCommand(end, start, (TileY(start) != TileY(end) ? 4 : 0) | (start < end ? 1 : 2) | (ROADTYPE_ROAD << 3), CMD_BUILD_LONG_ROAD);
}
+bool AIRoad::BuildRoadFull(TileIndex start, TileIndex end)
+{
+ /* Outside of the map */
+ if (start >= ::MapSize() || end >= ::MapSize() || start == end) return false;
+ /* Not on one line */
+ if (TileX(start) != TileX(end) &&
+ TileY(start) != TileY(end)) return false;
+
+ return this->DoCommand(end, start, (TileY(start) != TileY(end) ? 4 : 0) | (start < end ? 2 : 1), CMD_BUILD_LONG_ROAD);
+}
+
bool AIRoad::BuildRoadDepot(TileIndex tile, TileIndex front)
{
/* Outside of the map */
@@ -140,6 +151,17 @@
return this->DoCommand(end, start, (TileY(start) != TileY(end) ? 4 : 0) | (start < end ? 1 : 2) | (ROADTYPE_ROAD << 3), CMD_REMOVE_LONG_ROAD);
}
+bool AIRoad::RemoveRoadFull(TileIndex start, TileIndex end)
+{
+ /* Outside of the map */
+ if (start >= ::MapSize() || end >= ::MapSize()) return false;
+ /* Not on one line */
+ if (TileX(start) != TileX(end) &&
+ TileY(start) != TileY(end)) return false;
+
+ return this->DoCommand(end, start, (TileY(start) != TileY(end) ? 4 : 0) | (start < end ? 2 : 1), CMD_REMOVE_LONG_ROAD);
+}
+
bool AIRoad::RemoveRoadDepot(TileIndex tile)
{
/* Outside of the map */
--- a/src/ai/api/ai_road.hpp Sat Jul 14 22:06:38 2007 +0000
+++ b/src/ai/api/ai_road.hpp Sat Jul 14 23:35:46 2007 +0000
@@ -125,6 +125,21 @@
bool BuildRoad(TileIndex start, TileIndex end);
/**
+ * Builds a road from the edge of tile start to the
+ * edge of tile end (both included).
+ * @param start the start tile of the road.
+ * @param end the end tile of the road.
+ * @pre start is not equal to end
+ * @pre start is always positive and smaller than AIMap::GetMapSize().
+ * @pre end is always positive and smaller than AIMap::GetMapSize().
+ * @pre start and end are in a straight line, i.e.
+ * AIMap::GetTileX(start) == AIMap::GetTileX(end) or
+ * AIMap::GetTileY(start) == AIMap::GetTileY(end).
+ * @return whether the road has been/can be build or not.
+ */
+ bool BuildRoadFull(TileIndex start, TileIndex end);
+
+ /**
* Builds a road depot.
* @param tile place to build the depot.
* @param front the tile exactly in front of the depot
@@ -164,6 +179,20 @@
bool RemoveRoad(TileIndex start, TileIndex end);
/**
+ * Removes a road from the edge of tile start to the
+ * edge of tile end (both included).
+ * @param start the start tile of the road.
+ * @param end the end tile of the road.
+ * @pre start is always positive and smaller than AIMap::GetMapSize().
+ * @pre end is always positive and smaller than AIMap::GetMapSize().
+ * @pre start and end are in a straight line, i.e.
+ * AIMap::GetTileX(start) == AIMap::GetTileX(end) or
+ * AIMap::GetTileY(start) == AIMap::GetTileY(end).
+ * @return whether the road has been/can be removed or not.
+ */
+ bool RemoveRoadFull(TileIndex start, TileIndex end);
+
+ /**
* Removes a road depot.
* @param tile place to remove the depot from.
* @pre tile is always positive and smaller than AIMap::GetMapSize().
--- a/src/ai/api/ai_road.hpp.sq Sat Jul 14 22:06:38 2007 +0000
+++ b/src/ai/api/ai_road.hpp.sq Sat Jul 14 23:35:46 2007 +0000
@@ -25,9 +25,11 @@
SQAIRoad.DefSQMethod(engine, &AIRoad::GetRoadStationFrontTile, "GetRoadStationFrontTile", 2, "xi");
SQAIRoad.DefSQMethod(engine, &AIRoad::GetDriveThroughBackTile, "GetDriveThroughBackTile", 2, "xi");
SQAIRoad.DefSQMethod(engine, &AIRoad::BuildRoad, "BuildRoad", 3, "xii");
+ SQAIRoad.DefSQMethod(engine, &AIRoad::BuildRoadFull, "BuildRoadFull", 3, "xii");
SQAIRoad.DefSQMethod(engine, &AIRoad::BuildRoadDepot, "BuildRoadDepot", 3, "xii");
SQAIRoad.DefSQMethod(engine, &AIRoad::BuildRoadStation, "BuildRoadStation", 5, "xiibb");
SQAIRoad.DefSQMethod(engine, &AIRoad::RemoveRoad, "RemoveRoad", 3, "xii");
+ SQAIRoad.DefSQMethod(engine, &AIRoad::RemoveRoadFull, "RemoveRoadFull", 3, "xii");
SQAIRoad.DefSQMethod(engine, &AIRoad::RemoveRoadDepot, "RemoveRoadDepot", 2, "xi");
SQAIRoad.DefSQMethod(engine, &AIRoad::RemoveRoadStation, "RemoveRoadStation", 2, "xi");