Changeset - r7216:15c27d8bad4a
[Not reviewed]
master
0 3 0
rubidium - 17 years ago 2007-07-09 20:08:25
rubidium@openttd.org
(svn r10494) -Fix (r10490): possible null dereference in some exotic newgrfs.
3 files changed with 8 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/industry_cmd.cpp
Show inline comments
 
@@ -1188,13 +1188,13 @@ static bool CheckIfIndustryTilesAreFree(
 

	
 
			const IndustryTileSpec *its = GetIndustryTileSpec(it->gfx);
 
			IndustyBehaviour ind_behav = GetIndustrySpec(type)->behaviour;
 

	
 
			if (HASBIT(its->callback_flags, CBM_INDT_SHAPE_CHECK)) {
 
				if (custom_shape_check != NULL) *custom_shape_check = true;
 
				if (!PerformIndustryTileSlopeCheck(cur_tile, its, it->gfx)) return false;
 
				if (!PerformIndustryTileSlopeCheck(cur_tile, its, type, it->gfx)) return false;
 
			} else {
 
				if (ind_behav & INDUSTRYBEH_BUILT_ONWATER) {
 
					/* As soon as the tile is not water, bail out.
 
					* But that does not mean the search is over.  You have
 
					* to make sure every tile of the industry will be only water*/
 
					if (!IsClearWaterTile(cur_tile)) return false;
src/newgrf_industrytiles.cpp
Show inline comments
 
@@ -226,15 +226,19 @@ bool DrawNewIndustryTile(TileInfo *ti, I
 
		stage = clamp(stage - 4 + group->g.layout.num_sprites, 0, group->g.layout.num_sprites - 1);
 
		IndustryDrawTileLayout(ti, group, i->random_color, stage, gfx);
 
		return true;
 
	}
 
}
 

	
 
bool PerformIndustryTileSlopeCheck(TileIndex tile, const IndustryTileSpec *its, IndustryGfx gfx)
 
bool PerformIndustryTileSlopeCheck(TileIndex tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx)
 
{
 
	uint16 callback_res = GetIndustryTileCallback(CBID_INDTILE_SHAPE_CHECK, 0, 0, gfx, NULL, tile);
 
	Industry ind;
 
	ind.xy = 0;
 
	ind.type = type;
 

	
 
	uint16 callback_res = GetIndustryTileCallback(CBID_INDTILE_SHAPE_CHECK, 0, 0, gfx, &ind, tile);
 
	if (its->grf_prop.grffile->grf_version < 7) {
 
		return callback_res != 0;
 
	}
 
	if (callback_res != CALLBACK_FAILED) return true;
 

	
 
	switch (callback_res) {
src/newgrf_industrytiles.h
Show inline comments
 
@@ -4,9 +4,9 @@
 

	
 
#ifndef NEWGRF_INDUSTRYTILES_H
 
#define NEWGRF_INDUSTRYTILES_H
 

	
 
bool DrawNewIndustryTile(TileInfo *ti, Industry *i, IndustryGfx gfx, const IndustryTileSpec *inds);
 
uint16 GetIndustryTileCallback(uint16 callback, uint32 param1, uint32 param2, IndustryGfx gfx_id, Industry *industry, TileIndex tile);
 
bool PerformIndustryTileSlopeCheck(TileIndex tile, const IndustryTileSpec *its, IndustryGfx gfx);
 
bool PerformIndustryTileSlopeCheck(TileIndex tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx);
 

	
 
#endif /* NEWGRF_INDUSTRYTILES_H */
0 comments (0 inline, 0 general)