diff --git a/bin/ai/compat_0.7.nut b/bin/ai/compat_0.7.nut index c40308592c..341b543bd3 100644 --- a/bin/ai/compat_0.7.nut +++ b/bin/ai/compat_0.7.nut @@ -379,3 +379,16 @@ AIGroup.CreateGroup <- function(vehicle_type) { return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID); } + +/* 13 really checks RoadType against RoadType */ +AIRoad._HasRoadType <- AIRoad.HasRoadType; +AIRoad.HasRoadType <- function(tile, road_type) +{ + local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (AIRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/ai/compat_1.0.nut b/bin/ai/compat_1.0.nut index b8da71a194..6b76f11534 100644 --- a/bin/ai/compat_1.0.nut +++ b/bin/ai/compat_1.0.nut @@ -131,3 +131,16 @@ AIGroup.CreateGroup <- function(vehicle_type) { return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID); } + +/* 13 really checks RoadType against RoadType */ +AIRoad._HasRoadType <- AIRoad.HasRoadType; +AIRoad.HasRoadType <- function(tile, road_type) +{ + local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (AIRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/ai/compat_1.1.nut b/bin/ai/compat_1.1.nut index f1bda9c7fe..9c568a7006 100644 --- a/bin/ai/compat_1.1.nut +++ b/bin/ai/compat_1.1.nut @@ -68,3 +68,16 @@ AIGroup.CreateGroup <- function(vehicle_type) { return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID); } + +/* 13 really checks RoadType against RoadType */ +AIRoad._HasRoadType <- AIRoad.HasRoadType; +AIRoad.HasRoadType <- function(tile, road_type) +{ + local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (AIRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/ai/compat_1.10.nut b/bin/ai/compat_1.10.nut index 2baaddb836..44bc2542ce 100644 --- a/bin/ai/compat_1.10.nut +++ b/bin/ai/compat_1.10.nut @@ -6,3 +6,16 @@ */ AILog.Info("1.10 API compatibility in effect."); + +/* 13 really checks RoadType against RoadType */ +AIRoad._HasRoadType <- AIRoad.HasRoadType; +AIRoad.HasRoadType <- function(tile, road_type) +{ + local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (AIRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/ai/compat_1.11.nut b/bin/ai/compat_1.11.nut index 887f3f7fd9..3d8370ffc6 100644 --- a/bin/ai/compat_1.11.nut +++ b/bin/ai/compat_1.11.nut @@ -6,3 +6,16 @@ */ AILog.Info("1.11 API compatibility in effect."); + +/* 13 really checks RoadType against RoadType */ +AIRoad._HasRoadType <- AIRoad.HasRoadType; +AIRoad.HasRoadType <- function(tile, road_type) +{ + local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (AIRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/ai/compat_1.2.nut b/bin/ai/compat_1.2.nut index 550f79969c..fc52b04935 100644 --- a/bin/ai/compat_1.2.nut +++ b/bin/ai/compat_1.2.nut @@ -20,3 +20,16 @@ AIGroup.CreateGroup <- function(vehicle_type) { return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID); } + +/* 13 really checks RoadType against RoadType */ +AIRoad._HasRoadType <- AIRoad.HasRoadType; +AIRoad.HasRoadType <- function(tile, road_type) +{ + local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (AIRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/ai/compat_1.3.nut b/bin/ai/compat_1.3.nut index 6b2c7e8a71..a06e98d2dd 100644 --- a/bin/ai/compat_1.3.nut +++ b/bin/ai/compat_1.3.nut @@ -20,3 +20,16 @@ AIGroup.CreateGroup <- function(vehicle_type) { return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID); } + +/* 13 really checks RoadType against RoadType */ +AIRoad._HasRoadType <- AIRoad.HasRoadType; +AIRoad.HasRoadType <- function(tile, road_type) +{ + local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (AIRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/ai/compat_1.4.nut b/bin/ai/compat_1.4.nut index a9ab5a4757..6de24bf80c 100644 --- a/bin/ai/compat_1.4.nut +++ b/bin/ai/compat_1.4.nut @@ -20,3 +20,16 @@ AIGroup.CreateGroup <- function(vehicle_type) { return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID); } + +/* 13 really checks RoadType against RoadType */ +AIRoad._HasRoadType <- AIRoad.HasRoadType; +AIRoad.HasRoadType <- function(tile, road_type) +{ + local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (AIRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/ai/compat_1.5.nut b/bin/ai/compat_1.5.nut index 23944149f6..8ff5a39d15 100644 --- a/bin/ai/compat_1.5.nut +++ b/bin/ai/compat_1.5.nut @@ -20,3 +20,16 @@ AIGroup.CreateGroup <- function(vehicle_type) { return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID); } + +/* 13 really checks RoadType against RoadType */ +AIRoad._HasRoadType <- AIRoad.HasRoadType; +AIRoad.HasRoadType <- function(tile, road_type) +{ + local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (AIRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/ai/compat_1.6.nut b/bin/ai/compat_1.6.nut index bcbe91455c..91744512a7 100644 --- a/bin/ai/compat_1.6.nut +++ b/bin/ai/compat_1.6.nut @@ -20,3 +20,16 @@ AIGroup.CreateGroup <- function(vehicle_type) { return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID); } + +/* 13 really checks RoadType against RoadType */ +AIRoad._HasRoadType <- AIRoad.HasRoadType; +AIRoad.HasRoadType <- function(tile, road_type) +{ + local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (AIRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/ai/compat_1.7.nut b/bin/ai/compat_1.7.nut index 7c2fd9b825..584a970f60 100644 --- a/bin/ai/compat_1.7.nut +++ b/bin/ai/compat_1.7.nut @@ -20,3 +20,16 @@ AIGroup.CreateGroup <- function(vehicle_type) { return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID); } + +/* 13 really checks RoadType against RoadType */ +AIRoad._HasRoadType <- AIRoad.HasRoadType; +AIRoad.HasRoadType <- function(tile, road_type) +{ + local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (AIRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/ai/compat_1.8.nut b/bin/ai/compat_1.8.nut index a118a63b57..f57a0eab27 100644 --- a/bin/ai/compat_1.8.nut +++ b/bin/ai/compat_1.8.nut @@ -20,3 +20,16 @@ AIGroup.CreateGroup <- function(vehicle_type) { return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID); } + +/* 13 really checks RoadType against RoadType */ +AIRoad._HasRoadType <- AIRoad.HasRoadType; +AIRoad.HasRoadType <- function(tile, road_type) +{ + local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (AIRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/ai/compat_1.9.nut b/bin/ai/compat_1.9.nut index a3d0941327..0dde6dc6da 100644 --- a/bin/ai/compat_1.9.nut +++ b/bin/ai/compat_1.9.nut @@ -6,3 +6,16 @@ */ AILog.Info("1.9 API compatibility in effect."); + +/* 13 really checks RoadType against RoadType */ +AIRoad._HasRoadType <- AIRoad.HasRoadType; +AIRoad.HasRoadType <- function(tile, road_type) +{ + local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (AIRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/ai/compat_12.nut b/bin/ai/compat_12.nut index 2ff41f8b4f..d54895632f 100644 --- a/bin/ai/compat_12.nut +++ b/bin/ai/compat_12.nut @@ -6,3 +6,16 @@ */ AILog.Info("12 API compatibility in effect."); + +/* 13 really checks RoadType against RoadType */ +AIRoad._HasRoadType <- AIRoad.HasRoadType; +AIRoad.HasRoadType <- function(tile, road_type) +{ + local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (AIRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/game/compat_1.10.nut b/bin/game/compat_1.10.nut index 92cef84c53..2559ff0a9c 100644 --- a/bin/game/compat_1.10.nut +++ b/bin/game/compat_1.10.nut @@ -13,3 +13,16 @@ GSCompany.ChangeBankBalance <- function(company, delta, expenses_type) { return GSCompany._ChangeBankBalance(company, delta, expenses_type, GSMap.TILE_INVALID); } + +/* 13 really checks RoadType against RoadType */ +GSRoad._HasRoadType <- GSRoad.HasRoadType; +GSRoad.HasRoadType <- function(tile, road_type) +{ + local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (GSRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/game/compat_1.11.nut b/bin/game/compat_1.11.nut index fa240b5d2d..eac9a05d36 100644 --- a/bin/game/compat_1.11.nut +++ b/bin/game/compat_1.11.nut @@ -6,3 +6,16 @@ */ GSLog.Info("1.11 API compatibility in effect."); + +/* 13 really checks RoadType against RoadType */ +GSRoad._HasRoadType <- GSRoad.HasRoadType; +GSRoad.HasRoadType <- function(tile, road_type) +{ + local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (GSRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/game/compat_1.2.nut b/bin/game/compat_1.2.nut index 5fb29efedf..66e2ca5d62 100644 --- a/bin/game/compat_1.2.nut +++ b/bin/game/compat_1.2.nut @@ -35,3 +35,16 @@ GSCompany.ChangeBankBalance <- function(company, delta, expenses_type) { return GSCompany._ChangeBankBalance(company, delta, expenses_type, GSMap.TILE_INVALID); } + +/* 13 really checks RoadType against RoadType */ +GSRoad._HasRoadType <- GSRoad.HasRoadType; +GSRoad.HasRoadType <- function(tile, road_type) +{ + local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (GSRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/game/compat_1.3.nut b/bin/game/compat_1.3.nut index 7546e54c69..9986ea03e5 100644 --- a/bin/game/compat_1.3.nut +++ b/bin/game/compat_1.3.nut @@ -35,3 +35,16 @@ GSCompany.ChangeBankBalance <- function(company, delta, expenses_type) { return GSCompany._ChangeBankBalance(company, delta, expenses_type, GSMap.TILE_INVALID); } + +/* 13 really checks RoadType against RoadType */ +GSRoad._HasRoadType <- GSRoad.HasRoadType; +GSRoad.HasRoadType <- function(tile, road_type) +{ + local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (GSRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/game/compat_1.4.nut b/bin/game/compat_1.4.nut index c90b3e550b..b3ec5c45cb 100644 --- a/bin/game/compat_1.4.nut +++ b/bin/game/compat_1.4.nut @@ -28,3 +28,15 @@ GSCompany.ChangeBankBalance <- function(company, delta, expenses_type) return GSCompany._ChangeBankBalance(company, delta, expenses_type, GSMap.TILE_INVALID); } +/* 13 really checks RoadType against RoadType */ +GSRoad._HasRoadType <- GSRoad.HasRoadType; +GSRoad.HasRoadType <- function(tile, road_type) +{ + local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (GSRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/game/compat_1.5.nut b/bin/game/compat_1.5.nut index 0c62e56462..2d25d7acf0 100644 --- a/bin/game/compat_1.5.nut +++ b/bin/game/compat_1.5.nut @@ -20,3 +20,16 @@ GSCompany.ChangeBankBalance <- function(company, delta, expenses_type) { return GSCompany._ChangeBankBalance(company, delta, expenses_type, GSMap.TILE_INVALID); } + +/* 13 really checks RoadType against RoadType */ +GSRoad._HasRoadType <- GSRoad.HasRoadType; +GSRoad.HasRoadType <- function(tile, road_type) +{ + local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (GSRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/game/compat_1.6.nut b/bin/game/compat_1.6.nut index 198b863a77..d205832209 100644 --- a/bin/game/compat_1.6.nut +++ b/bin/game/compat_1.6.nut @@ -20,3 +20,16 @@ GSCompany.ChangeBankBalance <- function(company, delta, expenses_type) { return GSCompany._ChangeBankBalance(company, delta, expenses_type, GSMap.TILE_INVALID); } + +/* 13 really checks RoadType against RoadType */ +GSRoad._HasRoadType <- GSRoad.HasRoadType; +GSRoad.HasRoadType <- function(tile, road_type) +{ + local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (GSRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/game/compat_1.7.nut b/bin/game/compat_1.7.nut index 76dc424353..1108f41a7c 100644 --- a/bin/game/compat_1.7.nut +++ b/bin/game/compat_1.7.nut @@ -20,3 +20,16 @@ GSCompany.ChangeBankBalance <- function(company, delta, expenses_type) { return GSCompany._ChangeBankBalance(company, delta, expenses_type, GSMap.TILE_INVALID); } + +/* 13 really checks RoadType against RoadType */ +GSRoad._HasRoadType <- GSRoad.HasRoadType; +GSRoad.HasRoadType <- function(tile, road_type) +{ + local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (GSRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/game/compat_1.8.nut b/bin/game/compat_1.8.nut index b9d27458a9..139f91214b 100644 --- a/bin/game/compat_1.8.nut +++ b/bin/game/compat_1.8.nut @@ -20,3 +20,16 @@ GSCompany.ChangeBankBalance <- function(company, delta, expenses_type) { return GSCompany._ChangeBankBalance(company, delta, expenses_type, GSMap.TILE_INVALID); } + +/* 13 really checks RoadType against RoadType */ +GSRoad._HasRoadType <- GSRoad.HasRoadType; +GSRoad.HasRoadType <- function(tile, road_type) +{ + local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (GSRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/game/compat_1.9.nut b/bin/game/compat_1.9.nut index 32eec114af..053e377d4c 100644 --- a/bin/game/compat_1.9.nut +++ b/bin/game/compat_1.9.nut @@ -13,3 +13,16 @@ GSCompany.ChangeBankBalance <- function(company, delta, expenses_type) { return GSCompany._ChangeBankBalance(company, delta, expenses_type, GSMap.TILE_INVALID); } + +/* 13 really checks RoadType against RoadType */ +GSRoad._HasRoadType <- GSRoad.HasRoadType; +GSRoad.HasRoadType <- function(tile, road_type) +{ + local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (GSRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/game/compat_12.nut b/bin/game/compat_12.nut index df08583914..a11cd04a23 100644 --- a/bin/game/compat_12.nut +++ b/bin/game/compat_12.nut @@ -6,3 +6,16 @@ */ GSLog.Info("12 API compatibility in effect."); + +/* 13 really checks RoadType against RoadType */ +GSRoad._HasRoadType <- GSRoad.HasRoadType; +GSRoad.HasRoadType <- function(tile, road_type) +{ + local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (GSRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/src/script/api/ai_changelog.hpp b/src/script/api/ai_changelog.hpp index f728ab18fe..1e014266a3 100644 --- a/src/script/api/ai_changelog.hpp +++ b/src/script/api/ai_changelog.hpp @@ -20,6 +20,9 @@ * \li AIIndustryType::ResolveNewGRFID * \li AIObjectType::ResolveNewGRFID * + * Other changes: + * \li AIRoad::HasRoadType now correctly checks RoadType against RoadType + * * \b 12.0 * * API additions: diff --git a/src/script/api/game_changelog.hpp b/src/script/api/game_changelog.hpp index 159671807d..91dd0d22f5 100644 --- a/src/script/api/game_changelog.hpp +++ b/src/script/api/game_changelog.hpp @@ -20,6 +20,9 @@ * \li GSIndustryType::ResolveNewGRFID * \li GSObjectType::ResolveNewGRFID * + * Other changes: + * \li GSRoad::HasRoadType now correctly checks RoadType against RoadType + * * \b 12.0 * * API additions: diff --git a/src/script/api/script_road.cpp b/src/script/api/script_road.cpp index 65ee83f5bb..20e38398de 100644 --- a/src/script/api/script_road.cpp +++ b/src/script/api/script_road.cpp @@ -98,7 +98,7 @@ { if (!ScriptMap::IsValidTile(tile)) return false; if (!IsRoadTypeAvailable(road_type)) return false; - return ::GetAnyRoadBits(tile, ::GetRoadTramType((::RoadType)road_type), false) != ROAD_NONE; + return ::MayHaveRoad(tile) && HasBit(::GetPresentRoadTypes(tile), (::RoadType)road_type); } /* static */ bool ScriptRoad::AreRoadTilesConnected(TileIndex t1, TileIndex t2)