summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-07-30 15:17:03 +0000
committerrubidium <rubidium@openttd.org>2009-07-30 15:17:03 +0000
commit4a1f6547c678331f5e16b0c06c1e84eaa7d50db9 (patch)
tree5ca6c956a0f2244dbf8c7d4f65c4db598306517b
parentde99f212dc5c9829ba031b6c66f2ef88a1a29666 (diff)
downloadopenttd-4a1f6547c678331f5e16b0c06c1e84eaa7d50db9.tar.xz
(svn r16992) -Add [NoAI]: function to clear waypoint(s) in a certain rectangle on the map
-rw-r--r--src/ai/api/ai_rail.cpp8
-rw-r--r--src/ai/api/ai_rail.hpp12
-rw-r--r--src/ai/api/ai_rail.hpp.sq59
3 files changed, 49 insertions, 30 deletions
diff --git a/src/ai/api/ai_rail.cpp b/src/ai/api/ai_rail.cpp
index a278acad2..1579dc165 100644
--- a/src/ai/api/ai_rail.cpp
+++ b/src/ai/api/ai_rail.cpp
@@ -188,6 +188,14 @@
return AIObject::DoCommand(tile, 0, 0, CMD_REMOVE_FROM_RAIL_WAYPOINT);
}
+/* static */ bool AIRail::RemoveRailWaypointTileRect(TileIndex tile, TileIndex tile2)
+{
+ EnforcePrecondition(false, ::IsValidTile(tile));
+ EnforcePrecondition(false, ::IsValidTile(tile2));
+
+ return AIObject::DoCommand(tile, tile2, 0, CMD_REMOVE_FROM_RAIL_WAYPOINT);
+}
+
/* static */ bool AIRail::RemoveRailStationTileRect(TileIndex tile, TileIndex tile2)
{
EnforcePrecondition(false, ::IsValidTile(tile));
diff --git a/src/ai/api/ai_rail.hpp b/src/ai/api/ai_rail.hpp
index a16c27e1e..e17a5d52c 100644
--- a/src/ai/api/ai_rail.hpp
+++ b/src/ai/api/ai_rail.hpp
@@ -282,7 +282,17 @@ public:
static bool RemoveRailWaypoint(TileIndex tile);
/**
- * Remove a rectangle of platform pieces from a rail station.
+ * Remove all rail waypoint pieces within a rectangle on the map.
+ * @param tile One corner of the rectangle to clear.
+ * @param tile2 The oppposite corner.
+ * @pre IsValidTile(tile).
+ * @pre IsValidTile(tile2).
+ * @return Whether at least one tile has been/can be cleared or not.
+ */
+ static bool RemoveRailWaypointTileRect(TileIndex tile, TileIndex tile2);
+
+ /**
+ * Remove all rail station platform pieces within a rectangle on the map.
* @param tile One corner of the rectangle to clear.
* @param tile2 The oppposite corner.
* @pre IsValidTile(tile).
diff --git a/src/ai/api/ai_rail.hpp.sq b/src/ai/api/ai_rail.hpp.sq
index d6a005379..85d531d46 100644
--- a/src/ai/api/ai_rail.hpp.sq
+++ b/src/ai/api/ai_rail.hpp.sq
@@ -60,35 +60,36 @@ void SQAIRail_Register(Squirrel *engine) {
AIError::RegisterErrorMapString(AIRail::ERR_UNSUITABLE_TRACK, "ERR_UNSUITABLE_TRACK");
AIError::RegisterErrorMapString(AIRail::ERR_NONUNIFORM_STATIONS_DISABLED, "ERR_NONUNIFORM_STATIONS_DISABLED");
- SQAIRail.DefSQStaticMethod(engine, &AIRail::IsRailTile, "IsRailTile", 2, ".i");
- SQAIRail.DefSQStaticMethod(engine, &AIRail::IsLevelCrossingTile, "IsLevelCrossingTile", 2, ".i");
- SQAIRail.DefSQStaticMethod(engine, &AIRail::IsRailDepotTile, "IsRailDepotTile", 2, ".i");
- SQAIRail.DefSQStaticMethod(engine, &AIRail::IsRailStationTile, "IsRailStationTile", 2, ".i");
- SQAIRail.DefSQStaticMethod(engine, &AIRail::IsRailWaypointTile, "IsRailWaypointTile", 2, ".i");
- SQAIRail.DefSQStaticMethod(engine, &AIRail::IsRailTypeAvailable, "IsRailTypeAvailable", 2, ".i");
- SQAIRail.DefSQStaticMethod(engine, &AIRail::GetCurrentRailType, "GetCurrentRailType", 1, ".");
- SQAIRail.DefSQStaticMethod(engine, &AIRail::SetCurrentRailType, "SetCurrentRailType", 2, ".i");
- SQAIRail.DefSQStaticMethod(engine, &AIRail::TrainCanRunOnRail, "TrainCanRunOnRail", 3, ".ii");
- SQAIRail.DefSQStaticMethod(engine, &AIRail::TrainHasPowerOnRail, "TrainHasPowerOnRail", 3, ".ii");
- SQAIRail.DefSQStaticMethod(engine, &AIRail::GetRailType, "GetRailType", 2, ".i");
- SQAIRail.DefSQStaticMethod(engine, &AIRail::ConvertRailType, "ConvertRailType", 4, ".iii");
- SQAIRail.DefSQStaticMethod(engine, &AIRail::GetRailDepotFrontTile, "GetRailDepotFrontTile", 2, ".i");
- SQAIRail.DefSQStaticMethod(engine, &AIRail::GetRailStationDirection, "GetRailStationDirection", 2, ".i");
- SQAIRail.DefSQStaticMethod(engine, &AIRail::BuildRailDepot, "BuildRailDepot", 3, ".ii");
- SQAIRail.DefSQStaticMethod(engine, &AIRail::BuildRailStation, "BuildRailStation", 6, ".iiiii");
- SQAIRail.DefSQStaticMethod(engine, &AIRail::BuildNewGRFRailStation, "BuildNewGRFRailStation", 11, ".iiiiiiiiib");
- SQAIRail.DefSQStaticMethod(engine, &AIRail::BuildRailWaypoint, "BuildRailWaypoint", 2, ".i");
- SQAIRail.DefSQStaticMethod(engine, &AIRail::RemoveRailWaypoint, "RemoveRailWaypoint", 2, ".i");
- SQAIRail.DefSQStaticMethod(engine, &AIRail::RemoveRailStationTileRect, "RemoveRailStationTileRect", 3, ".ii");
- SQAIRail.DefSQStaticMethod(engine, &AIRail::GetRailTracks, "GetRailTracks", 2, ".i");
- SQAIRail.DefSQStaticMethod(engine, &AIRail::BuildRailTrack, "BuildRailTrack", 3, ".ii");
- SQAIRail.DefSQStaticMethod(engine, &AIRail::RemoveRailTrack, "RemoveRailTrack", 3, ".ii");
- SQAIRail.DefSQStaticMethod(engine, &AIRail::AreTilesConnected, "AreTilesConnected", 4, ".iii");
- SQAIRail.DefSQStaticMethod(engine, &AIRail::BuildRail, "BuildRail", 4, ".iii");
- SQAIRail.DefSQStaticMethod(engine, &AIRail::RemoveRail, "RemoveRail", 4, ".iii");
- SQAIRail.DefSQStaticMethod(engine, &AIRail::GetSignalType, "GetSignalType", 3, ".ii");
- SQAIRail.DefSQStaticMethod(engine, &AIRail::BuildSignal, "BuildSignal", 4, ".iii");
- SQAIRail.DefSQStaticMethod(engine, &AIRail::RemoveSignal, "RemoveSignal", 3, ".ii");
+ SQAIRail.DefSQStaticMethod(engine, &AIRail::IsRailTile, "IsRailTile", 2, ".i");
+ SQAIRail.DefSQStaticMethod(engine, &AIRail::IsLevelCrossingTile, "IsLevelCrossingTile", 2, ".i");
+ SQAIRail.DefSQStaticMethod(engine, &AIRail::IsRailDepotTile, "IsRailDepotTile", 2, ".i");
+ SQAIRail.DefSQStaticMethod(engine, &AIRail::IsRailStationTile, "IsRailStationTile", 2, ".i");
+ SQAIRail.DefSQStaticMethod(engine, &AIRail::IsRailWaypointTile, "IsRailWaypointTile", 2, ".i");
+ SQAIRail.DefSQStaticMethod(engine, &AIRail::IsRailTypeAvailable, "IsRailTypeAvailable", 2, ".i");
+ SQAIRail.DefSQStaticMethod(engine, &AIRail::GetCurrentRailType, "GetCurrentRailType", 1, ".");
+ SQAIRail.DefSQStaticMethod(engine, &AIRail::SetCurrentRailType, "SetCurrentRailType", 2, ".i");
+ SQAIRail.DefSQStaticMethod(engine, &AIRail::TrainCanRunOnRail, "TrainCanRunOnRail", 3, ".ii");
+ SQAIRail.DefSQStaticMethod(engine, &AIRail::TrainHasPowerOnRail, "TrainHasPowerOnRail", 3, ".ii");
+ SQAIRail.DefSQStaticMethod(engine, &AIRail::GetRailType, "GetRailType", 2, ".i");
+ SQAIRail.DefSQStaticMethod(engine, &AIRail::ConvertRailType, "ConvertRailType", 4, ".iii");
+ SQAIRail.DefSQStaticMethod(engine, &AIRail::GetRailDepotFrontTile, "GetRailDepotFrontTile", 2, ".i");
+ SQAIRail.DefSQStaticMethod(engine, &AIRail::GetRailStationDirection, "GetRailStationDirection", 2, ".i");
+ SQAIRail.DefSQStaticMethod(engine, &AIRail::BuildRailDepot, "BuildRailDepot", 3, ".ii");
+ SQAIRail.DefSQStaticMethod(engine, &AIRail::BuildRailStation, "BuildRailStation", 6, ".iiiii");
+ SQAIRail.DefSQStaticMethod(engine, &AIRail::BuildNewGRFRailStation, "BuildNewGRFRailStation", 11, ".iiiiiiiiib");
+ SQAIRail.DefSQStaticMethod(engine, &AIRail::BuildRailWaypoint, "BuildRailWaypoint", 2, ".i");
+ SQAIRail.DefSQStaticMethod(engine, &AIRail::RemoveRailWaypoint, "RemoveRailWaypoint", 2, ".i");
+ SQAIRail.DefSQStaticMethod(engine, &AIRail::RemoveRailWaypointTileRect, "RemoveRailWaypointTileRect", 3, ".ii");
+ SQAIRail.DefSQStaticMethod(engine, &AIRail::RemoveRailStationTileRect, "RemoveRailStationTileRect", 3, ".ii");
+ SQAIRail.DefSQStaticMethod(engine, &AIRail::GetRailTracks, "GetRailTracks", 2, ".i");
+ SQAIRail.DefSQStaticMethod(engine, &AIRail::BuildRailTrack, "BuildRailTrack", 3, ".ii");
+ SQAIRail.DefSQStaticMethod(engine, &AIRail::RemoveRailTrack, "RemoveRailTrack", 3, ".ii");
+ SQAIRail.DefSQStaticMethod(engine, &AIRail::AreTilesConnected, "AreTilesConnected", 4, ".iii");
+ SQAIRail.DefSQStaticMethod(engine, &AIRail::BuildRail, "BuildRail", 4, ".iii");
+ SQAIRail.DefSQStaticMethod(engine, &AIRail::RemoveRail, "RemoveRail", 4, ".iii");
+ SQAIRail.DefSQStaticMethod(engine, &AIRail::GetSignalType, "GetSignalType", 3, ".ii");
+ SQAIRail.DefSQStaticMethod(engine, &AIRail::BuildSignal, "BuildSignal", 4, ".iii");
+ SQAIRail.DefSQStaticMethod(engine, &AIRail::RemoveSignal, "RemoveSignal", 3, ".ii");
SQAIRail.PostRegister(engine);
}