04-05-2015, 10:59 PM
OK, managed to update the script so it works for those as well:
I did two things here. First of all, I used an offset table at the front of the table to get at the information chunks. The first time round I wasn't aware how it worked but I got it this time. To be perfectly honest it doesn't really help at all and actually makes the script longer than necessary, but it doesn't slow it down and I guess it's more correct (and probably makes it more compatible for reimporting).
The other thing was that I didn't hard-code the name length. This is what screwed it up. I assumed that all names were 0x1D long but the Beetle Bug 2 files have different lengths. Unfortunately there's no way to detect the name length so I had to make a hackish loop that kind of goes through the padding until it reaches something else. It's not as clean as I would like but it's the only way I could think of. At least it doesn't seem to slow it down.
Should work for all archives now. Oh and by the way, Distr.stg does contain 2 tiny files but they're just config stuff that probably isn't really useful.
Code:
# Beetle Bug .stg
#
# Written by puggsoy
# script for QuickBMS http://quickbms.aluigi.org
idstring "stg2"
getdstring DUMMY 0x0e
get TBLEND long
get FILES long
get DUMMY short
for i = 0 < FILES
get INFOFF long
get CHNKNM long
if CHNKNM != 0
savepos TMP
goto INFOFF
for j = 0 < CHNKNM
get NMSZ short #not necessary but whatever
get DUMMY long
get ZERO byte
get SIZE long
get OFFSET long
getdstring NAME NMSZ
log NAME OFFSET SIZE
for TEST = 0 == 0
get TEST byte
next
savepos POS
math POS -= 1
goto POS
math i += 1
next j
goto TMP
endif
next
I did two things here. First of all, I used an offset table at the front of the table to get at the information chunks. The first time round I wasn't aware how it worked but I got it this time. To be perfectly honest it doesn't really help at all and actually makes the script longer than necessary, but it doesn't slow it down and I guess it's more correct (and probably makes it more compatible for reimporting).
The other thing was that I didn't hard-code the name length. This is what screwed it up. I assumed that all names were 0x1D long but the Beetle Bug 2 files have different lengths. Unfortunately there's no way to detect the name length so I had to make a hackish loop that kind of goes through the padding until it reaches something else. It's not as clean as I would like but it's the only way I could think of. At least it doesn't seem to slow it down.
Should work for all archives now. Oh and by the way, Distr.stg does contain 2 tiny files but they're just config stuff that probably isn't really useful.