mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 08:05:45 +00:00
fix: address review comments
This commit is contained in:
parent
9306210227
commit
0ad1964864
@ -53,10 +53,13 @@ bool AssetLoaderScriptFile::LoadFromRaw(
|
|||||||
memcpy(&scriptFile->bytecodeLen, fileBuffer.get() + offset, sizeof(scriptFile->bytecodeLen));
|
memcpy(&scriptFile->bytecodeLen, fileBuffer.get() + offset, sizeof(scriptFile->bytecodeLen));
|
||||||
offset += sizeof(scriptFile->bytecodeLen);
|
offset += sizeof(scriptFile->bytecodeLen);
|
||||||
|
|
||||||
// Get the file size
|
if (scriptFile->compressedLen <= 0 || scriptFile->bytecodeLen <= 0)
|
||||||
auto fileSize = file.m_length;
|
{
|
||||||
|
std::cerr << "Error: Invalid length of the buffers in " << assetName << " specified" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (offset + scriptFile->compressedLen > fileSize || offset + scriptFile->bytecodeLen > fileSize)
|
if (offset + (scriptFile->compressedLen + scriptFile->bytecodeLen) > file.m_length)
|
||||||
{
|
{
|
||||||
std::cerr << "Error: Specified length in " << assetName << " GSC BIN structure exceeds the actual file size" << std::endl;
|
std::cerr << "Error: Specified length in " << assetName << " GSC BIN structure exceeds the actual file size" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
@ -68,7 +71,6 @@ bool AssetLoaderScriptFile::LoadFromRaw(
|
|||||||
|
|
||||||
scriptFile->bytecode = static_cast<unsigned char*>(memory->Alloc(scriptFile->bytecodeLen));
|
scriptFile->bytecode = static_cast<unsigned char*>(memory->Alloc(scriptFile->bytecodeLen));
|
||||||
memcpy(scriptFile->bytecode, fileBuffer.get() + offset, scriptFile->bytecodeLen);
|
memcpy(scriptFile->bytecode, fileBuffer.get() + offset, scriptFile->bytecodeLen);
|
||||||
offset += scriptFile->bytecodeLen;
|
|
||||||
|
|
||||||
manager->AddAsset(ASSET_TYPE_SCRIPTFILE, assetName, scriptFile);
|
manager->AddAsset(ASSET_TYPE_SCRIPTFILE, assetName, scriptFile);
|
||||||
|
|
||||||
|
@ -8,8 +8,6 @@ namespace IW5
|
|||||||
{
|
{
|
||||||
class AssetLoaderScriptFile final : public BasicAssetLoader<ASSET_TYPE_SCRIPTFILE, ScriptFile>
|
class AssetLoaderScriptFile final : public BasicAssetLoader<ASSET_TYPE_SCRIPTFILE, ScriptFile>
|
||||||
{
|
{
|
||||||
static constexpr size_t COMPRESSED_BUFFER_SIZE_PADDING = 64;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||||
_NODISCARD bool CanLoadFromRaw() const override;
|
_NODISCARD bool CanLoadFromRaw() const override;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user