Skip to content
View in the app

A better way to browse. Learn more.

ResHax

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
Help us keep the site running.
Zero Tolerance for Disrespect

Tool that can repack custom data and files into Conflict: Desert Storm (PC) *.dat

Featured Replies

  • Localization
Spoiler

import os
import struct

def str2hex(s:str)->bytes:
    b = b''
    hexstring = '0123456789ABCDEF'
    s = s.zfill(8)
    for c in range(0,len(s)-1,2):
        n1 = hexstring.find(s[c])<<4
        n2 = hexstring.find(s[c+1])
        b += struct.pack('B', n1+n2)
    return b
    
def extract(fname):
    """extracts Conflict: Desert Storm (PC) *.dat files into dir/*.*"""
    directory = fname.lower().replace('.dat', '/')
    table = []
    if not os.path.isdir(directory):
        os.mkdir(directory)
    with open(fname, 'rb') as f:
        while True:
            stream = f.read(12)
            if stream == b'\x00'*12:
                break
            hashed, offset, size = struct.unpack('III', stream)
            hashed = hex(hashed).lstrip('0x').upper().zfill(8)
            table.append((hashed, offset, size))
        for file in table:
            hashed, offset, size = file
            path = directory+hashed
            with open(path, 'wb') as f2:
                f.seek(offset)
                f2.write(f.read(size))
                print(f'Extracted: {hashed}')
                

def import_(directory):
    """import directory into Conflict: Desert Storm (PC) *.dat file"""
    fname = directory.rstrip('/').rstrip('\r')+'.dat'
    tablesize = 0x800
    table = []
    files = os.listdir(directory)
    offset = tablesize
    archive = b''
    print('Checking filenames...')
    for file in files:
        for c in file:
            if not c in '0123456789ABCDEF':
                raise Exception(f"{file} aren't correct filename.")
        with open(directory+'/'+file, 'rb') as f:
            f = f.read()
            size = len(f)
            table.append((file, offset, size))
            archive += f
            offset += size
    print('Writing dat file table...')
    with open(fname, 'wb') as f2:
        zeros = tablesize - (len(table) * 12)
        for file in table:
            fname, offset, size = file
            fname = str2hex(fname)
            offset = struct.pack('I', offset)
            size = struct.pack('I', size)
            f2.write(fname+offset+size)
        f2.write(b'\x00'*zeros) #padding
        print('Writing all files...')
        f2.write(archive)

        
def main():
    print('Conflict: Desert Storm (PC) Dat Tool')
    inp = input('Use [e] to extract from file, and to import compile file.\n:  ')
    while True:
        match inp:
            case 'e':
                inp = input('Input filename:  ')
                extract(inp)
                break
            case 'i':
                inp = input('Input directory:  ')
                import_(inp)
                break
            case _:
                print('try again')


if __name__ == '__main__':
    main()
    input('done!')

python code

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.