From 3ab411782b0d82bb6510ed0b18defab98433c4b6 Mon Sep 17 00:00:00 2001 From: Xymph Date: Fri, 15 Jul 2022 17:20:05 +0200 Subject: [PATCH] Add MBF21 support --- README.md | 3 +++ lmpstats.inc.php | 23 ++++++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 07ba6e1..bf4c79b 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ Requirements: [PHP](https://www.php.net) * Doom Classic: v1.11-1.12 * Doom Legacy: v1.29+ * Eternity Engine: v3.29+ +* MBF21 v2.21 * PrBoom+ v1.11 longtics * PrBoom+um v2.6+ * RUDE: v3.1.0pre5+ extended @@ -109,6 +110,7 @@ This is a list of LMP version bytes currently recognized and returned by LmpStat | 203 | TASMBF v2.03 | | 205-207 | CDoom v2.05-2.07 | | 210-214 | Boom/MBF v2.10-2.14 | +| 221 | MBF21 v2.21 | | 222 | RUDE v3.1.0pre5+ extended | | 255 | Eternity Engine, PrBoom+um v2.6+ | @@ -120,6 +122,7 @@ ZDoom_versions.txt provides a list of version numbers in the ZDoom-family. * [The unofficial LMP format description](http://web.archive.org/web/20090920220417/http://demospecs.planetquake.gamespy.com/lmp/lmp.html) * [Demo version bytes list](https://www.doomworld.com/forum/topic/120007-specifications-for-source-port-demo-formats/?tab=comments#comment-2265059) * [Boom / MBF demo header format](https://www.doomworld.com/forum/topic/72033-boom-mbf-demo-header-format/) +* [MBF21 demo header format](https://github.com/kraflab/mbf21/blob/master/docs/developer_spec.md#demo-format--header) * [ZDaemon .zdd version format](https://www.doomworld.com/forum/topic/120789-lmpstats-a-php-library-to-collect-demo-statistics/?tab=comments#comment-2313099) * Analysis of [CDoom sources](https://sourceforge.net/projects/cdoom207/files/) * Analysis of [Doom Classic sources](https://github.com/id-Software/DOOM-3-BFG/tree/master/doomclassic) diff --git a/lmpstats.inc.php b/lmpstats.inc.php index dd629b3..1edf367 100644 --- a/lmpstats.inc.php +++ b/lmpstats.inc.php @@ -2,7 +2,7 @@ // Analyze Doom-engine demos - main include // Copyright (C) 2021 by Frans P. de Vries -define('VERSION', '0.10.0'); +define('VERSION', '0.11.0'); define('DEMOEND', 0x80); function lmpStats($file, $game = null, $debug = 0, $classic = false, $zdoom9 = false) @@ -138,8 +138,8 @@ function lmpStats($file, $game = null, $debug = 0, $classic = false, $zdoom9 = f // Boom/MBF v2.00-2.04 / 2.10-2.14, CDoom v2.05-2.07 } elseif (($vers >= 200 && $vers <= 204) || ($vers >= 205 && $vers <= 207) || - ($vers >= 210 && $vers <= 214)) { - if (($vers >= 205 && $vers <= 207) || $vers == 214) + ($vers >= 210 && $vers <= 214) || $vers == 221) { + if (($vers >= 205 && $vers <= 207) || $vers == 214 | $vers == 221) $ticlen = 5; $sign = fread($fp, 6); if ($sign != 'CDOOMC' && (ord($sign[0]) != 0x1D || @@ -147,8 +147,10 @@ function lmpStats($file, $game = null, $debug = 0, $classic = false, $zdoom9 = f echo "version $vers unexpected signature: $sign\n"; return false; } + $comp = $insr = 0; // 0x07: compatibility (0 or 1) - $comp = readByte($fp); + if ($vers != 221) + $comp = readByte($fp); // 0x08-0x0A $skll = readByte($fp) + 1; $epis = readByte($fp); @@ -158,18 +160,25 @@ function lmpStats($file, $game = null, $debug = 0, $classic = false, $zdoom9 = f // 0x0C: console player: 0 = 1st, 1 = 2nd, etc. $view = readByte($fp); // 0x0D-0x12: expansion - $skip = fread($fp, 6); + if ($vers == 221) + $skip = fread($fp, 3); + else + $skip = fread($fp, 6); // 0x13-0x15 $resp = readByte($fp); $fast = readByte($fp); $nomo = readByte($fp); // 0x16: demo insurance (0 or 1) - $insr = readByte($fp); + if ($vers != 221) + $insr = readByte($fp); // 0x17-0x1A: random seed $seed = unpack('N', fread($fp, 4)); $seed = sprintf('%08X', $seed[1]); // 0x1B-0x4C: expansion - $skip = fread($fp, 50); + if ($vers == 221) + $skip = fread($fp, 36); + else + $skip = fread($fp, 50); // 0x4D-0x50: players 1-4 present $ply1 = readByte($fp); $ply2 = readByte($fp);