Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global Config =
- {
- IMGFile = "models/gta3.img",
- DIRFile = "models/gta3.dir",
- OutputDir = "x_files",
- };
- include_library( "fmt" );
- include_library( "io" );
- include_library( "string" );
- function OpenGTA3Archive( img, dir )
- {
- imgfile = io_file( img, FILE_READ );
- dirfile = io_file( dir, FILE_READ );
- numentries = dirfile.size / 32;
- println( "OpenGTA3Archive: " $ numentries $ " files found" );
- files = [];
- for( i = 0; i < numentries; ++i )
- {
- fbit = dirfile.read( 32 );
- data = fmt_unpack( "ll24s", fbit );
- data[ 0 ] *= 2048;
- data[ 1 ] *= 2048;
- data[ 2 ] = string_part( data[ 2 ], 0, string_find( data[ 2 ], "\0" ) );
- files.push( data );
- }
- println( "OpenGTA3Archive: loaded file table" );
- gta3archive = { img = imgfile, dir = dirfile, files = files };
- function gta3archive.loadfile( id )
- {
- if( this.files.size <= id )
- return null;
- this.img.seek( this.files[ id ][ 0 ] );
- return this.img.read( this.files[ id ][ 1 ] );
- }
- println( "Loaded archive!" );
- return gta3archive;
- }
- arch = OpenGTA3Archive( Config.IMGFile, Config.DIRFile );
- println( "Extracting..." );
- for( i = 0; i < arch.files.size; ++i )
- {
- data = arch.loadfile( i );
- io_file_write( Config.OutputDir $ "/" $ arch.files[ i ][ 2 ], data );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement