summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzuu <zuu@openttd.org>2012-10-25 19:25:31 +0000
committerzuu <zuu@openttd.org>2012-10-25 19:25:31 +0000
commit1f764f51f0a146ee797dd21bda65507d361c79da (patch)
treea3b8dee2078228fae8ed8e81599e90b428b8e986
parent355790435e9c6b0d9ea6214d4ccb4ff2fb58b322 (diff)
downloadopenttd-1f764f51f0a146ee797dd21bda65507d361c79da.tar.xz
(svn r24628) -Fix: Document and enforce precondition start != end for ScriptRoad::RemoveRoad and ScriptRoad::RemoveRoadFull
-rw-r--r--src/script/api/script_road.cpp2
-rw-r--r--src/script/api/script_road.hpp2
2 files changed, 4 insertions, 0 deletions
diff --git a/src/script/api/script_road.cpp b/src/script/api/script_road.cpp
index 19db9a901..137ae7618 100644
--- a/src/script/api/script_road.cpp
+++ b/src/script/api/script_road.cpp
@@ -537,6 +537,7 @@ static bool NeighbourHasReachableRoad(::RoadTypes rts, TileIndex start_tile, Dia
/* static */ bool ScriptRoad::RemoveRoad(TileIndex start, TileIndex end)
{
EnforcePrecondition(false, ScriptObject::GetCompany() != OWNER_DEITY);
+ EnforcePrecondition(false, start != end);
EnforcePrecondition(false, ::IsValidTile(start));
EnforcePrecondition(false, ::IsValidTile(end));
EnforcePrecondition(false, ::TileX(start) == ::TileX(end) || ::TileY(start) == ::TileY(end));
@@ -548,6 +549,7 @@ static bool NeighbourHasReachableRoad(::RoadTypes rts, TileIndex start_tile, Dia
/* static */ bool ScriptRoad::RemoveRoadFull(TileIndex start, TileIndex end)
{
EnforcePrecondition(false, ScriptObject::GetCompany() != OWNER_DEITY);
+ EnforcePrecondition(false, start != end);
EnforcePrecondition(false, ::IsValidTile(start));
EnforcePrecondition(false, ::IsValidTile(end));
EnforcePrecondition(false, ::TileX(start) == ::TileX(end) || ::TileY(start) == ::TileY(end));
diff --git a/src/script/api/script_road.hpp b/src/script/api/script_road.hpp
index 9818fa55c..6f928e25c 100644
--- a/src/script/api/script_road.hpp
+++ b/src/script/api/script_road.hpp
@@ -418,6 +418,7 @@ public:
* Removes a road from the center of tile start to the center of tile end.
* @param start The start tile of the road.
* @param end The end tile of the road.
+ * @pre 'start' is not equal to 'end'.
* @pre ScriptMap::IsValidTile(start).
* @pre ScriptMap::IsValidTile(end).
* @pre 'start' and 'end' are in a straight line, i.e.
@@ -437,6 +438,7 @@ public:
* 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 ScriptMap::IsValidTile(start).
* @pre ScriptMap::IsValidTile(end).
* @pre 'start' and 'end' are in a straight line, i.e.