[Extractor-gtk-cvslog] SF.net SVN: extractor-gtk:[86] trunk/extractor/nwn.c
Extract files from unusual archive formats
Brought to you by:
someone-guy
|
From: <som...@us...> - 2008-08-22 16:03:33
|
Revision: 86
http://extractor-gtk.svn.sourceforge.net/extractor-gtk/?rev=86&view=rev
Author: someone-guy
Date: 2008-08-22 16:03:31 +0000 (Fri, 22 Aug 2008)
Log Message:
-----------
Partial support for NWN2 data files
Modified Paths:
--------------
trunk/extractor/nwn.c
Modified: trunk/extractor/nwn.c
===================================================================
--- trunk/extractor/nwn.c 2008-08-22 16:03:12 UTC (rev 85)
+++ trunk/extractor/nwn.c 2008-08-22 16:03:31 UTC (rev 86)
@@ -13,18 +13,23 @@
#include "formats.h"
#include "helpers.h"
-//! check for nwn archive (starts with MOD V1.0)
+//! check for nwn archive (starts with MOD V1.0 or MOD V1.1 for NWN2)
static int check_file(FILE *in) {
char sig[9] = {0};
rewind(in);
fread(sig, 8, 1, in);
- return strcmp(sig, "MOD V1.0") == 0;
+ return strcmp(sig, "MOD V1.0") == 0 || strcmp(sig, "MOD V1.1") == 0;
}
static file_t *get_list(FILE *in) {
file_t *list;
uint32_t count, namepos, tblpos;
+ int namelen = 16;
int i;
+ char sig[9] = {0};
+ rewind(in);
+ fread(sig, 8, 1, in);
+ if (strcmp(sig, "MOD V1.1") == 0) namelen = 32;
fseek(in, 0x10, SEEK_SET);
count = read_le32(in);
if (count > MAX_FILES) count = MAX_FILES;
@@ -34,10 +39,10 @@
list = calloc(count + 1, sizeof(file_t));
for (i = 0; i < count; i++) {
uint32_t type_id;
- fseek(in, namepos + 24 * i, SEEK_SET);
- list[i].name = calloc(1, 21);
- fread(list[i].name, 16, 1, in);
- list[i].name[16] = 0;
+ fseek(in, namepos + (namelen + 8) * i, SEEK_SET);
+ list[i].name = calloc(1, namelen + 5);
+ fread(list[i].name, namelen, 1, in);
+ list[i].name[namelen] = 0;
read_le32(in); // file number
type_id = read_le32(in);
fseek(in, tblpos + 8 * i, SEEK_SET);
@@ -63,8 +68,8 @@
}
const fmt_desc_t nwn_fmt = {
- "Neverwinter Nights",
- "Neverwinter Nights (*.mod;*.nwm;*.sav)",
+ "Neverwinter Nights (1/2)",
+ "Neverwinter Nights (1/2) (*.mod;*.nwm;*.sav)",
"*.mod;*.nwm;*.sav",
check_file,
get_list,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|