2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-11-23 05:12:05 +00:00

remove GSC-Tool use

This commit is contained in:
LJW-Dev
2025-10-08 19:47:46 +08:00
parent dd460a65c8
commit b1670445f5
2 changed files with 12 additions and 31 deletions

View File

@@ -4,8 +4,6 @@
#include <cstring>
#include "ScriptCompileT6.h"
using namespace T6;
namespace
@@ -19,40 +17,23 @@ namespace
{
}
const unsigned char T6GSCMagic[8] = {0x80, 0x47, 0x53, 0x43, 0x0D, 0x0A, 0x00, 0x06 };
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
{
const auto file = m_search_path.Open(assetName);
if (!file.IsOpen())
return AssetCreationResult::NoAction();
auto* scriptParseTree = m_memory.Alloc<ScriptParseTree>();
scriptParseTree->name = m_memory.Dup(assetName.c_str());
scriptParseTree->len = static_cast<int>(file.m_length);
auto* fileBuffer = m_memory.Alloc<char>(static_cast<size_t>(file.m_length + 1));
file.m_stream->read(fileBuffer, file.m_length);
if (file.m_stream->gcount() != file.m_length || file.m_length < 0x10)
if (file.m_stream->gcount() != file.m_length)
return AssetCreationResult::Failure();
fileBuffer[file.m_length] = '\0';
fileBuffer[scriptParseTree->len] = '\0';
auto* scriptParseTree = m_memory.Alloc<ScriptParseTree>();
scriptParseTree->name = m_memory.Dup(assetName.c_str());
if (memcmp(fileBuffer, T6GSCMagic, 8) == 0)
{
scriptParseTree->len = static_cast<int>(file.m_length);
scriptParseTree->buffer = static_cast<char16*>(fileBuffer);
}
else
{
size_t compiledSize;
char* result = compileScriptT6(assetName, fileBuffer, static_cast<size_t>(file.m_length), &compiledSize);
if (result == NULL)
return AssetCreationResult::Failure();
scriptParseTree->buffer = result;
scriptParseTree->len = static_cast<int>(compiledSize);
}
return AssetCreationResult::Success(context.AddAsset<AssetScript>(assetName, scriptParseTree));
}
@@ -63,10 +44,10 @@ namespace
};
} // namespace
namespace T6
namespace script
{
std::unique_ptr<AssetCreator<AssetScript>> CreateScriptLoader(MemoryManager& memory, ISearchPath& searchPath)
std::unique_ptr<AssetCreator<AssetScript>> CreateLoaderT6(MemoryManager& memory, ISearchPath& searchPath)
{
return std::make_unique<ScriptLoader>(memory, searchPath);
}
} // namespace T6
} // namespace script

View File

@@ -7,7 +7,7 @@
#include <memory>
namespace T6
namespace script
{
std::unique_ptr<AssetCreator<AssetScript>> CreateScriptLoader(MemoryManager& memory, ISearchPath& searchPath);
} // namespace T6
std::unique_ptr<AssetCreator<T6::AssetScript>> CreateLoaderT6(MemoryManager& memory, ISearchPath& searchPath);
} // namespace script