BioWare Atari
Information de BioWare Jeux BioWare Assistance Forums Visit the BioWare Store
Neverwinter Nights Home
Neverwinter Nights Home

Tutorial: Building a Custom ERF Data Extractor

Intended Audience: For Developers
By Don Moar

NOTICE: This tutorial is to give software developers an example of how to use the Encapsulated Resource File (ERF) Format. The source code provided is unsupported; compile and run at your own risk. Please refer to the For Developers FAQ and the NWN End User License Agreement (EULA) for more information.

Description

1. Purpose

I need a command-line program that can extract resources by type id / name from an erf and save them to another directory. I can use this to help automate the merging of data files from different modules into the same module.

2. Command Line

The command line should look like this:
erfget erfname restype resref dirname

Parameter Description
erfname Required Name of the encapsulated resource file from which to extract the resource
restype Required ID number of the resource type
resref Required Name of the resource to extract
dirname Required Name of the directory to save extracted resources

3. Program Architecture

In an ideal world, I would create a class that handles all ERF behaviours and put it in a library that I would then link into my executable. However, it's Saturday afternoon and I want to get this done as quickly as possible and all I really want at this moment is to get that data out of the ERF. So, I'll forego all the standard practices and just stick all that code required to accomplish what I want in my main function.

Note: This is not the recommended approach!

4. Class Definitions

None.

C Source Code

To view or download the C Source Code you need to be logged into your BioWare Community Account. If you don't have an account you can sign up for a free BioWare Community Account.

Extra Credit

1. Clean Up The Code

Okay, while functional, this really isn't the best approach. Restructure the program by creating an interface to the set of typical ERF behaviours that we expect most programs to require: OpenFile, CloseFile, SaveFile, AddResource, GetResource, RemoveResource. Put this interface in a separate library to which the program will link. The program should then be modified to create an instance of this class and use it to navigate the ERF file.

2. Make the Program More Robust

The command line system that the program currently supports is very fragile. If you don't get the parameters exactly right, the program will fail (and it won't report anything). Extend the program to make it handle extracting all the resources from the erf, all the resources of a particular type and all the resources of a particular name.

3. Write the ERF Data Integrator

Write a program that takes data files in a directory and adds them to the specified ERF, creating the file if it doesn't already exist. The program should take an ERF file name and a directory as parameters. Watch out of files that don't correspond to known resource types and resources that already exist in the ERF.

Together these two programs then allow you to transfer data between ERFs (modules) without having to use the toolset.

 

 

BioWare Store
Neverwinter Nights 2 Forums
Cacher/Afficher

English
Deutsch
Français
Español
Italiano

Cacher/Afficher

Voir les dernières captures d'écran 

Voir les dernières captures d'écran
Cacher/Afficher

Multiplayer Games at Neverwinter Connections

Today
Schedule a Game...



Il est actuellement: (régler heure)
sam, 21 novembre 2009 11:48

Cacher/Afficher

Download Modules

Top NWN: HotU Modules:
1. Good vs Evil III
2. More...

Top NWN: SoU Modules:
1. Good vs Evil III
2. More...

Top CEP Modules:
1. The Lord of Terror The Diablo Campa...
2. More...

Top Modules - NWVault:
1. Hall of Fame
2. More...

Total Modules: 4423

Cacher/Afficher

5,048,300 utilisateurs sur le site de BioWare:
  64 connectés
  8 invisibles
  216 invités

1471 Playing Online
  100% NWN
  100% NWN: SoU
  99% NWN: HotU

447 Registered Guilds

8,768,411 messages dans les forums

Sujets les plus récents dans les forums:
1. Another update coming next week? (Mass Effect 2 General Discussion (No Spoilers Allowed))

2. Inferno armor available at Amaz... (Mass Effect 2 General Discussion (No Spoilers Allowed))

3. Will ME2 feature "ME1" or "DAO" ... (Mass Effect 2 General Discussion (No Spoilers Allowed))

4. conversation node spawning an it... (NWN2: Builders - NWN2 Scripting)

5. Stupid MAKO!! (Mass Effect 1 General Discussion (No spoilers allowed))