static void Main() { AELogger.Prepare(); try { AppDomain currentDomain = AppDomain.CurrentDomain; ThreadExceptionHandler handler = new ThreadExceptionHandler(); currentDomain.UnhandledException += new UnhandledExceptionEventHandler(handler.ApplicationThreadException); Application.ThreadException += new ThreadExceptionEventHandler(handler.ApplicationThreadException); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new LALEForm()); } catch (Exception e) { AELogger.Log("Exception: " + e.Message); AELogger.Log("Exception: " + e.StackTrace); int i = 1; while (e.InnerException != null) { e = e.InnerException; AELogger.Log("InnerException " + i + ": " + e.Message); AELogger.Log("InnerException " + i + ": " + e.StackTrace); i++; } Console.WriteLine(e.Message); MessageBox.Show("UNHAPPY ERROR :(\nhey, you should save the logfile.txt and give it to the developers of this tool \n--------------\n " + e.Message + "\n" + e.StackTrace, "Exception!", MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); } AELogger.WriteLog(); }
public void HandleException(object sender, Exception e) { string exceptionString = "UNHAPPY ERROR :(\nyou should save the logfile.txt and give it to the developers of this tool \n--------------\n "; if (e == null) { AELogger.Log("BIG PROBLEM, EXCEPTION IS NULL"); exceptionString += "BIG PROBLEM, EXCEPTION IS NULL\n"; } else { AELogger.Log("Exception: " + e.Message); AELogger.Log("Exception: " + e.StackTrace); if (e.Data.Count > 0) { AELogger.Log("Exception: additional data:"); foreach (DictionaryEntry d in e.Data) { AELogger.Log(" " + d.Key + ": " + d.Value); } } int i = 1; Exception a = e; while (a.InnerException != null) { a = a.InnerException; AELogger.Log("InnerException " + i + ": " + a.Message); AELogger.Log("InnerException " + i + ": " + a.StackTrace); if (a.Data.Count > 0) { AELogger.Log("InnerException " + i + ": additional data:"); foreach (DictionaryEntry d in a.Data) { AELogger.Log(" " + d.Key + ": " + d.Value); } } i++; } Console.WriteLine(e.Message); exceptionString += e.Message + "\n" + e.StackTrace + "\n"; } if (sender != null) { AELogger.Log("sender is " + sender.ToString()); exceptionString += "sender is " + sender.ToString(); } else { AELogger.Log("sender is null"); exceptionString += "sender is null"; } MessageBox.Show(exceptionString, "Exception!", MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); AELogger.WriteLog(); Application.Exit(); }
public void ApplicationThreadException(object sender, ThreadExceptionEventArgs e) { AELogger.Log("threadexception"); HandleException(sender, e.Exception); }
public void ApplicationThreadException(object sender, UnhandledExceptionEventArgs e) { AELogger.Log("unhandled\ne.IsTerminating = " + e.IsTerminating); HandleException(sender, (Exception)e.ExceptionObject); }
public void Analyze(string filename) { if (File.Exists(filename)) { byte[] buffer; spritebankinfo = new SortedDictionary <int, HashSet <byte> >(); reversespritebankinfo = new SortedDictionary <byte, HashSet <int> >(); spritelocationinfo = new SortedDictionary <byte, HashSet <Room> >(); using (BinaryReader br = new BinaryReader(File.OpenRead(filename))) { buffer = br.ReadBytes((Int32)br.BaseStream.Length); } gb = new GBHL.GBFile(buffer); tileLoader = new TileLoader(gb); dungeonDrawer = new DungeonDrawer(gb); minimapDrawer = new MinimapDrawer(gb); overworldDrawer = new OverworldDrawer(gb); patches = new Patch(gb); sprites = new Sprites(gb); AELogger.Log("BEGIN ANALYSIS"); for (int room_index = 0; room_index < 0xFF; room_index++) { DoOverworld((byte)room_index); DoDungeon(0, (byte)room_index); DoDungeon(0x6, (byte)room_index); } { StringBuilder sb = new StringBuilder(); sb.Append("\n\n================================================\nSprite banks contain these sprites:\n"); foreach (KeyValuePair <int, HashSet <byte> > pair in spritebankinfo) { sb.Append("bank "); sb.Append(pair.Key.ToString("X2")); foreach (byte id in pair.Value) { sb.Append("\n\t"); sb.Append(Names.GetName(Names.sprites, id)); sb.Append(","); } sb.Length = sb.Length - 1; sb.Append("\n"); } AELogger.Log(sb); } { StringBuilder sb = new StringBuilder(); sb.Append("\n\n================================================\nSprites are used in these rooms:\n"); foreach (KeyValuePair <byte, HashSet <Room> > pair in spritelocationinfo) { sb.Append("sprite '"); sb.Append(Names.GetName(Names.sprites, pair.Key)); sb.Append("' in rooms:\n"); foreach (Room room in pair.Value) { if (room.bOverworld) { sb.Append("\tOVE ---: "); } else if (room.dungeonIndex < 6) { sb.Append("\tDUN 0-5: "); } else { sb.Append("\tDUN 6-?: "); } sb.Append(room.mapIndex.ToString("X2")); sb.Append(" (bank "); sb.Append(room.bank.ToString("X2")); sb.Append("),\n"); } sb.Length = sb.Length - 1; sb.Append("\n"); } AELogger.Log(sb); } { StringBuilder sb = new StringBuilder(); sb.Append("\n\n================================================\nSprites are pickable in these sprite banks:\n"); foreach (KeyValuePair <byte, HashSet <int> > pair in reversespritebankinfo) { sb.Append("sprite '"); sb.Append(Names.GetName(Names.sprites, pair.Key)); sb.Append("':\n\t"); foreach (int id in pair.Value) { sb.Append(id.ToString("X2")); sb.Append(", "); } sb.Length = sb.Length - 1; sb.Append("\n"); } AELogger.Log(sb); } } // if file.exists } // analyze
public void DoWarps(List <Warps> warps, byte dungeonIndex, byte mapIndex, bool bOverworld) { if (warps == null) { //AELogger.Log("null warps"); return; } else if (warps.Count <= 0) { //AELogger.Log("no warps"); return; } StringBuilder sb = new StringBuilder(); if (bOverworld) { sb.Append("overworld map "); sb.Append((char)((int)'A' + mapIndex % 16)); sb.Append('-'); sb.Append((mapIndex / 16) + 1); } else { sb.Append("interior map "); sb.Append(dungeonIndex.ToString("X2")); sb.Append('_'); sb.Append(mapIndex.ToString("X2")); } sb.Append("\n\thas warps: "); int index = 0; //string[] types = { "Overworld", "Interior", "Side-Scroller" }; foreach (Warps w in warps) { sb.Append("\n\t\twarp number: "); sb.Append(index); if (w.type == 0) // overworld { sb.Append("\n\t\t\tdestination: OVERWORLD "); sb.Append((char)((int)'A' + w.map % 16)); sb.Append('-'); sb.Append((w.map / 16) + 1); } else if (w.type == 1) // dungeon { if (w.region < 6) { sb.Append("\n\t\t\tdestination: dungeon 0-5 room number: "); } else { sb.Append("\n\t\t\tdestination: dungeon 6++ room number: "); } sb.Append(w.map.ToString("X2")); } else //sidescroller { sb.Append("\n\t\t\tdestination map: "); sb.Append(w.map.ToString("X2")); sb.Append("\n\t\t\tdestination region: "); sb.Append(w.region.ToString("X2")); } //sb.Append(w.x.ToString("X2")); //sb.Append(w.y.ToString("X2")); index++; } AELogger.Log(sb, false); }