v1.7.0.3 (#34)

* change tpfconvert functionality to backup into backup folder

* use vcpkg for more packages

* update readme, bump to 1.7.0.2

* rework dll path

* https://github.com/gwdevhub/gMod/issues/33

* v1.7.0.3
This commit is contained in:
Marc
2025-07-20 22:08:50 +07:00
committed by GitHub
parent 326b7086c9
commit b060e25ee2
5 changed files with 17 additions and 11 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ endif()
set(VERSION_MAJOR 1)
set(VERSION_MINOR 7)
set(VERSION_PATCH 0)
set(VERSION_TWEAK 2)
set(VERSION_TWEAK 3)
set(VERSION_RC "${CMAKE_CURRENT_BINARY_DIR}/version.rc")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/version.rc.in" "${VERSION_RC}" @ONLY)
+1
View File
@@ -32,3 +32,4 @@
extern unsigned int gl_ErrorState;
extern HINSTANCE gl_hThisInstance;
inline std::filesystem::path gmod_dll_path;
+8 -5
View File
@@ -154,16 +154,16 @@ int TextureClient::UnlockMutex()
return RETURN_OK;
}
gsl::owner<TextureFileStruct*> AddFile(TexEntry& entry, const bool compress, const std::filesystem::path& dll_path)
gsl::owner<TextureFileStruct*> AddFile(TexEntry& entry, const bool compress)
{
const auto texture_file_struct = new TextureFileStruct();
texture_file_struct->crc_hash = entry.crc_hash;
const auto dds_blob = TextureFunction::ConvertToCompressedDDS(entry, compress, dll_path);
const auto dds_blob = TextureFunction::ConvertToCompressedDDS(entry, compress);
texture_file_struct->data.assign(static_cast<BYTE*>(dds_blob.GetBufferPointer()), static_cast<BYTE*>(dds_blob.GetBufferPointer()) + dds_blob.GetBufferSize());
return texture_file_struct;
}
std::vector<gsl::owner<TextureFileStruct*>> ProcessModfile(const std::filesystem::path& modfile, const std::filesystem::path& dll_path, const bool compress)
std::vector<gsl::owner<TextureFileStruct*>> ProcessModfile(const std::filesystem::path& modfile, const bool compress)
{
const auto hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
if (FAILED(hr)) return {};
@@ -179,7 +179,7 @@ std::vector<gsl::owner<TextureFileStruct*>> ProcessModfile(const std::filesystem
texture_file_structs.reserve(entries.size());
unsigned file_bytes_loaded = 0;
for (auto& tpf_entry : entries) {
const auto tex_file_struct = AddFile(tpf_entry, compress, dll_path);
const auto tex_file_struct = AddFile(tpf_entry, compress);
texture_file_structs.push_back(tex_file_struct);
file_bytes_loaded += texture_file_structs.back()->data.size();
}
@@ -198,6 +198,9 @@ void TextureClient::LoadModsFromModlist(std::pair<std::string, std::string> modf
std::string line;
std::vector<std::filesystem::path> modfiles;
while (std::getline(file, line)) {
if (line.starts_with("//") || line.starts_with("#") || line.empty()) {
continue;
}
// Remove newline character
line.erase(std::ranges::remove(line, '\r').begin(), line.end());
line.erase(std::ranges::remove(line, '\n').begin(), line.end());
@@ -218,7 +221,7 @@ void TextureClient::LoadModsFromModlist(std::pair<std::string, std::string> modf
}
std::vector<std::future<std::vector<gsl::owner<TextureFileStruct*>>>> futures;
for (const auto modfile : modfiles) {
futures.emplace_back(std::async(std::launch::async, ProcessModfile, modfile, dll_path, files_size > 400'000'000));
futures.emplace_back(std::async(std::launch::async, ProcessModfile, modfile, files_size > 400'000'000));
}
auto loaded_size = 0u;
for (auto& future : futures) {
+4 -5
View File
@@ -338,10 +338,10 @@ export namespace TextureFunction {
return compressed_image;
}
void ImageSave(const DirectX::ScratchImage& image, const TexEntry& entry, const std::filesystem::path& dll_path)
void ImageSave(const DirectX::ScratchImage& image, const TexEntry& entry)
{
const auto file_name = std::format("0x{:x}.dds", entry.crc_hash);
const auto file_out = dll_path / "textures" / file_name;
const auto file_out = gmod_dll_path.parent_path() / "textures" / file_name;
try {
if (std::filesystem::exists(file_out)) {
return;
@@ -361,11 +361,10 @@ export namespace TextureFunction {
}
catch (const std::exception& e) {
Warning("SaveDDSImageToDisk (%#lX%s): %s\n", entry.crc_hash, entry.ext.c_str(), e.what());
return;
}
}
DirectX::Blob ConvertToCompressedDDS(TexEntry& entry, const bool compress, [[maybe_unused]] const std::filesystem::path& dll_path)
DirectX::Blob ConvertToCompressedDDS(TexEntry& entry, const bool compress)
{
DirectX::ScratchImage image;
HRESULT hr = 0;
@@ -408,7 +407,7 @@ export namespace TextureFunction {
}
#ifdef _DEBUG
ImageSave(compressed_image, entry, dll_path);
ImageSave(compressed_image, entry);
#endif
return dds_blob;
}
+3
View File
@@ -185,6 +185,9 @@ BOOL WINAPI DllMain(HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
switch (ul_reason_for_call) {
case DLL_PROCESS_ATTACH: {
#ifdef _DEBUG
wchar_t dllFilePath[512 + 1]{};
GetModuleFileNameW(hModule, dllFilePath, 512);
gmod_dll_path = dllFilePath;
AllocConsole();
SetConsoleTitleA("gMod Console");
freopen_s(&stdout_proxy, "CONOUT$", "w", stdout);