3D-Arena (Duell, Hub, Freiheit, Erstellung, Bestenliste), Retiarius beidhändig, Waffen je Klasse, Einführung, Willkommen, weniger Reiter, Wirtschaft ohne Taberna, Kantenglättung, Leuchten, weiche Schatten, Gamepad, Absturz-Protokoll
Stand von main 20cd8ba2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -25,10 +25,46 @@ namespace GladiatorIdle
|
||||
if (DevShot.Active) SoundManager.Enabled = false; // Testläufe stumm
|
||||
if (DevShot.Playtest) { Playtest.Run(); return; }
|
||||
|
||||
using var game = new ArenaGame();
|
||||
game.Run();
|
||||
SoundManager.StopAll();
|
||||
SoundManager.Shutdown();
|
||||
AppDomain.CurrentDomain.UnhandledException += (_, e) => CrashLog(e.ExceptionObject as Exception);
|
||||
try
|
||||
{
|
||||
using var game = new ArenaGame();
|
||||
_game = game;
|
||||
game.Run();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
CrashLog(ex);
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
SoundManager.StopAll();
|
||||
SoundManager.Shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
static ArenaGame? _game;
|
||||
static bool _crashed;
|
||||
|
||||
/// Absturz: erst den Spielstand sichern, dann die Ursache nach %AppData%\GladiatorIdle\crash.log
|
||||
/// (die neueste oben). Testläufe schreiben ins Protokoll des Laufs.
|
||||
static void CrashLog(Exception? ex)
|
||||
{
|
||||
if (_crashed) return;
|
||||
_crashed = true;
|
||||
try { _game?.SaveNow(); } catch { /* Spielstand nicht sicherbar */ }
|
||||
try
|
||||
{
|
||||
string text = $"=== {DateTime.Now:yyyy-MM-dd HH:mm:ss} {typeof(Program).Assembly.GetName().Version}\n{ex}\n\n";
|
||||
if (DevShot.Active) { DevShot.Log("CRASH " + ex); return; }
|
||||
string dir = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "GladiatorIdle");
|
||||
System.IO.Directory.CreateDirectory(dir);
|
||||
string file = System.IO.Path.Combine(dir, "crash.log");
|
||||
string old = System.IO.File.Exists(file) ? System.IO.File.ReadAllText(file) : "";
|
||||
System.IO.File.WriteAllText(file, text + (old.Length > 200_000 ? old[..200_000] : old));
|
||||
}
|
||||
catch { /* nichts mehr zu tun */ }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user