| 202 | |
| 203 | |
| 204 | static void processTileImport(FScanner& sc, const char* cmd, FScriptPosition& pos, TileImport& imp) |
| 205 | { |
| 206 | if (!ValidateTilenum(cmd, imp.tile, pos)) |
| 207 | return; |
| 208 | |
| 209 | auto tex = tbuild->tile[imp.tile].tileimage; |
| 210 | if (imp.crc32 != INT64_MAX && int(imp.crc32) != tileGetCRC32(tex)) |
| 211 | return; |
| 212 | |
| 213 | if (imp.sizex != INT_MAX) |
| 214 | { |
| 215 | // the size must match the previous tile |
| 216 | if (!tex) |
| 217 | { |
| 218 | if (imp.sizex != 0 || imp.sizey != 0) return; |
| 219 | } |
| 220 | else |
| 221 | { |
| 222 | if (tex->GetWidth() != imp.sizex || tex->GetHeight() != imp.sizey) return; |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | imp.alphacut = clamp(imp.alphacut, 0, 255); |
| 227 | |
| 228 | if (imp.fn.IsNotEmpty() && tileImportFromTexture(sc, imp.fn.GetChars(), imp.tile, imp.alphacut, imp.istexture) < 0) return; |
| 229 | |
| 230 | tbuild->tile[imp.tile].extinfo.picanm.sf |= imp.flags; |
| 231 | if (imp.surface != INT_MAX) tbuild->tile[imp.tile].extinfo.surftype = imp.surface; |
| 232 | if (imp.shade != INT_MAX) tbuild->tile[imp.tile].extinfo.tileshade = imp.shade; |
| 233 | |
| 234 | // This is not quite the same as originally, for two reasons: |
| 235 | // 1: Since these are texture properties now, there's no need to clear them. |
| 236 | // 2: The original code assumed that an imported texture cannot have an offset. But this can import Doom patches and PNGs with grAb, so the situation is very different. |
| 237 | auto itex = tbuild->tile[imp.tile].imported; |
| 238 | |
| 239 | if (imp.xoffset == INT_MAX) imp.xoffset = itex->GetTexelLeftOffset(); |
| 240 | else imp.xoffset = clamp(imp.xoffset, -128, 127); |
| 241 | if (imp.yoffset == INT_MAX) imp.yoffset = itex->GetTexelTopOffset(); |
| 242 | else imp.yoffset = clamp(imp.yoffset, -128, 127); |
| 243 | tbuild->tile[imp.tile].leftOffset = imp.xoffset; |
| 244 | tbuild->tile[imp.tile].topOffset = imp.yoffset; |
| 245 | if (imp.extra != INT_MAX) tbuild->tile[imp.tile].extinfo.picanm.extra = imp.extra; |
| 246 | } |
| 247 | |
| 248 | //=========================================================================== |
| 249 | // |
no test coverage detected