void buildSplitPlayer(PSO2DamageTrackers tracker, string nameSuffix) { if (IsSplit(tracker)) { if (parser.trackersToSuppress.HasFlag(tracker)) { return; //do nothing if tracker is suppressed } var player = new PSO2Player($"{name} | {nameSuffix}", id, updateInterval, parser.InstanceUpdateHistoryDuration, tracker, parser); player.SetSpecialPlayer(true, true); playerTrackerDict.Add(tracker, player); Players.Add(player); } }
private void updateTick(object user) { lock (updateLock) { if (resetQueued) { resetQueued = false; internalReset(); } if ((DateTime.Now - timeLastLogScanned).TotalSeconds > 10) { timeLastLogScanned = DateTime.Now; string latestLogFile = getLatestLogFile(); if (latestLogFile != lastOpenedFile) { initializeLogFile(latestLogFile); } } var damageInstances = getLatestDamageInstances(); NewDamageInstanceCount = damageInstances.Count; if (NewDamageInstanceCount > 0 && resetParserOnNewInstance) { resetParserOnNewInstance = false; internalReset(); foreach (var instance in damageInstances) { EnsurePlayerExists(instance); //since we clear the _players in internalReset, we must ensure all players exist again. } } foreach (var instance in damageInstances) { if (!hasLogStartTime) { hasLogStartTime = true; timeLogStarted = instance.Timestamp; NewSessionStarted?.Invoke(this, EventArgs.Empty); } instance.UpdateLogStartTime(timeLogStarted); lastDamageInstance = instance; if (_players.ContainsKey(instance.SourceId)) { var sourcePlayer = _players[instance.SourceId]; sourcePlayer.AddDamageInstance(instance); } if (_players.ContainsKey(instance.TargetId)) { var targetPlayer = _players[instance.TargetId]; targetPlayer.AddDamageInstance(instance); } if (instance.IsZanverseDamage && IsZanverseSplit && !trackersToSuppress.HasFlag(PSO2DamageTrackers.Zanverse)) { if (ZanversePlayer == null) { ZanversePlayer = new PSO2Player("Zanverse", long.MaxValue, updateClock, InstanceUpdateHistoryDuration, PSO2DamageTrackers.Zanverse, this); ZanversePlayer.SetSpecialPlayer(true, false); } ZanversePlayer.AddZanverseDamageInstance(instance); } damageInstancesQueued++; //should send out an update every time updateClock interval is passed between last update and this. //allows an old log to be pasted at once and still read out dps accurately over time while (lastDamageInstance.RelativeTimestamp - lastUpdateTime > updateClock) { DoUpdateTick(); } } if (timeLastUpdateInvoked != DateTime.MinValue && DateTime.Now - timeLastUpdateInvoked > timeUntilSendManualUpdate && damageInstancesQueued > 0) { NewDamageInstanceCount = damageInstancesQueued; //bugfix, NewDamageInstanceCount being set to 0 by above call is incorrect, since there actually are new instances being processed DoUpdateTick(); } if (AutoEndSession && timeLastUpdateInvoked != DateTime.MinValue && DateTime.Now - timeLastUpdateInvoked > AutoEndTimeout && !resetParserOnNewInstance) { Console.WriteLine("Notifying to end session"); AutoEndSessionEvent?.Invoke(this, EventArgs.Empty); } } }