md5 texture export prototype

This commit is contained in:
T1ti
2024-07-14 03:12:16 +02:00
parent f33f7eb571
commit 478d842e10

View File

@@ -10,6 +10,7 @@
#include <QDir>
#include <QBuffer>
#include <QCryptographicHash>
using namespace Noggit::Rendering;
@@ -1730,6 +1731,20 @@ bool WorldRender::saveMinimap(TileIndex const& tile_idx, MinimapRenderSettings*
uint32_t file_size;
void* blp_image = blp.createBlpDxtInMemory(true, FORMAT_DXT5, file_size);
// converts the texture name to an md5 hash like blizzard, this is used to avoid duplicates textures for ocean
// downside is that if the file gets updated regularly there will be a lot of duplicates in the project folder
// probably should be a patching option when deploying
bool use_md5 = false;
if (use_md5)
{
QCryptographicHash md5_hash(QCryptographicHash::Md5);
// auto data = reinterpret_cast<char*>(blp_image);
md5_hash.addData(reinterpret_cast<char*>(blp_image), file_size);
auto resulthex = md5_hash.result().toHex().toStdString() + ".blp";
tex_name = resulthex;
}
QFile file(dir.filePath(tex_name.c_str()));
file.open(QIODevice::WriteOnly);