summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-07-09 20:08:25 +0000
committerrubidium <rubidium@openttd.org>2007-07-09 20:08:25 +0000
commit09eb6623ab6d8750dc08111ecbd3e20fc1bfc06b (patch)
tree12fc144dcff919b030af8acc977d785bd29ebf48 /src
parentb876be00646fabe692fbfd2f40b2e4e738fa8627 (diff)
downloadopenttd-09eb6623ab6d8750dc08111ecbd3e20fc1bfc06b.tar.xz
(svn r10494) -Fix (r10490): possible null dereference in some exotic newgrfs.
Diffstat (limited to 'src')
-rw-r--r--src/industry_cmd.cpp2
-rw-r--r--src/newgrf_industrytiles.cpp8
-rw-r--r--src/newgrf_industrytiles.h2
3 files changed, 8 insertions, 4 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 9fa957d03..3bc22d45b 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -1191,7 +1191,7 @@ static bool CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTileTable
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.
diff --git a/src/newgrf_industrytiles.cpp b/src/newgrf_industrytiles.cpp
index 75e61f6ba..77993eafa 100644
--- a/src/newgrf_industrytiles.cpp
+++ b/src/newgrf_industrytiles.cpp
@@ -229,9 +229,13 @@ bool DrawNewIndustryTile(TileInfo *ti, Industry *i, IndustryGfx gfx, const Indus
}
}
-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;
}
diff --git a/src/newgrf_industrytiles.h b/src/newgrf_industrytiles.h
index 9495aa202..16321217b 100644
--- a/src/newgrf_industrytiles.h
+++ b/src/newgrf_industrytiles.h
@@ -7,6 +7,6 @@
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 */