Changeset - r26435:b03b1a6191cb
[Not reviewed]
master
0 28 0
SamuXarick - 2 years ago 2022-06-26 19:49:08
43006711+SamuXarick@users.noreply.github.com
Fix: ScriptRoad::HasRoadType really check for RoadType

Script::HasRoadType was only checking if the tile had the same RoadTramType as that of the RoadType provided.
Now it really checks RoadType against RoadType.
28 files changed with 331 insertions and 1 deletions:
0 comments (0 inline, 0 general)
bin/ai/compat_0.7.nut
Show inline comments
 
@@ -379,3 +379,16 @@ AIGroup.CreateGroup <- function(vehicle_
 
{
 
	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;
 
}
bin/ai/compat_1.0.nut
Show inline comments
 
@@ -131,3 +131,16 @@ AIGroup.CreateGroup <- function(vehicle_
 
{
 
	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;
 
}
bin/ai/compat_1.1.nut
Show inline comments
 
@@ -68,3 +68,16 @@ AIGroup.CreateGroup <- function(vehicle_
 
{
 
	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;
 
}
bin/ai/compat_1.10.nut
Show inline comments
 
@@ -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;
 
}
bin/ai/compat_1.11.nut
Show inline comments
 
@@ -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;
 
}
bin/ai/compat_1.2.nut
Show inline comments
 
@@ -20,3 +20,16 @@ AIGroup.CreateGroup <- function(vehicle_
 
{
 
	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;
 
}
bin/ai/compat_1.3.nut
Show inline comments
 
@@ -20,3 +20,16 @@ AIGroup.CreateGroup <- function(vehicle_
 
{
 
	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;
 
}
bin/ai/compat_1.4.nut
Show inline comments
 
@@ -20,3 +20,16 @@ AIGroup.CreateGroup <- function(vehicle_
 
{
 
	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;
 
}
bin/ai/compat_1.5.nut
Show inline comments
 
@@ -20,3 +20,16 @@ AIGroup.CreateGroup <- function(vehicle_
 
{
 
	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;
 
}
bin/ai/compat_1.6.nut
Show inline comments
 
@@ -20,3 +20,16 @@ AIGroup.CreateGroup <- function(vehicle_
 
{
 
	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;
 
}
bin/ai/compat_1.7.nut
Show inline comments
 
@@ -20,3 +20,16 @@ AIGroup.CreateGroup <- function(vehicle_
 
{
 
	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;
 
}
bin/ai/compat_1.8.nut
Show inline comments
 
@@ -20,3 +20,16 @@ AIGroup.CreateGroup <- function(vehicle_
 
{
 
	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;
 
}
bin/ai/compat_1.9.nut
Show inline comments
 
@@ -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;
 
}
bin/ai/compat_12.nut
Show inline comments
 
@@ -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;
 
}
bin/game/compat_1.10.nut
Show inline comments
 
@@ -13,3 +13,16 @@ GSCompany.ChangeBankBalance <- function(
 
{
 
	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;
 
}
bin/game/compat_1.11.nut
Show inline comments
 
@@ -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;
 
}
bin/game/compat_1.2.nut
Show inline comments
 
@@ -35,3 +35,16 @@ GSCompany.ChangeBankBalance <- function(
 
{
 
	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;
 
}
bin/game/compat_1.3.nut
Show inline comments
 
@@ -35,3 +35,16 @@ GSCompany.ChangeBankBalance <- function(
 
{
 
	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;
 
}
bin/game/compat_1.4.nut
Show inline comments
 
@@ -28,3 +28,15 @@ GSCompany.ChangeBankBalance <- function(
 
	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;
 
}
bin/game/compat_1.5.nut
Show inline comments
 
@@ -20,3 +20,16 @@ GSCompany.ChangeBankBalance <- function(
 
{
 
	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;
 
}
bin/game/compat_1.6.nut
Show inline comments
 
@@ -20,3 +20,16 @@ GSCompany.ChangeBankBalance <- function(
 
{
 
	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;
 
}
bin/game/compat_1.7.nut
Show inline comments
 
@@ -20,3 +20,16 @@ GSCompany.ChangeBankBalance <- function(
 
{
 
	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;
 
}
bin/game/compat_1.8.nut
Show inline comments
 
@@ -20,3 +20,16 @@ GSCompany.ChangeBankBalance <- function(
 
{
 
	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;
 
}
bin/game/compat_1.9.nut
Show inline comments
 
@@ -13,3 +13,16 @@ GSCompany.ChangeBankBalance <- function(
 
{
 
	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;
 
}
bin/game/compat_12.nut
Show inline comments
 
@@ -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;
 
}
src/script/api/ai_changelog.hpp
Show inline comments
 
@@ -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:
src/script/api/game_changelog.hpp
Show inline comments
 
@@ -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:
src/script/api/script_road.cpp
Show inline comments
 
@@ -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)
0 comments (0 inline, 0 general)