Commits

Lars Viklund committed cda29e0

Reject files larger than requested tileset dimension

Comments (0)

Files changed (1)

Katla/src/layout.cc

         bool validFile = !! stbi_info(info.filename.c_str(), &info.width, &info.height, &info.channels);
         if (validFile)
         {
+            if (info.width > input.maxDimension)
+            {
+                std::cerr << "File \"" << info.filename << "\" has dimensions "
+                    << info.width << "x" << info.height << " incompatible with maximum extent "
+                    << input.maxDimension << ", skipping it." << std::endl;
+                continue;
+            }
             input.imageInfos.push_back(info);
         }
         else
         {
             TilemapDesc desc;
             Page const& page = dims[p];
-            sprintf(buf, "-%dx%d-%dch-%d", w, h, ch, p+1);
+            sprintf(buf, "-%dx%d-%dch-%d", w, h, ch, (int)p+1);
             desc.filename = input.tilemapBasename + buf + ".png";
             desc.width = page.xCount * w;
             desc.height = page.yCount * h;