Add ProjectZomboidMapLog (map.txt)

Per-line world object placement/removal log. LINE pattern handles both
integer and floating-point coordinates and both 'Base.X' and
'IsoObject (X)' object encodings. Detectors: filename match plus content
signature on the added/removed verbs paired with Base./IsoObject prefix.
This commit is contained in:
2026-04-30 20:37:50 +00:00
parent 49cf4927f6
commit 6387fb1c52
4 changed files with 123 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
<?php
namespace IndifferentKetchup\Codex\Log\ProjectZomboid;
use IndifferentKetchup\Codex\Analyser\AnalyserInterface;
use IndifferentKetchup\Codex\Analyser\PatternAnalyser;
use IndifferentKetchup\Codex\Detective\FilenameDetector;
use IndifferentKetchup\Codex\Detective\WeightedSinglePatternDetector;
use IndifferentKetchup\Codex\Parser\ParserInterface;
use IndifferentKetchup\Codex\Parser\PatternParser;
use IndifferentKetchup\Codex\Pattern\ProjectZomboid\MapPattern;
class ProjectZomboidMapLog extends ProjectZomboidEventLog
{
public static function getDefaultParser(): ParserInterface
{
return static::makePatternParser(
MapPattern::LINE,
[PatternParser::TIME]
);
}
public static function getDefaultAnalyser(): AnalyserInterface
{
return new PatternAnalyser();
}
public static function getDetectors(): array
{
return [
(new FilenameDetector())
->setPattern('/_map\.txt$/')
->setWeight(0.95),
(new WeightedSinglePatternDetector())
->setPattern('/^\[[^\]]+\] \d{17} "[^"]+" (?:added|removed) (?:Base\.|IsoObject )/m')
->setWeight(0.90),
];
}
public function getTitle(): string
{
return "Project Zomboid Map Log";
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace IndifferentKetchup\Codex\Pattern\ProjectZomboid;
/**
* Regex constants for the Project Zomboid map.txt format.
*
* [time] steamid "player" verb object at x,y,z.
*
* Coordinates may be integer or floating point; objects may be Base.X
* tokens or 'IsoObject (X)' parenthesised forms.
*/
class MapPattern
{
public const string LINE = '/^\[(\d{2}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3})\] \d{17} "[^"]+" \S+ .+ at [\d.]+,[\d.]+,[\d.]+\.$/';
public const string FIELDS = '/^\[\d{2}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3}\] (?<steamid>\d{17}) "(?<player>[^"]+)" (?<verb>\S+) (?<object>.+) at (?<x>[\d.]+),(?<y>[\d.]+),(?<z>[\d.]+)\.$/';
}