public static ParseLootMessages ( |
||
h | ||
newDrops | Dictionary |
|
newItems | int>.List | |
commit | bool | |
switchHunt | bool | |
addEverything | bool | |
return | void |
public static void LoadLog(Hunt h, string logPath) { resetHunt(h); StreamReader streamReader = new StreamReader(logPath); string line; Dictionary <string, List <string> > logMessages = new Dictionary <string, List <string> >(); while ((line = streamReader.ReadLine()) != null) { if (line.Length < 15) { continue; } string t = line.Substring(0, 5); if (!(t[0].isDigit() && t[1].isDigit() && t[3].isDigit() && t[4].isDigit() && t[2] == ':')) { continue; //not a valid timestamp } if (!logMessages.ContainsKey(t)) { logMessages.Add(t, new List <string>()); } logMessages[t].Add(line); } Parser.ParseLootMessages(h, logMessages, null, true, true); LootDatabaseManager.UpdateLoot(); }
public static void clearOldLog(Hunt h, int clearMinutes = 10) { var time = DateTime.Now; int hour = time.Hour; int minute = time.Minute; while (clearMinutes > 60) { hour--; clearMinutes -= 60; } if (minute >= clearMinutes) { minute -= clearMinutes; } else { hour--; minute = 60 + (minute - clearMinutes); } int stamp = TimestampManager.getDayStamp(); while (hour < 0) { hour += 24; stamp--; } h.Reset(clearMinutes); HuntManager.SetHuntTime(h, clearMinutes); LootDatabaseManager.DeleteMessagesBefore(h, stamp, hour, minute); SQLiteDataReader reader = LootDatabaseManager.GetHuntMessages(h); Dictionary <string, List <string> > logMessages = new Dictionary <string, List <string> >(); while (reader.Read()) { string line = reader["message"].ToString(); if (line.Length < 15) { continue; } string t = line.Substring(0, 5); if (!(t[0].isDigit() && t[1].isDigit() && t[3].isDigit() && t[4].isDigit() && t[2] == ':')) { continue; //not a valid timestamp } if (!logMessages.ContainsKey(t)) { logMessages.Add(t, new List <string>()); } logMessages[t].Add(line); } Parser.ParseLootMessages(h, logMessages, null, false, false, true); LootDatabaseManager.UpdateLoot(); }
public static ParseMemoryResults ParseLogResults(ReadMemoryResults res) { if (res == null) { return(null); } ParseMemoryResults o = new ParseMemoryResults(); // first we add the new parsed damage logs to the totalDamageResults o.newDamage = GlobalDataManager.UpdateDamageInformation(res.damageDealt); // now that we have updated the damage results, fill in the DPS meter, we use damage from the last 15 minutes for this List <string> times = TimestampManager.getLatestTimes(15); GlobalDataManager.GenerateDamageResults(o.damagePerSecond, times); // similar to damage, we keep a totalExperienceResults list // first update it with the new information int newExperience = GlobalDataManager.UpdateExperience(res.exp); // now compute the experience per hour // we use the same formula Tibia itself does so we get the same value // this formula is basically, take the experience in the last 15 minutes and multiply it by 4 o.expPerHour = GlobalDataManager.GetExperiencePerHour(); // Parse event messages foreach (Tuple <Event, string> newEvent in GlobalDataManager.UpdateEventInformation(res.eventMessages)) { o.newEventMessages.Add(newEvent); } // Update the look information foreach (string newLook in GlobalDataManager.UpdateLookInformation(res.lookMessages)) { o.newLooks.Add(newLook); } // Update death information o.death = GlobalDataManager.UpdateDeaths(res.deaths); // now parse any new commands given by users foreach (string newCommand in GlobalDataManager.UpdateCommands(res.commands)) { o.newCommands.Add(newCommand); } // check new urls GlobalDataManager.UpdateURLs(res.urls); HuntManager.AddUsedItems(HuntManager.activeHunt, res.usingMessages); Parser.ParseLootMessages(HuntManager.activeHunt, res.itemDrops, o.newItems, true, true); HuntManager.activeHunt.totalExp += newExperience; readWatch.Stop(); if (newExperience == 0) { if (ticksSinceExperience < 120) { ticksSinceExperience += readWatch.Elapsed.TotalSeconds; } } else { ticksSinceExperience = 0; } if (ticksSinceExperience < 120) { HuntManager.activeHunt.totalTime += readWatch.Elapsed.TotalSeconds; } readWatch.Restart(); HuntManager.SaveHunts(); return(o); }