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