diff --git a/src/project.cpp b/src/project.cpp index 3370dacd..475512ff 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -1977,18 +1977,29 @@ bool Project::readFieldmapMasks() { projectConfig.setSaveDisabled(true); // Read Block masks - auto it = defines.find(metatileIdMaskName); - if (it != defines.end()) - projectConfig.setBlockMetatileIdMask(static_cast(it.value())); - it = defines.find(collisionMaskName); - if (it != defines.end()) - projectConfig.setBlockCollisionMask(static_cast(it.value())); - it = defines.find(elevationMaskName); - if (it != defines.end()) - projectConfig.setBlockElevationMask(static_cast(it.value())); + auto readBlockMask = [defines](const QString name, uint16_t *value) { + auto it = defines.find(name); + if (it == defines.end()) + return false; + *value = static_cast(it.value()); + if (*value != it.value()){ + logWarn(QString("Value for %1 truncated from '0x%2' to '0x%3'") + .arg(name) + .arg(QString::number(it.value(), 16).toUpper()) + .arg(QString::number(*value, 16).toUpper())); + } + return true; + }; + uint16_t blockMask; + if (readBlockMask(metatileIdMaskName, &blockMask)) + projectConfig.setBlockMetatileIdMask(blockMask); + if (readBlockMask(collisionMaskName, &blockMask)) + projectConfig.setBlockCollisionMask(blockMask); + if (readBlockMask(elevationMaskName, &blockMask)) + projectConfig.setBlockElevationMask(blockMask); // Read RSE metatile attribute masks - it = defines.find(behaviorMaskName); + auto it = defines.find(behaviorMaskName); if (it != defines.end()) projectConfig.setMetatileBehaviorMask(static_cast(it.value())); it = defines.find(layerTypeMaskName);