From 1f18c3728a625b418ed23707c1f19336440753a4 Mon Sep 17 00:00:00 2001 From: Nicklas Lindgren Date: Mon, 2 Jan 2017 22:54:11 +0100 Subject: [PATCH 1/3] Fix texture dumping overwriting .fx files Texture loading, and thereby texture dumping is performed in a secondary thread. Both texture dumping and .fx file loading makes calls to GetDirectoryFile, which returns a pointer to a static buffer. Since these activities can happen at the same time this is a race condition, and sometimes .fx files are overwritten with dumped textures. This change declares the static buffer for GetDirectoryFile as thread local, which fixes the race condition. --- main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index fd3af86..a07503f 100644 --- a/main.cpp +++ b/main.cpp @@ -81,7 +81,7 @@ bool WINAPI DllMain(HMODULE hDll, DWORD dwReason, PVOID pvReserved) { } char *GetDirectoryFile(const char *filename) { - static char path[320]; + thread_local static char path[320]; strcpy_s(path, dlldir); strcat_s(path, filename); return path; From c6a63331791405c0a0f90ab230cdbe84cd98119d Mon Sep 17 00:00:00 2001 From: Nicklas Lindgren Date: Mon, 2 Jan 2017 23:00:05 +0100 Subject: [PATCH 2/3] Correct texture dump path in DSfix.ini comment --- DATA/DSfix.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DATA/DSfix.ini b/DATA/DSfix.ini index 5d1bd8d..de0ba09 100644 --- a/DATA/DSfix.ini +++ b/DATA/DSfix.ini @@ -184,7 +184,7 @@ maxBackups 10 # enables texture dumping # you *only* need this if you want to create your own override textures -# textures will be dumped to "dsfix\tex_override\[hash].tga" +# textures will be dumped to "dsfix\tex_dump\[hash].tga" enableTextureDumping 0 # enables texture override From 88f93b86ee22e60d4e2587ba17f53e2ec52e134e Mon Sep 17 00:00:00 2001 From: Nicklas Lindgren Date: Tue, 31 Jan 2017 17:32:18 +0100 Subject: [PATCH 3/3] Fix VS2012 compatibility --- main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index a07503f..7c15e98 100644 --- a/main.cpp +++ b/main.cpp @@ -81,7 +81,7 @@ bool WINAPI DllMain(HMODULE hDll, DWORD dwReason, PVOID pvReserved) { } char *GetDirectoryFile(const char *filename) { - thread_local static char path[320]; + __declspec( thread ) static char path[320]; strcpy_s(path, dlldir); strcat_s(path, filename); return path;