File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -88,7 +88,17 @@ Rect TMXTilesetInfo::getRectForGID(uint32_t gid)
8888 // max_x = (int)((_imageSize.width - _margin*2 + _spacing) / (_tileSize.width + _spacing));
8989 // but in editor "Tiled", _margin variable only effect the left side
9090 // for compatible with "Tiled", change the max_x calculation
91+ if ((_tileSize.width + _spacing) == 0 )
92+ {
93+ AXLOGE (" TMXTilesetInfo::getRectForGID - invalid tile size or spacing (width + spacing == 0)" );
94+ return rect;
95+ }
9196 int max_x = (int )((_imageSize.width - _margin + _spacing) / (_tileSize.width + _spacing));
97+ if (max_x == 0 )
98+ {
99+ AXLOGE (" TMXTilesetInfo::getRectForGID - invalid tileset layout (calculated column count == 0)" );
100+ return rect;
101+ }
92102
93103 rect.origin .x = (gid % max_x) * (_tileSize.width + _spacing) + _margin;
94104 rect.origin .y = (gid / max_x) * (_tileSize.height + _spacing) + _margin;
You can’t perform that action at this time.
0 commit comments