]> git.rm.cloudns.org Git - xonotic/xonotic.git/commitdiff
align output lumps
authorRudolf Polzer <divverent@xonotic.org>
Fri, 29 Jul 2011 10:50:31 +0000 (12:50 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Fri, 29 Jul 2011 10:51:32 +0000 (12:51 +0200)
misc/tools/bsptool.pl

index 84f23233aa388f3f91c86422623f394f6db5dc57..dd425953eade8c8021e8e98333bae3d04b10097d 100755 (executable)
@@ -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";