(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
replace/41b28d7194a279bdc17475d4fbe2ea6ec885a466
smatz 15 years ago
parent 100ae8efcc
commit 072ce4bb17

@ -69,3 +69,10 @@ AISubsidy.GetDestination <- function(subsidy_id)
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);
}

@ -35,6 +35,7 @@
* \li AISubsidy::GetSource
* \li AISubsidy::DestinationIsTown
* \li AISubsidy::GetDestination
* \li AITown::GetMaxProduction
* \li AIWaypoint::WAYPOINT_INVALID
*
* Other changes:

@ -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)

@ -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;
}
}

@ -175,18 +175,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.

@ -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");

Loading…
Cancel
Save