From e74c1056258e36fd32ff40923a02cbf2174a3d2f Mon Sep 17 00:00:00 2001 From: indifferentketchup Date: Thu, 30 Apr 2026 20:35:40 +0000 Subject: [PATCH] Add ProjectZomboidClientActionLog (ClientActionLog.txt) Strict 5-field bracketed format. Parser captures only the timestamp; analysers that want steamid/action/player/coords/param decompose the Line text via ClientActionPattern::FIELDS. Detectors: filename match plus content signature on the IS{Enter,Exit}Vehicle / ISWalkToTimedAction action tokens. --- .../ProjectZomboidClientActionLog.php | 44 +++++++++++++++++++ .../ProjectZomboid/ClientActionPattern.php | 21 +++++++++ .../fixtures/client-action-minimal.txt | 10 +++++ .../Log/ProjectZomboidClientActionLogTest.php | 44 +++++++++++++++++++ 4 files changed, 119 insertions(+) create mode 100644 src/Log/ProjectZomboid/ProjectZomboidClientActionLog.php create mode 100644 src/Pattern/ProjectZomboid/ClientActionPattern.php create mode 100644 test/src/Games/ProjectZomboid/fixtures/client-action-minimal.txt create mode 100644 test/tests/Games/ProjectZomboid/Log/ProjectZomboidClientActionLogTest.php diff --git a/src/Log/ProjectZomboid/ProjectZomboidClientActionLog.php b/src/Log/ProjectZomboid/ProjectZomboidClientActionLog.php new file mode 100644 index 0000000..4807225 --- /dev/null +++ b/src/Log/ProjectZomboid/ProjectZomboidClientActionLog.php @@ -0,0 +1,44 @@ +setPattern('/_ClientActionLog\.txt$/') + ->setWeight(0.95), + (new WeightedSinglePatternDetector()) + ->setPattern('/\[\d{17}\]\[(?:ISEnterVehicle|ISExitVehicle|ISWalkToTimedAction)\]\[/') + ->setWeight(0.95), + ]; + } + + public function getTitle(): string + { + return "Project Zomboid Client Action Log"; + } +} diff --git a/src/Pattern/ProjectZomboid/ClientActionPattern.php b/src/Pattern/ProjectZomboid/ClientActionPattern.php new file mode 100644 index 0000000..84a7b43 --- /dev/null +++ b/src/Pattern/ProjectZomboid/ClientActionPattern.php @@ -0,0 +1,21 @@ +\d{17})\]\[(?[^\]]+)\]\[(?[^\]]+)\]\[(?\d+),(?\d+),(?\d+)\]\[(?[^\]]+)\]\.$/'; +} diff --git a/test/src/Games/ProjectZomboid/fixtures/client-action-minimal.txt b/test/src/Games/ProjectZomboid/fixtures/client-action-minimal.txt new file mode 100644 index 0000000..3e729dc --- /dev/null +++ b/test/src/Games/ProjectZomboid/fixtures/client-action-minimal.txt @@ -0,0 +1,10 @@ +[29-04-26 21:41:25.084] [76561198000000001][ISEnterVehicle][Player1][1000,2000,0][Van_LectroMax]. +[29-04-26 21:42:30.152] [76561198000000001][ISExitVehicle][Player1][1001,2001,0][Van_LectroMax]. +[29-04-26 21:46:31.034] [76561198000000001][ISEnterVehicle][Player1][1002,2002,0][Van_LectroMax]. +[29-04-26 21:46:53.257] [76561198000000001][ISExitVehicle][Player1][1003,2003,0][Van_LectroMax]. +[29-04-26 21:47:04.159] [76561198000000002][ISEnterVehicle][Player2][1010,2010,0][Pickup_Truck]. +[29-04-26 21:47:30.512] [76561198000000002][ISWalkToTimedAction][Player2][1011,2011,0][None]. +[29-04-26 21:48:00.812] [76561198000000002][ISExitVehicle][Player2][1011,2011,0][Pickup_Truck]. +[29-04-26 21:50:14.221] [76561198000000003][ISEnterVehicle][AdminUser][1020,2020,0][SUV_Modern]. +[29-04-26 21:51:00.512] [76561198000000003][ISExitVehicle][AdminUser][1021,2021,0][SUV_Modern]. +[29-04-26 21:52:15.018] [76561198000000001][ISEnterVehicle][Player1][1004,2004,0][Van_LectroMax]. diff --git a/test/tests/Games/ProjectZomboid/Log/ProjectZomboidClientActionLogTest.php b/test/tests/Games/ProjectZomboid/Log/ProjectZomboidClientActionLogTest.php new file mode 100644 index 0000000..b0c4f8d --- /dev/null +++ b/test/tests/Games/ProjectZomboid/Log/ProjectZomboidClientActionLogTest.php @@ -0,0 +1,44 @@ +setLogFile(new PathLogFile($this->fixturePath())); + $log->parse(); + + $this->assertCount(10, $log->getEntries()); + } + + public function testFieldsRegexExtractsStructuredData(): void + { + $line = "[29-04-26 21:41:25.084] [76561198000000001][ISEnterVehicle][Player1][1000,2000,0][Van_LectroMax]."; + $this->assertSame(1, preg_match(ClientActionPattern::FIELDS, $line, $m)); + $this->assertSame('76561198000000001', $m['steamid']); + $this->assertSame('ISEnterVehicle', $m['action']); + $this->assertSame('Player1', $m['player']); + $this->assertSame('Van_LectroMax', $m['param']); + } + + public function testDetectiveDispatchesByContent(): void + { + $detective = (new Detective()) + ->setLogFile(new PathLogFile($this->fixturePath())) + ->addPossibleLogClass(ProjectZomboidClientActionLog::class); + + $this->assertInstanceOf(ProjectZomboidClientActionLog::class, $detective->detect()); + } +}