mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-13 01:26:50 -04:00
Attempt to workaround rare crash that would happen when IDirect3DDevice9_Reset returns D3DERR_NOTAVAILABLE
This commit is contained in:
parent
1ff3f481c4
commit
a318d9ed98
@ -180,8 +180,10 @@ void Gfx_Create(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cc_bool Gfx_TryRestoreContext(void) {
|
cc_bool Gfx_TryRestoreContext(void) {
|
||||||
|
static int availFails;
|
||||||
D3DPRESENT_PARAMETERS args = { 0 };
|
D3DPRESENT_PARAMETERS args = { 0 };
|
||||||
cc_result res;
|
cc_result res;
|
||||||
|
|
||||||
/* Rarely can't even create device to begin with */
|
/* Rarely can't even create device to begin with */
|
||||||
if (!deviceCreated) {
|
if (!deviceCreated) {
|
||||||
TryCreateDevice();
|
TryCreateDevice();
|
||||||
@ -195,6 +197,12 @@ cc_bool Gfx_TryRestoreContext(void) {
|
|||||||
res = IDirect3DDevice9_Reset(device, &args);
|
res = IDirect3DDevice9_Reset(device, &args);
|
||||||
if (res == D3DERR_DEVICELOST) return false;
|
if (res == D3DERR_DEVICELOST) return false;
|
||||||
|
|
||||||
|
/* A user reported an issue where after changing some settings in */
|
||||||
|
/* nvidia control panel, IDirect3DDevice9_Reset would return */
|
||||||
|
/* D3DERR_NOTAVAILABLE and hence crash the game */
|
||||||
|
/* So try to workaround this by only crashing after 50 failures */
|
||||||
|
if (res == D3DERR_NOTAVAILABLE && availFails++ < 50) return false;
|
||||||
|
|
||||||
if (res) Logger_Abort2(res, "Error recreating D3D9 context");
|
if (res) Logger_Abort2(res, "Error recreating D3D9 context");
|
||||||
D3D9_UpdateCachedDimensions();
|
D3D9_UpdateCachedDimensions();
|
||||||
return true;
|
return true;
|
||||||
|
@ -337,22 +337,22 @@ void Launcher_LoadTheme(void) {
|
|||||||
ParseColor("launcher-btn-highlight-inactive-col", &Launcher_Theme.ButtonHighlightColor);
|
ParseColor("launcher-btn-highlight-inactive-col", &Launcher_Theme.ButtonHighlightColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
CC_NOINLINE static void Launcher_SetCol(const char* key, BitmapCol col) {
|
CC_NOINLINE static void SaveColor(const char* key, BitmapCol color) {
|
||||||
cc_string value; char valueBuffer[8];
|
cc_string value; char valueBuffer[6];
|
||||||
/* Component order might be different to BitmapCol */
|
|
||||||
PackedCol tmp = PackedCol_Make(BitmapCol_R(col), BitmapCol_G(col), BitmapCol_B(col), 0);
|
|
||||||
|
|
||||||
String_InitArray(value, valueBuffer);
|
String_InitArray(value, valueBuffer);
|
||||||
PackedCol_ToHex(&value, tmp);
|
String_AppendHex(&value, BitmapCol_R(color));
|
||||||
|
String_AppendHex(&value, BitmapCol_G(color));
|
||||||
|
String_AppendHex(&value, BitmapCol_B(color));
|
||||||
Options_Set(key, &value);
|
Options_Set(key, &value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Launcher_SaveTheme(void) {
|
void Launcher_SaveTheme(void) {
|
||||||
Launcher_SetCol("launcher-back-col", Launcher_Theme.BackgroundColor);
|
SaveColor("launcher-back-col", Launcher_Theme.BackgroundColor);
|
||||||
Launcher_SetCol("launcher-btn-border-col", Launcher_Theme.ButtonBorderColor);
|
SaveColor("launcher-btn-border-col", Launcher_Theme.ButtonBorderColor);
|
||||||
Launcher_SetCol("launcher-btn-fore-active-col", Launcher_Theme.ButtonForeActiveColor);
|
SaveColor("launcher-btn-fore-active-col", Launcher_Theme.ButtonForeActiveColor);
|
||||||
Launcher_SetCol("launcher-btn-fore-inactive-col", Launcher_Theme.ButtonForeColor);
|
SaveColor("launcher-btn-fore-inactive-col", Launcher_Theme.ButtonForeColor);
|
||||||
Launcher_SetCol("launcher-btn-highlight-inactive-col", Launcher_Theme.ButtonHighlightColor);
|
SaveColor("launcher-btn-highlight-inactive-col", Launcher_Theme.ButtonHighlightColor);
|
||||||
Options_SetBool("nostalgia-classicbg", Launcher_Theme.ClassicBackground);
|
Options_SetBool("nostalgia-classicbg", Launcher_Theme.ClassicBackground);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user