NPK File Format

Source: Internet
Author: User

I dragged a donkey <drakensang> to use the resource.

This game uses N2 + N3, file format or N2.

I found the code in N2 and found the code for reading the NPK file.

It is too troublesome to decompress all the files. It is better to create a viewer.

However, it is not very cost-effective to do it from the ground up. In addition, I am a loyal friend of TC.

So, just make a plug-in like mpq.

 

NPK file package format. After reading the N2 comments, you will understand that it is nothing more than a combination of files.

The data segment is the chunk structure of fourcc + size + data, and there is no version number concept.

In this way, there is no compression and encryption, and it belongs to the original file package format.

NPK file format: </P> <p> @ verbatim <br/> # header <br/> block header {<br/> uint32 'npk0'/magic number <br/> uint32 blocklen // Number of following bytes in block <br/> uint32 dataoffset // byte offset of data block from beginning of file <br/>}</P> <p> # TABLE contents, sequence of blocks of 3 types: <br/> block dir {<br/> uint32 'dir _ '// magic number of directory block <br/> uint32 blocklen // Number of following bytes in block <br/> uint16 dirnamelength // length of the following name <br/> char [] dirname/Name of directory <br/>}</P> <p> block file {<br /> uint32 'file' // magic number of file block <br/> uint32 blocklen // Number of following bytes in block <br/> uint32 fileoffset // start of file data inside data Block <br/> uint32 filelength // length of file data in bytes <br/> uint16 filenamelength // length of the following name <br/> char [] filename/Name of File <br/>}</P> <p> block endofdir {<br/> uint32 'dend' // magic number of end of Dir block <br/> uint32 blocklen // Number of following bytes in block (0) <br/>}</P> <p> # The data block <br/> block data {<br/> uint32 'data' // magic number of data block <br /> uint32 blocklen // Number of following bytes in block <br/> char [] data // The data <br/>}< br/> @ endverbatim <br/>

The structure of the entire file is organized as follows:

  • Npk0
  • Dir _
    • Dir _

      • File
      • File
      • ...
    • Dend
    • Dir _
      • File
      • File
      • ...
    • Dend
    • ...
  • Dend
  • Data

It's so simple that it's no longer easy. If you want to write a file for reading, you don't need to rely on the N2 library.

I checked the ISO source code of TC again. It turned out to be a DLL. I implemented the corresponding function and threw it to TC.

 

========================================================== ========================

Update a TC Plugin:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.