(svn r17113) -Change [FS#265][FS#2094][FS#2589]: apply the subsidy when subsidy's destination is in station's catchment area and cargo packets originate from subsidy's source
-Change [FS#1134]: subsidies aren't bound to stations after awarding anymore, they still apply to town or industry, no matter what station is used for loading and unloading. Awarded subsidies from older savegames are lost -Change [NoAI]: due to these changes, AISubsidy::GetSource and AISubsidy::GetDestination now return STATION_INVALID for awarded subsidies
This commit is contained in:
@@ -29,6 +29,8 @@
|
||||
* \li WaypointID was replaced by StationID. All WaypointIDs from previous
|
||||
* savegames are invalid
|
||||
* \li WAYPOINT_INVALID is now deprecated, use STATION_INVALID instead
|
||||
* \li AISubsidy::GetSource and AISubsidy::GetDestination return STATION_INVALID
|
||||
* for awarded subsidies
|
||||
* \li AIs can create subclasses of API classes and use API constants as part
|
||||
* of their own constants
|
||||
* \li AIVehicleList_Station now also works for waypoints
|
||||
|
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "ai_subsidy.hpp"
|
||||
#include "ai_date.hpp"
|
||||
#include "ai_log.hpp"
|
||||
#include "../../subsidy_base.h"
|
||||
#include "../../station_base.h"
|
||||
#include "../../cargotype.h"
|
||||
@@ -24,7 +25,7 @@
|
||||
{
|
||||
if (!IsAwarded(subsidy_id)) return AICompany::COMPANY_INVALID;
|
||||
|
||||
return (AICompany::CompanyID)((byte)::Station::Get(::Subsidy::Get(subsidy_id)->src)->owner);
|
||||
return (AICompany::CompanyID)((byte)::Subsidy::Get(subsidy_id)->awarded);
|
||||
}
|
||||
|
||||
/* static */ int32 AISubsidy::GetExpireDate(SubsidyID subsidy_id)
|
||||
@@ -34,11 +35,7 @@
|
||||
int year = AIDate::GetYear(AIDate::GetCurrentDate());
|
||||
int month = AIDate::GetMonth(AIDate::GetCurrentDate());
|
||||
|
||||
if (IsAwarded(subsidy_id)) {
|
||||
month += 24 - ::Subsidy::Get(subsidy_id)->age;
|
||||
} else {
|
||||
month += 12 - ::Subsidy::Get(subsidy_id)->age;
|
||||
}
|
||||
month += ::Subsidy::Get(subsidy_id)->remaining;
|
||||
|
||||
year += (month - 1) / 12;
|
||||
month = ((month - 1) % 12) + 1;
|
||||
@@ -64,6 +61,11 @@
|
||||
{
|
||||
if (!IsValidSubsidy(subsidy_id)) return INVALID_STATION;
|
||||
|
||||
if (IsAwarded(subsidy_id)) {
|
||||
AILog::Error("AISubsidy::GetSource returned INVALID_STATION due to internal changes in the Subsidy logic.");
|
||||
return INVALID_STATION;
|
||||
}
|
||||
|
||||
return ::Subsidy::Get(subsidy_id)->src;
|
||||
}
|
||||
|
||||
@@ -78,5 +80,10 @@
|
||||
{
|
||||
if (!IsValidSubsidy(subsidy_id)) return INVALID_STATION;
|
||||
|
||||
if (IsAwarded(subsidy_id)) {
|
||||
AILog::Error("AISubsidy::GetDestination returned INVALID_STATION due to internal changes in the Subsidy logic.");
|
||||
return INVALID_STATION;
|
||||
}
|
||||
|
||||
return ::Subsidy::Get(subsidy_id)->dst;
|
||||
}
|
||||
|
@@ -69,12 +69,12 @@ public:
|
||||
|
||||
/**
|
||||
* Return the source TownID/IndustryID/StationID the subsidy is for.
|
||||
* 1) IsAwarded(subsidy_id) -> return the StationID the subsidy is awarded to.
|
||||
* 2) !IsAwarded(subsidy_id) && SourceIsTown(subsidy_id) -> return the TownID.
|
||||
* 3) !IsAwarded(subsidy_id) && !SourceIsTown(subsidy_id) -> return the IndustryID.
|
||||
* \li IsAwarded(subsidy_id) -> return INVALID_STATION.
|
||||
* \li !IsAwarded(subsidy_id) && SourceIsTown(subsidy_id) -> return the TownID.
|
||||
* \li !IsAwarded(subsidy_id) && !SourceIsTown(subsidy_id) -> return the IndustryID.
|
||||
* @param subsidy_id The SubsidyID to check.
|
||||
* @pre IsValidSubsidy(subsidy_id).
|
||||
* @return One of TownID/IndustryID/StationID.
|
||||
* @return One of TownID/IndustryID/INVALID_STATION.
|
||||
*/
|
||||
static int32 GetSource(SubsidyID subsidy_id);
|
||||
|
||||
@@ -88,12 +88,12 @@ public:
|
||||
|
||||
/**
|
||||
* Return the destination TownID/IndustryID/StationID the subsidy is for.
|
||||
* 1) IsAwarded(subsidy_id) -> return the StationID the subsidy is awarded to.
|
||||
* 2) !IsAwarded(subsidy_id) && SourceIsTown(subsidy_id) -> return the TownID.
|
||||
* 3) !IsAwarded(subsidy_id) && !SourceIsTown(subsidy_id) -> return the IndustryID.
|
||||
* \li IsAwarded(subsidy_id) -> return INVALID_STATION.
|
||||
* \li !IsAwarded(subsidy_id) && DestinationIsTown(subsidy_id) -> return the TownID.
|
||||
* \li !IsAwarded(subsidy_id) && !DestinationIsTown(subsidy_id) -> return the IndustryID.
|
||||
* @param subsidy_id the SubsidyID to check.
|
||||
* @pre IsValidSubsidy(subsidy_id).
|
||||
* @return One of TownID/IndustryID/StationID.
|
||||
* @return One of TownID/IndustryID/INVALID_STATION.
|
||||
*/
|
||||
static int32 GetDestination(SubsidyID subsidy_id);
|
||||
};
|
||||
|
Reference in New Issue
Block a user