diff --git a/src/ObjLoading/Game/T6/Script/LoaderScriptT6.cpp b/src/ObjLoading/Game/T6/Script/LoaderScriptT6.cpp index 60982351..a7284bc7 100644 --- a/src/ObjLoading/Game/T6/Script/LoaderScriptT6.cpp +++ b/src/ObjLoading/Game/T6/Script/LoaderScriptT6.cpp @@ -4,8 +4,6 @@ #include -#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->name = m_memory.Dup(assetName.c_str()); + scriptParseTree->len = static_cast(file.m_length); auto* fileBuffer = m_memory.Alloc(static_cast(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->name = m_memory.Dup(assetName.c_str()); - - if (memcmp(fileBuffer, T6GSCMagic, 8) == 0) - { - scriptParseTree->len = static_cast(file.m_length); - scriptParseTree->buffer = static_cast(fileBuffer); - } - else - { - size_t compiledSize; - char* result = compileScriptT6(assetName, fileBuffer, static_cast(file.m_length), &compiledSize); - if (result == NULL) - return AssetCreationResult::Failure(); - - scriptParseTree->buffer = result; - scriptParseTree->len = static_cast(compiledSize); - } + scriptParseTree->buffer = static_cast(fileBuffer); return AssetCreationResult::Success(context.AddAsset(assetName, scriptParseTree)); } @@ -63,10 +44,10 @@ namespace }; } // namespace -namespace T6 +namespace script { - std::unique_ptr> CreateScriptLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoaderT6(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace T6 +} // namespace script diff --git a/src/ObjLoading/Game/T6/Script/LoaderScriptT6.h b/src/ObjLoading/Game/T6/Script/LoaderScriptT6.h index 754da2ec..ebaab5da 100644 --- a/src/ObjLoading/Game/T6/Script/LoaderScriptT6.h +++ b/src/ObjLoading/Game/T6/Script/LoaderScriptT6.h @@ -7,7 +7,7 @@ #include -namespace T6 +namespace script { - std::unique_ptr> CreateScriptLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace T6 + std::unique_ptr> CreateLoaderT6(MemoryManager& memory, ISearchPath& searchPath); +} // namespace script