Rebel Raiders: Operation Nighthawk (PS2)

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

Rebel Raiders: Operation Nighthawk (PS2)

Post by AlphaTwentyThree »

Hi there!

Here's a really easy task for you: Extract the DATA.BAG from the above game - http://*USE_ANOTHER_FILEHOSTING*/452a45a ... d4/DATA.7z. I thought I understood the folder structure but I cancelled after the 20th try to get it right. So... could somebody quickly write a correct script for the file? That'd be great! :)
Thanks in advance.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Rebel Raiders: Operation Nighthawk (PS2)

Post by aluigi »

Oh no thanks, that directory tree is senseless.
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: Rebel Raiders: Operation Nighthawk (PS2)

Post by AlphaTwentyThree »

It isn't as complicated as it may look. Starting at 0x13a0304c:
Leave out the first 0x30 bytes, that's the root folder with no name
The structure is as follows:
0x20 bytes - file name or folder name
4 bytes - identifier: 0xffffffff = last file in folder = next name is a folder name = reset FOLDER to "" (automatically set the next name as new folder in the next step); anything else = file id, not needed
4 bytes - zero
4 bytes - offset OR 0xffffffff
4 bytes - size OR 0xffffffff
both offset and size 0xffffffff means that there's a subfolder in the current folder
only size 0xffffffff means that the current folder is the last subfolder and the next name is a file

Somehow I'm too dumb to write this into a script. :\
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: Rebel Raiders: Operation Nighthawk (PS2)

Post by AlphaTwentyThree »

Well, it's more complicated than I thought... I couldn't figure out when a folder is contained inside an upper branch folder but the files are in their according folder. So, some of the folders that are extracted belong inside another folder, like "english", "french" and so on belong into "text/" but hey, it's an effort.

Code: Select all

get UNK long
get ENTRIES long # including folders
get TOC_OFF long

math ENTRIES -= 1 # skip the root folder
math TOC_OFF += 0x30 # first "file" is the root directory -> skip that
goto TOC_OFF
set FOLDER ""
set NXTFOLDER 0
for i = 1 <= ENTRIES
   getDstring NAME 0x20
   get LAST long
   get ZERO long
   get OFFSET long
   get SIZE long
   if FOLDER == "/" # next folder in root dir, NEVER file
      string FOLDER p= "%s" NAME      
   else
      if OFFSET != 0xffffffff
         if NXTFOLDER == 1
            string FOLDER p= "%s/%s" FOLDER NAME
            set NXTFOLDER 0
         else
            string NAME p= "%s/%s" FOLDER NAME
            log NAME OFFSET SIZE
            #print "%i% - %NAME%"
         endif
      else
         if NXTFOLDER == 1
            string FOLDER p= "%s/%s" FOLDER NAME
            set NXTFOLDER 0
         endif
      endif
   endif
   if SIZE == 0xffffffff
      set NXTFOLDER 1
   endif
   if LAST == 0xffffffff
      if OFFSET != 0xffffffff # only if current is file, no folder
         set FOLDER "/"
      endif
   endif
next i
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Rebel Raiders: Operation Nighthawk (PS2)

Post by aluigi »

I hate you.
I just found that already existed a script for this game but I don't understand why both you and I didn't check it on my website...
http://aluigi.org/papers/bms/others/rebel_raiders.bms

Anyway I wrote also a new script from scratch with a different method but I don't know what of them is the best:
http://aluigi.org/papers/bms/others/reb ... rs_alt.bms