This commit is contained in:
2025-11-03 09:52:54 +01:00
parent 1409ab5bff
commit 3f1c737247
32 changed files with 254 additions and 243 deletions
+7 -7
View File
@@ -10,7 +10,7 @@
#include <fstream>
#include <iostream>
namespace jdd {
namespace Jdd {
// Calculate CRC32 checksum for data verification
auto ResourcePack::calculateChecksum(const std::vector<uint8_t>& data) -> uint32_t {
@@ -100,7 +100,7 @@ auto ResourcePack::addDirectory(const std::string& dir_path,
std::string relative_path = entry.path().lexically_relative(dir_path).string();
// Convert backslashes to forward slashes (Windows compatibility)
std::replace(relative_path.begin(), relative_path.end(), '\\', '/');
std::ranges::replace(relative_path, '\\', '/');
// Skip development files
if (relative_path.find(".world") != std::string::npos ||
@@ -129,13 +129,13 @@ auto ResourcePack::savePack(const std::string& pack_file) -> bool {
file.write(reinterpret_cast<const char*>(&VERSION), sizeof(VERSION));
// Write resource count
uint32_t resource_count = static_cast<uint32_t>(resources_.size());
auto resource_count = static_cast<uint32_t>(resources_.size());
file.write(reinterpret_cast<const char*>(&resource_count), sizeof(resource_count));
// Write resource entries
for (const auto& [name, entry] : resources_) {
// Write filename length and name
uint32_t name_len = static_cast<uint32_t>(entry.filename.length());
auto name_len = static_cast<uint32_t>(entry.filename.length());
file.write(reinterpret_cast<const char*>(&name_len), sizeof(name_len));
file.write(entry.filename.c_str(), name_len);
@@ -269,7 +269,7 @@ auto ResourcePack::getResourceList() const -> std::vector<std::string> {
for (const auto& [name, entry] : resources_) {
list.push_back(name);
}
std::sort(list.begin(), list.end());
std::ranges::sort(list);
return list;
}
@@ -288,7 +288,7 @@ auto ResourcePack::calculatePackChecksum() const -> uint32_t {
for (const auto& [name, entry] : resources_) {
sorted_names.push_back(name);
}
std::sort(sorted_names.begin(), sorted_names.end());
std::ranges::sort(sorted_names);
// Combine individual checksums
for (const auto& name : sorted_names) {
@@ -300,4 +300,4 @@ auto ResourcePack::calculatePackChecksum() const -> uint32_t {
return global_checksum;
}
} // namespace jdd
} // namespace Jdd