|
10 | 10 |
|
11 | 11 | namespace Beef {
|
12 | 12 | class Application : ProfileInfoProvider, MmrListener {
|
13 |
| - private readonly String _version = "1.5"; |
| 13 | + private readonly String _version = "1.6"; |
14 | 14 | private BeefConfig _config;
|
15 | 15 | private String _botPrefix;
|
16 | 16 | private BeefUserConfigManager _userManager;
|
@@ -694,8 +694,28 @@ public void OnMmrRead(List<Tuple<ProfileInfo, LadderInfo>> mmrList) {
|
694 | 694 | if (user == null)
|
695 | 695 | continue;
|
696 | 696 |
|
| 697 | + // If the LadderInfo for a user is null, we failed to update their information. |
| 698 | + // In this case, use the last known values so they are still displayed. |
| 699 | + Tuple<ProfileInfo, LadderInfo> mmrDictionaryEntry = entry; |
| 700 | + if (entry.Item2 == null) { |
| 701 | + // Also make sure we have a previous MMR to show |
| 702 | + // If there isn't, leave it null so it displays correctly. |
| 703 | + if (!String.IsNullOrEmpty(user.LastKnownMmr)) { |
| 704 | + LadderInfo previousInfo = new LadderInfo(); |
| 705 | + previousInfo.League = user.LastKnownLeague; |
| 706 | + previousInfo.Mmr = user.LastKnownMmr; |
| 707 | + previousInfo.Race = user.LastKnownMainRace; |
| 708 | + |
| 709 | + mmrDictionaryEntry = new Tuple<ProfileInfo, LadderInfo>(entry.Item1, previousInfo); |
| 710 | + } |
| 711 | + } else { |
| 712 | + // If the update was successful, record it for later too. |
| 713 | + // (Note: Should this be done on the MMR reading thread? Seems silly to block the main context for this.) |
| 714 | + _userManager.UpdateUserLadderInfo(user.BeefName, entry.Item2); |
| 715 | + } |
| 716 | + |
697 | 717 | if (!profileIdToMaxMmrDict.ContainsKey(user.BeefName))
|
698 |
| - profileIdToMaxMmrDict.Add(user.BeefName, entry); |
| 718 | + profileIdToMaxMmrDict.Add(user.BeefName, mmrDictionaryEntry); |
699 | 719 | else
|
700 | 720 | Console.WriteLine("Warning: User " + user.BeefName + " already exists in the profileIdToMaxMmrDict!");
|
701 | 721 | }
|
|
0 commit comments