#!/usr/bin/env php 3) { $map = $argv[1]; $cs = $argv[2]; $ents = file_get_contents($argv[3] === '-' ? 'php://stdin' : $argv[3]); if ($map != '') { $bits += 1; } if ($cs != '') { $bits += 2; $cs = intval ($cs); } if ($ents != '') { $bits += 4; $ents = trim($ents); $ents = str_replace ("\r", "", $ents); } $filebits = pack ('V', $bits); print $filebits; $out = fopen ("php://output", "wb"); if ($bits & 1) { $map = pack ('a64@64', $map); fwrite ($out, $map, 64); } if ($bits & 2) { $filecs = pack ('V', $cs); fwrite ($out, $filecs, 4); } if ($bits & 4) { $entsize = pack ('V', strlen($ents)); fwrite ($out, $entsize, 4); print $ents; } fclose ($out); exit; } else { print <<<_EOF_ CLI version of r1ch's .override generator. Only minor changes. All credits goes to r1ch. Usage: You can run this file with php interpreter or make it executable and run it directly (unix-like systems [php still required]). \$ php -f thisfile -- mapname checksum inputfile or \$ ./thisfile mapname checksum inputfile All three arguments are required. Any of them can be empty (''). For inputfile you can specify a '-' to read data from the standard input. Also you can use available php stream wrappers like http://path/file, etc. Output file will be written to the standard output. Examples: empty checksum, output saved to file q2dm3.bsp.override: \$ ./this maps/q2dm3.bsp '' q2dm3.txt >q2dm3.bsp.override empty checksum, input read from standard input, output saved: \$ cat q2dm3.txt | ./this maps/q2dm3.bsp '' - >q2dm3.bsp.override _EOF_; } ?>