]> git.xonotic.org Git - xonotic/xonotic.git/commitdiff
align here too
authorRudolf Polzer <divverent@xonotic.org>
Fri, 29 Jul 2011 10:53:15 +0000 (12:53 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Fri, 29 Jul 2011 10:53:15 +0000 (12:53 +0200)
misc/tools/bsptool.pl

index dd425953eade8c8021e8e98333bae3d04b10097d..efc6cccb2efa3a2770e7c99a4cc81cfd3d97cb81 100755 (executable)
@@ -218,12 +218,14 @@ for(@ARGV)
 {
        if(/^-i$/) # info
        {
 {
        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];
                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;
                        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];
                        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;
                        print $fh pack "VV", $_->[0], $_->[1];
                }
                print $fh $msg;