mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +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));
|
||||
offset += sizeof(scriptFile->bytecodeLen);
|
||||
|
||||
// Get the file size
|
||||
auto fileSize = file.m_length;
|
||||
if (scriptFile->compressedLen <= 0 || scriptFile->bytecodeLen <= 0)
|
||||
{
|
||||
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;
|
||||
return false;
|
||||
@ -68,7 +71,6 @@ bool AssetLoaderScriptFile::LoadFromRaw(
|
||||
|
||||
scriptFile->bytecode = static_cast<unsigned char*>(memory->Alloc(scriptFile->bytecodeLen));
|
||||
memcpy(scriptFile->bytecode, fileBuffer.get() + offset, scriptFile->bytecodeLen);
|
||||
offset += scriptFile->bytecodeLen;
|
||||
|
||||
manager->AddAsset(ASSET_TYPE_SCRIPTFILE, assetName, scriptFile);
|
||||
|
||||
|
@ -8,8 +8,6 @@ namespace IW5
|
||||
{
|
||||
class AssetLoaderScriptFile final : public BasicAssetLoader<ASSET_TYPE_SCRIPTFILE, ScriptFile>
|
||||
{
|
||||
static constexpr size_t COMPRESSED_BUFFER_SIZE_PADDING = 64;
|
||||
|
||||
public:
|
||||
_NODISCARD void* CreateEmptyAsset(const std::string& assetName, MemoryManager* memory) override;
|
||||
_NODISCARD bool CanLoadFromRaw() const override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user