Changeset - r12795:1614e6c8dece
[Not reviewed]
master
0 6 0
smatz - 15 years ago 2009-08-27 13:47:03
smatz@openttd.org
(svn r17293) -Fix [NoAI]: AITown::GetLastMonthTransported didn't work as documented at all, make it return what AITown::GetLastMonthProduction did
-Change [NoAI]: mark AITown::GetMaxProduction as deprecated, AITown::GetLastMonthProduction returns now the value GetMaxProduction did
6 files changed with 13 insertions and 32 deletions:
0 comments (0 inline, 0 general)
bin/ai/compat_0.7.nut
Show inline comments
 
@@ -69,3 +69,10 @@ AISubsidy.GetDestination <- function(sub
 

	
 
	return AISubsidy.GetDestinationIndex(subsidy_id);
 
}
 

	
 
AITown.GetMaxProduction <- function(town_id, cargo_id)
 
{
 
	AILog.Warning("AITown::GetMaxProduction is deprecated and will be removed soon, please use AITown::GetLastMonthProduction instead.");
 
	AILog.Warning("Also note that behaviour of AITown::GetLastMonthProduction has slightly changed.");
 
	return AITown.GetLastMonthProduction(town_id, cargo_id);
 
}
src/ai/api/ai_changelog.hpp
Show inline comments
 
@@ -35,6 +35,7 @@
 
 * \li AISubsidy::GetSource
 
 * \li AISubsidy::DestinationIsTown
 
 * \li AISubsidy::GetDestination
 
 * \li AITown::GetMaxProduction
 
 * \li AIWaypoint::WAYPOINT_INVALID
 
 *
 
 * Other changes:
src/ai/api/ai_station.cpp
Show inline comments
 
@@ -48,7 +48,7 @@
 
	if (!IsValidStation(station_id)) return -1;
 
	if (!AICargo::IsValidCargo(cargo_id)) return -1;
 

	
 
	return ::Station::Get(station_id)->goods[cargo_id].rating * 101 >> 8;
 
	return ::ToPercent8(::Station::Get(station_id)->goods[cargo_id].rating);
 
}
 

	
 
/* static */ int32 AIStation::GetCoverageRadius(AIStation::StationType station_type)
src/ai/api/ai_town.cpp
Show inline comments
 
@@ -72,8 +72,8 @@
 
	const Town *t = ::Town::Get(town_id);
 

	
 
	switch (AICargo::GetTownEffect(cargo_id)) {
 
		case AICargo::TE_PASSENGERS: return t->act_pass;
 
		case AICargo::TE_MAIL:       return t->act_mail;
 
		case AICargo::TE_PASSENGERS: return t->max_pass;
 
		case AICargo::TE_MAIL:       return t->max_mail;
 
		default: return -1;
 
	}
 
}
 
@@ -86,22 +86,8 @@
 
	const Town *t = ::Town::Get(town_id);
 

	
 
	switch (AICargo::GetTownEffect(cargo_id)) {
 
		case AICargo::TE_PASSENGERS: return t->pct_pass_transported;
 
		case AICargo::TE_MAIL:       return t->pct_mail_transported;
 
		default: return -1;
 
	}
 
}
 

	
 
/* static */ int32 AITown::GetMaxProduction(TownID town_id, CargoID cargo_id)
 
{
 
	if (!IsValidTown(town_id)) return -1;
 
	if (!AICargo::IsValidCargo(cargo_id)) return -1;
 

	
 
	const Town *t = ::Town::Get(town_id);
 

	
 
	switch (AICargo::GetTownEffect(cargo_id)) {
 
		case AICargo::TE_PASSENGERS: return t->max_pass;
 
		case AICargo::TE_MAIL:       return t->max_mail;
 
		case AICargo::TE_PASSENGERS: return t->act_pass;
 
		case AICargo::TE_MAIL:       return t->act_mail;
 
		default: return -1;
 
	}
 
}
src/ai/api/ai_town.hpp
Show inline comments
 
@@ -176,18 +176,6 @@ public:
 
	static int32 GetLastMonthTransported(TownID town_id, CargoID cargo_id);
 

	
 
	/**
 
	 * Get the maximum production of the given cargo at a town.
 
	 * @param town_id The index of the town.
 
	 * @param cargo_id The index of the cargo.
 
	 * @pre IsValidTown(town_id).
 
	 * @pre AICargo::IsValidCargo(cargo_id).
 
	 * @pre AICargo::GetTownEffect(cargo_id) == TE_PASSENGERS || AICargo::GetTownEffect(cargo_id) == TE_MAIL.
 
	 * @return The maximum production of the given cargo for this town.
 
	 * @post Return value is always non-negative.
 
	 */
 
	static int32 GetMaxProduction(TownID town_id, CargoID cargo_id);
 

	
 
	/**
 
	 * Get the manhattan distance from the tile to the AITown::GetLocation()
 
	 *  of the town.
 
	 * @param town_id The town to get the distance to.
src/ai/api/ai_town.hpp.sq
Show inline comments
 
@@ -65,7 +65,6 @@ void SQAITown_Register(Squirrel *engine)
 
	SQAITown.DefSQStaticMethod(engine, &AITown::GetLocation,                "GetLocation",                2, ".i");
 
	SQAITown.DefSQStaticMethod(engine, &AITown::GetLastMonthProduction,     "GetLastMonthProduction",     3, ".ii");
 
	SQAITown.DefSQStaticMethod(engine, &AITown::GetLastMonthTransported,    "GetLastMonthTransported",    3, ".ii");
 
	SQAITown.DefSQStaticMethod(engine, &AITown::GetMaxProduction,           "GetMaxProduction",           3, ".ii");
 
	SQAITown.DefSQStaticMethod(engine, &AITown::GetDistanceManhattanToTile, "GetDistanceManhattanToTile", 3, ".ii");
 
	SQAITown.DefSQStaticMethod(engine, &AITown::GetDistanceSquareToTile,    "GetDistanceSquareToTile",    3, ".ii");
 
	SQAITown.DefSQStaticMethod(engine, &AITown::IsWithinTownInfluence,      "IsWithinTownInfluence",      3, ".ii");
0 comments (0 inline, 0 general)