summaryrefslogtreecommitdiff
path: root/src/ai
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-09-08 10:12:13 +0000
committerrubidium <rubidium@openttd.org>2009-09-08 10:12:13 +0000
commitdcd6b2096d0b8ecd1d9b95d56a8183e6bd604de6 (patch)
treeee8a9a27dff20f527d1de1e60a7c4799223d9a34 /src/ai
parent8cbcf17421a841696185db6318f2ed44ede9031c (diff)
downloadopenttd-dcd6b2096d0b8ecd1d9b95d56a8183e6bd604de6.tar.xz
(svn r17471) -Change: when removing a station or waypoint keep the rail unless Ctrl is pressed. This makes the behaviour consistent between the two.
Diffstat (limited to 'src/ai')
-rw-r--r--src/ai/api/ai_changelog.hpp16
-rw-r--r--src/ai/api/ai_rail.cpp16
-rw-r--r--src/ai/api/ai_rail.hpp15
-rw-r--r--src/ai/api/ai_rail.hpp.sq59
4 files changed, 51 insertions, 55 deletions
diff --git a/src/ai/api/ai_changelog.hpp b/src/ai/api/ai_changelog.hpp
index 6fe23765f..7a0f0fef3 100644
--- a/src/ai/api/ai_changelog.hpp
+++ b/src/ai/api/ai_changelog.hpp
@@ -16,11 +16,14 @@
*
* \b 0.8.0
*
+ * 0.8.0 is not yet released. The following changes are not set in stone yet.
+ *
* API additions:
* \li AIBaseStation
* \li AIBuoyList
* \li AIEventCompanyAskMerger
- * \li AIRail::RemoveRailWaypointTileRect
+ * \li AIRail::RemoveRailStationTileRectangle
+ * \li AIRail::RemoveRailWaypointTileRectangle
* \li AISubsidy::SubsidyParticipantType
* \li AISubsidy::GetSourceType
* \li AISubsidy::GetSourceIndex
@@ -31,12 +34,14 @@
*
* API removals:
* \li AIOrder::ChangeOrder, use AIOrder::SetOrderFlags instead
+ * \li AIRail::RemoveRailStationTileRect, use AIRail::RemoveRailStationTileRectangle instead
+ * \li AIRail::RemoveRailWaypoint, use AIRail::RemoveRailWaypointTileRectangle instead
* \li AISign::GetMaxSignID, use AISignList instead
- * \li AITile::GetHeight, use AITile::GetMinHeight/GetMaxHeight/GetCornerHeight instead
* \li AISubsidy::SourceIsTown, use AISubsidy::GetSourceType instead
* \li AISubsidy::GetSource, use AISubsidy::GetSourceIndex instead
* \li AISubsidy::DestinationIsTown, use AISubsidy::GetDestinationType instead
* \li AISubsidy::GetDestination, use AISubsidy::GetDestinationIndex instead
+ * \li AITile::GetHeight, use AITile::GetMinHeight/GetMaxHeight/GetCornerHeight instead
* \li AITown::GetMaxProduction, use AITown::GetLastMonthProduction instead
* \li AIWaypoint::WAYPOINT_INVALID, use AIBaseStation::STATION_INVALID instead
*
@@ -49,6 +54,13 @@
* \li WaypointID was replaced by StationID. All WaypointIDs from previous
* savegames are invalid. Use STATION_INVALID instead of WAYPOINT_INVALID
* \li AIVehicleList_Station now also works for waypoints
+ * \li Stations can be build over rail without signals that is in the right
+ * direction for the to-be built station. It will also convert the rail if
+ * the station's rail type supports the old type.
+ * \li GetAPIVersion() was added as function to info.nut. If it does not exist
+ * API version 0.7 is assumed. This function should return the major and
+ * minor number of the stable version of the API the AI is written against.
+ * For 0.7.2 that would be 0.7, for 1.1.3 it would be 1.1, etc.
*
* \b 0.7.3
*
diff --git a/src/ai/api/ai_rail.cpp b/src/ai/api/ai_rail.cpp
index 37589092c..39781bc44 100644
--- a/src/ai/api/ai_rail.cpp
+++ b/src/ai/api/ai_rail.cpp
@@ -187,28 +187,20 @@
return AIObject::DoCommand(tile, GetCurrentRailType() | (GetRailTracks(tile) == RAILTRACK_NE_SW ? AXIS_X : AXIS_Y) << 4 | 1 << 8 | 1 << 16, STAT_CLASS_WAYP | INVALID_STATION << 16, CMD_BUILD_RAIL_WAYPOINT);
}
-/* static */ bool AIRail::RemoveRailWaypoint(TileIndex tile)
-{
- EnforcePrecondition(false, ::IsValidTile(tile));
- EnforcePrecondition(false, IsRailWaypointTile(tile));
-
- return AIObject::DoCommand(tile, 0, 0, CMD_REMOVE_FROM_RAIL_WAYPOINT);
-}
-
-/* static */ bool AIRail::RemoveRailWaypointTileRect(TileIndex tile, TileIndex tile2)
+/* static */ bool AIRail::RemoveRailWaypointTileRectangle(TileIndex tile, TileIndex tile2, bool keep_rail)
{
EnforcePrecondition(false, ::IsValidTile(tile));
EnforcePrecondition(false, ::IsValidTile(tile2));
- return AIObject::DoCommand(tile, tile2, 0, CMD_REMOVE_FROM_RAIL_WAYPOINT);
+ return AIObject::DoCommand(tile, tile2, keep_rail ? 1 : 0, CMD_REMOVE_FROM_RAIL_WAYPOINT);
}
-/* static */ bool AIRail::RemoveRailStationTileRect(TileIndex tile, TileIndex tile2)
+/* static */ bool AIRail::RemoveRailStationTileRectangle(TileIndex tile, TileIndex tile2, bool keep_rail)
{
EnforcePrecondition(false, ::IsValidTile(tile));
EnforcePrecondition(false, ::IsValidTile(tile2));
- return AIObject::DoCommand(tile, tile2, 0, CMD_REMOVE_FROM_RAIL_STATION);
+ return AIObject::DoCommand(tile, tile2, keep_rail ? 1 : 0, CMD_REMOVE_FROM_RAIL_STATION);
}
/* static */ uint AIRail::GetRailTracks(TileIndex tile)
diff --git a/src/ai/api/ai_rail.hpp b/src/ai/api/ai_rail.hpp
index 50da72057..2b662bc38 100644
--- a/src/ai/api/ai_rail.hpp
+++ b/src/ai/api/ai_rail.hpp
@@ -280,33 +280,26 @@ public:
static bool BuildRailWaypoint(TileIndex tile);
/**
- * Remove a rail waypoint.
- * @param tile Place to remove the waypoint from.
- * @pre AIMap::IsValidTile(tile).
- * @pre IsRailWaypointTile(tile).
- * @return Whether the rail waypoint has been/can be removed or not.
- */
- static bool RemoveRailWaypoint(TileIndex tile);
-
- /**
* 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.
+ * @param keep_rail Whether to keep the rail after removal.
* @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);
+ static bool RemoveRailWaypointTileRectangle(TileIndex tile, TileIndex tile2, bool keep_rail);
/**
* 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.
+ * @param keep_rail Whether to keep the rail after removal.
* @pre IsValidTile(tile).
* @pre IsValidTile(tile2).
* @return Whether at least one tile has been/can be cleared or not.
*/
- static bool RemoveRailStationTileRect(TileIndex tile, TileIndex tile2);
+ static bool RemoveRailStationTileRectangle(TileIndex tile, TileIndex tile2, bool keep_rail);
/**
* Get all RailTracks on the given tile.
diff --git a/src/ai/api/ai_rail.hpp.sq b/src/ai/api/ai_rail.hpp.sq
index de1cdce77..6ecaf45db 100644
--- a/src/ai/api/ai_rail.hpp.sq
+++ b/src/ai/api/ai_rail.hpp.sq
@@ -68,36 +68,35 @@ 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::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.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::RemoveRailWaypointTileRectangle, "RemoveRailWaypointTileRectangle", 4, ".iib");
+ SQAIRail.DefSQStaticMethod(engine, &AIRail::RemoveRailStationTileRectangle, "RemoveRailStationTileRectangle", 4, ".iib");
+ 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);
}