Skip to content

Commit

Permalink
Add MBF21 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Xymph committed Jul 15, 2022
1 parent 693d2f0 commit 3ab4117
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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+ |

Expand All @@ -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)
Expand Down
23 changes: 16 additions & 7 deletions lmpstats.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -138,17 +138,19 @@ 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 ||
(ord($sign[4]) != 0xE6 && ord($sign[5]) != 0xE6))) {
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);
Expand All @@ -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);
Expand Down

0 comments on commit 3ab4117

Please sign in to comment.