Skip to content

Commit b060e25

Browse files
authored
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 * #33 * v1.7.0.3
1 parent 326b708 commit b060e25

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ endif()
1212
set(VERSION_MAJOR 1)
1313
set(VERSION_MINOR 7)
1414
set(VERSION_PATCH 0)
15-
set(VERSION_TWEAK 2)
15+
set(VERSION_TWEAK 3)
1616

1717
set(VERSION_RC "${CMAKE_CURRENT_BINARY_DIR}/version.rc")
1818
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/version.rc.in" "${VERSION_RC}" @ONLY)

header/Main.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@
3232

3333
extern unsigned int gl_ErrorState;
3434
extern HINSTANCE gl_hThisInstance;
35+
inline std::filesystem::path gmod_dll_path;

modules/TextureClient.ixx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,16 @@ int TextureClient::UnlockMutex()
154154
return RETURN_OK;
155155
}
156156

157-
gsl::owner<TextureFileStruct*> AddFile(TexEntry& entry, const bool compress, const std::filesystem::path& dll_path)
157+
gsl::owner<TextureFileStruct*> AddFile(TexEntry& entry, const bool compress)
158158
{
159159
const auto texture_file_struct = new TextureFileStruct();
160160
texture_file_struct->crc_hash = entry.crc_hash;
161-
const auto dds_blob = TextureFunction::ConvertToCompressedDDS(entry, compress, dll_path);
161+
const auto dds_blob = TextureFunction::ConvertToCompressedDDS(entry, compress);
162162
texture_file_struct->data.assign(static_cast<BYTE*>(dds_blob.GetBufferPointer()), static_cast<BYTE*>(dds_blob.GetBufferPointer()) + dds_blob.GetBufferSize());
163163
return texture_file_struct;
164164
}
165165

166-
std::vector<gsl::owner<TextureFileStruct*>> ProcessModfile(const std::filesystem::path& modfile, const std::filesystem::path& dll_path, const bool compress)
166+
std::vector<gsl::owner<TextureFileStruct*>> ProcessModfile(const std::filesystem::path& modfile, const bool compress)
167167
{
168168
const auto hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
169169
if (FAILED(hr)) return {};
@@ -179,7 +179,7 @@ std::vector<gsl::owner<TextureFileStruct*>> ProcessModfile(const std::filesystem
179179
texture_file_structs.reserve(entries.size());
180180
unsigned file_bytes_loaded = 0;
181181
for (auto& tpf_entry : entries) {
182-
const auto tex_file_struct = AddFile(tpf_entry, compress, dll_path);
182+
const auto tex_file_struct = AddFile(tpf_entry, compress);
183183
texture_file_structs.push_back(tex_file_struct);
184184
file_bytes_loaded += texture_file_structs.back()->data.size();
185185
}
@@ -198,6 +198,9 @@ void TextureClient::LoadModsFromModlist(std::pair<std::string, std::string> modf
198198
std::string line;
199199
std::vector<std::filesystem::path> modfiles;
200200
while (std::getline(file, line)) {
201+
if (line.starts_with("//") || line.starts_with("#") || line.empty()) {
202+
continue;
203+
}
201204
// Remove newline character
202205
line.erase(std::ranges::remove(line, '\r').begin(), line.end());
203206
line.erase(std::ranges::remove(line, '\n').begin(), line.end());
@@ -218,7 +221,7 @@ void TextureClient::LoadModsFromModlist(std::pair<std::string, std::string> modf
218221
}
219222
std::vector<std::future<std::vector<gsl::owner<TextureFileStruct*>>>> futures;
220223
for (const auto modfile : modfiles) {
221-
futures.emplace_back(std::async(std::launch::async, ProcessModfile, modfile, dll_path, files_size > 400'000'000));
224+
futures.emplace_back(std::async(std::launch::async, ProcessModfile, modfile, files_size > 400'000'000));
222225
}
223226
auto loaded_size = 0u;
224227
for (auto& future : futures) {

modules/TextureFunction.ixx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,10 @@ export namespace TextureFunction {
338338
return compressed_image;
339339
}
340340

341-
void ImageSave(const DirectX::ScratchImage& image, const TexEntry& entry, const std::filesystem::path& dll_path)
341+
void ImageSave(const DirectX::ScratchImage& image, const TexEntry& entry)
342342
{
343343
const auto file_name = std::format("0x{:x}.dds", entry.crc_hash);
344-
const auto file_out = dll_path / "textures" / file_name;
344+
const auto file_out = gmod_dll_path.parent_path() / "textures" / file_name;
345345
try {
346346
if (std::filesystem::exists(file_out)) {
347347
return;
@@ -361,11 +361,10 @@ export namespace TextureFunction {
361361
}
362362
catch (const std::exception& e) {
363363
Warning("SaveDDSImageToDisk (%#lX%s): %s\n", entry.crc_hash, entry.ext.c_str(), e.what());
364-
return;
365364
}
366365
}
367366

368-
DirectX::Blob ConvertToCompressedDDS(TexEntry& entry, const bool compress, [[maybe_unused]] const std::filesystem::path& dll_path)
367+
DirectX::Blob ConvertToCompressedDDS(TexEntry& entry, const bool compress)
369368
{
370369
DirectX::ScratchImage image;
371370
HRESULT hr = 0;
@@ -408,7 +407,7 @@ export namespace TextureFunction {
408407
}
409408

410409
#ifdef _DEBUG
411-
ImageSave(compressed_image, entry, dll_path);
410+
ImageSave(compressed_image, entry);
412411
#endif
413412
return dds_blob;
414413
}

source/dll_main.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ BOOL WINAPI DllMain(HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
185185
switch (ul_reason_for_call) {
186186
case DLL_PROCESS_ATTACH: {
187187
#ifdef _DEBUG
188+
wchar_t dllFilePath[512 + 1]{};
189+
GetModuleFileNameW(hModule, dllFilePath, 512);
190+
gmod_dll_path = dllFilePath;
188191
AllocConsole();
189192
SetConsoleTitleA("gMod Console");
190193
freopen_s(&stdout_proxy, "CONOUT$", "w", stdout);

0 commit comments

Comments
 (0)