Add truncation warnings for Block masks

This commit is contained in:
GriffinR 2024-01-03 14:24:14 -05:00
parent 59f0d9fe11
commit a0069b6a3f

View file

@ -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<uint16_t>(it.value()));
it = defines.find(collisionMaskName);
if (it != defines.end())
projectConfig.setBlockCollisionMask(static_cast<uint16_t>(it.value()));
it = defines.find(elevationMaskName);
if (it != defines.end())
projectConfig.setBlockElevationMask(static_cast<uint16_t>(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<uint16_t>(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<uint32_t>(it.value()));
it = defines.find(layerTypeMaskName);