mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-05-16 23:11:42 +00:00
Fix LMAP parsing and don't resolve till after ptr is ready.
This commit is contained in:
@@ -32,13 +32,10 @@ namespace
|
||||
auto* lightDef = m_memory.Alloc<GfxLightDef>();
|
||||
lightDef->name = m_memory.Dup(assetName.c_str());
|
||||
|
||||
context.GetZoneAssetCreationState<LightDefAssetCreationState>().SetLightDefLookupStart(lightDef, context);
|
||||
|
||||
AssetRegistration<AssetLightDef> registration(assetName, lightDef);
|
||||
|
||||
std::string imageName;
|
||||
int8_t samplerState;
|
||||
int8_t lmapLookupStart;
|
||||
file.m_stream->read(reinterpret_cast<char*>(&samplerState), sizeof(int8_t));
|
||||
std::getline(*file.m_stream, imageName, '\0');
|
||||
|
||||
@@ -53,6 +50,8 @@ namespace
|
||||
lightDef->attenuation.samplerState = samplerState;
|
||||
lightDef->attenuation.image = imageDependency->Asset();
|
||||
|
||||
context.GetZoneAssetCreationState<LightDefAssetCreationState>().SetLightDefLookupStart(lightDef, context);
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
||||
}
|
||||
|
||||
|
||||
@@ -32,13 +32,10 @@ namespace
|
||||
auto* lightDef = m_memory.Alloc<GfxLightDef>();
|
||||
lightDef->name = m_memory.Dup(assetName.c_str());
|
||||
|
||||
context.GetZoneAssetCreationState<LightDefAssetCreationState>().SetLightDefLookupStart(lightDef, context);
|
||||
|
||||
AssetRegistration<AssetLightDef> registration(assetName, lightDef);
|
||||
|
||||
std::string imageName;
|
||||
int8_t samplerState;
|
||||
int8_t lmapLookupStart;
|
||||
file.m_stream->read(reinterpret_cast<char*>(&samplerState), sizeof(int8_t));
|
||||
std::getline(*file.m_stream, imageName, '\0');
|
||||
|
||||
@@ -52,7 +49,8 @@ namespace
|
||||
|
||||
lightDef->attenuation.samplerState = samplerState;
|
||||
lightDef->attenuation.image = imageDependency->Asset();
|
||||
lightDef->lmapLookupStart = static_cast<int>(static_cast<uint8_t>(lmapLookupStart));
|
||||
|
||||
context.GetZoneAssetCreationState<LightDefAssetCreationState>().SetLightDefLookupStart(lightDef, context);
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
||||
}
|
||||
|
||||
@@ -33,8 +33,6 @@ namespace
|
||||
auto* lightDef = m_memory.Alloc<GfxLightDef>();
|
||||
lightDef->name = m_memory.Dup(assetName.c_str());
|
||||
|
||||
context.GetZoneAssetCreationState<LightDefAssetCreationState>().SetLightDefLookupStart(lightDef, context);
|
||||
|
||||
AssetRegistration<AssetLightDef> registration(assetName, lightDef);
|
||||
|
||||
int8_t attenuationSamplerState;
|
||||
@@ -55,24 +53,22 @@ namespace
|
||||
|
||||
std::string cucolorisName;
|
||||
std::getline(*file.m_stream, cucolorisName, '\0');
|
||||
auto* cucolorisImageDependency = context.LoadDependency<AssetImage>(cucolorisName);
|
||||
if (!cucolorisImageDependency)
|
||||
{
|
||||
con::warn("Could not load GfxLightDef \"{}\" due to missing cucoloris image \"{}\"", assetName, cucolorisName);
|
||||
}
|
||||
else
|
||||
if (!cucolorisName.empty())
|
||||
{
|
||||
auto* cucolorisImageDependency = context.LoadDependency<AssetImage>(cucolorisName);
|
||||
if (!cucolorisImageDependency)
|
||||
{
|
||||
con::warn("Could not load GfxLightDef \"{}\" due to missing cucoloris image \"{}\"", assetName, cucolorisName);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
registration.AddDependency(cucolorisImageDependency);
|
||||
lightDef->cucoloris.image = cucolorisImageDependency->Asset();
|
||||
}
|
||||
|
||||
int8_t lmapLookupStart;
|
||||
file.m_stream->read(reinterpret_cast<char*>(&lmapLookupStart), sizeof(int8_t));
|
||||
|
||||
lightDef->attenuation.samplerState = attenuationSamplerState;
|
||||
lightDef->attenuation.image = attenuationImageDependency->Asset();
|
||||
lightDef->cucoloris.samplerState = cucolorisSamplerState;
|
||||
lightDef->cucoloris.image = cucolorisImageDependency->Asset();
|
||||
lightDef->lmapLookupStart = static_cast<int>(static_cast<uint8_t>(lmapLookupStart));
|
||||
|
||||
context.GetZoneAssetCreationState<LightDefAssetCreationState>().SetLightDefLookupStart(lightDef, context);
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
||||
}
|
||||
|
||||
@@ -35,20 +35,19 @@ namespace
|
||||
|
||||
std::string attenuationName;
|
||||
int8_t samplerState;
|
||||
int8_t lmapLookupStart;
|
||||
file.m_stream->read(reinterpret_cast<char*>(&samplerState), sizeof(int8_t));
|
||||
std::getline(*file.m_stream, attenuationName, '\0');
|
||||
|
||||
auto* imageDependency = context.LoadDependency<AssetImage>(imageName);
|
||||
if (!imageDependency)
|
||||
auto* attenuationImageDependency = context.LoadDependency<AssetImage>(attenuationName);
|
||||
if (!attenuationImageDependency)
|
||||
{
|
||||
con::error("Could not load GfxLightDef \"{}\" due to missing image \"{}\"", assetName, imageName);
|
||||
con::error("Could not load GfxLightDef \"{}\" due to missing attenuation image \"{}\"", assetName, attenuationName);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
registration.AddDependency(imageDependency);
|
||||
registration.AddDependency(attenuationImageDependency);
|
||||
|
||||
lightDef->attenuation.samplerState = samplerState;
|
||||
lightDef->attenuation.image = imageDependency->Asset();
|
||||
lightDef->attenuation.image = attenuationImageDependency->Asset();
|
||||
lightDef->lmapLookupStart = 0;
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
||||
|
||||
@@ -35,20 +35,19 @@ namespace
|
||||
|
||||
std::string attenuationName;
|
||||
int8_t samplerState;
|
||||
int8_t lmapLookupStart;
|
||||
file.m_stream->read(reinterpret_cast<char*>(&samplerState), sizeof(int8_t));
|
||||
std::getline(*file.m_stream, attenuationName, '\0');
|
||||
|
||||
auto* imageDependency = context.LoadDependency<AssetImage>(imageName);
|
||||
if (!imageDependency)
|
||||
auto* attenuationImageDependency = context.LoadDependency<AssetImage>(attenuationName);
|
||||
if (!attenuationImageDependency)
|
||||
{
|
||||
con::error("Could not load GfxLightDef \"{}\" due to missing image \"{}\"", assetName, imageName);
|
||||
con::error("Could not load GfxLightDef \"{}\" due to missing attenuation image \"{}\"", assetName, attenuationName);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
registration.AddDependency(imageDependency);
|
||||
registration.AddDependency(attenuationImageDependency);
|
||||
|
||||
lightDef->attenuation.samplerState = samplerState;
|
||||
lightDef->attenuation.image = imageDependency->Asset();
|
||||
lightDef->attenuation.image = attenuationImageDependency->Asset();
|
||||
lightDef->lmapLookupStart = 0;
|
||||
|
||||
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
||||
|
||||
@@ -10,9 +10,15 @@ namespace light_def
|
||||
{
|
||||
const auto* lightDef = asset.Asset();
|
||||
const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset.m_name));
|
||||
|
||||
if (!assetFile || lightDef->attenuation.image == nullptr || lightDef->attenuation.image->name == nullptr)
|
||||
if (!assetFile)
|
||||
{
|
||||
con::error("Could not open GfxLightDef file for dumping!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (lightDef->attenuation.image == nullptr || lightDef->attenuation.image->name == nullptr)
|
||||
{
|
||||
con::error("GfxLightDef attenuation data was invalid!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -22,6 +28,6 @@ namespace light_def
|
||||
if (imageName[0] == ',')
|
||||
imageName = &imageName[1];
|
||||
|
||||
stream << lightDef->attenuation.samplerState << imageName;
|
||||
stream << lightDef->attenuation.samplerState << imageName << '\0';
|
||||
}
|
||||
} // namespace light_def
|
||||
|
||||
@@ -10,9 +10,17 @@ namespace light_def
|
||||
{
|
||||
const auto* lightDef = asset.Asset();
|
||||
const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset.m_name));
|
||||
|
||||
if (!assetFile || lightDef->attenuation.image == nullptr || lightDef->attenuation.image->name == nullptr)
|
||||
if (!assetFile)
|
||||
{
|
||||
con::error("Could not open GfxLightDef file for dumping!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (lightDef->attenuation.image == nullptr || lightDef->attenuation.image->name == nullptr)
|
||||
{
|
||||
con::error("GfxLightDef attenuation data was invalid!");
|
||||
return;
|
||||
}
|
||||
|
||||
auto& stream = *assetFile;
|
||||
|
||||
@@ -20,6 +28,6 @@ namespace light_def
|
||||
if (imageName[0] == ',')
|
||||
imageName = &imageName[1];
|
||||
|
||||
stream << lightDef->attenuation.samplerState << imageName << static_cast<char>(lightDef->lmapLookupStart);
|
||||
stream << lightDef->attenuation.samplerState << imageName << '\0';
|
||||
}
|
||||
} // namespace light_def
|
||||
|
||||
@@ -13,20 +13,30 @@ namespace light_def
|
||||
const auto* lightDef = asset.Asset();
|
||||
const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset.m_name));
|
||||
auto& stream = *assetFile;
|
||||
if (!assetFile)
|
||||
{
|
||||
con::error("Could not open GfxLightDef file for dumping!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (lightDef->attenuation.image == nullptr || lightDef->attenuation.image->name == nullptr)
|
||||
{
|
||||
con::error("GfxLightDef attenuation data was invalid!");
|
||||
return;
|
||||
}
|
||||
|
||||
assert(lightDef->attenuation.image != nullptr);
|
||||
const auto* attenuationImageName = lightDef->attenuation.image->name;
|
||||
if (attenuationImageName && attenuationImageName[0] == ',')
|
||||
attenuationImageName = &attenuationImageName[1];
|
||||
|
||||
const auto* cucolorisImageName = "";
|
||||
if (lightDef->cucoloris.image)
|
||||
if (lightDef->cucoloris.image && lightDef->cucoloris.image->name)
|
||||
{
|
||||
cucolorisImageName = lightDef->cucoloris.image->name;
|
||||
if (cucolorisImageName && cucolorisImageName[0] == ',')
|
||||
cucolorisImageName = &cucolorisImageName[1];
|
||||
}
|
||||
|
||||
stream << lightDef->attenuation.samplerState << attenuationImageName << '\0' << lightDef->cucoloris.samplerState << cucolorisImageName;
|
||||
stream << lightDef->attenuation.samplerState << attenuationImageName << '\0' << lightDef->cucoloris.samplerState << cucolorisImageName << '\0';
|
||||
}
|
||||
} // namespace light_def
|
||||
|
||||
@@ -10,9 +10,17 @@ namespace light_def
|
||||
{
|
||||
const auto* lightDef = asset.Asset();
|
||||
const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset.m_name));
|
||||
|
||||
if (!assetFile || lightDef->attenuation.image == nullptr || lightDef->attenuation.image->name == nullptr)
|
||||
if (!assetFile)
|
||||
{
|
||||
con::error("Could not open GfxLightDef file for dumping!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (lightDef->attenuation.image == nullptr || lightDef->attenuation.image->name == nullptr)
|
||||
{
|
||||
con::error("GfxLightDef attenuation data was invalid!");
|
||||
return;
|
||||
}
|
||||
|
||||
auto& stream = *assetFile;
|
||||
|
||||
@@ -20,6 +28,6 @@ namespace light_def
|
||||
if (imageName[0] == ',')
|
||||
imageName = &imageName[1];
|
||||
|
||||
stream << lightDef->attenuation.samplerState << imageName << static_cast<char>(lightDef->lmapLookupStart);
|
||||
stream << lightDef->attenuation.samplerState << imageName << '\0';
|
||||
}
|
||||
} // namespace light_def
|
||||
|
||||
@@ -10,9 +10,17 @@ namespace light_def
|
||||
{
|
||||
const auto* lightDef = asset.Asset();
|
||||
const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset.m_name));
|
||||
|
||||
if (!assetFile || lightDef->attenuation.image == nullptr || lightDef->attenuation.image->name == nullptr)
|
||||
if (!assetFile)
|
||||
{
|
||||
con::error("Could not open GfxLightDef file for dumping!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (lightDef->attenuation.image == nullptr || lightDef->attenuation.image->name == nullptr)
|
||||
{
|
||||
con::error("GfxLightDef attenuation data was invalid!");
|
||||
return;
|
||||
}
|
||||
|
||||
auto& stream = *assetFile;
|
||||
|
||||
@@ -20,6 +28,6 @@ namespace light_def
|
||||
if (imageName[0] == ',')
|
||||
imageName = &imageName[1];
|
||||
|
||||
stream << lightDef->attenuation.samplerState << imageName << static_cast<char>(lightDef->lmapLookupStart);
|
||||
stream << lightDef->attenuation.samplerState << imageName << '\0';
|
||||
}
|
||||
} // namespace light_def
|
||||
|
||||
Reference in New Issue
Block a user