From c94328ae7d1371db8a3d7711895fd6e1501d4b7c Mon Sep 17 00:00:00 2001
From: =?utf8?q?Jos=C3=A9=20Fonseca?= <jose.r.fonseca@gmail.com>
Date: Thu, 8 Nov 2012 12:29:02 +0000
Subject: [PATCH] d3dretrace: Fix MSVC build.

---
 retrace/d3d9retrace.py      | 14 ++++++++++++++
 retrace/d3dretrace.hpp      |  3 ---
 retrace/d3dretrace_main.cpp |  9 ---------
 retrace/dllretrace.py       |  1 -
 4 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/retrace/d3d9retrace.py b/retrace/d3d9retrace.py
index 44104ce..7030f86 100644
--- a/retrace/d3d9retrace.py
+++ b/retrace/d3d9retrace.py
@@ -43,6 +43,20 @@ class D3DRetracer(Retracer):
 
         Retracer.retraceApi(self, api)
 
+    def invokeFunction(self, function):
+        if function.name in ('Direct3DCreate9', 'Direct3DCreate9Ex'):
+            print 'if (retrace::debug && !g_szD3D9DllName) {'
+            print '    /* '
+            print '     * XXX: D3D9D only works for simple things, it often introduces errors'
+            print '     * on complex traces, or traces which use unofficial D3D9 features.'
+            print '     */'
+            print '    if (0) {'
+            print '        g_szD3D9DllName = "d3d9d.dll";'
+            print '    }'
+            print '}'
+
+        Retracer.invokeFunction(self, function)
+
     def invokeInterfaceMethod(self, interface, method):
         # keep track of the last used device for state dumping
         if interface.name in ('IDirect3DDevice9', 'IDirect3DDevice9Ex'):
diff --git a/retrace/d3dretrace.hpp b/retrace/d3dretrace.hpp
index b479237..dc174a8 100644
--- a/retrace/d3dretrace.hpp
+++ b/retrace/d3dretrace.hpp
@@ -35,9 +35,6 @@
 struct IDirect3DDevice9;
 
 
-extern const char *g_szD3D9DllName;
-
-
 namespace d3dretrace {
 
 
diff --git a/retrace/d3dretrace_main.cpp b/retrace/d3dretrace_main.cpp
index 4bd4b80..a19511a 100644
--- a/retrace/d3dretrace_main.cpp
+++ b/retrace/d3dretrace_main.cpp
@@ -39,15 +39,6 @@ d3dretrace::pLastDirect3DDevice9 = NULL;
 
 void
 retrace::setUp(void) {
-    if (retrace::debug) {
-        /* 
-         * XXX: D3D9D only works for simple things, it often introduces errors
-         * on complex traces, or traces which use unofficial D3D9 features.
-         */
-        if (0) {
-            g_szD3D9DllName = "d3d9d.dll";
-        }
-    }
 }
 
 
diff --git a/retrace/dllretrace.py b/retrace/dllretrace.py
index 318741c..4fd481c 100644
--- a/retrace/dllretrace.py
+++ b/retrace/dllretrace.py
@@ -50,7 +50,6 @@ class DllDispatcher(Dispatcher):
         print r'        if (!g_h%sModule) {' % tag
         print r'            os::log("error: failed to load %s.dll\n");' % api.name
         print r'            exit(1);'
-        print r'            return NULL;'
         print r'        }'
         print r'    }'
         print r'    return GetProcAddress(g_h%sModule, lpProcName);' % tag
-- 
2.45.2