44
55#include " stdafx.h"
66#include " EngineAPI.h"
7- #include " xrCDB/xrXRC.h"
8- #include " xrScriptEngine/script_engine.hpp"
97
108#include " xrCore/ModuleLookup.hpp"
119
@@ -98,12 +96,10 @@ void CEngineAPI::InitializeRenderers()
9896 InitializeNotDedicated ();
9997#endif // DEDICATED_SERVER
10098
101- if (!hRender->exist ())
99+ if (( !hRender->exist ()) | (!psDeviceFlags. test (rsR4|rsR3|rsR2) ))
102100 {
103101 // try to load R1
104- psDeviceFlags.set (rsR4, false );
105- psDeviceFlags.set (rsR3, false );
106- psDeviceFlags.set (rsR2, false );
102+ psDeviceFlags.set (rsR4|rsR3|rsR2, false );
107103 renderer_value = 0 ; // con cmd
108104
109105 hRender->open (r1_name);
@@ -158,19 +154,15 @@ void CEngineAPI::Initialize(void)
158154
159155void CEngineAPI::Destroy (void )
160156{
161- pCreate = 0 ;
162- pDestroy = 0 ;
157+ if (hGame) hGame->close ();
158+ if (hTuner) hTuner->close ();
159+ if (hRender) hRender->close ();
160+ pCreate = nullptr ;
161+ pDestroy = nullptr ;
163162 Engine.Event ._destroy ();
164163 XRC.r_clear_compact ();
165164}
166165
167- extern " C"
168- {
169- using SupportsAdvancedRendering = bool __cdecl ();
170- using SupportsDX10Rendering = bool XR_EXPORT ();
171- using SupportsDX11Rendering = bool XR_EXPORT ();
172- };
173-
174166void CEngineAPI::CreateRendererList ()
175167{
176168#ifdef DEDICATED_SERVER
@@ -208,10 +200,10 @@ void CEngineAPI::CreateRendererList()
208200 if (hRender->exist ())
209201 {
210202 bSupports_r2 = true ;
211- auto test_rendering =
212- (SupportsAdvancedRendering* )hRender->getProcAddress (" SupportsAdvancedRendering" );
213- R_ASSERT (test_rendering );
214- bSupports_r2_5 = test_rendering ();
203+ using SupportsAdvancedRendering = bool (*)();
204+ auto test = (SupportsAdvancedRendering)hRender->getProcAddress (" SupportsAdvancedRendering" );
205+ R_ASSERT (test );
206+ bSupports_r2_5 = test ();
215207 }
216208
217209 // try to initialize R3
@@ -222,10 +214,10 @@ void CEngineAPI::CreateRendererList()
222214 SetErrorMode (0 );
223215 if (hRender->exist ())
224216 {
225- auto test_dx10_rendering =
226- (SupportsDX10Rendering* )hRender->getProcAddress (" SupportsDX10Rendering" );
227- R_ASSERT (test_dx10_rendering );
228- bSupports_r3 = test_dx10_rendering ();
217+ using SupportsDX10Rendering = bool (*)();
218+ auto test = (SupportsDX10Rendering)hRender->getProcAddress (" SupportsDX10Rendering" );
219+ R_ASSERT (test );
220+ bSupports_r3 = test ();
229221 }
230222
231223 // try to initialize R4
@@ -236,10 +228,10 @@ void CEngineAPI::CreateRendererList()
236228 SetErrorMode (0 );
237229 if (hRender->exist ())
238230 {
239- auto test_dx11_rendering =
240- (SupportsDX11Rendering* )hRender->getProcAddress (" SupportsDX11Rendering" );
241- R_ASSERT (test_dx11_rendering );
242- bSupports_r4 = test_dx11_rendering ();
231+ using SupportsDX11Rendering = bool (*)();
232+ auto test = (SupportsDX11Rendering)hRender->getProcAddress (" SupportsDX11Rendering" );
233+ R_ASSERT (test );
234+ bSupports_r4 = test ();
243235 }
244236 }
245237
0 commit comments