diff options
author | smatz <smatz@openttd.org> | 2008-12-26 19:37:50 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2008-12-26 19:37:50 +0000 |
commit | 7fbd5beb0f92c6f53b4b8d9206773003328b2e7d (patch) | |
tree | d4bd34c6215ede747794b7a5273d6a5c6d3390c8 /src/disaster_cmd.cpp | |
parent | 047e40d33ff1b5b0d407dda7e73d34430e268494 (diff) | |
download | openttd-7fbd5beb0f92c6f53b4b8d9206773003328b2e7d.tar.xz |
(svn r14746) -Fix: don't let any disaster vehicle (Helicopter or Airplane) target invalid industry
Diffstat (limited to 'src/disaster_cmd.cpp')
-rw-r--r-- | src/disaster_cmd.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/disaster_cmd.cpp b/src/disaster_cmd.cpp index 36c365d11..910918f8c 100644 --- a/src/disaster_cmd.cpp +++ b/src/disaster_cmd.cpp @@ -1063,6 +1063,22 @@ void StartupDisasters() ResetDisasterDelay(); } +/** Marks all disasters targeting this industry in such a way + * they won't call GetIndustry(v->dest_tile) on invalid industry anymore. + * @param i deleted industry + */ +void ReleaseDisastersTargetingIndustry(IndustryID i) +{ + Vehicle *v; + FOR_ALL_VEHICLES(v) { + /* primary disaster vehicles that have chosen target */ + if (v->type == VEH_DISASTER && (v->subtype == ST_Airplane || v->subtype == ST_Helicopter)) { + /* if it has chosen target, and it is this industry (yes, dest_tile is IndustryID here), set order to "leaving map peacefully" */ + if (v->current_order.GetDestination() > 0 && v->dest_tile == i) v->current_order.SetDestination(3); + } + } +} + void DisasterVehicle::UpdateDeltaXY(Direction direction) { this->x_offs = -1; |