mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-05-17 07:21:43 +00:00
Remove un-needed constants and switch to parsing name by null character.
This commit is contained in:
@@ -13,8 +13,6 @@ using namespace IW3;
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr auto MAX_IMAGE_NAME_SIZE = 0x800;
|
||||
|
||||
class LoaderLightDef final : public AssetCreator<AssetLightDef>
|
||||
{
|
||||
public:
|
||||
@@ -31,23 +29,18 @@ namespace
|
||||
if (!file.IsOpen())
|
||||
return AssetCreationResult::NoAction();
|
||||
|
||||
const auto imageNameSize = file.m_length - sizeof(char) - sizeof(char);
|
||||
if (imageNameSize < 0 || imageNameSize > MAX_IMAGE_NAME_SIZE)
|
||||
return AssetCreationResult::Failure();
|
||||
|
||||
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(static_cast<size_t>(imageNameSize), '\0');
|
||||
|
||||
|
||||
std::string imageName;
|
||||
int8_t samplerState;
|
||||
int8_t lmapLookupStart;
|
||||
file.m_stream->read(reinterpret_cast<char*>(&samplerState), sizeof(int8_t));
|
||||
file.m_stream->read(&imageName[0], static_cast<size_t>(imageNameSize));
|
||||
std::getline(*file.m_stream, imageName, '\0');
|
||||
|
||||
auto* imageDependency = context.LoadDependency<AssetImage>(imageName);
|
||||
if (!imageDependency)
|
||||
|
||||
@@ -4,6 +4,11 @@
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr auto MAX_LMAP_USAGE = 512;
|
||||
};
|
||||
|
||||
LightDefAssetCreationState::LightDefAssetCreationState()
|
||||
: m_lmap_pixels_used_for_falloff(0)
|
||||
{
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
constexpr auto MAX_LMAP_USAGE = 512;
|
||||
|
||||
class LightDefAssetCreationState : public IZoneAssetCreationState
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -13,8 +13,6 @@ using namespace IW4;
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr auto MAX_IMAGE_NAME_SIZE = 0x800;
|
||||
|
||||
class LoaderLightDef final : public AssetCreator<AssetLightDef>
|
||||
{
|
||||
public:
|
||||
@@ -31,10 +29,6 @@ namespace
|
||||
if (!file.IsOpen())
|
||||
return AssetCreationResult::NoAction();
|
||||
|
||||
const auto imageNameSize = file.m_length - sizeof(char) - sizeof(char);
|
||||
if (imageNameSize < 0 || imageNameSize > MAX_IMAGE_NAME_SIZE)
|
||||
return AssetCreationResult::Failure();
|
||||
|
||||
auto* lightDef = m_memory.Alloc<GfxLightDef>();
|
||||
lightDef->name = m_memory.Dup(assetName.c_str());
|
||||
|
||||
@@ -42,13 +36,11 @@ namespace
|
||||
|
||||
AssetRegistration<AssetLightDef> registration(assetName, lightDef);
|
||||
|
||||
std::string imageName(static_cast<size_t>(imageNameSize), '\0');
|
||||
|
||||
std::string imageName;
|
||||
int8_t samplerState;
|
||||
int8_t lmapLookupStart;
|
||||
file.m_stream->read(reinterpret_cast<char*>(&samplerState), sizeof(int8_t));
|
||||
file.m_stream->read(&imageName[0], static_cast<size_t>(imageNameSize));
|
||||
file.m_stream->read(reinterpret_cast<char*>(&lmapLookupStart), sizeof(int8_t));
|
||||
std::getline(*file.m_stream, imageName, '\0');
|
||||
|
||||
auto* imageDependency = context.LoadDependency<AssetImage>(imageName);
|
||||
if (!imageDependency)
|
||||
|
||||
@@ -4,6 +4,11 @@
|
||||
|
||||
using namespace IW5;
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr auto MAX_LMAP_USAGE = 512;
|
||||
};
|
||||
|
||||
LightDefAssetCreationState::LightDefAssetCreationState()
|
||||
: m_lmap_pixels_used_for_falloff(0)
|
||||
{
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
constexpr auto MAX_LMAP_USAGE = 512;
|
||||
|
||||
class LightDefAssetCreationState : public IZoneAssetCreationState
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -12,8 +12,6 @@ using namespace T5;
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr auto MAX_IMAGE_NAME_SIZE = 0x800;
|
||||
|
||||
class LoaderLightDef final : public AssetCreator<AssetLightDef>
|
||||
{
|
||||
public:
|
||||
@@ -30,22 +28,16 @@ namespace
|
||||
if (!file.IsOpen())
|
||||
return AssetCreationResult::NoAction();
|
||||
|
||||
const auto imageNameSize = file.m_length - sizeof(char) - sizeof(char);
|
||||
if (imageNameSize < 0 || imageNameSize > MAX_IMAGE_NAME_SIZE)
|
||||
return AssetCreationResult::Failure();
|
||||
|
||||
auto* lightDef = m_memory.Alloc<GfxLightDef>();
|
||||
lightDef->name = m_memory.Dup(assetName.c_str());
|
||||
|
||||
AssetRegistration<AssetLightDef> registration(assetName, lightDef);
|
||||
|
||||
std::string imageName(static_cast<size_t>(imageNameSize), '\0');
|
||||
|
||||
std::string attenuationName;
|
||||
int8_t samplerState;
|
||||
int8_t lmapLookupStart;
|
||||
file.m_stream->read(reinterpret_cast<char*>(&samplerState), sizeof(int8_t));
|
||||
file.m_stream->read(&imageName[0], static_cast<size_t>(imageNameSize));
|
||||
file.m_stream->read(reinterpret_cast<char*>(&lmapLookupStart), sizeof(int8_t));
|
||||
std::getline(*file.m_stream, attenuationName, '\0');
|
||||
|
||||
auto* imageDependency = context.LoadDependency<AssetImage>(imageName);
|
||||
if (!imageDependency)
|
||||
|
||||
@@ -12,8 +12,6 @@ using namespace T6;
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr auto MAX_IMAGE_NAME_SIZE = 0x800;
|
||||
|
||||
class LoaderLightDef final : public AssetCreator<AssetLightDef>
|
||||
{
|
||||
public:
|
||||
@@ -30,22 +28,16 @@ namespace
|
||||
if (!file.IsOpen())
|
||||
return AssetCreationResult::NoAction();
|
||||
|
||||
const auto imageNameSize = file.m_length - sizeof(char) - sizeof(char);
|
||||
if (imageNameSize < 0 || imageNameSize > MAX_IMAGE_NAME_SIZE)
|
||||
return AssetCreationResult::Failure();
|
||||
|
||||
auto* lightDef = m_memory.Alloc<GfxLightDef>();
|
||||
lightDef->name = m_memory.Dup(assetName.c_str());
|
||||
|
||||
AssetRegistration<AssetLightDef> registration(assetName, lightDef);
|
||||
|
||||
std::string imageName(static_cast<size_t>(imageNameSize), '\0');
|
||||
|
||||
std::string attenuationName;
|
||||
int8_t samplerState;
|
||||
int8_t lmapLookupStart;
|
||||
file.m_stream->read(reinterpret_cast<char*>(&samplerState), sizeof(int8_t));
|
||||
file.m_stream->read(&imageName[0], static_cast<size_t>(imageNameSize));
|
||||
file.m_stream->read(reinterpret_cast<char*>(&lmapLookupStart), sizeof(int8_t));
|
||||
std::getline(*file.m_stream, attenuationName, '\0');
|
||||
|
||||
auto* imageDependency = context.LoadDependency<AssetImage>(imageName);
|
||||
if (!imageDependency)
|
||||
|
||||
Reference in New Issue
Block a user