Skip to content

Commit

Permalink
#1789 Combat log events are now output consistently if the timestamps…
Browse files Browse the repository at this point in the history
… match
  • Loading branch information
Wotuu committed Jun 28, 2023
1 parent 077fa4d commit 9b1d65b
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 32 deletions.
16 changes: 14 additions & 2 deletions app/Service/CombatLog/Filters/CombatLogDungeonRouteFilter.php
Expand Up @@ -3,6 +3,8 @@
namespace App\Service\CombatLog\Filters;

use App\Logic\CombatLog\BaseEvent;
use App\Logic\CombatLog\CombatEvents\AdvancedCombatLogEvent;
use App\Logic\CombatLog\Guid\Creature;
use App\Models\DungeonRoute;
use App\Service\CombatLog\Interfaces\CombatLogParserInterface;
use App\Service\CombatLog\ResultEvents\BaseResultEvent;
Expand Down Expand Up @@ -70,9 +72,19 @@ public function parse(BaseEvent $combatLogEvent, int $lineNr): bool
*/
public function getResultEvents(): Collection
{
// @TODO sorting here causes inconsistent results when the timestamp is the same
return $this->resultEvents->sortBy(function (BaseResultEvent $baseResultEvent) {
return $baseResultEvent->getBaseEvent()->getTimestamp()->getTimestampMs();
// Add some CONSISTENT (not necessarily accurate) numbers so that events with
$addition = 0;
$baseEvent = $baseResultEvent->getBaseEvent();
if ($baseEvent instanceof AdvancedCombatLogEvent) {
$guid = $baseEvent->getAdvancedData()->getInfoGuid();
if ($guid instanceof Creature) {
// Ensure that the addition doesn't go higher than 1
$addition = min(0.99999, ($guid->getId() + hexdec($guid->getSpawnUID())) / 10000000000000);
}
}

return $baseResultEvent->getBaseEvent()->getTimestamp()->getTimestampMs() + $addition;
});
}
}

0 comments on commit 9b1d65b

Please sign in to comment.