|
@@ -54,13 +54,13 @@ void InitializeSubsidies()
|
|
|
Pair SetupSubsidyDecodeParam(const Subsidy *s, bool mode)
|
|
|
{
|
|
|
NewsReferenceType reftype1 = NR_NONE;
|
|
|
NewsReferenceType reftype2 = NR_NONE;
|
|
|
|
|
|
/* if mode is false, use the singular form */
|
|
|
const CargoSpec *cs = GetCargo(s->cargo_type);
|
|
|
const CargoSpec *cs = CargoSpec::Get(s->cargo_type);
|
|
|
SetDParam(0, mode ? cs->name : cs->name_single);
|
|
|
|
|
|
if (s->age < 12) {
|
|
|
if (cs->town_effect != TE_PASSENGERS && cs->town_effect != TE_MAIL) {
|
|
|
SetDParam(1, STR_INDUSTRY);
|
|
|
SetDParam(2, s->from);
|
|
@@ -100,13 +100,13 @@ Pair SetupSubsidyDecodeParam(const Subsi
|
|
|
|
|
|
void DeleteSubsidyWithTown(TownID index)
|
|
|
{
|
|
|
Subsidy *s;
|
|
|
FOR_ALL_SUBSIDIES(s) {
|
|
|
if (s->age < 12) {
|
|
|
const CargoSpec *cs = GetCargo(s->cargo_type);
|
|
|
const CargoSpec *cs = CargoSpec::Get(s->cargo_type);
|
|
|
if (((cs->town_effect == TE_PASSENGERS || cs->town_effect == TE_MAIL) && (index == s->from || index == s->to)) ||
|
|
|
((cs->town_effect == TE_GOODS || cs->town_effect == TE_FOOD) && index == s->to)) {
|
|
|
s->cargo_type = CT_INVALID;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -114,13 +114,13 @@ void DeleteSubsidyWithTown(TownID index)
|
|
|
|
|
|
void DeleteSubsidyWithIndustry(IndustryID index)
|
|
|
{
|
|
|
Subsidy *s;
|
|
|
FOR_ALL_SUBSIDIES(s) {
|
|
|
if (s->age < 12) {
|
|
|
const CargoSpec *cs = GetCargo(s->cargo_type);
|
|
|
const CargoSpec *cs = CargoSpec::Get(s->cargo_type);
|
|
|
if (cs->town_effect != TE_PASSENGERS && cs->town_effect != TE_MAIL &&
|
|
|
(index == s->from || (cs->town_effect != TE_GOODS && cs->town_effect != TE_FOOD && index == s->to))) {
|
|
|
s->cargo_type = CT_INVALID;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -189,13 +189,13 @@ static void FindSubsidyCargoRoute(FoundR
|
|
|
|
|
|
/* Quit if no production in this industry
|
|
|
* or if the cargo type is passengers
|
|
|
* or if the pct transported is already large enough */
|
|
|
if (total == 0 || trans > 42 || cargo == CT_INVALID) return;
|
|
|
|
|
|
const CargoSpec *cs = GetCargo(cargo);
|
|
|
const CargoSpec *cs = CargoSpec::Get(cargo);
|
|
|
if (cs->town_effect == TE_PASSENGERS) return;
|
|
|
|
|
|
fr->cargo = cargo;
|
|
|
|
|
|
if (cs->town_effect == TE_GOODS || cs->town_effect == TE_FOOD) {
|
|
|
/* The destination is a town */
|
|
@@ -284,13 +284,13 @@ void SubsidyMonthlyLoop()
|
|
|
}
|
|
|
FindSubsidyCargoRoute(&fr);
|
|
|
if (fr.distance <= 70) {
|
|
|
s->cargo_type = fr.cargo;
|
|
|
s->from = ((Industry*)fr.from)->index;
|
|
|
{
|
|
|
const CargoSpec *cs = GetCargo(fr.cargo);
|
|
|
const CargoSpec *cs = CargoSpec::Get(fr.cargo);
|
|
|
s->to = (cs->town_effect == TE_GOODS || cs->town_effect == TE_FOOD) ? ((Town*)fr.to)->index : ((Industry*)fr.to)->index;
|
|
|
}
|
|
|
add_subsidy:
|
|
|
if (!CheckSubsidyDuplicate(s)) {
|
|
|
s->age = 0;
|
|
|
Pair reftype = SetupSubsidyDecodeParam(s, 0);
|
|
@@ -323,13 +323,13 @@ bool CheckSubsidised(const Station *from
|
|
|
}
|
|
|
|
|
|
/* check if there's a new subsidy that applies.. */
|
|
|
FOR_ALL_SUBSIDIES(s) {
|
|
|
if (s->cargo_type == cargo_type && s->age < 12) {
|
|
|
/* Check distance from source */
|
|
|
const CargoSpec *cs = GetCargo(cargo_type);
|
|
|
const CargoSpec *cs = CargoSpec::Get(cargo_type);
|
|
|
if (cs->town_effect == TE_PASSENGERS || cs->town_effect == TE_MAIL) {
|
|
|
xy = Town::Get(s->from)->xy;
|
|
|
} else {
|
|
|
xy = Industry::Get(s->from)->xy;
|
|
|
}
|
|
|
if (DistanceMax(xy, from->xy) > 9) continue;
|