private void handleLine(String message) { try { if (messageParser.isActionStart(message)) { actionStart = GetMessageStamp(message); } else if (messageParser.isActionEnd(message)) { actionEnd = GetMessageStamp(message); if (actionStart < 0) { /* The script started during a mining action. The start timestamp is not valid. ignore. */ } else { /* Check for day wrap around */ while (actionStart > actionEnd) { actionStart -= 24 * 3600; } /* Calculate the duration of the mining action */ actionDuration = actionEnd - actionStart; /* Sum up total time spent in mining actions */ totalTime += actionDuration; } actions++; AddLog(String.Format("{0,-55}:{1,4}:{2,4}:{3,-7:G5}\n", message, ticks, actions, getRatio())); UpdateDisplay(); foreach (String line in deferred) { handleLine(line); } deferred.Clear(); } else if (messageParser.isSkillGain(message)) { int stamp = GetMessageStamp(message); if (stamp > actionEnd) { deferred.Add(message); } else { /* Get amount of skill gained */ Match m = Regex.Match(message, ".*increased by (.*) to.*"); double skill = Double.Parse(m.Groups[1].Value.Replace(",", "."), numberFormat); /* Sum up total skill gained */ totalSkill += skill; /* Sum up total time spent in skill gaining actions */ skillTime += actionDuration; /* Skill gain per hour of the last action */ if (actionDuration == 0) { rel = 0.0; } else { rel = skill / actionDuration; } /* Skill gain per hour of skill gaining actions */ if (skillTime == 0) { srel = 0.0; } else { srel = totalSkill / skillTime; } /* Skill gain per hour of all mining actions */ if (totalTime == 0) { trel = 0.0; } else { trel = totalSkill / totalTime; } /* Print ratio, number of actions, skill gain per hour of the last action, skill gaining actions and all actions */ ticks++; AddLog(String.Format("{0,-55}:{1,4}:{2,4}:{3,-7:G5}:{4,-7:G5}:{5,-7:G5}:{6,-7:G5}\n", message, ticks, actions, getRatio(), rel * 3600, srel * 3600, trel * 3600)); UpdateDisplay(); } } } catch (Exception e) { AddLog(e.Message + "\n"); } }