Star Wars: Battlefront II - *.lvl (ucbf identifier)

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Star Wars: Battlefront II - *.lvl (ucbf identifier)

Post by AlphaTwentyThree »

Can somebody help me to unpack these files? I know that some of them are encrypted but the ones containing sound files are not. Here are samples: http://www28.zippyshare.com/v/bLD0pitU/file.html.
Header creation not needed, I'll add that myself. I only have a problem with the offsets/sizes.
Thanks for your help!
Acewell
Posts: 706
Joined: Fri Aug 08, 2014 1:06 am

Re: Star Wars: Battlefront II - *.lvl (ucbf identifier)

Post by Acewell »

This is what riley-man's analysis of SWBF lvl files says, it might be the same for SWBFII but i don't know, you might be able to write a bms script from this

Code: Select all

Basic Algorithm - Iterate Through Chunks
This section explains how to iterate through all the chunks in any *.lvl file. 
This can be used to find all the chunks in a file, or all the chunks of a particular type.

The first eight bytes of a chunk is the "chunk header".  Everything that follows is the "chunk data". 
The following table illustrates how the chunk header is organized.

Data Type    Size (bytes)    Description
int          4               Chunk marker, as a 32-bit integer.  This could also be read as a char[4], for languages that do not use zero-terminated strings.
int          4               32-bit integer specifying the number of bytes to follow. Note that if this is not a multiple of 4,
                             there will be extra zero bytes of padding so that the next chunk begins at a 4-byte boundary.


The following functions are general purpose, and can be used when reading in chunks.

/* Returns the actual number of bytes that will follow the 8-byte chunk header (including the padded zero bytes, if any) */
int getTrueChunkSize(int sizeAsRead) {
    int remainder, result;
    result = sizeAsRead;
    remainder = ( sizeAsRead % 4 );
    if ( remainder != 0 ) {
       result -= ( 4 - remainder );
    }
    return( result );
}

The following algorithm will read in all chunks in a given file.  Generic function "readInt" is not necessarily an actual function. 
For C/C++, you can use the fread function in stdio.h, for example. 
Similarly, seekInFile() is not necessarily an actual function (its C/C++ equivalent would be fseek). 
This algorithm assumes you have opened a random-access binary file.

int fileMarker, fileSize;
int chunkMarker, chunkSize;
int curFilePosition;
int bytesReadSoFar;

fileMarker = readInt();
fileSize = readInt();

bytesReadSoFar = 0;
curFilePosition = 8;
while ( bytesReadSoFar < fileSize ) {
    seekInFile(curFilePosition);
    chunkMarker = readInt();
    chunkSize = readInt();
    ... Read / Process this chunk according to chunkMarker ...
    curFilePosition += getTrueChunkSize(chunkSize) + 8;
    bytesReadSoFar += getTrueChunkSize(chunkSize) + 8;
}


riley-man.zip
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: Star Wars: Battlefront II - *.lvl (ucbf identifier)

Post by AlphaTwentyThree »

Actually... I have no idea what to do with this, sorry. ;)
Acewell
Posts: 706
Joined: Fri Aug 08, 2014 1:06 am

Re: Star Wars: Battlefront II - *.lvl (ucbf identifier)

Post by Acewell »

kidding or no? surely someone that has written as many bms scripts as you can make sense of it. :?
Teancum
Posts: 94
Joined: Mon Sep 22, 2014 5:13 pm

Re: Star Wars: Battlefront II - *.lvl (ucbf identifier)

Post by Teancum »

Battlefront's lvl files are compiled assets that don't do much good after compilation. The lvl format isn't really a traditional container. Is there something specific you're looking for? I previously extracted the entire sound bank into separate .wav formats, but that's something different entirely. Everything in the lvl files can be obtained in a usable format in the game's mod tools. If you need the sounds, sift through the following thread at Gametoast.com

http://www.gametoast.com/viewtopic.php?f=64&t=28297
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: Star Wars: Battlefront II - *.lvl (ucbf identifier)

Post by AlphaTwentyThree »

I'm after the music but I want to split the files first. I know that lvl files are compiled bun in the case of the sound files there's a file table at the beginning or at least so it seems, so the sounds should all be exctractable nicely!
I sifted through the thread and actually all they do is import the file and split it by hand. That is a possibility but you'll get plain PCM for the split parts. I want to do a streamed music rip so I'll need the split streams.
To be honest, I thought that the file table would be something to work with to write a QuickBMS script. Maybe I'm wrong? :\
@Acewell: not kidding. :\ I'm not good at programming other than QuickBMS I'm afraid. Let's hope for somebody to write something or give some other hints. :)