public void LoadFile() { int i; string fileLine; string[] fileLineSplited; try { using (StreamReader reader = new StreamReader(filePath)) { for (int j = 0; j < 3; j++) { i = 0; try { while ((fileLine = reader.ReadLine()) != null && fileLine != "-") { fileLineSplited = fileLine.Split(null); PickTable(j)[i] = new ScoreboardEntry(fileLineSplited[0], fileLineSplited[1]); PickTable(j)[i].SetRank(i + 1); i++; } } catch (Exception e) { if (e is FormatException || e is IndexOutOfRangeException) { new ErrorMessageForm("Error loading scoreboard data\nData will be lost"); reader.Close(); Reset(j); break; } } } } } catch { isScoreboardAvailable = false; new ErrorMessageForm("Error loading scoreboard data\nScoreboard will be disabled"); } }
public override void AddEntry(ScoreboardEntry entry, int diffLevel) { ScoreboardEntry[] tab = PickTable(diffLevel); for (int i = 0; i < tab.Length; i++) { try { if (tab[i] == null) { entry.SetRank(i + 1); tab[i] = entry; break; } if (tab[i].GetTime() < entry.GetTime()) { continue; } if (tab[i].GetTime() > entry.GetTime()) { for (int j = tab.Length - 1; j > i; j--) { if (tab[j] != null || (tab[j] == null && tab[j - 1] != null)) { tab[j] = tab[j - 1]; tab[j].SetRank(j + 1); } } entry.SetRank(i + 1); tab[i] = entry; break; } } catch (IndexOutOfRangeException) { new ErrorMessageForm("Scorboard data corupted!\nData will be lost!"); Reset(diffLevel); break; } } Save(); }
public virtual void AddEntry(ScoreboardEntry entry, int diffLevel) { }