From 8de209f707b6064a4f8f80b7b2772ca444978f53 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Wed, 2 Feb 2011 17:43:36 +0000 Subject: [PATCH] Fix a crash caused by potential code/data discrepancies. --- src/tileset.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/tileset.cpp b/src/tileset.cpp index 98ab57cb..78e0ebe6 100644 --- a/src/tileset.cpp +++ b/src/tileset.cpp @@ -82,9 +82,8 @@ TileSet::TileSet(char const *path, int w, int h, float dilate) data->w = w; data->h = h; data->dilate = dilate; - /* FIXME: check for non-zero here */ - data->nw = data->img->w / w; - data->nh = data->img->h / h; + data->nw = data->img->w > w ? data->img->w / w : 1; + data->nh = data->img->h > h ? data->img->h / h : 1; data->ntiles = data->nw * data->nh; data->tx = (float)w / PotUp(data->img->w); data->ty = (float)h / PotUp(data->img->h);