From c189f323fb67ff575dc45ab0395c25b4e37fb898 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Fri, 29 Jul 2011 12:50:31 +0200 Subject: [PATCH] align output lumps --- misc/tools/bsptool.pl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/misc/tools/bsptool.pl b/misc/tools/bsptool.pl index 84f23233..dd425953 100755 --- a/misc/tools/bsptool.pl +++ b/misc/tools/bsptool.pl @@ -487,18 +487,23 @@ for(@ARGV) open my $fh, ">", $outfile or die "$outfile: $!"; print $fh $header; - my $pos = 17 * 8 + tell($fh) + length $msg; + my $msgalign = [0, 3, 2, 1]->[length($msg) % 4]; + my $pos = 17 * 8 + tell($fh) + length($msg) + $msgalign; for(@bsp) { + my $align = [0, 3, 2, 1]->[length($_->[2]) % 4]; $_->[0] = $pos; $_->[1] = length $_->[2]; $pos += $_->[1]; print $fh pack "VV", $_->[0], $_->[1]; } print $fh $msg; + print $fh "\x00" x $msgalign; for(@bsp) { + my $align = [0, 3, 2, 1]->[length($_->[2]) % 4]; print $fh $_->[2]; + print $fh "\x00" x $align; } close $fh; print STDERR "Wrote $outfile\n"; -- 2.39.2