From abb34dc9e140f7853b7b3282512f43c24e6db720 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Fri, 29 Jul 2011 12:53:15 +0200 Subject: [PATCH] align here too --- misc/tools/bsptool.pl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/misc/tools/bsptool.pl b/misc/tools/bsptool.pl index dd425953..efc6cccb 100755 --- a/misc/tools/bsptool.pl +++ b/misc/tools/bsptool.pl @@ -218,12 +218,14 @@ for(@ARGV) { if(/^-i$/) # info { - my $total = 17 * 8 + 8 + length($msg); + my $msgalign = [0, 3, 2, 1]->[length($msg) % 4]; + my $total = 17 * 8 + 8 + length($msg) + $msgalign; my $max = 0; for(0..@bsp-1) { my $nl = length $bsp[$_]->[2]; - $total += $nl; + my $align = [0, 3, 2, 1]->[$nl % 4]; + $total += $nl + $align; print "BSP lump $_ ($lumpname[$_]): offset $bsp[$_]->[0] length $bsp[$_]->[1] newlength $nl\n"; my $endpos = $bsp[$_]->[0] + $bsp[$_]->[1]; $max = $endpos if $max < $endpos; @@ -494,7 +496,7 @@ for(@ARGV) my $align = [0, 3, 2, 1]->[length($_->[2]) % 4]; $_->[0] = $pos; $_->[1] = length $_->[2]; - $pos += $_->[1]; + $pos += $_->[1] + $align; print $fh pack "VV", $_->[0], $_->[1]; } print $fh $msg; -- 2.39.2