summaryrefslogtreecommitdiff
path: root/economy.c
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2006-12-26 15:28:11 +0000
committerrubidium <rubidium@openttd.org>2006-12-26 15:28:11 +0000
commitc140ca6f200e48444ccec4320067dd91165d98f0 (patch)
treed978822803398fab14cfb710a8ad0fa321cc8a3b /economy.c
parentb58c90a07539a15f3f05c5b11ca3bb5ebdda5fe8 (diff)
downloadopenttd-c140ca6f200e48444ccec4320067dd91165d98f0.tar.xz
(svn r7563) -Fix (FS#468): removing towns in the scenario editor could leave subsidies with that town as source/destination, resulting in an assertion when displaying the Subsidies Window.
Diffstat (limited to 'economy.c')
-rw-r--r--economy.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/economy.c b/economy.c
index 97fc55c0d..8839d7db1 100644
--- a/economy.c
+++ b/economy.c
@@ -848,6 +848,19 @@ Pair SetupSubsidyDecodeParam(const Subsidy* s, bool mode)
return tp;
}
+void DeleteSubsidyWithTown(TownID index)
+{
+ Subsidy *s;
+
+ for (s = _subsidies; s != endof(_subsidies); s++) {
+ if (s->cargo_type != CT_INVALID && s->age < 12 &&
+ (((s->cargo_type == CT_PASSENGERS || s->cargo_type == CT_MAIL) && (index == s->from || index == s->to)) ||
+ ((s->cargo_type == CT_GOODS || s->cargo_type == CT_FOOD) && index == s->to))) {
+ s->cargo_type = CT_INVALID;
+ }
+ }
+}
+
void DeleteSubsidyWithIndustry(IndustryID index)
{
Subsidy *s;
@@ -855,7 +868,7 @@ void DeleteSubsidyWithIndustry(IndustryID index)
for (s = _subsidies; s != endof(_subsidies); s++) {
if (s->cargo_type != CT_INVALID && s->age < 12 &&
s->cargo_type != CT_PASSENGERS && s->cargo_type != CT_MAIL &&
- (index == s->from || (s->cargo_type!=CT_GOODS && s->cargo_type!=CT_FOOD && index==s->to))) {
+ (index == s->from || (s->cargo_type != CT_GOODS && s->cargo_type != CT_FOOD && index == s->to))) {
s->cargo_type = CT_INVALID;
}
}