mirror of
https://github.com/izzy2lost/Torch.git
synced 2026-07-06 00:18:35 -07:00
Fixed linux compilation
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
void WriteAnimationHeader(LUS::BinaryWriter* writer, nlohmann::json& offsets, std::vector<uint8_t>& buffer) {
|
||||
LUS::BinaryReader reader((char*) buffer.data() + offsets[0], offsets[1]);
|
||||
LUS::BinaryReader reader((char*) buffer.data() + (size_t)offsets[0], offsets[1]);
|
||||
reader.SetEndianness(LUS::Endianness::Big);
|
||||
|
||||
auto flags = reader.ReadInt16();
|
||||
@@ -33,7 +33,7 @@ void WriteAnimationHeader(LUS::BinaryWriter* writer, nlohmann::json& offsets, st
|
||||
}
|
||||
|
||||
void WriteAnimationIndex(LUS::BinaryWriter* writer, nlohmann::json& offsets, std::vector<uint8_t>& buffer) {
|
||||
LUS::BinaryReader reader((char*) buffer.data() + offsets[0], offsets[1]);
|
||||
LUS::BinaryReader reader((char*) buffer.data() + (size_t)offsets[0], offsets[1]);
|
||||
reader.SetEndianness(LUS::Endianness::Big);
|
||||
size_t entries = ((size_t) offsets[1]);
|
||||
WRITE_U32(entries);
|
||||
@@ -44,7 +44,7 @@ void WriteAnimationIndex(LUS::BinaryWriter* writer, nlohmann::json& offsets, std
|
||||
}
|
||||
|
||||
void WriteAnimationValues(LUS::BinaryWriter* writer, nlohmann::json& offsets, std::vector<uint8_t>& buffer) {
|
||||
LUS::BinaryReader reader((char*) buffer.data() + offsets[0], offsets[1]);
|
||||
LUS::BinaryReader reader((char*) buffer.data() + (size_t)offsets[0], offsets[1]);
|
||||
reader.SetEndianness(LUS::Endianness::Big);
|
||||
size_t entries = ((size_t) offsets[1]);
|
||||
WRITE_U32(entries);
|
||||
@@ -64,4 +64,4 @@ bool AnimFactory::process(LUS::BinaryWriter* writer, nlohmann::json& data, std::
|
||||
WriteAnimationValues(writer, metadata["values"], buffer);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@ bool BlobFactory::process(LUS::BinaryWriter* writer, nlohmann::json& data, std::
|
||||
auto* blob = new uint8_t[size];
|
||||
if(this->isMIOChunk){
|
||||
auto mio0 = MIO0Decoder::Decode(buffer, offsets[0]);
|
||||
memcpy(blob, mio0.data() + offsets[1], size);
|
||||
memcpy(blob, mio0.data() + (size_t)offsets[1], size);
|
||||
} else {
|
||||
memcpy(blob, buffer.data() + offsets[0], size);
|
||||
memcpy(blob, buffer.data() + (size_t)offsets[0], size);
|
||||
}
|
||||
|
||||
WRITE_U32(size); // Blob Data Size
|
||||
@@ -35,4 +35,4 @@ bool BlobFactory::process(LUS::BinaryWriter* writer, nlohmann::json& data, std::
|
||||
|
||||
delete[] blob;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,9 +64,9 @@ bool TextureFactory::process(LUS::BinaryWriter* writer, nlohmann::json& data, st
|
||||
|
||||
if(offsets.size() > 1){
|
||||
auto mio0 = MIO0Decoder::Decode(buffer, offsets[0]);
|
||||
memcpy(texture, mio0.data() + offsets[1], size);
|
||||
memcpy(texture, mio0.data() + (size_t)offsets[1], size);
|
||||
} else {
|
||||
memcpy(texture, buffer.data() + offsets[0], size);
|
||||
memcpy(texture, buffer.data() + (size_t)offsets[0], size);
|
||||
}
|
||||
|
||||
WRITE_U32(size); // Texture Data Size
|
||||
@@ -74,4 +74,4 @@ bool TextureFactory::process(LUS::BinaryWriter* writer, nlohmann::json& data, st
|
||||
|
||||
delete[] texture;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ extern "C" {
|
||||
#include <libmio0/mio0.h>
|
||||
}
|
||||
#include <stdexcept>
|
||||
#include <cstdint>
|
||||
|
||||
std::unordered_map<uint32_t, std::vector<char>> MIO0Decoder::gCachedChunks;
|
||||
|
||||
@@ -25,4 +26,4 @@ std::vector<char>& MIO0Decoder::Decode(std::vector<uint8_t>& buffer, uint32_t of
|
||||
|
||||
void MIO0Decoder::ClearCache() {
|
||||
gCachedChunks.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <cstdint>
|
||||
|
||||
class MIO0Decoder {
|
||||
public:
|
||||
static std::unordered_map<uint32_t, std::vector<char>> gCachedChunks;
|
||||
static std::vector<char>& Decode(std::vector<uint8_t>& buffer, uint32_t offset);
|
||||
static void ClearCache();
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user