fix: bucles cap a ranges algorithms (38 troballes)

This commit is contained in:
2026-05-14 21:36:21 +02:00
parent 0aa9f8fe0a
commit b4d3776239
14 changed files with 110 additions and 169 deletions

View File

@@ -6,6 +6,7 @@
#include <SDL3/SDL_filesystem.h>
#include <algorithm>
#include <numeric>
#include <filesystem>
#include <fstream>
#include <iostream>
@@ -14,11 +15,10 @@ namespace Resource {
// Calculate CRC32 checksum for data verification
auto Pack::calculateChecksum(const std::vector<uint8_t>& data) -> uint32_t { // NOLINT(readability-convert-member-functions-to-static)
uint32_t checksum = 0x12345678;
for (unsigned char byte : data) {
checksum = ((checksum << 5) + checksum) + byte;
}
return checksum;
return std::accumulate(data.begin(), data.end(), uint32_t{0x12345678},
[](uint32_t acc, unsigned char byte) -> uint32_t {
return ((acc << 5) + acc) + byte;
});
}
// XOR encryption (symmetric - same function for encrypt/decrypt)