diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-05-03 13:02:15 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-05-03 13:02:15 -0400 |
commit | c84310dfebafd3085dc418f3620154f9934865de (patch) | |
tree | d71d47797d2b2ad13371b7f9d562aa3e097d330e /src/StardewModdingAPI/Framework/SGame.cs | |
parent | 482a91962ac02cf83c2647fd7e5ba8627bd0bb0b (diff) | |
parent | 0a2f7e52b9fc1e60fe491b8fd28cf8377f79290b (diff) | |
download | SMAPI-c84310dfebafd3085dc418f3620154f9934865de.tar.gz SMAPI-c84310dfebafd3085dc418f3620154f9934865de.tar.bz2 SMAPI-c84310dfebafd3085dc418f3620154f9934865de.zip |
Merge branch 'develop' into stable
Diffstat (limited to 'src/StardewModdingAPI/Framework/SGame.cs')
-rw-r--r-- | src/StardewModdingAPI/Framework/SGame.cs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/StardewModdingAPI/Framework/SGame.cs b/src/StardewModdingAPI/Framework/SGame.cs index fe7d3aa3..1f2bf3ac 100644 --- a/src/StardewModdingAPI/Framework/SGame.cs +++ b/src/StardewModdingAPI/Framework/SGame.cs @@ -947,7 +947,28 @@ namespace StardewModdingAPI.Framework } catch (Exception ex) { + // log error this.Monitor.Log($"An error occured in the overridden draw loop: {ex.GetLogSummary()}", LogLevel.Error); + + // fix sprite batch + try + { + bool isSpriteBatchOpen = +#if SMAPI_FOR_WINDOWS + SGame.Reflection.GetPrivateValue<bool>(Game1.spriteBatch, "inBeginEndPair"); +#else + SGame.Reflection.GetPrivateValue<bool>(Game1.spriteBatch, "_beginCalled"); +#endif + if (isSpriteBatchOpen) + { + this.Monitor.Log("Recovering sprite batch from error...", LogLevel.Trace); + Game1.spriteBatch.End(); + } + } + catch (Exception innerEx) + { + this.Monitor.Log($"Could not recover sprite batch state: {innerEx.GetLogSummary()}", LogLevel.Error); + } } Context.IsInDrawLoop = false; } @@ -1345,8 +1366,8 @@ namespace StardewModdingAPI.Framework /// <param name="enumerable">The enumeration of items to hash.</param> private int GetHash(IEnumerable enumerable) { - var hash = 0; - foreach (var v in enumerable) + int hash = 0; + foreach (object v in enumerable) hash ^= v.GetHashCode(); return hash; } |