Skip to content

Commit 2a685a3

Browse files
committed
Change: Improve graphics init error handling on 32-bit modded process
As some drivers are just plain broken, and OpenTK throws an access violation exception when requesting certain GL3 features which should be supported
1 parent 3b48616 commit 2a685a3

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

source/DevTools/LBAHeader/Program.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.IO;
33
using Mono.Cecil;
44

@@ -66,6 +66,7 @@ static void AddLbaFlag(string f)
6666
/// <summary>Marks an ANYCPU executable as 32-bit preferred</summary>
6767
public static void Add32BitFlag(string fileToProcess)
6868
{
69+
string configFile = fileToProcess + ".config";
6970
string finalFileName = fileToProcess.Replace(".exe", "-32.exe");
7071
Console.WriteLine("Creating 32-bit preferred copy of executable " + fileToProcess);
7172
var output = Console.Out;
@@ -101,6 +102,11 @@ public static void Add32BitFlag(string fileToProcess)
101102
Console.WriteLine("An unexpected error occured whilst attempting to apply Corflags to executable " + fileToProcess);
102103
}
103104

105+
if (File.Exists(configFile))
106+
{
107+
//Also copy the application config file, so that LoadFromRemoteSources etc. are preserved
108+
File.Copy(configFile, configFile.Replace(".exe", "-32.exe"));
109+
}
104110
}
105111
}
106112
}

source/LibRender2/BaseRenderer.cs

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using System.Runtime.ExceptionServices;
45
using LibRender2.Backgrounds;
56
using LibRender2.Cameras;
67
using LibRender2.Fogs;
@@ -265,6 +266,7 @@ protected BaseRenderer(HostInterface CurrentHost, BaseOptions CurrentOptions, Fi
265266
/// <summary>
266267
/// Call this once to initialise the renderer
267268
/// </summary>
269+
[HandleProcessCorruptedStateExceptions] //As some graphics cards crash really nastily if we request unsupported features
268270
public virtual void Initialize()
269271
{
270272

source/OpenBVE/app.config

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8" ?>
22
<configuration>
33
<startup>
44
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
55
</startup>
66
<runtime>
77
<loadFromRemoteSources enabled="true" />
88
<gcAllowVeryLargeObjects enabled="true" />
9-
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
10-
<probing privatePath="Data\Formats" />
11-
<dependentAssembly>
12-
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
13-
<bindingRedirect oldVersion="0.0.0.0-4.0.6.0" newVersion="4.0.6.0" />
14-
</dependentAssembly>
15-
</assemblyBinding>
9+
<legacyCorruptedStateExceptionsPolicy enabled="true|false"/>
1610
</runtime>
1711
</configuration>

0 commit comments

Comments
 (0)