Changeset - r10491:e3e4bb1ebaea
[Not reviewed]
master
0 3 0
smatz - 15 years ago 2008-12-26 19:37:50
smatz@openttd.org
(svn r14746) -Fix: don't let any disaster vehicle (Helicopter or Airplane) target invalid industry
3 files changed with 21 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/disaster_cmd.cpp
Show inline comments
 
@@ -1060,12 +1060,28 @@ void DisasterDailyLoop()
 

	
 
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;
 
	this->y_offs        = -1;
 
	this->x_extent      =  2;
 
	this->y_extent      =  2;
src/industry.h
Show inline comments
 
@@ -235,12 +235,14 @@ struct IndustryTileSpec {
 
/* industry_cmd.cpp*/
 
const IndustrySpec *GetIndustrySpec(IndustryType thistype);    ///< Array of industries data
 
const IndustryTileSpec *GetIndustryTileSpec(IndustryGfx gfx);  ///< Array of industry tiles data
 
void ResetIndustries();
 
void PlantRandomFarmField(const Industry *i);
 

	
 
void ReleaseDisastersTargetingIndustry(IndustryID);
 

	
 
/* writable arrays of specs */
 
extern IndustrySpec _industry_specs[NUM_INDUSTRYTYPES];
 
extern IndustryTileSpec _industry_tile_specs[NUM_INDUSTRYTILES];
 

	
 
static inline IndustryGfx GetTranslatedIndustryTileID(IndustryGfx gfx)
 
{
src/industry_cmd.cpp
Show inline comments
 
@@ -163,12 +163,15 @@ Industry::~Industry()
 
					GetIndustryIndexOfField(tile_cur) == this->index) {
 
				SetIndustryIndexOfField(tile_cur, INVALID_INDUSTRY);
 
			}
 
		} END_TILE_LOOP(tile_cur, 42, 42, this->xy - TileDiff(21, 21))
 
	}
 

	
 
	/* don't let any disaster vehicle target invalid industry */
 
	ReleaseDisastersTargetingIndustry(this->index);
 

	
 
	DecIndustryTypeCount(this->type);
 

	
 
	DeleteSubsidyWithIndustry(this->index);
 
	DeleteWindowById(WC_INDUSTRY_VIEW, this->index);
 
	InvalidateWindowData(WC_INDUSTRY_DIRECTORY, 0, 0);
 
	this->xy = 0;
0 comments (0 inline, 0 general)