Diff of /ielister.cpp [000000] .. [a5ab64]  Maximize  Restore

Switch to side-by-side view

--- a
+++ b/ielister.cpp
@@ -0,0 +1,3796 @@
+// ielister.cpp : a total commander lister plugin for displaying IE filetypes
+// (C) Avenger
+// based on the listplug example
+// further hacked to be useful as a Midnight Commander external command too
+#ifdef WIN32
+#include "stdafx.h"
+#include "listplug.h"
+#else
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#define O_BINARY 0
+#define stricmp strcasecmp
+
+int filelength(int fhandle)
+{
+	struct stat buf;
+	buf.st_size = -1;
+	fstat(fhandle, &buf);
+	return buf.st_size;
+}
+#endif
+
+#define FT_ITM  1
+#define FT_SPL  2
+#define FT_CRE  3
+#define FT_STO  4
+#define FT_ARE  5
+#define FT_CHU  6
+#define FT_EFF  7
+#define FT_VVC  8
+#define FT_PRO  9
+#define FT_DLG  10
+#define FT_CHR  11
+#define FT_GAM  12
+#define FT_WED  13
+#define FT_WMP  14
+
+#define supportedextension1 ".itm"
+#define supportedextension2 ".spl"
+#define supportedextension3 ".cre"
+#define supportedextension4 ".sto"
+#define supportedextension5 ".are"
+#define supportedextension6 ".chu"
+#define supportedextension7 ".eff"
+#define supportedextension8 ".vvc"
+#define supportedextension9 ".pro"
+#define supportedextension10 ".dlg"
+#define supportedextension11 ".chr"
+#define supportedextension12 ".gam"
+#define supportedextension13 ".wed"
+#define supportedextension14 ".wmp"
+
+#ifdef WIN32
+/* Note: in C, double quotes inside a string need to be escaped with a backslash!  */
+/* Don't end the parse string with space, crash may occur */
+#define parsefunction \
+	"(ext=\"ITM\") | " \
+	"(ext=\"SPL\") | " \
+	"(ext=\"CRE\") | " \
+	"(ext=\"STO\") | " \
+	"(ext=\"ARE\") | " \
+	"(ext=\"CHU\") | " \
+	"(ext=\"EFF\") | " \
+	"(ext=\"VVC\") | " \
+	"(ext=\"PRO\") | " \
+	"(ext=\"DLG\") | " \
+	"(ext=\"GAM\") | " \
+	"(ext=\"WED\") | " \
+	"(ext=\"WMP\") | " \
+	"(ext=\"CHR\")"
+#endif
+
+#define INDENTSIZE 2
+#define OTHERSIZE 16  //space, label and CR
+#define DWORDSIZE 8
+#define WORDSIZE 4
+#define BYTESIZE 2
+#define POINTSIZE 11
+#define RESREFSIZE 8
+#define VARSIZE 32
+
+#ifdef WIN32
+HINSTANCE hinst;
+HMODULE FLibHandle=0;
+char inifilename[MAX_PATH]="";  // Unused in this plugin, may be used to save data
+#endif
+
+#define SLOT_COUNT 38
+char *bg2_slot_names[SLOT_COUNT]={"0-Helmet","1-Armor","2-Shield","3-Gloves","4-L.Ring","5-R.Ring","6-Amulet",
+"7-Belt","8-Boots","9-Weapon 1","10-Weapon 2","11-Weapon 3","12-Weapon 4","13-Quiver 1","14-Quiver 2",
+"15-Quiver 3","16-Unknown","17-Cloak","18-Quick item 1","19-Quick item 2","20-Quick item 3",
+"21-Inventory 1","22-Inventory 2","23-Inventory 3","24-Inventory 4","25-Inventory 5","26-Inventory 6",
+"27-Inventory 7","28-Inventory 8","29-Inventory 9","30-Inventory 10","31-Inventory 11","32-Inventory 12",
+"33-Inventory 13","34-Inventory 14","35-Inventory 15","36-Inventory 16","37-Fist"};
+
+#define PST_SLOT_COUNT 46
+char *pst_slot_names[PST_SLOT_COUNT]={"0-Earring","1-Armor","2-L.Tattoo","3-Gloves","4-L.Ring","5-R.Ring","6-Eyeball",
+"7-R.Tattoo","8-Boots","9-Weapon 1","10-Weapon 2","11-Weapon 3","12-Weapon 4","13-Quiver 1","14-Quiver 2",
+"15-Quiver 3","16-Quiver 4","17-Quiver 5","18-Unknown","19-Cloak","20-Quick item 1","21-Quick item 2","22-Quick item 3",
+"23-Quick item 4","24-Quick item 5","25-Inventory 1","26-Inventory 2","27-Inventory 3","28-Inventory 4","29-Inventory 5","30-Inventory 6",
+"31-Inventory 7","32-Inventory 8","33-Inventory 9","34-Inventory 10","35-Inventory 11","36-Inventory 12",
+"37-Inventory 13","38-Inventory 14","39-Inventory 15","40-Inventory 16","41-Inventory 17","42-Inventory 18",
+"43-Inventory 19","44-Inventory 20","45-Unknown"};
+
+#define IWD2_SLOT_COUNT 50
+char *iwd2_slot_names[IWD2_SLOT_COUNT]={"0-Helmet","1-Armor","2-Shield","3-Gloves","4-L.Ring","5-R.Ring","6-Amulet",
+"7-Belt","8-Boots","9-Weapon 1","10-Shield 1","11-Weapon 2","12-Shield 2","13-Weapon 3","14-Shield 3","15-Weapon 4","16-Shield 4",
+"17-Cloak","18-Quiver 1","19-Quiver 2","20-Quiver 3","21-Fist","22-Quick item 1","23-Quick item 2","24-Quick item 3",
+"25-Inventory 1","26-Inventory 2","27-Inventory 3","28-Inventory 4","29-Inventory 5","30-Inventory 6",
+"31-Inventory 7","32-Inventory 8","33-Inventory 9","34-Inventory 10","35-Inventory 11","36-Inventory 12",
+"37-Inventory 13","38-Inventory 14","39-Inventory 15","40-Inventory 16",
+"41-Inventory 17","42-Inventory 18","43-Inventory 19","44-Inventory 20","45-Inventory 21","46-Inventory 22",
+"47-Inventory 23","48-Inventory 24","49-Unknown"};
+
+char *classstr[7]={"Bard", "Cleric", "Druid", "Paladin", "Ranger", "Sorceror", "Wizard"};
+char *otherstr[3]={"Innates","Songs","Shapes"};
+class OutStream {
+public:
+	 int indent;
+	 int hexnumsize;
+	 int fileoffset;
+	 #ifdef WIN32
+	 int outoffset;
+	 int buffsize;
+	 int increment;
+	 char *poi;
+#endif
+	 int fhandle;
+	 char signature[RESREFSIZE];
+
+	 OutStream();
+	 ~OutStream();
+	 int OpenStream(char *filename);
+	 int CloseStream();
+	 int AddString(int length, char *label);
+	 int AddBitmap(int length, char *label);
+	 int AddDword(char *label);
+	 int AddWord(char *label);
+	 int AddByte(char *label);
+	 int AddPoint(char *label);
+	 int AddIndent();
+	 int EndIndent();
+	 int AddSignature();
+	 int Prefetch(char *signature, int length);
+private:
+	 int ReallocBuffer();
+	 int DrawIndent();
+};
+
+OutStream::OutStream()
+{
+	fileoffset=0;
+#ifdef WIN32
+	outoffset=0;
+	buffsize=0;
+	increment=0;
+	poi=NULL;
+#endif
+	fhandle=0;
+	indent=0;
+}
+
+OutStream::~OutStream()
+{
+	CloseStream();
+}
+
+int OutStream::ReallocBuffer()
+{
+#ifdef WIN32
+	if(!increment) increment=256;
+	buffsize+=increment;
+	char *poi2=(char *) realloc(poi,buffsize);
+	if(!poi2) return 0;
+	poi=poi2;
+#endif
+	return 1;
+}
+int OutStream::OpenStream(char *FileToLoad)
+{
+	fhandle=open(FileToLoad,O_RDONLY|O_BINARY);
+	if (fhandle<1)
+		return 0;
+	hexnumsize=filelength(fhandle);
+	if(hexnumsize<256) hexnumsize=2;
+	else if(hexnumsize<65536) hexnumsize=4;
+	else hexnumsize=6;
+#ifdef WIN32
+	increment=128<<hexnumsize;
+	if(!poi)
+	{
+		buffsize=increment;
+		poi=(char *) malloc(buffsize);
+	}
+#endif
+	return 1;
+}
+
+int OutStream::AddIndent()
+{
+	if(indent<5)
+	{
+		indent++;
+		return 1;
+	}
+	return 0;
+}
+
+int OutStream::EndIndent()
+{
+	if(indent)
+	{
+		indent--;
+		return 1;
+	}
+	return 0;
+}
+
+int OutStream::CloseStream()
+{
+	if(fhandle) close(fhandle);
+	fhandle=0;
+	fileoffset=0;
+#ifdef WIN32
+	if(poi) free(poi);
+	poi=0;
+	outoffset=0;
+	buffsize=0;
+#endif
+	return 1;
+}
+
+#ifdef WIN32
+BOOL APIENTRY DllMain( HANDLE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved)
+{
+		switch (ul_reason_for_call)
+	{
+		case DLL_PROCESS_ATTACH:
+			hinst=(HINSTANCE)hModule;
+			break;
+		case DLL_PROCESS_DETACH:
+			if (FLibHandle)
+				FreeLibrary(FLibHandle);
+			FLibHandle=NULL;
+			break;
+		case DLL_THREAD_ATTACH:
+			break;
+		case DLL_THREAD_DETACH:
+			break;
+		}
+		return TRUE;
+}
+#else
+void *DumpFile(char* FileToLoad);
+
+int main(int argc, char **argv)
+{
+	if (argc!=2) {
+		return -1;
+	}
+	DumpFile(argv[1]);
+	return 0;
+}
+
+#endif
+
+char* strlcpy(char* p,char*p2,int maxlen)
+{
+	if ((int)strlen(p2)>=maxlen) {
+		strncpy(p,p2,maxlen);
+		p[maxlen]=0;
+	} else
+		strcpy(p,p2);
+	return p;
+}
+
+int OutStream::DrawIndent()
+{
+	if(indent<0 || indent>4)
+	{
+		return -1;
+	}
+	int i = INDENTSIZE*indent;
+#ifdef WIN32
+	if(outoffset+i>=buffsize)
+	{
+		ReallocBuffer();
+	}
+	while(i--)
+	{
+		poi[outoffset++]=' ';
+	}
+#else
+	printf("%*s",i,"");
+#endif
+	return 0;
+}
+
+int OutStream::Prefetch(char *signature, int length)
+{
+	char tmpstr[20];
+
+	if(length>20) return 0;
+	if(read(fhandle, tmpstr, length)!=length) return 0;
+	lseek(fhandle,-length,SEEK_CUR);
+	if(memcmp(signature,tmpstr,length) ) return 0;
+	return 1;
+}
+
+int OutStream::AddSignature()
+{
+	signature[0]=0;
+	return AddString(RESREFSIZE,"Signature");
+}
+
+int OutStream::AddString(int length, char *label)
+{
+	char tmpstr[VARSIZE];
+	memset(tmpstr,0,sizeof(tmpstr));
+	if(length>VARSIZE)
+	{
+		read(fhandle, tmpstr, VARSIZE);
+		lseek(fhandle, length-VARSIZE, SEEK_CUR);
+	}
+	else
+	{
+		read(fhandle, tmpstr, length);
+	}
+	if(!signature[0])
+	{
+		memcpy(signature,tmpstr,RESREFSIZE);
+	}
+	DrawIndent();
+	if(length<=RESREFSIZE)
+	{
+#ifdef WIN32
+		if(outoffset+hexnumsize+OTHERSIZE+RESREFSIZE>=buffsize)
+		{
+			ReallocBuffer();
+		}
+		sprintf(poi+outoffset,"%0*.*xh %-12.12s %-8.8s\n",hexnumsize,hexnumsize,fileoffset,label,tmpstr);
+		outoffset+=hexnumsize+OTHERSIZE+RESREFSIZE;
+#else
+		printf("%*.*xh %-12.12s %-8.8s\n",hexnumsize,hexnumsize,fileoffset,label,tmpstr);
+#endif
+	}
+	else
+	{
+#ifdef WIN32
+		if(outoffset+hexnumsize+OTHERSIZE+VARSIZE>=buffsize)
+		{
+			ReallocBuffer();
+		}
+		sprintf(poi+outoffset,"%0*.*xh %-12.12s %-32.32s\n",hexnumsize,hexnumsize,fileoffset,label,tmpstr);
+		outoffset+=hexnumsize+OTHERSIZE+VARSIZE;
+#else
+		printf("%*.*xh %-12.12s %-32.32s\n",hexnumsize,hexnumsize,fileoffset,label,tmpstr);
+#endif
+	}
+	
+	fileoffset+=length;
+	return 0;
+}
+
+int OutStream::AddBitmap(int length, char *label)
+{
+	lseek(fhandle, length, SEEK_CUR);
+	DrawIndent();
+#ifdef WIN32
+	if(outoffset+hexnumsize+OTHERSIZE+RESREFSIZE>=buffsize)
+	{
+		ReallocBuffer();
+	}
+	sprintf(poi+outoffset,"%0*.*xh %-12.12s #bitmap#\n",hexnumsize,hexnumsize,fileoffset,label);
+	outoffset+=hexnumsize+OTHERSIZE+RESREFSIZE;
+#else
+	printf("%*.*xh %-12.12s #bitmap#\n",hexnumsize,hexnumsize,fileoffset,label);
+#endif
+	fileoffset+=length;
+	return 0;
+}
+
+int OutStream::AddDword(char *label)
+{
+	unsigned int tmpdword;
+	read(fhandle, &tmpdword, 4);
+	DrawIndent();
+#ifdef WIN32
+	if(outoffset+hexnumsize+OTHERSIZE+DWORDSIZE>=buffsize)
+	{
+		ReallocBuffer();
+	}
+	sprintf(poi+outoffset,"%0*.*xh %-12.12s %08.8x\n",hexnumsize,hexnumsize,fileoffset,label,tmpdword);
+	outoffset+=hexnumsize+OTHERSIZE+DWORDSIZE;
+#else
+	printf("%*.*xh %-12.12s %8.8x\n",hexnumsize,hexnumsize,fileoffset,label,tmpdword);
+#endif
+	fileoffset+=4;
+	return tmpdword;
+}
+
+int OutStream::AddWord(char *label)
+{
+	unsigned short tmpword;
+	read(fhandle, &tmpword, 2);
+	DrawIndent();
+#ifdef WIN32
+	if(outoffset+hexnumsize+OTHERSIZE+WORDSIZE>=buffsize)
+	{
+		ReallocBuffer();
+	}
+	sprintf(poi+outoffset,"%0*.*xh %-12.12s %04.4x\n",hexnumsize,hexnumsize,fileoffset,label,tmpword);
+	outoffset+=hexnumsize+OTHERSIZE+WORDSIZE;
+#else
+	printf("%*.*xh %-12.12s %4.4x\n",hexnumsize,hexnumsize,fileoffset,label,tmpword);
+#endif
+	fileoffset+=2;
+	return tmpword;
+}
+
+int OutStream::AddPoint(char *label)
+{
+	unsigned short tmpword1, tmpword2;
+	read(fhandle, &tmpword1, 2);
+	read(fhandle, &tmpword2, 2);
+	DrawIndent();
+#ifdef WIN32
+	if(outoffset+hexnumsize+OTHERSIZE+POINTSIZE>=buffsize)
+	{
+		ReallocBuffer();
+	}
+	sprintf(poi+outoffset,"%0*.*xh %-12.12s [%04.4x.%04.4x]\n",hexnumsize,hexnumsize,fileoffset,label,tmpword1,tmpword2);
+	outoffset+=hexnumsize+OTHERSIZE+POINTSIZE;
+#else
+	printf("%*.*xh %-12.12s [%4.4x.%4.4x]\n",hexnumsize,hexnumsize,fileoffset,label,tmpword1,tmpword2);
+#endif
+	fileoffset+=4;
+	return (tmpword2<<16) | tmpword1;
+}
+
+int OutStream::AddByte(char *label)
+{
+	unsigned char tmpbyte;
+	read(fhandle, &tmpbyte, 1);
+	DrawIndent();
+#ifdef WIN32
+	if(outoffset+hexnumsize+OTHERSIZE+BYTESIZE>=buffsize)
+	{
+		ReallocBuffer();
+	}
+	sprintf(poi+outoffset,"%0*.*xh %-12.12s %02.2x\n",hexnumsize,hexnumsize,fileoffset,label,tmpbyte);
+	outoffset+=hexnumsize+OTHERSIZE+BYTESIZE;
+#else
+	printf("%*.*xh %-12.12s %2.2x\n",hexnumsize,hexnumsize,fileoffset,label,tmpbyte);
+#endif
+	fileoffset+=1;
+	return tmpbyte;
+}
+
+void CreateOutputVariable(OutStream &os)
+{
+	int k;
+
+	os.AddString(32,"Variable");
+	os.AddIndent();
+	os.AddDword("UNKNOWN");
+	os.AddDword("UNKNOWN");
+	os.AddDword("Value");
+	for(k=0;k<10;k++)
+	{
+		os.AddDword("UNKNOWN");
+	}
+	os.EndIndent();
+}
+
+void CreateOutputITM(OutStream &os)
+{
+	int extheadcount, extheadoffset;
+	int featblockcount,featblockoffset;
+	char tmpstr[20];
+	bool pst,iwd2;
+	int i;
+	int tmp;
+
+	pst=os.signature[7]=='1';
+	iwd2=os.signature[5]=='2';
+	os.AddDword("UnID name");
+	os.AddDword("ID name");
+	os.AddString(8,"Usedup");
+	os.AddDword("Attributes");
+	os.AddWord("Itemtype");
+	os.AddDword("Usability");
+	os.AddWord("Animation");
+	os.AddByte("MinLevel");
+	os.AddByte("UNKNOWN");
+	os.AddByte("MinStr");
+	os.AddByte("UNKNOWN");
+	os.AddByte("MinStrBonus");
+	os.AddByte("Kit 1");
+	os.AddByte("MinInt");
+	os.AddByte("Kit 2");
+	os.AddByte("MinDex");
+	os.AddByte("Kit 3");
+	os.AddByte("MinWis");
+	os.AddByte("Kit 4");
+	os.AddByte("MinCon");
+	os.AddByte("Proficiency");
+	os.AddByte("MinCha");
+	os.AddByte("UNKNOWN");
+	os.AddDword("Price");
+	os.AddWord("Stack");
+	os.AddString(8,"Inventory");
+	os.AddWord("Lore to ID");
+	os.AddString(8,"Ground");
+	os.AddDword("Weight");
+	os.AddDword("UnID desc");
+	os.AddDword("ID desc");
+	os.AddString(8,"Desc icon");
+	os.AddDword("Magiclevel");
+	extheadoffset=os.AddDword("Ext. offset");
+	extheadcount=os.AddWord("Ext. count");
+	featblockoffset=os.AddDword("Feat. offset");
+	os.AddWord("Equip offset");
+	os.AddWord("Equip count");
+	if(iwd2)
+	{
+		for(i=0;i<4;i++)
+		{
+			os.AddDword("UNKNOWN");
+		}
+	}
+	if(pst)
+	{
+		os.AddString(8,"Dialog");
+		os.AddDword("Name");
+		os.AddWord("Color");
+		os.AddWord("UNKNOWN");
+		for(i=0;i<6;i++)
+		{
+			os.AddDword("UNKNOWN");
+		}
+	}
+	if(extheadoffset!=os.fileoffset)
+	{
+		os.AddString(0, "**Error**");
+		return;
+	}
+
+	featblockcount=0;
+	for(i=0;i<extheadcount;i++)
+	{
+		sprintf(tmpstr,"Ext. head %.1d",i+1);
+		os.AddString(0, tmpstr);
+		os.AddIndent();
+		os.AddByte( "Attacktype");
+		os.AddByte( "Force ID");
+		os.AddWord( "Use location");
+		os.AddString(8,"Use icon");
+		os.AddByte( "Target type");
+		os.AddByte( "Target #");
+		os.AddWord("Range");
+		os.AddWord("Proj. type");
+		os.AddWord("Speed");
+		os.AddWord("Thac0 bonus");
+		os.AddWord( "Dice size");
+		os.AddWord( "Dice count");
+		os.AddWord( "Dice bonus");
+		os.AddWord( "Damagetype");
+		tmp=os.AddWord( "Feat. count");
+		tmp+=os.AddWord( "Feat. offset");
+		if(tmp>featblockcount) featblockcount=tmp;
+		os.AddWord("Charges");
+		os.AddWord("Drain type");
+		os.AddDword("Flags");
+		os.AddWord("Effect animation");
+		os.AddWord( "Melee anim 1");
+		os.AddWord( "Melee anim 2");
+		os.AddWord( "Melee anim 3");
+		os.AddWord( "Bow");
+		os.AddWord("Crossbow");
+		os.AddWord("Throwing");
+		os.EndIndent();
+	}
+	if(featblockoffset!=os.fileoffset)
+	{
+		os.AddString(0, "**Error**");
+		return;
+	}
+	for(i=0;i<featblockcount;i++)
+	{
+		sprintf(tmpstr,"Feat block %.1d",i+1);
+		os.AddString(0, tmpstr);
+		os.AddIndent();
+		os.AddWord("Opcode");
+		os.AddByte("Target type");
+		os.AddByte("Power");
+		os.AddDword("Parameter 1");
+		os.AddDword("Parameter 2");
+		os.AddByte("Timing method");
+		os.AddByte("Resistance");
+		os.AddDword("Duration");
+		os.AddByte("Max. prob.");
+		os.AddByte( "Min. prob.");
+		os.AddString(8,"Resource");
+		os.AddDword("Min level");
+		os.AddDword("Max level");
+		os.AddDword("S. throw type");
+		os.AddDword("S. throw bonus");
+		os.AddDword("UNKNOWN");
+		os.EndIndent();
+	}
+}
+
+void CreateOutputSPL(OutStream &os)
+{
+	int extheadcount, extheadoffset;
+	int featblockcount,featblockoffset;
+	char tmpstr[20];
+	bool iwd2;
+	int i;
+	int tmp;
+
+	iwd2=os.signature[5]=='2';
+	os.AddDword("UnID name");
+	os.AddDword("ID name");
+	os.AddString(8,"Completion");
+	os.AddDword("Attributes");
+	os.AddWord("Spelltype");
+	os.AddDword("Usability");
+	os.AddWord("Casting glow");
+	os.AddByte("UNKNOWN");
+	os.AddWord("School type");
+	os.AddByte("Sec. type");
+	os.AddDword("UNKNOWN");
+	os.AddDword("UNKNOWN");
+	os.AddDword("UNKNOWN");
+	os.AddDword("Level");
+	os.AddWord("UNKNOWN");
+	os.AddString(8,"Book icon");
+	os.AddWord("UNKNOWN");
+	os.AddString(8,"UNKNOWN");
+	os.AddDword("UNKNOWN");
+	os.AddDword("UnID desc");
+	os.AddDword("ID desc");
+	os.AddString(8,"UNKNOWN");
+	os.AddDword("UNKNOWN");
+	extheadoffset=os.AddDword("Ext. offset");
+	extheadcount=os.AddWord("Ext. count");
+	featblockoffset=os.AddDword("Feat. offset");
+	os.AddWord("CFB offset");
+	os.AddWord("CFB count");
+	if(iwd2)
+	{
+		os.AddByte("Multiplier");
+		os.AddByte("Modifier");
+		os.AddWord("UNKNOWN");
+		for(i=0;i<3;i++)
+		{
+			os.AddDword("UNKNOWN");
+		}
+	}
+	if(extheadoffset!=os.fileoffset)
+	{
+		os.AddString(0, "**Error**");
+		return;
+	}
+
+	featblockcount=0;
+	for(i=0;i<extheadcount;i++)
+	{
+		sprintf(tmpstr,"Ext. head %.1d",i+1);
+		os.AddString(0, tmpstr);
+		os.AddIndent();    
+		os.AddByte("Spelltype");
+		os.AddByte( "UNKNOWN");
+		os.AddWord("Use location");
+		os.AddString(8,"Use icon");
+		os.AddByte( "Target type");
+		os.AddByte( "Target #");
+		os.AddWord("Range");
+		os.AddWord("Level req.");
+		os.AddWord( "Speed");
+		os.AddWord( "UNKNOWN");
+		os.AddWord( "UNKNOWN");
+		os.AddWord( "UNKNOWN");
+		os.AddWord( "UNKNOWN");
+		os.AddWord( "UNKNOWN");
+		tmp=os.AddWord( "Feat. count");
+		tmp+=os.AddWord("Feat. offset");
+		if(tmp>featblockcount) featblockcount=tmp;
+		os.AddWord( "UNKNOWN");
+		os.AddWord("UNKNOWN");
+		os.AddWord("Projectile");
+		os.EndIndent();
+	}
+	if(featblockoffset!=os.fileoffset)
+	{
+		os.AddString(0, "**Error**");
+		return;
+	}
+	for(i=0;i<featblockcount;i++)
+	{
+		sprintf(tmpstr,"Feat block %.1d",i+1);
+		os.AddString(0, tmpstr);
+		os.AddIndent();
+		os.AddWord("Opcode");
+		os.AddByte("Target type");
+		os.AddByte("Power");
+		os.AddDword("Parameter 1");
+		os.AddDword("Parameter 2");
+		os.AddByte( "Timing method");
+		os.AddByte( "Resistance");
+		os.AddDword( "Duration");
+		os.AddByte("Max. prob.");
+		os.AddByte( "Min. prob.");
+		os.AddString(8,"Resource");
+		os.AddDword( "Min level");
+		os.AddDword( "Max level");
+		os.AddDword( "S. throw type");
+		os.AddDword("S. throw bonus");
+		os.AddDword( "UNKNOWN");
+		os.EndIndent();
+	}
+}
+
+void CreateOutputSTO(OutStream &os)
+{
+	int pitemoffset, pitemcount;
+	int storeoffset, storecount;
+	int drinkoffset, drinkcount;
+	int spelloffset, spellcount;
+	char tmpstr[20];
+	bool pst, iwd2;
+	int i,j,k;
+	int type;
+
+	pst=os.signature[7]=='1';
+	iwd2=os.signature[5]=='9';
+	type=os.AddDword("Store type");
+	os.AddDword("Name");
+	os.AddDword("Flags");
+	os.AddDword("Sell markup");
+	os.AddDword("Buy markup");
+	os.AddDword("Depreciation");
+	if(iwd2)
+	{
+		os.AddDword("Stealing %");
+	}
+	else
+	{
+		os.AddWord("Stealing %");
+		if(type==5)
+		{
+			os.AddWord("Capacity");
+		}
+		else
+		{
+			os.AddWord("UNKNOWN");
+		}
+	}
+	os.AddString( RESREFSIZE,"UNKNOWN");
+	pitemoffset=os.AddDword("P items offset");
+	pitemcount=os.AddDword("P items count");
+	if(!pitemcount) pitemoffset=0;
+	storeoffset=os.AddDword("Store offset");
+	storecount=os.AddDword("Store count");
+	if(!storecount) storeoffset=0;
+	os.AddDword("Lore");
+	os.AddDword("ID price");
+	os.AddString( RESREFSIZE,"Tavern rumour");
+	drinkoffset=os.AddDword("Drinks offset");
+	drinkcount=os.AddDword("Drinks count");
+	if(!drinkcount) drinkoffset=0;
+	os.AddString(RESREFSIZE,"Temple rumour");
+	os.AddDword("Rentable rooms");
+	os.AddDword("Peasant price");
+	os.AddDword("Merchant price");
+	os.AddDword("Noble price");
+	os.AddDword("Royal price");
+	spelloffset=os.AddDword("Spells offset");
+	spellcount=os.AddDword("Spells count");
+	if(!spellcount) spelloffset=0;
+	for(i=0;i<9;i++)
+	{
+		os.AddDword("UNKNOWN");
+	}
+	if(iwd2)
+	{
+		os.AddDword("Capacity");    
+		for(i=0;i<20;i++)
+		{
+			os.AddDword("UNKNOWN");
+		}
+	}
+	for(i=0;i<4;i++)
+	{
+		if(pitemoffset && (pitemoffset==os.fileoffset))
+		{
+			os.AddString(0, "Accepted items");
+			os.AddIndent();
+			for(j=0;j<pitemcount;j++)
+			{
+				os.AddDword("ItemType");
+			}
+			os.EndIndent();
+			pitemoffset=0;
+			continue;
+		}
+		if(storeoffset && (storeoffset==os.fileoffset))
+		{
+			os.AddString(0, "Stored items");
+			for(j=0;j<storecount;j++)
+			{
+				sprintf(tmpstr,"Item #%d",j+1);
+				os.AddString(0, tmpstr);
+				os.AddIndent();
+				os.AddString(8,"Item");
+				os.AddWord("UNKNOWN");
+				os.AddWord("Charge 1");
+				os.AddWord("Charge 2");
+				os.AddWord("Charge 3");
+				os.AddDword("Flags");
+				os.AddDword("Stock");
+				os.AddDword("Infinite supply");
+				if(pst)
+				{
+					os.AddDword("Trigger strref");
+					for(k=0;k<14;i++)
+					{
+						os.AddDword("UNKNOWN");
+					}
+				}
+				os.EndIndent();
+			}
+			storeoffset=0;
+			continue;
+		}
+		if(drinkoffset && (drinkoffset==os.fileoffset))
+		{
+			os.AddString(0, "Drinks");
+			for(j=0;j<drinkcount;j++)
+			{
+				sprintf(tmpstr,"Drink #%d",j+1);
+				os.AddString(0, tmpstr);
+				os.AddIndent();
+				os.AddDword("UNKNOWN");
+				os.AddDword("UNKNOWN");
+				os.AddDword("Drink name");
+				os.AddDword("Drink price");
+				os.AddDword("Rumour chance");
+				os.EndIndent();
+			}
+			drinkoffset=0;
+			continue;
+		}
+		if(spelloffset && (spelloffset==os.fileoffset))
+		{
+			os.AddString(0, "Drinks");
+			for(j=0;j<spellcount;j++)
+			{
+				sprintf(tmpstr,"Cure #%d",j+1);
+				os.AddString(0, tmpstr);
+				os.AddIndent();
+				os.AddString(8,"Spell resref");
+				os.AddDword("Price");
+				os.EndIndent();
+			}
+			spelloffset=0;
+			continue;
+		}
+		if(spelloffset || drinkoffset || pitemoffset || storeoffset)
+		{
+			os.AddString(0, "**Error**");
+			return;
+		}
+	}
+}
+
+void CreateOutputEFF(OutStream &os)
+{
+	int i;
+
+	os.AddString(8,"Signature copy");
+	os.AddDword("Effect opcode");
+	os.AddDword("Target type");
+	os.AddDword("Power");
+	os.AddDword("Parameter 1");
+	os.AddDword("Parameter 2");
+	os.AddDword("Timing");
+	os.AddDword("Duration");
+	os.AddWord("Prob. high");
+	os.AddWord("Prob. low");
+	os.AddString(8,"Resource 1");
+	os.AddDword("Dice count");
+	os.AddDword("Dice sides");
+	os.AddDword("Saving throw");
+	os.AddDword("Save bonus");
+	os.AddDword("Variable?");
+	os.AddDword("School");
+	for(i=0;i<3;i++)
+	{
+		os.AddDword("UNKNOWN");
+	}
+	os.AddDword("Resistance");
+	os.AddDword("Parameter 3");
+	os.AddDword("Parameter 4");
+	os.AddDword("UNKNOWN");
+	os.AddDword("UNKNOWN");
+	os.AddString(8,"Resource 2");
+	os.AddString(8,"Resource 3");
+	os.AddDword("Pos1 X");
+	os.AddDword("Pos1 Y");
+	os.AddDword("Pos2 X");
+	os.AddDword("Pos2 Y");
+	os.AddDword("UNKNOWN");
+	os.AddString(8,"Source");
+	for(i=0;i<3;i++)
+	{
+		os.AddDword("UNKNOWN");
+	}
+	os.AddString(32,"Variable");
+	os.AddDword("UNKNOWN");
+	os.AddDword("UNKNOWN");
+	os.AddDword("Sec. type");
+	for(i=0;i<15;i++)
+	{
+		os.AddDword("UNKNOWN");
+	}
+}
+
+void CreateOutputVVC(OutStream &os)
+{
+	int i;
+
+	os.AddString(8,"BAM resref");
+	os.AddDword("UNKNOWN");
+	os.AddDword("UNKNOWN");
+	os.AddDword("Flags");
+	os.AddDword("UNKNOWN");
+	os.AddDword("Sequencing");
+	os.AddDword("UNKNOWN");
+	os.AddDword("X position");
+	os.AddDword("Y position");
+	os.AddDword("UNKNOWN");
+	os.AddDword("Framerate");
+	os.AddDword("UNKNOWN");
+	os.AddDword("UNKNOWN");
+	os.AddDword("Position flags");
+	os.AddDword("UNKNOWN");
+	os.AddDword("UNKNOWN");
+	os.AddDword("Z position");
+	os.AddDword("UNKNOWN");
+	os.AddDword("UNKNOWN");
+	os.AddDword("UNKNOWN");
+	os.AddDword("Duration");
+	os.AddDword("UNKNOWN");
+	os.AddDword("UNKNOWN");
+	os.AddDword("Cycle 1");
+	os.AddDword("Cycle 2");
+	os.AddDword("UNKNOWN");
+	os.AddDword("UNKNOWN");
+	os.AddString(8,"Sound 1");
+	os.AddString(8,"Sound 2");
+	for(i=0;i<89;i++)
+	{
+		os.AddDword("UNKNOWN");
+	}
+}
+
+void IWD2CreHeaders(OutStream &os)
+{
+	int bookoffset[9*16];
+	int bookcount[9*16];
+	int domoffset[9];
+	int domcount[9];
+	int otheroffset[3];
+	int othercount[3];
+	int slotoffset, itemoffset, itemcount;
+	int effoffset, effcount;
+	char tmpstr[20];
+	int i,j;
+
+	os.AddString(0,"Book offsets");
+	os.AddIndent();
+	for(i=0;i<9*7;i++)
+	{
+		sprintf(tmpstr,"%s %d",classstr[i/9], (i%9)+1);
+		bookoffset[i]=os.AddDword(tmpstr);
+	}
+	os.EndIndent();
+	os.AddString(0,"Book counts");
+	os.AddIndent();
+	for(i=0;i<9*7;i++)
+	{
+		sprintf(tmpstr,"%s %d",classstr[i/9], (i%9)+1);
+		bookcount[i]=os.AddDword(tmpstr);
+	}
+	os.EndIndent();
+
+	os.AddString(0,"Domain offsets");
+	os.AddIndent();
+	for(i=0;i<9;i++)
+	{
+		sprintf(tmpstr,"Level %d",i+1);
+		domoffset[i]=os.AddDword(tmpstr);
+	}
+	os.EndIndent();
+	os.AddString(0,"Domain counts");
+	os.AddIndent();
+	for(i=0;i<9;i++)
+	{
+		sprintf(tmpstr,"Level %d",i+1);
+		domcount[i]=os.AddDword(tmpstr);
+	}
+	os.EndIndent();
+
+	for(i=0;i<3;i++)
+	{
+		sprintf(tmpstr,"%s offset",otherstr[i]);
+		otheroffset[i]=os.AddDword(tmpstr);
+		sprintf(tmpstr,"%s count",otherstr[i]);
+		othercount[i]=os.AddDword(tmpstr);
+	}
+
+	slotoffset=os.AddDword("Itemslots");//4
+	itemoffset=os.AddDword("Item offset");
+	itemcount=os.AddDword("Item count");//5
+	if(!itemcount) itemoffset=0;
+	effoffset=os.AddDword("Effect offset");
+	effcount=os.AddDword("Effect count");//6
+	if(!effcount) effoffset=0;
+	os.AddString(8,"Dialog");
+	//always saved in order
+	for(i=0;i<9*7;i++)
+	{
+		if(bookoffset[i]==os.fileoffset )
+		{
+			sprintf(tmpstr,"%s %d",classstr[i/9], (i%9)+1);
+			os.AddString(0,tmpstr);
+			os.AddIndent();
+			for(j=0;j<bookcount[i];j++)
+			{
+				os.AddIndent();
+				os.AddDword("Spell ID");
+				os.AddDword("Total");
+				os.AddDword("Remaining");
+				os.AddDword("UNKNOWN");
+				os.EndIndent();
+			}
+			os.AddDword("Free");
+			os.AddDword("UNKNOWN");
+			os.EndIndent();
+		}
+		else
+		{
+			os.AddString(0, "**Error**");
+			return;
+		}
+	}
+	for(i=0;i<9;i++)
+	{
+		if(domoffset[i]==os.fileoffset )
+		{
+			sprintf(tmpstr,"Domain %d",i+1);
+			os.AddString(0,tmpstr);
+			os.AddIndent();
+			for(j=0;j<domcount[i];j++)
+			{
+				os.AddIndent();
+				os.AddDword("Spell ID");
+				os.AddDword("Total");
+				os.AddDword("Remaining");
+				os.AddDword("UNKNOWN");
+				os.EndIndent();
+			}
+			os.AddDword("Free");
+			os.AddDword("UNKNOWN");
+			os.EndIndent();
+		}
+		else
+		{
+			os.AddString(0, "**Error**");
+			return;
+		}
+	}
+
+	for(i=0;i<3;i++)
+	{
+		if(otheroffset[i]==os.fileoffset )
+		{      
+			os.AddString(0,otherstr[i]);
+			os.AddIndent();
+			for(j=0;j<othercount[i];j++)
+			{
+				os.AddIndent();
+				os.AddDword("Spell ID");
+				os.AddDword("Total");
+				os.AddDword("Remaining");
+				os.AddDword("UNKNOWN");
+				os.EndIndent();
+			}
+			os.AddDword("Free");
+			os.AddDword("UNKNOWN");
+			os.EndIndent();
+		}
+		else
+		{
+			os.AddString(0, "**Error**");
+			return;
+		}
+	}
+	for(i=0;i<3;i++)
+	{
+		if(slotoffset==os.fileoffset)
+		{
+			for(j=0;j<IWD2_SLOT_COUNT;j++)
+			{
+				os.AddWord(iwd2_slot_names[j]);
+			}
+			os.AddDword("Equipped");
+			slotoffset=0;
+			continue;
+		}
+		if(itemcount && (itemoffset==os.fileoffset) )
+		{
+			os.AddString(0, "Items");
+			for(j=0;j<itemcount;j++)
+			{
+				sprintf(tmpstr,"Item #%d",j); //intentionally 0 based
+				os.AddString(0, tmpstr);
+				os.AddIndent();
+				os.AddString(8,"Item");
+				os.AddWord("UNKNOWN");
+				os.AddWord("Charge 1");
+				os.AddWord("Charge 2");
+				os.AddWord("Charge 3");
+				os.AddDword("Flags");
+				os.EndIndent();
+			}
+			itemoffset=0;
+			continue;
+		}
+		if(effcount && (effoffset==os.fileoffset) )
+		{
+			os.AddString(0, "Effects");
+			for(j=0;j<effcount;j++)
+			{
+				sprintf(tmpstr,"Effect #%d",j+1);
+				os.AddString(0, tmpstr);
+				os.AddIndent();
+				CreateOutputEFF(os);
+				os.EndIndent();
+			}
+			effoffset=0;
+			continue;
+		}
+		if(slotoffset || itemoffset || effoffset)
+		{
+			os.AddString(0, "**Error**");
+			return;
+		}
+	}
+}
+
+void CreateOutputCRE(OutStream &os)
+{
+	int bookoffset, bookcount;
+	int seloffset, selcount;
+	int memoffset, memcount;
+	int slotoffset, itemoffset, itemcount;
+	int effoffset, effcount;
+	char tmpstr[20];
+	bool pst, iwd, iwd2;
+	int i,j,k;
+	int effver;
+	char **slotnames;
+
+	if(os.signature[7]=='2')
+	{
+		pst=os.signature[5]=='1';
+		iwd2=os.signature[5]=='2';
+	}
+	else
+	{
+		pst=0;
+		iwd2=0;
+	}
+	iwd=os.signature[5]=='9';
+	os.AddDword("Longname");
+	os.AddDword("Shortname");
+	os.AddDword("Flags");
+	os.AddDword("XP Value");
+	os.AddDword("Current XP");
+	os.AddDword("Gold");
+	os.AddDword("State");
+	os.AddWord("Current HP");
+	os.AddWord("Max. HP");
+	os.AddDword("Animation ID");
+	os.AddByte("Metal color");
+	os.AddByte("Minor color");
+	os.AddByte("Major color");
+	os.AddByte("Skin color");
+	os.AddByte("Leather color");
+	os.AddByte("Armor color");
+	os.AddByte("Hair color");
+	effver=os.AddByte("Effect version");
+	os.AddString( RESREFSIZE,"Small Portrait");
+	os.AddString( RESREFSIZE,"Large Portrait");
+	os.AddByte("Reputation");
+	os.AddByte("Hide in shadows");
+	os.AddWord("Natural AC");
+	if(!iwd2)
+	{
+		os.AddWord("Actual AC");
+	}
+	os.AddWord("Crushing mod.");
+	os.AddWord("Missile mod.");
+	os.AddWord("Piercing mod.");
+	os.AddWord("Slashing mod.");
+	os.AddByte("THAC0");
+	os.AddByte("Number of att.");
+	if(iwd2)
+	{
+		os.AddByte("Fortitude");
+		os.AddByte("Reflex");
+		os.AddByte("Will");
+	}
+	else
+	{
+		os.AddByte("Save vs. death");
+		os.AddByte("Save vs. wand");
+		os.AddByte("Save vs. poly");
+		os.AddByte("Save vs. breath");
+		os.AddByte("Save vs. spell");
+	}
+	os.AddByte("Fire resistance");
+	os.AddByte("Cold resistance");
+	os.AddByte("Elec. resistance");
+	os.AddByte("Acid resistance");
+	os.AddByte("Magic resistance");
+	os.AddByte("M. fire resistance");
+	os.AddByte("M. cold resistance");
+	os.AddByte("Slashing resistance");
+	os.AddByte("Crushing resistance");
+	os.AddByte("Piercing resistance");
+	os.AddByte("Missile resistance");
+	if(iwd2)
+	{
+		os.AddByte("M. damage resistance");
+		for(i=0;i<4;i++)
+		{
+			os.AddByte("UNKNOWN");
+		}
+	}
+	else
+	{
+		os.AddByte("Detect illusion");
+		os.AddByte("Set traps");
+		os.AddByte("Lore");
+		os.AddByte("Lockpicking");
+		os.AddByte("Stealth");
+		os.AddByte("Disarm trap");
+		os.AddByte("Pickpocket");
+	}
+	os.AddByte("Fatigue");
+	os.AddByte("Intoxication");
+	os.AddByte("Luck");
+	if(iwd2)
+	{
+		os.AddByte("Turn level");
+		for(i=0;i<33;i++)
+		{
+			os.AddByte("UNKNOWN");
+		}
+		os.AddByte("Total levels");
+		for(i=0;i<11;i++)
+		{
+			os.AddByte("Level");
+		}
+		for(i=0;i<22;i++)
+		{
+			os.AddByte("UNKNOWN");
+		}
+		for(i=0;i<64;i++)
+		{
+			os.AddDword("String ref.");
+		}
+		os.AddString(8,"Team script");
+		os.AddString(8,"Special script");
+		os.AddDword("UNKNOWN");
+		os.AddDword("Feats 1");
+		os.AddDword("Feats 2");
+		os.AddDword("Feats 3");
+		for(i=0;i<3;i++)
+		{
+			os.AddDword("UNKNOWN");
+		}
+		os.AddByte("Bow");
+		os.AddByte("Crossbow");
+		os.AddByte("Sling");
+		os.AddByte("Axe");
+		os.AddByte("Mace");
+		os.AddByte("Flail");
+		os.AddByte("Polearm");
+		os.AddByte("Hammer");
+		os.AddByte("Staff");
+		os.AddByte("Great sword");
+		os.AddByte("Large sword");
+		os.AddByte("Small sword");
+		os.AddByte("Toughness");
+		os.AddByte("Armour casting");
+		os.AddByte("Cleave");
+		os.AddByte("Armour");
+		os.AddByte("Enchantment");
+		os.AddByte("Evocation");
+		os.AddByte("Necromancy");
+		os.AddByte("Transmutation");
+		os.AddByte("Spell penetration");
+		os.AddByte("Extra rage");
+		os.AddByte("Extra shape");
+		os.AddByte("Extra smiting");
+		os.AddByte("Extra turning");
+		os.AddByte("Bastardsword");
+		for(i=0;i<38;i++)
+		{
+			os.AddByte("Unknown");
+		}
+
+		os.AddByte("Alchemy");
+		os.AddByte("Animals");
+		os.AddByte("Bluff");
+		os.AddByte("Concentration");
+		os.AddByte("Diplomacy");
+		os.AddByte("Disarm trap");
+		os.AddByte("Hide");
+		os.AddByte("Intimidate");
+		os.AddByte("Lore");
+		os.AddByte("Move silently");
+		os.AddByte("Open lock");
+		os.AddByte("Pickpocket");
+		os.AddByte("Search");
+		os.AddByte("Spellcraft");
+		os.AddByte("Use magic device");
+		os.AddByte("Tracking");
+
+		for(i=0;i<51;i++)
+		{
+			os.AddByte("Unknown");
+		}
+		for(i=0;i<8;i++)
+		{
+			os.AddByte("Enemy");
+		}
+		os.AddByte("Subrace");
+		os.AddByte("UNKNOWN");
+		goto iwd2_done;
+	}
+	if(iwd)
+	{
+		os.AddByte("Large swords");
+		os.AddByte("Small swords");
+		os.AddByte("Bows");
+		os.AddByte("Spears");
+		os.AddByte("Axe");
+		os.AddByte("Missile");
+		os.AddByte("Great swords");
+		os.AddByte("Daggers");
+		os.AddByte("Halberds");
+		os.AddByte("Maces");
+		os.AddByte("Flails");
+		os.AddByte("Hammers");
+		os.AddByte("Clubs");
+		os.AddByte("Quarterstaves");
+		os.AddByte("Crossbows");
+		for(i=0;i<6;i++)
+		{
+			os.AddByte("UNKNOWN");
+		}
+		goto weapon_done;
+	}
+	if(effver)
+	{
+		for (i=0;i<8;i++) {
+			os.AddByte("BG1 Weapon");
+		}
+		for(i=0;i<13;i++)
+		{
+			os.AddByte("UNKNOWN");
+		}
+		goto weapon_done;
+	}
+	os.AddByte("Large swords");
+	os.AddByte("Small swords");
+	os.AddByte("Bows");
+	os.AddByte("Spears");
+	os.AddByte("Blunt");
+	os.AddByte("Spiked");
+	os.AddByte("Axe");
+	os.AddByte("Missile");
+	for(i=0;i<13;i++)
+	{
+		os.AddByte("UNKNOWN");
+	}
+weapon_done:
+	os.AddByte("Tracking");
+	for(i=0;i<8;i++)
+	{
+		os.AddDword("UNKNOWN");
+	}
+	for(i=0;i<100;i++)
+	{
+		os.AddDword("String ref.");
+	}
+	os.AddByte("Level 1");
+	os.AddByte("Level 2");
+	os.AddByte("Level 3");
+iwd2_done:
+	os.AddByte("Sex"); //same as Gender
+	os.AddByte("Strength");
+	if(!iwd2)
+	{
+		os.AddByte("Strength bonus");
+	}
+	os.AddByte("Intelligence");
+	os.AddByte("Wisdom");
+	os.AddByte("Dexterity");
+	os.AddByte("Constitution");
+	os.AddByte("Charisma");
+	os.AddByte("Morale");
+	os.AddByte("Morale break");
+	if(!iwd2)
+	{
+		os.AddByte("Racial enemy");
+	}
+	os.AddByte("Morale recovery");
+	os.AddByte("UNKNOWN");
+	os.AddDword("Kit");
+	os.AddString(8,"Override");
+	os.AddString(8,"Class");
+	os.AddString(8,"Race");
+	os.AddString(8,"General");
+	os.AddString(8,"Default");
+	if(iwd2)
+	{
+		os.AddDword("UNKNOWN");
+		for(i=0;i<5;i++)
+		{
+			sprintf(tmpstr,"Internal #%x",i);
+			os.AddWord(tmpstr);
+		}
+		os.AddWord("UNKNOWN");
+		for(i=0;i<16;i++)
+		{
+			os.AddDword("UNKNOWN");
+		}
+		os.AddWord("Saved X pos.");
+		os.AddWord("Saved Y pos.");
+		os.AddWord("Saved orientation");
+		os.AddWord("UNKNOWN");
+		for(i=0;i<36;i++)
+		{
+			os.AddDword("UNKNOWN");
+		}
+		goto iwd2_done2;
+	}
+	if(iwd)
+	{
+		for(i=0;i<7;i++)
+		{
+			os.AddWord("UNKNOWN");
+		}
+		os.AddString(32,"UNKNOWN");
+		os.AddString(32,"UNKNOWN");
+		for(i=0;i<13;i++)
+		{
+			os.AddWord("UNKNOWN");
+		}
+	}
+	if(pst)
+	{
+		for(i=0;i<13;i++)
+		{
+			os.AddDword("UNKNOWN");
+		}
+		for(i=0;i<10;i++)
+		{
+			os.AddWord("Internal");
+		}
+		os.AddDword("UNKNOWN");
+		os.AddString(32,"Bestiary ref.");
+		os.AddByte("Dialog radius"); //?
+		os.AddByte("Personal space");//?
+		os.AddByte("UNKNOWN");
+		os.AddByte("Color count");
+		os.AddDword("Display flags");
+		for(i=0;i<7;i++)
+		{
+			os.AddWord("Color");
+		}
+		os.AddByte("UNKNOWN");
+		os.AddByte("UNKNOWN");
+		os.AddByte("UNKNOWN");
+		for(i=0;i<7;i++)
+		{
+			os.AddByte("Color slot");
+		}
+		for(i=0;i<4;i++)
+		{
+			os.AddDword("UNKNOWN");
+		}
+		os.AddWord("UNKNOWN");
+		os.AddWord("UNKNOWN");
+		os.AddByte("UNKNOWN");
+		os.AddByte("Species");
+		os.AddByte("Team");
+		os.AddByte("Faction");
+	}
+iwd2_done2:
+	os.AddByte("EA");
+	os.AddByte("General");
+	os.AddByte("Race");
+	os.AddByte("Class");
+	os.AddByte("Specific");
+	os.AddByte("Gender");
+	for(i=0;i<5;i++)
+	{
+		os.AddByte("UNKNOWN");
+	}
+	os.AddByte("Alignment");
+	os.AddWord("UNKNOWN");
+	os.AddWord("UNKNOWN");
+	os.AddString(VARSIZE,"Scripting name");
+	if(iwd2)
+	{
+		for(i=0;i<3;i++)
+		{
+			os.AddWord("UNKNOWN");
+		}
+		IWD2CreHeaders(os); //iwd2 is so different!
+		return;
+	}
+	bookoffset=os.AddDword("Book offset");
+	bookcount=os.AddDword("Book count");//1
+	if(!bookcount) bookoffset=0;
+	seloffset=os.AddDword("Selected offset");
+	selcount=os.AddDword("Selected count");//2
+	if(!selcount) seloffset=0;
+	memoffset=os.AddDword("Memorized offset");
+	memcount=os.AddDword("Memorized count");//3
+	if(!memcount) memoffset=0;
+	slotoffset=os.AddDword("Itemslots");//4
+	itemoffset=os.AddDword("Item offset");
+	itemcount=os.AddDword("Item count");//5
+	if(!itemcount) itemoffset=0;
+	effoffset=os.AddDword("Effect offset");
+	effcount=os.AddDword("Effect count");//6
+	if(!effcount) effoffset=0;
+	os.AddString(8,"Dialog");
+	for(i=0;i<6;i++)
+	{
+		if(bookcount && (bookoffset==os.fileoffset) )
+		{
+			os.AddString(0, "Spellbook");
+			for(j=0;j<bookcount;j++)
+			{
+				sprintf(tmpstr,"Spell #%d",j+1);
+				os.AddString(0, tmpstr);
+				os.AddIndent();
+				os.AddString(8,"Spell");
+				os.AddWord("Spell level");
+				os.AddWord("Spell type");
+				os.EndIndent();
+			}
+			bookoffset=0;
+			continue;
+		}
+		if(selcount && (seloffset==os.fileoffset) )
+		{
+			os.AddString(0, "Memorized spell pages");
+			for(j=0;j<selcount;j++)
+			{
+				sprintf(tmpstr,"Page #%d",j+1);
+				os.AddString(0, tmpstr);
+				os.AddIndent();
+				os.AddWord("Spell level");
+				os.AddWord("Base number");
+				os.AddWord("Actual number"); //modified by spells
+				os.AddWord("Spell type");
+				os.AddDword("Spell index");
+				os.AddDword("Spell count");
+				os.EndIndent();
+			}
+			seloffset=0;
+			continue;
+		}
+		if(memcount && (memoffset==os.fileoffset) )
+		{
+			os.AddString(0, "Memorized spells");
+			for(j=0;j<memcount;j++)
+			{
+				sprintf(tmpstr,"Spell #%d",j+1);
+				os.AddString(0, tmpstr);
+				os.AddIndent();
+				os.AddString(8,"Spell");
+				os.AddDword("Castable");
+				os.EndIndent();
+			}
+			memoffset=0;
+			continue;
+		}
+
+		if(slotoffset==os.fileoffset)
+		{
+			slotnames=bg2_slot_names;
+			k=SLOT_COUNT;
+			if(pst)
+			{
+				slotnames=pst_slot_names;
+				k=PST_SLOT_COUNT;
+			}
+			for(j=0;j<k;j++)
+			{
+				os.AddWord(slotnames[j]);
+			}
+			os.AddDword("Equipped");
+			slotoffset=0;
+			continue;
+		}
+		if(itemcount && (itemoffset==os.fileoffset) )
+		{
+			os.AddString(0, "Items");
+			for(j=0;j<itemcount;j++)
+			{
+				sprintf(tmpstr,"Item #%d",j); //intentionally 0 based
+				os.AddString(0, tmpstr);
+				os.AddIndent();
+				os.AddString(8,"Item");
+				os.AddWord("UNKNOWN");
+				os.AddWord("Charge 1");
+				os.AddWord("Charge 2");
+				os.AddWord("Charge 3");
+				os.AddDword("Flags");
+				os.EndIndent();
+			}
+			itemoffset=0;
+			continue;
+		}
+		if(effcount && (effoffset==os.fileoffset) )
+		{
+			os.AddString(0, "Effects");
+			for(j=0;j<effcount;j++)
+			{
+				sprintf(tmpstr,"Effect #%d",j+1);
+				os.AddString(0, tmpstr);
+				os.AddIndent();
+				if(effver)
+				{
+					CreateOutputEFF(os);
+				}
+				else
+				{
+					os.AddWord("Opcode");
+					os.AddByte("Target type");
+					os.AddByte("Power");
+					os.AddDword("Parameter 1");
+					os.AddDword("Parameter 2");
+					os.AddByte("Timing method");
+					os.AddByte("Resistance");
+					os.AddDword("Duration");
+					os.AddByte("Max. prob.");
+					os.AddByte("Min. prob.");
+					os.AddString(8,"Resource");
+					os.AddDword("Min level");
+					os.AddDword("Max level");
+					os.AddDword("S. throw type");
+					os.AddDword("S. throw bonus");
+					os.AddDword("UNKNOWN");
+				}
+				os.EndIndent();
+			}
+			effoffset=0;
+			continue;
+		}
+		if(bookoffset || seloffset || memoffset || slotoffset || itemoffset || effoffset)
+		{
+			os.AddString(0, "**Error**");
+			return;
+		}
+	}
+}
+
+void CreateOutputCHR(OutStream &os)
+{
+	int creoffset;
+	bool iwd2;
+	int i;
+	//chr header
+	//cre
+
+	iwd2=os.signature[7]=='2';
+	os.AddString(32,"Name");
+	creoffset=os.AddDword("Offset");
+	os.AddDword("Size");
+	if(iwd2) i=125;
+	else i=13;
+	while(i--)
+	{
+		os.AddDword("Unknown");
+	}
+	os.AddString(0,"Embedded CRE");
+	os.fileoffset=0;      
+	os.AddIndent();
+	os.AddSignature();
+	CreateOutputCRE(os);
+	os.EndIndent();
+}
+
+void CreateOutputARE(OutStream &os)
+{
+	int actoroffset, actorcount;
+	int triggeroffset, triggercount;
+	int spawnoffset, spawncount;
+	int entranceoffset, entrancecount;
+	int containeroffset, containercount;
+	int itemoffset, itemcount;
+	int vertexoffset, vertexcount;
+	int ambioffset, ambicount;
+	int varoffset, varcount;
+	int exploredoffset, exploredcount;
+	int dooroffset, doorcount;
+	int animoffset, animcount;
+	int tiledoffset, tiledcount;
+	int songoffset, restoffset;
+	int noteoffset, notecount;
+	int trapoffset, trapcount;
+	char tmpstr[20];
+	bool pst,iwd2;
+	int i,j,k;
+
+	pst = 0;
+	iwd2=os.signature[5]=='9';
+	os.AddString(8,"Wed");
+	os.AddDword("Lastsaved");
+	os.AddDword("Areaflag");
+	os.AddString(8,"North link");
+	os.AddDword("North flags");
+	os.AddString(8,"West link");
+	os.AddDword("West flags");
+	os.AddString(8,"South link");
+	os.AddDword("South flags");
+	os.AddString(8,"East link");
+	os.AddDword("East flags");
+	os.AddWord("Area type");
+	os.AddWord("Rain");
+	os.AddWord("Snow");
+	os.AddWord("Fog");
+	os.AddWord("Lightning");
+	os.AddWord("Unknown weather");
+	if(iwd2)
+	{
+		for(i=0;i<4;i++)
+		{
+			os.AddDword("UNKNOWN");
+		}
+	}
+	actoroffset=os.AddDword("Actor offset");
+	actorcount=os.AddWord("Actor count"); //1
+	if(!actorcount) actoroffset=0;
+	triggercount=os.AddWord("Trigger count");
+	triggeroffset=os.AddDword("Trigger offset");//2
+	if(!triggercount) triggeroffset=0;
+	spawnoffset=os.AddDword("Spawn offset");
+	spawncount=os.AddDword("Spawn count"); //3
+	if(!spawncount) spawnoffset=0;
+	entranceoffset=os.AddDword("Entrance offset");
+	entrancecount=os.AddDword("Entrance count");//4
+	if(!entrancecount) entranceoffset=0;
+	containeroffset=os.AddDword("Container offset");
+	containercount=os.AddWord("Container count");//5
+	if(!containercount) containeroffset=0;
+	itemcount=os.AddWord("Item count");
+	itemoffset=os.AddDword("Item offset");//6
+	if(!itemcount) itemoffset=0;
+	vertexoffset=os.AddDword("Vertex offset");
+	vertexcount=os.AddWord("Vertex count");//7
+	if(!vertexcount) vertexoffset=0;
+	ambicount=os.AddWord("Ambient count");
+	ambioffset=os.AddDword("Ambient offset");//8
+	if(!ambicount) ambioffset=0;
+	varoffset=os.AddDword("Variable offset");
+	varcount=os.AddDword("Variable count");//9
+	if(!varcount) varoffset=0;
+	os.AddDword("UNKNOWN");
+	os.AddString(8,"Area script");
+	exploredcount=os.AddDword("Explored size");
+	exploredoffset=os.AddDword("Explored offset");//10
+	if(!exploredcount) exploredoffset=0;
+	doorcount=os.AddDword("Door count");
+	dooroffset=os.AddDword("Door offset");//11
+	if(!doorcount) dooroffset=0;
+	animcount=os.AddDword("Anim. count");
+	animoffset=os.AddDword("Anim. offset");//12
+	if(!animcount) animoffset=0;
+	tiledcount=os.AddDword("Tiled count"); //unused feature
+	tiledoffset=os.AddDword("Tiled offset");//unused feature 13
+	if(!tiledcount) tiledoffset=0;
+	songoffset=os.AddDword("Song offset");//14
+	restoffset=os.AddDword("Rest offset");//15
+	noteoffset=os.AddDword("Mapnote offset");
+	if(noteoffset==-1) //pst screwup
+	{
+		pst=1;
+	}
+	if(pst)
+	{
+		noteoffset=os.AddDword("Real offset PST");
+		notecount=os.AddDword("Mapnote count");//16
+		if(!notecount) noteoffset=0;
+		for(i=0;i<19;i++)
+		{
+			os.AddDword("UNKNOWN");
+		}
+	}
+	else
+	{
+		notecount=os.AddDword("Mapnote count");//16
+		trapoffset=os.AddDword("Trap offset");
+		trapcount=os.AddDword("Trap count");
+		if(!notecount) noteoffset=0;
+		for(i=0;i<18;i++)
+		{
+			os.AddDword("UNKNOWN");
+		}
+	}
+	for(i=0;i<16;i++)
+	{
+retry:
+		if(actorcount && (actoroffset==os.fileoffset) )
+		{
+			os.AddString(0, "Actors");
+			for(j=0;j<actorcount;j++)
+			{
+				sprintf(tmpstr,"Actor #%d",j+1);
+				os.AddString(0, tmpstr);
+				os.AddIndent();
+				os.AddString(32, "Label");
+				os.AddPoint("Position");
+				//os.AddWord("X Position");
+				//os.AddWord("Y Position");
+				os.AddPoint("Destination");
+				//os.AddWord("X Destination");
+				//os.AddWord("Y Destination");
+				os.AddDword("Unknown flags");
+				os.AddDword("UNKNOWN");
+				os.AddDword("Animation ID");
+				os.AddDword("Orientation");
+				os.AddDword("UNKNOWN");
+				os.AddDword("UNKNOWN");
+				os.AddDword("Schedule");
+				os.AddDword("TalkCount");
+				os.AddString(8,"Dialog");
+				os.AddString(8,"Override");
+				os.AddString(8,"Class script");
+				os.AddString(8,"Race script");
+				os.AddString(8,"General script");
+				os.AddString(8,"Default script");
+				os.AddString(8,"Specific script");
+				os.AddString(8,"Creature");
+				os.AddDword("Creature offset");
+				os.AddDword("Creature size");
+				os.AddString(8,"Area script");
+				for(k=0;k<30;k++)
+				{
+					os.AddDword("UNKNOWN");
+				}
+				os.EndIndent();
+			}
+			actoroffset=0;
+			continue;
+		}
+
+		if(triggercount && (triggeroffset==os.fileoffset) )
+		{
+			for(j=0;j<triggercount;j++)
+			{
+				sprintf(tmpstr,"Region #%d",j+1);
+				os.AddString(0, tmpstr);
+				os.AddIndent();
+				os.AddString(32,"Label");
+				os.AddWord("Type");
+				os.AddWord("Left");
+				os.AddWord("Top");
+				os.AddWord("Right");
+				os.AddWord("Bottom");
+				os.AddWord("Vertex count");
+				os.AddDword("Vertex index");
+				os.AddDword("UNKNOWN");
+				os.AddDword("Cursor type");
+				os.AddString(8,"Dest. area");
+				os.AddString(32,"Dest. entrance");
+				os.AddDword("Info flags");
+				os.AddDword("Strref");
+				os.AddWord("Trap detection");
+				os.AddWord("Trap removal");
+				os.AddWord("Trapped");
+				os.AddWord("Detected");
+				os.AddPoint("Launch point");
+				//os.AddWord("X launch");
+				//os.AddWord("Y launch");
+				os.AddString(8,"Key");
+				os.AddString(8,"Script");
+				for(k=0;k<12;k++)
+				{
+					os.AddDword("UNKNOWN");
+				}
+				os.AddPoint("Unknown point");
+				//os.AddWord("Unknown X");
+				//os.AddWord("Unknown Y");
+				os.AddDword("UNKNOWN");
+				os.AddString(8,"Dialog"); //?
+				os.EndIndent();
+			}
+			triggeroffset=0;
+			continue;
+		}
+
+		if(spawncount && (spawnoffset==os.fileoffset) )
+		{
+			for(j=0;j<spawncount;j++)
+			{
+				sprintf(tmpstr,"Spawn point #%d",j+1);
+				os.AddString(0, tmpstr);
+				os.AddIndent();
+				os.AddString(32,"Label");
+				os.AddPoint("Position");
+				//os.AddWord("X Position");
+				//os.AddWord("Y Position");
+				for(k=0;k<10;k++)
+				{
+					sprintf(tmpstr,"Creature #%d",k+1);
+					os.AddString(8,tmpstr);
+				}
+				os.AddWord("Creature count");
+				os.AddWord("Flag");
+				for(k=0;k<6;k++)
+				{
+					os.AddWord("UNKNOWN");
+				}
+				os.AddWord("Difficulty");
+				os.AddWord("UNKNOWN");
+				os.AddDword("Schedule");
+				os.AddWord("Day chance");
+				os.AddWord("Night chance");
+				for(k=0;k<14;k++)
+				{
+					os.AddDword("UNKNOWN");
+				}
+				os.EndIndent();
+			}
+			spawnoffset=0;
+			continue;
+		}
+
+		if(entrancecount && (entranceoffset==os.fileoffset) )
+		{
+			for(j=0;j<entrancecount;j++)
+			{
+				sprintf(tmpstr,"Entrance #%d",j+1);
+				os.AddString(0, tmpstr);
+				os.AddIndent();
+				os.AddString(32,"Label");
+				os.AddPoint("Position");
+				//os.AddWord("X Position");
+				//os.AddWord("Y Position");
+				os.AddDword("Orientation");
+				for(k=0;k<16;k++)
+				{
+					os.AddDword("UNKNOWN");
+				}
+				os.EndIndent();
+			}
+			entranceoffset=0;
+			continue;
+		}
+
+		if(containercount && (containeroffset==os.fileoffset) )
+		{
+			for(j=0;j<containercount;j++)
+			{
+				sprintf(tmpstr,"Container #%d",j+1);
+				os.AddString(0, tmpstr);
+				os.AddIndent();
+				os.AddString(32,"Label");
+				os.AddPoint("Position");
+				//os.AddWord("X position");
+				//os.AddWord("Y position");
+				os.AddWord("Type");
+				os.AddWord("Lock difficulty");
+				os.AddDword("Flags");
+				os.AddWord("Trap detection");
+				os.AddWord("Trap removal");
+				os.AddWord("Trapped");
+				os.AddWord("Detected");
+				os.AddPoint("Launch point");
+				//os.AddWord("Launch X");
+				//os.AddWord("Launch Y");
+				os.AddWord("Left");
+				os.AddWord("Top");
+				os.AddWord("Right");
+				os.AddWord("Bottom");
+				os.AddDword("Item index");
+				os.AddDword("Item count");
+				os.AddString(8,"Script");
+				os.AddDword("Vertex index");
+				os.AddWord("Vertex count");
+				os.AddWord("UNKNOWN");
+				os.AddString(32,"Scripting name");
+				os.AddString(8,"Key");
+				for(k=0;k<16;k++)
+				{
+					os.AddDword("UNKNOWN");
+				}
+				os.EndIndent();
+			}
+			containeroffset=0;
+			continue;
+		}
+
+		if(itemcount && (itemoffset==os.fileoffset) )
+		{
+			for(j=0;j<itemcount;j++)
+			{
+				sprintf(tmpstr,"Item #%d",j); //intentionally 0 based
+				os.AddString(0, tmpstr);
+				os.AddIndent();
+				os.AddString(8,"Item");
+				os.AddWord("UNKNOWN");
+				os.AddWord("Charge 1");
+				os.AddWord("Charge 2");
+				os.AddWord("Charge 3");
+				os.AddDword("Flags");
+				os.EndIndent();
+			}
+			itemoffset=0;
+			continue;
+		}
+
+		if(vertexcount && (vertexoffset==os.fileoffset) )
+		{
+			for(j=0;j<vertexcount;j++)
+			{
+				sprintf(tmpstr,"Vertex #%d",j); //intentionally 0 based
+				os.AddPoint(tmpstr);
+			}
+			vertexoffset=0;
+			continue;
+		}
+
+		if(ambicount && (ambioffset==os.fileoffset) )
+		{
+			for(j=0;j<ambicount;j++)
+			{
+				sprintf(tmpstr,"Ambient #%d",j+1); 
+				os.AddString(0, tmpstr);
+				os.AddIndent();
+				os.AddString(32,"Label");
+				os.AddPoint("Position");
+				//os.AddWord("X position");
+				//os.AddWord("Y position");
+				os.AddWord("Radius");
+				os.AddWord("Height");
+				os.AddDword("UNKNOWN");
+				os.AddWord("Unknown");
+				os.AddWord("Volume");
+				for(k=0;k<10;k++)
+				{
+					sprintf(tmpstr,"Sound #%d",k+1);
+					os.AddString(8,tmpstr);
+				}
+				os.AddWord("Sound count");
+				os.AddWord("UNKNOWN");
+				os.AddDword("Interval");
+				os.AddDword("UNKNOWN");
+				os.AddDword("Schedule");
+				os.AddDword("Flags");
+				for(k=0;k<16;k++)
+				{
+					os.AddDword("UNKNOWN");
+				}
+				os.EndIndent();
+			}
+			ambioffset=0;
+			continue;
+		}
+
+		if(varcount && (varoffset==os.fileoffset) )
+		{
+			for(j=0;j<varcount;j++)
+			{
+				CreateOutputVariable(os);
+			}
+			varoffset=0;
+			continue;
+		}
+
+		if(exploredcount && (exploredoffset==os.fileoffset) )
+		{
+			os.AddBitmap(exploredcount,"Explored area");
+			exploredoffset=0;
+			continue;
+		}
+
+		if(doorcount && (dooroffset==os.fileoffset) )
+		{
+			for(j=0;j<doorcount;j++)
+			{
+				sprintf(tmpstr,"Door #%d",j+1);
+				os.AddString(0, tmpstr);
+				os.AddIndent();
+				os.AddString(32,"Label");
+				os.AddString(8,"Door name");
+				os.AddDword("Flags");
+				os.AddDword("Open vertex index");
+				os.AddWord("Open vertex count");
+				os.AddWord("Closed vertex count");
+				os.AddDword("Closed vertex index");
+				os.AddWord("Open left");
+				os.AddWord("Open top");
+				os.AddWord("Open right");
+				os.AddWord("Open bottom");
+				os.AddWord("Closed left");
+				os.AddWord("Closed top");
+				os.AddWord("Closed right");
+				os.AddWord("Closed bottom");
+				os.AddDword("Open block index");
+				os.AddWord("Open block count");
+				os.AddWord("Closed block count");
+				os.AddDword("Closed block index");
+				os.AddDword("UNKNOWN"); //strref?
+				os.AddString(8,"Open sound");
+				os.AddString(8,"Close sound");
+				os.AddDword("Cursor type");
+				os.AddWord("Trap detection");
+				os.AddWord("Trap removal");
+				os.AddWord("Trapped");
+				os.AddWord("Detected");
+				os.AddPoint("Launch point");
+				//os.AddWord("X launch");
+				//os.AddWord("Y launch");
+				os.AddString(8,"Key");
+				os.AddString(8,"Script");
+				os.AddDword("Locked");
+				os.AddDword("Lock difficulty");
+				os.AddPoint("Front");
+				os.AddPoint("Back");
+				//os.AddWord("Front X");
+				//os.AddWord("Front Y");
+				//os.AddWord("Back X");
+				//os.AddWord("Back Y");
+				os.AddDword("Failed strref");
+				os.AddString(32,"Region link");
+				os.AddDword("Name strref");
+				os.AddString(8,"Dialog");
+				os.EndIndent();
+			}
+			dooroffset=0;
+			continue;
+		}
+
+		if(animcount && (animoffset==os.fileoffset) )
+		{
+			for(j=0;j<animcount;j++)
+			{
+				sprintf(tmpstr,"Animation #%d",j+1);
+				os.AddString(0, tmpstr);
+				os.AddIndent();
+				os.AddString(32,"Label");
+				os.AddPoint("Position");
+				os.AddDword("Schedule");
+				os.AddString(8,"BAM");
+				os.AddWord("Cycle");
+				os.AddWord("Frame");
+				os.AddDword("Flags");
+				os.AddWord("UNKNOWN");
+				os.AddWord("Transparency");
+				os.AddDword("UNKNOWN");
+				os.AddString(8,"Palette");
+				os.AddDword("UNKNOWN");	
+				os.EndIndent();
+			}
+			animoffset=0;
+			continue;
+		}
+
+		if(tiledcount && (tiledoffset==os.fileoffset) )
+		{
+			for(j=0;j<tiledcount;j++)
+			{
+				sprintf(tmpstr,"Tiles #%d",j+1);
+				os.AddString(0, tmpstr);
+				os.AddIndent();
+				os.AddString(32,"Label");
+				os.AddString(8, "Name");
+				os.AddDword("UNKNOWN");
+				os.AddDword("Primary index");
+				os.AddDword("Primary count");
+				os.AddDword("Secondary index");
+				os.AddDword("Secondary count");
+				for(k=0;k<16;k++)
+				{
+					os.AddDword("UNKNOWN");
+				}
+				os.EndIndent();
+			}
+			tiledoffset=0;
+			continue;
+		}
+
+		if(songoffset==os.fileoffset)
+		{
+			os.AddString(0, "Song header");
+			os.AddIndent();
+			for(k=0;k<10;k++)
+			{
+				sprintf(tmpstr,"Song %d",k+1);
+				os.AddDword(tmpstr);
+			}
+			os.AddString(8,"Day ambient 1");
+			os.AddString(8,"Day ambient 2");
+			os.AddDword("Day volume");
+			os.AddString(8,"Night ambient 1");
+			os.AddString(8,"Night ambient 2");
+			os.AddDword("Night volume");
+			os.AddDword("Song flags");
+			for(k=0;k<15;k++)
+			{
+				os.AddDword("UNKNOWN");
+			}
+			os.EndIndent();
+			songoffset=0;
+			continue;
+		}
+
+		if(restoffset==os.fileoffset)
+		{
+			os.AddString(0, "Rest header");
+			os.AddIndent();
+			os.AddString(32,"Label");
+			for(k=0;k<10;k++)
+			{
+				sprintf(tmpstr,"Strref #%d",k+1);
+				os.AddDword(tmpstr);
+			}
+			for(k=0;k<10;k++)
+			{
+				sprintf(tmpstr,"Creature #%d",k+1);
+				os.AddString(8,tmpstr);
+			}
+			os.AddWord("Creature count");
+			os.AddWord("Difficulty");
+			for(k=0;k<4;k++)
+			{
+				os.AddWord("UNKNOWN");
+			}
+			os.AddWord("UNKNOWN");
+			os.AddWord("UNKNOWN");
+			os.AddWord("Day chance");
+			os.AddWord("Night chance");
+			for(k=0;k<14;k++)
+			{
+				os.AddDword("UNKNOWN");
+			}
+			os.EndIndent();
+			restoffset=0;
+			continue;
+		}
+
+		if(notecount && (noteoffset==os.fileoffset) )
+		{
+			if(pst)
+			{
+				for(j=0;j<notecount;j++)
+				{
+					sprintf(tmpstr,"Note #%d",j+1); 
+					os.AddString(0, tmpstr);
+					os.AddIndent();
+					os.AddDword("X position");
+					os.AddDword("Y position");
+					os.AddString(500,"Note");
+					os.AddDword("Read only");
+					for(k=0;k<5;k++)
+					{
+						os.AddDword("UNKNOWN");
+					}
+					os.EndIndent();
+				}
+			}
+			else
+			{
+				for(j=0;j<notecount;j++)
+				{
+					sprintf(tmpstr,"Note #%d",j+1); 
+					os.AddString(0, tmpstr);
+					os.AddIndent();
+					os.AddPoint("Position");
+					os.AddDword("Strref");
+					os.AddWord("Original");
+					os.AddWord("Colour");
+					os.AddDword("Count");
+					for(k=0;k<9;k++)
+					{
+						os.AddDword("UNKNOWN");
+					}		
+					os.EndIndent();
+				}
+			}
+			noteoffset=0;
+			continue;
+		}
+
+		if(trapcount && (trapoffset==os.fileoffset) )
+		{
+			for(j=0;j<trapcount;j++)
+			{
+				sprintf(tmpstr,"Trap #%d",j+1);
+				os.AddString(8,"Trapname");
+				os.AddDword("Offset");
+				os.AddDword("Size");
+				os.AddDword("Unknown");
+				os.AddDword("Unknown");
+				os.AddDword("Unknown");
+			}
+			trapoffset=0;
+			continue;
+		}
+
+		if(os.Prefetch("\0\0\0\0\0\0\0\0",8) )
+		{
+			os.AddString(0,"Embedded EFF");
+			int z=os.fileoffset;
+			os.fileoffset=0;
+			os.AddIndent();
+			//os.AddSignature();
+			CreateOutputEFF(os);
+			os.EndIndent();
+			os.fileoffset+=z;
+			goto retry;
+		}
+
+		if(os.Prefetch("CRE ",4))
+		{
+			os.AddString(0,"Embedded CRE");
+			int z=os.fileoffset;
+			os.fileoffset=0;      
+			os.AddIndent();
+			os.AddSignature();
+			CreateOutputCRE(os);
+			os.EndIndent();
+			os.fileoffset+=z;
+			goto retry;
+		}
+
+		if( actoroffset || triggeroffset|| spawnoffset|| entranceoffset ||
+				containeroffset|| itemoffset|| vertexoffset|| ambioffset|| varoffset||
+				exploredoffset|| dooroffset|| animoffset|| tiledoffset||
+				songoffset|| restoffset || noteoffset || trapoffset)
+		{
+			os.AddString(0, "**Error**");
+			return;
+		}
+	}
+}
+
+void CreateOutputWMP(OutStream &os)
+{
+	int mapcount, mapoffset;
+	int *areacounts;
+	int *areaoffsets;
+	int *linkcounts;
+	int *linkoffsets;
+	char tmpstr[20];
+	int i,j,k;
+
+	mapcount=os.AddDword("Map count");
+	mapoffset=os.AddDword("Map offset");
+	if(!mapcount) return;  
+	areaoffsets=(int *) malloc(mapcount*sizeof(int) );
+	areacounts=(int *) malloc(mapcount*sizeof(int) );
+	linkoffsets=(int *) malloc(mapcount*sizeof(int) );
+	linkcounts=(int *) malloc(mapcount*sizeof(int) );
+	if(mapoffset!=os.fileoffset || !areaoffsets || !areacounts || !linkoffsets || !linkcounts)
+	{
+		os.AddString(0, "**Error**");
+		goto end_of_quest;
+	}
+	for(j=0;j<mapcount;j++)
+	{
+		sprintf(tmpstr,"Map %d",j+1);
+		os.AddString(0,tmpstr);
+		os.AddIndent();
+		os.AddString(8,"Map background");
+		os.AddDword("Width");
+		os.AddDword("Height");
+		os.AddDword("Map ID");
+		os.AddDword("Name strref");
+		os.AddDword("UNKNOWN");
+		os.AddDword("UNKNOWN");
+		areacounts[j]=os.AddDword("Area count");
+		areaoffsets[j]=os.AddDword("Area offset");    
+		linkoffsets[j]=os.AddDword("Link offset");
+		linkcounts[j]=os.AddDword("Link count");
+		os.AddString(8,"Mapicons");
+		for(k=0;k<32;k++)
+		{
+			os.AddDword("UNKNOWN");
+		}
+		os.EndIndent();
+	}
+	for(i=0;i<mapcount;i++)
+	{
+		if(areaoffsets[i]!=os.fileoffset)
+		{
+			os.AddString(0, "**Error**");
+			goto end_of_quest;
+		}
+		sprintf(tmpstr,"Area block %d",i+1);
+		os.AddString(0,tmpstr);
+		os.AddIndent();
+		for(j=0;j<areacounts[i];j++)
+		{
+			os.AddString(8,"Area name");
+			os.AddString(8,"Area resref");
+			os.AddString(32,"Long name");
+			os.AddDword("Flags");
+			os.AddDword("Icon index");
+			os.AddDword("X position");
+			os.AddDword("Y position");
+			os.AddDword("Name strref");
+			os.AddDword("Tooltip strref");
+			os.AddString(8,"Loadscreen");
+			os.AddDword("North index");
+			os.AddDword("North count");
+			os.AddDword("East index");
+			os.AddDword("East count");
+			os.AddDword("South index");
+			os.AddDword("South count");
+			os.AddDword("West index");
+			os.AddDword("West count");
+			for(k=0;k<32;k++)
+			{
+				os.AddDword("UNKNOWN");
+			}
+		}
+		os.EndIndent();
+	}
+	for(i=0;i<mapcount;i++)
+	{
+		if(linkoffsets[i]!=os.fileoffset)
+		{
+			os.AddString(0, "**Error**");
+			goto end_of_quest;
+		}
+		sprintf(tmpstr,"Link block %d",i+1);
+		os.AddString(0,tmpstr);
+		os.AddIndent();
+		for(j=0;j<linkcounts[i];j++)
+		{
+			os.AddDword("Area index");
+			os.AddString(32,"Entrance");
+			os.AddDword("Scale");
+			os.AddDword("Flags");
+			for(k=0;k<5;k++)
+			{
+				sprintf(tmpstr,"Amb. area %d",k);
+				os.AddString(8,tmpstr);
+			}
+			os.AddDword("Probability");
+			for(k=0;k<32;k++)
+			{
+				os.AddDword("UNKNOWN");
+			}
+		}
+		os.EndIndent();
+	}
+end_of_quest:
+	if(areacounts) free(areacounts);
+	if(areaoffsets) free(areaoffsets);
+	if(linkcounts) free(linkcounts);
+	if(linkoffsets) free(linkoffsets);
+}
+
+void CreateOutputWED(OutStream &os)
+{
+	int ovcount, ovoffset;
+	int doorcount, dooroffset;
+	int secoffset;
+	int dtcoffset, dtccount;
+	int wgcount, wgoffset;
+	int wpcount, dpcount, polyoffset;
+	int plookcount, plookoffset;
+	int vertcount, vertoffset;
+	int *ovtilecounts;
+	int *ovtileoffsets;
+	int *ovlookupoffsets;
+	char tmpstr[20];
+	int i,j,k;
+
+	wgcount=-1;
+	dpcount=0;
+	ovcount=os.AddDword("Overlays");
+	doorcount=os.AddDword("Doors");
+	ovoffset=os.AddDword("Overlay offset");
+	secoffset=os.AddDword("Sec. header");
+	dooroffset=os.AddDword("Door offset");
+	if(!doorcount) dooroffset=0;
+	dtcoffset=os.AddDword("Door cell offset");
+	ovtilecounts=(int *) malloc(ovcount*sizeof(int));
+	ovtileoffsets=(int *) malloc(ovcount*sizeof(int));
+	ovlookupoffsets=(int *) malloc(ovcount*sizeof(int));
+	if(ovoffset!=os.fileoffset || !ovtilecounts || !ovtileoffsets || !ovlookupoffsets)
+	{
+		os.AddString(0, "**Error**");
+		goto end_of_quest;
+	}
+	for(i=0;i<ovcount;i++)
+	{
+		sprintf(tmpstr,"Overlay %d",i);
+		os.AddString(0,tmpstr);
+		os.AddIndent();
+		j=os.AddWord("Width");
+		k=os.AddWord("Height");
+		ovtilecounts[i]=j*k;
+		if(!i)
+		{
+			wgcount=((j+9)/10)*((k*2+14)/15);
+		}
+		os.AddString(8,"Tileset");
+		os.AddDword("UNKNOWN");
+		ovtileoffsets[i]=os.AddDword("Tilemap offset");
+		ovlookupoffsets[i]=os.AddDword("Lookup offset");
+		if(!ovtilecounts[i])
+		{
+			ovtileoffsets[i]=0;
+			ovlookupoffsets[i]=0;
+		}
+		os.EndIndent();
+	}
+	if(secoffset!=os.fileoffset)
+	{
+		os.AddString(0, "**Error**");
+		goto end_of_quest;
+	}
+	os.AddString(0,"Sec. header");
+	wpcount=os.AddDword("Wall poly. count");
+	polyoffset=os.AddDword("Polygon offset");
+	vertoffset=os.AddDword("Vertices offset");
+	wgoffset=os.AddDword("Wallgroup offset");
+	plookoffset=os.AddDword("Poly. lookup offset");
+	dtccount=0;
+	if(dooroffset)
+	{
+		if(dooroffset!=os.fileoffset)
+		{
+			os.AddString(0, "**Error**");
+			goto end_of_quest;
+		}
+		for(i=0;i<doorcount;i++)
+		{
+			sprintf(tmpstr,"Door %d",i+1);
+			os.AddString(0,tmpstr);
+			os.AddIndent();
+			os.AddString(8,"Door ID");
+			os.AddWord("Closed");
+			j=os.AddWord("DTC index");
+			j+=os.AddWord("DTC count");
+			if(j>dtccount) dtccount=j;
+			dpcount+=os.AddWord("Open poly. count");
+			dpcount+=os.AddWord("Closed poly. count");
+			os.AddDword("Open poly. offset");
+			os.AddDword("Closed poly. offset");
+			os.EndIndent();
+		}
+	}
+	j=0;
+retry:
+	for(i=0;i<ovcount;i++)
+	{
+		if(ovtilecounts[i])
+		{
+			if(ovtileoffsets[i]==os.fileoffset)
+			{
+				for(k=0;k<ovtilecounts[i];k++)
+				{
+					sprintf(tmpstr,"Tilemap %d",k);
+					os.AddString(0,tmpstr);
+					os.AddWord("Start index");
+					os.AddWord("Tile count");
+					os.AddWord("Secondary tile");
+					os.AddDword("Overlay flags");
+				}
+				ovtileoffsets[i]=0;
+				j++;
+				goto retry;
+			}
+		}
+		else j++;
+	}
+	if(j!=ovcount)
+	{
+		os.AddString(0, "**Error**");
+		goto end_of_quest;
+	}
+	if(dtccount)
+	{
+		if(dtcoffset!=os.fileoffset)
+		{
+			os.AddString(0, "**Error**");
+			goto end_of_quest;
+		}
+		for(i=0;i<dtccount;i++)
+		{
+			sprintf(tmpstr,"DTC %d",i);
+			os.AddWord(tmpstr);
+		}
+	}
+
+	for(i=0;i<ovcount;i++)
+	{
+		if(ovlookupoffsets[i])
+		{
+			if((ovlookupoffsets[i]!=os.fileoffset) )
+			{
+				os.AddString(0, "**Error**");
+				goto end_of_quest;
+			}
+			sprintf(tmpstr,"Tile cells %d",i);
+			os.AddString(0,tmpstr);
+			os.AddIndent();
+			for(j=0;j<ovtilecounts[i];j++)
+			{
+				sprintf(tmpstr,"OTC %d",j);
+				os.AddWord(tmpstr);
+			}
+			os.EndIndent();
+		}
+	}
+	
+	if(wgcount<0)
+	{
+		os.AddString(0, "**Error**");
+		goto end_of_quest;
+	}
+	if(!wgcount) wgoffset=0;
+	if(!(dpcount+wpcount) ) polyoffset=0;
+
+	plookcount=0;
+	vertcount=0;
+	for(i=0;i<2;i++)
+	{
+		if(wgcount && (wgoffset==os.fileoffset))
+		{
+			for(j=0;j<wgcount;j++)
+			{
+				sprintf(tmpstr,"Wallgroup %d",j);
+				os.AddString(0,tmpstr);
+				os.AddIndent();
+				k=os.AddWord("Start index");
+				k+=os.AddWord("Polygon count");
+				if(plookcount<k) plookcount=k;
+				os.EndIndent();
+			}
+			wgoffset=0;
+			continue;
+		}
+		if((dpcount + wpcount) && (polyoffset==os.fileoffset))
+		{
+			for(j=0;j<dpcount+wpcount;j++)
+			{
+				sprintf(tmpstr,"Polygon %d",j);
+				os.AddString(0,tmpstr);
+				os.AddIndent();
+				k=os.AddDword("Starting vertex");
+				k+=os.AddDword("Vertex count");
+				if(vertcount<k) vertcount=k;
+				os.AddWord("Wall flags");
+				os.AddWord("Min X");
+				os.AddWord("Max X");
+				os.AddWord("Min Y");
+				os.AddWord("Max Y");
+				os.EndIndent();
+			}
+			polyoffset=0;
+			continue;
+		}
+		if(wgoffset || polyoffset)
+		{
+			os.AddString(0, "**Error**");
+			goto end_of_quest;
+		}
+	}
+	if(!plookcount) plookoffset=0;
+	if(!vertcount) vertoffset=0;
+	for(i=0;i<2;i++)
+	{
+		if(plookcount && (plookoffset==os.fileoffset))
+		{
+			os.AddString(0,"P lookup table");
+			os.AddIndent();
+			for(j=0;j<plookcount;j++)
+			{
+				sprintf(tmpstr,"P index %d",j);
+				os.AddWord(tmpstr);
+			}
+			os.EndIndent();
+			plookoffset=0;
+			continue;
+		}
+
+		if(vertcount && (vertoffset==os.fileoffset))
+		{
+			os.AddString(0,"Vertices");
+			os.AddIndent();
+			for(j=0;j<vertcount;j++)
+			{
+				sprintf(tmpstr,"Vertex %d",j);
+				os.AddPoint(tmpstr);
+			}
+			os.EndIndent();
+			vertoffset=0;
+			continue;
+		}
+		if(vertoffset || plookoffset)
+		{
+			os.AddString(0, "**Error**");
+			goto end_of_quest;
+		}
+	}
+	end_of_quest:
+	if(ovtilecounts) free(ovtilecounts);
+	if(ovtileoffsets) free(ovtileoffsets);
+	if(ovlookupoffsets) free(ovlookupoffsets);
+}
+
+void CreateOutputCHU(OutStream &os)
+{
+	int ctoffset, controlcount;
+	int winoffset, wincount;
+	char tmpstr[20];
+	int i,j;
+	int tmp;
+	int type;
+
+	wincount=os.AddDword("Window count");
+	ctoffset=os.AddDword("Control table offset");
+	winoffset=os.AddDword("Window offset");  
+	if(winoffset==os.fileoffset)
+	{
+		controlcount=0;
+		for(j=0;j<wincount;j++)
+		{
+			sprintf(tmpstr,"Window #%d",j+1);
+			os.AddString(0,tmpstr);
+			os.AddIndent();
+			os.AddDword("Window ID");
+			os.AddPoint("Position");
+			//os.AddWord("X position");
+			//os.AddWord("Y position");
+			os.AddWord("Width");
+			os.AddWord("Height");
+			os.AddWord("Background");
+			tmp=os.AddWord("Control count");
+			os.AddString(8,"MOS");
+			tmp+=os.AddWord("Control index");
+			if(tmp>controlcount) controlcount=tmp;
+			os.AddWord("UNKNOWN");
+			os.EndIndent();
+		}
+	}
+	int *ctable = (int *) malloc(controlcount*sizeof(int));
+	if(!ctable)
+	{
+		os.AddString(0, "**Error**");
+		return;
+	}
+	if(ctoffset==os.fileoffset)
+	{
+		for(i=0;i<controlcount;i++)
+		{
+			sprintf(tmpstr,"Control #%d",i+1);
+			os.AddString(0,tmpstr);
+			os.AddIndent();
+			ctable[i]=os.AddDword("Offset");
+			os.AddDword("Size");
+			os.EndIndent();
+		}
+	}
+	for(i=0;i<controlcount;i++)
+	{
+		if(ctable[i]==os.fileoffset)
+		{
+			os.AddDword("Control ID");
+			os.AddPoint("Position");
+			//os.AddWord("X position");
+			//os.AddWord("Y position");
+			os.AddWord("Width");
+			os.AddWord("Height");
+			type=os.AddWord("Type");
+			switch(type)
+			{
+			case 0: //button
+				os.AddString(0,"Button");
+				os.AddIndent();
+				os.AddString(8,"BAM");
+				os.AddByte("Alignment");
+				os.AddByte("Cycle");
+				os.AddWord("Unpressed");
+				os.AddWord("Pressed");
+				os.AddWord("Selected");
+				os.AddWord("Disabled");
+				break;
+			case 1:
+				os.AddString(0,"Progressbar");
+				os.AddIndent();
+				break;
+			case 2: //slider
+				os.AddString(0,"Slider");
+				os.AddIndent();
+				os.AddString(8,"Background");
+				os.AddString(8,"Slider");
+				os.AddWord("Cycle");
+				os.AddWord("Ungrabbed");
+				os.AddWord("Grabbed");
+				os.AddPoint("Position");
+				//os.AddWord("X offset");
+				//os.AddWord("Y offset");
+				os.AddWord("Jump width");
+				os.AddWord("Jump count");
+				for(j=0;j<4;j++)
+				{
+					os.AddWord("UNKNOWN");
+				}
+				break;
+			case 3: //text edit
+				os.AddString(0,"Editbox");
+				os.AddIndent();
+				os.AddString(8,"MOS");
+				os.AddString(8,"MOS");
+				os.AddString(8,"MOS");
+				os.AddString(8,"Cursor");
+				for(j=0;j<3;j++) //cursor cycle/frame?
+				{
+					os.AddDword("UNKNOWN");
+				}
+				os.AddString(8,"Font");
+				os.AddWord("UNKNOWN");
+				for(j=0;j<8;j++) //buffer?
+				{
+					os.AddDword("UNKNOWN");
+				}
+				os.AddWord("Max length");
+				os.AddDword("UNKNOWN");
+				break;
+			case 5: //textarea
+				os.AddString(0,"Textarea");
+				os.AddIndent();
+				os.AddString(8,"Font");
+				os.AddString(8,"Initials");
+				os.AddDword("Color 1");
+				os.AddDword("Color 2");
+				os.AddDword("Color 3");
+				os.AddDword("Scroll ID");
+				break;
+			case 6: //label
+				os.AddString(0,"Label");
+				os.AddIndent();
+				os.AddDword("Strref");
+				os.AddString(8,"Font");
+				os.AddDword("Color 1");
+				os.AddDword("Color 2");
+				os.AddWord("Alignment");
+				break;
+			case 7: //scrollbar
+				os.AddString(0,"Scrollbar");
+				os.AddIndent();
+				os.AddString(8,"BAM");
+				os.AddWord("Cycle");
+				os.AddWord("Up unpressed");
+				os.AddWord("Up pressed");
+				os.AddWord("Down unpressed");
+				os.AddWord("Down pressed");
+				os.AddWord("Trough");
+				os.AddWord("Slider");
+				os.AddDword("Textarea ID");
+				break;
+			default:
+				os.AddString(0, "**Error**");
+				type=-1;
+			}
+			if(type==-1) break;
+			os.EndIndent();
+		}
+		else
+		{
+			os.AddString(0, "**Error**");
+			break;
+		}
+	}
+	free(ctable);
+}
+
+void CreateOutputPRO(OutStream &os)
+{
+	int type;
+	int i;
+
+	type=os.AddWord("Projectile type")&1;
+	os.AddWord("Speed");
+	os.AddDword("Spark flags");
+	os.AddString(8,"Sound 1");
+	os.AddString(8,"Sound 2");
+	os.AddString(8,"UNKNOWN");
+	os.AddDword("Spark colour");
+	for(i=0;i<53;i++)
+	{
+		os.AddDword("UNKNOWN");
+	}
+	os.AddString(0,"Travel section");
+	os.AddIndent();
+	os.AddDword("Travel flags");
+	os.AddString(8,"Travel BAM");
+	os.AddString(8,"Shadow BAM");
+	os.AddByte("Travel Cycle");
+	os.AddByte("Shadow Cycle");
+	os.AddWord("Lightspot");
+	os.AddWord("Lightspot X");
+	os.AddWord("Lightspot Y");
+	os.AddString(8,"Palette");
+	for(i=0;i<7;i++)
+	{
+		os.AddByte("Color");
+	}
+	os.EndIndent();
+	os.AddString(0,"Smoke section");
+	os.AddIndent();
+	os.AddByte("Puff frequency");
+	for(i=0;i<7;i++)
+	{
+		os.AddByte("Puff color");
+	}
+	os.AddByte("Face target");
+	os.AddWord("Animation ID");
+	os.AddString(8,"Trail 1");
+	os.AddString(8,"Trail 2");
+	os.AddString(8,"Trail 3");
+	os.AddWord("Trail freq. 1");
+	os.AddWord("Trail freq. 2");
+	os.AddWord("Trail freq. 3");
+	os.EndIndent();
+	for(i=0;i<43;i++)
+	{
+		os.AddDword("UNKNOWN");
+	}
+	if(!type) return;
+	os.AddString(0,"AOE section");
+	os.AddIndent();
+	os.AddDword("AOE flags");
+	os.AddWord("Trigger radius");
+	os.AddWord("Effect radius");
+	os.AddString(8,"Explosion sound");
+	os.AddWord("Delay");
+	os.AddWord("Animation ID");
+	os.AddWord("Projectile ID");
+	os.AddByte("Explosion count");
+	os.AddByte("Explosion type");
+	os.AddWord("Explosion colour");
+	os.AddWord("Another projectile");
+	os.AddString(8,"VVC");
+	os.AddWord("Cone width");
+	os.EndIndent();
+	os.AddWord("UNKNOWN");
+	for(i=0;i<54;i++)
+	{
+		os.AddDword("UNKNOWN");
+	}
+}
+
+void CreateOutputDLG(OutStream &os)
+{
+	int statecount, stateoffset;
+	int transcount, transoffset;
+	int sttrcount, sttroffset;
+	int trtrcount, trtroffset;
+	int actioncount, actionoffset;
+	int *sttriggertable=NULL;
+	int *trtriggertable=NULL;
+	int *actiontable=NULL;
+	char tmpstr[20];
+	int i,j;
+	bool flag=true;
+
+	statecount=os.AddDword("State count");
+	stateoffset=os.AddDword("State offset");
+	if(!statecount) stateoffset=0;
+	transcount=os.AddDword("Trans count");
+	transoffset=os.AddDword("Trans offset");
+	if(!transcount) transoffset=0;
+	sttroffset=os.AddDword("St. tr. offset");
+	sttrcount=os.AddDword("St. tr. count");
+	if(!sttrcount) sttroffset=0;
+	sttriggertable=(int *) malloc(2*sizeof(int)*sttrcount);
+	trtroffset=os.AddDword("Tr. tr. offset");
+	trtrcount=os.AddDword("Tr. tr. count");
+	if(!trtrcount) trtroffset=0;
+	trtriggertable=(int *) malloc(2*sizeof(int)*trtrcount);
+	actionoffset=os.AddDword("Action offset");
+	actioncount=os.AddDword("Action count");
+	if(!actioncount) actionoffset=0;
+	actiontable=(int *) malloc(2*sizeof(int)*actioncount);
+	for(i=0;i<5;i++)
+	{
+		if(statecount && (stateoffset == os.fileoffset) )
+		{
+			for(j=0;j<statecount;j++)
+			{
+				sprintf(tmpstr,"State #%d",j+1);
+				os.AddString(0, tmpstr);
+				os.AddIndent();
+				os.AddDword("Actor text");
+				os.AddDword("Trans. index");
+				os.AddDword("Trans. count");
+				os.AddDword("Trigger index");
+				os.EndIndent();
+			}
+			stateoffset=0;
+			continue;
+		}
+
+		if(transcount && (transoffset == os.fileoffset) )
+		{
+			for(j=0;j<transcount;j++)
+			{
+				sprintf(tmpstr,"State #%d",j+1);
+				os.AddString(0, tmpstr);
+				os.AddIndent();
+				os.AddDword("Flags");
+				os.AddDword("Player text");
+				os.AddDword("Journal text");
+				os.AddDword("Trigger index");
+				os.AddDword("Action index");
+				os.AddString(8,"Dialog ref.");
+				os.AddDword("State index");
+				os.EndIndent();	
+			}
+			transoffset=0;
+			continue;
+		}
+
+		if(sttrcount && (sttroffset == os.fileoffset) )
+		{
+			for(j=0;j<sttrcount;j++)
+			{
+				sprintf(tmpstr,"St. trigger #%d",j+1);
+				os.AddString(0, tmpstr);
+				os.AddIndent();
+				sttriggertable[j*2]=os.AddDword("Offset");
+				sttriggertable[j*2+1]=os.AddDword("Length");
+				os.EndIndent();
+			}
+			sttroffset=0;
+			continue;
+		}
+
+		if(trtrcount && (trtroffset == os.fileoffset) )
+		{
+			for(j=0;j<trtrcount;j++)
+			{
+				sprintf(tmpstr,"Tr. trigger #%d",j+1);
+				os.AddString(0, tmpstr);
+				os.AddIndent();
+				trtriggertable[j*2]=os.AddDword("Offset");
+				trtriggertable[j*2+1]=os.AddDword("Length");
+				os.EndIndent();
+			}
+			trtroffset=0;
+			continue;
+		}
+
+		if(actioncount && (actionoffset == os.fileoffset) )
+		{
+			for(j=0;j<actioncount;j++)
+			{
+				sprintf(tmpstr,"Action #%d",j+1);
+				os.AddString(0, tmpstr);
+				os.AddIndent();
+				actiontable[j*2]=os.AddDword("Offset");
+				actiontable[j*2+1]=os.AddDword("Length");
+				os.EndIndent();
+			}
+			actionoffset=0;
+			continue;
+		}
+
+		if(stateoffset || transoffset || sttroffset || trtroffset || actionoffset)
+		{
+			if(flag && !i) //bg2 specific hack
+			{
+				os.AddDword("Freeze flag");
+				i--;
+				continue;
+			}
+			os.AddString(0, "**Error**");
+			goto end_of_quest;
+		}
+	}
+	for(i=0;i<sttrcount;i++)
+	{
+		if(sttriggertable[i]!=-1)
+		{
+			if(os.fileoffset!=sttriggertable[i*2])
+			{
+				os.AddString(0, "**Error**");
+				goto end_of_quest;
+			}
+			os.AddString(sttriggertable[i*2+1],"State trigger");
+		}
+	}
+	for(i=0;i<trtrcount;i++)
+	{
+		if(trtriggertable[i]!=-1)
+		{
+			if(os.fileoffset!=trtriggertable[i*2])
+			{
+				os.AddString(0, "**Error**");
+				goto end_of_quest;
+			}
+			os.AddString(trtriggertable[i*2+1],"Trans. trigger");
+		}
+	}
+	for(i=0;i<actioncount;i++)
+	{
+		if(actiontable[i]!=-1)
+		{
+			if(os.fileoffset!=actiontable[i*2])
+			{
+				os.AddString(0, "**Error**");
+				goto end_of_quest;
+			}
+			os.AddString(actiontable[i*2+1],"Action");
+		}
+	}
+end_of_quest:
+	if(sttriggertable) free(sttriggertable);
+	if(trtriggertable) free(trtriggertable);
+	if(actiontable) free(actiontable);
+}
+
+void CreateOutputGAMActor(OutStream &os,bool pst, bool iwd, bool iwd2)
+{
+	int i;
+
+	os.AddWord("Selected");
+	os.AddWord("Order");
+	os.AddDword("Offset");
+	os.AddDword("Size");
+	os.AddString(8,"Creature");
+	os.AddDword("Orientation");
+	os.AddString(8,"Area");
+	os.AddPoint("Position");
+	//os.AddWord("X position");
+	//os.AddWord("Y position");
+	os.AddPoint("Viewport");
+	//os.AddWord("X rectangle");
+	//os.AddWord("Y rectangle");
+	for(i=0;i<25;i++)
+	{
+		os.AddDword("UNKNOWN");
+	}
+	os.AddWord("Quickweapon 1");
+	os.AddWord("Quickweapon 2");
+	os.AddWord("Quickweapon 3");
+	os.AddWord("Quickweapon 4");
+	os.AddString(8,"UNKNOWN");
+	os.AddString(8,"Quickspell 1");
+	os.AddString(8,"Quickspell 2");
+	os.AddString(8,"Quickspell 3");
+	os.AddWord("Quickitem 1");
+	os.AddWord("Quickitem 2");
+	os.AddWord("Quickitem 3");
+	if(pst)
+	{
+		os.AddWord("Quickitem 4");
+		os.AddWord("Quickitem 5");
+	}
+	else  
+	{
+		os.AddWord("UNKNOWN");
+		os.AddWord("UNKNOWN");
+	}
+	os.AddWord("UNKNOWN");
+	if(iwd2)
+	{
+		os.AddWord("UNKNOWN");
+		for(i=0;i<63;i++)
+		{
+			os.AddDword("UNKNOWN");
+		}
+	}
+	os.AddString(32,"Name");
+	if(pst)
+	{
+		os.AddDword("UNKNOWN");
+		os.AddDword("UNKNOWN");
+	}
+	os.AddDword("Talk count");
+	os.AddString(0,"Statistics");
+	os.AddDword("MPV name");
+	os.AddDword("MPV XP");
+	os.AddDword("UNKNOWN");
+	os.AddDword("Time of joining");
+	os.AddDword("UNKNOWN");
+	os.AddDword("Kill xp");
+	os.AddDword("Kill number");
+	os.AddDword("Total kill xp");
+	os.AddDword("Total kill number");
+	os.AddString(8,"Fav spell 1");
+	os.AddString(8,"Fav spell 2");
+	os.AddString(8,"Fav spell 3");
+	os.AddString(8,"Fav spell 4");
+	os.AddWord("FS count 1");
+	os.AddWord("FS count 2");
+	os.AddWord("FS count 3");
+	os.AddWord("FS count 4");
+	os.AddString(8,"Fav weapon 1");
+	os.AddString(8,"Fav weapon 2");
+	os.AddString(8,"Fav weapon 3");
+	os.AddString(8,"Fav weapon 4");
+	os.AddWord("FW count 1");
+	os.AddWord("FW count 2");
+	os.AddWord("FW count 3");
+	os.AddWord("FW count 4");
+	os.AddString(8,"Soundset");
+	if(iwd || iwd2)
+	{
+		os.AddString(32,"Voiceset");
+		if(iwd2)
+		{
+			for(i=0;i<48;i++)
+			{
+				os.AddDword("UNKNOWN");
+			}
+			os.AddWord("UNKNOWN");
+		}
+	}
+}
+
+void CreateOutputGAM(OutStream &os)
+{
+	int pccount, pcoffset;
+	int npccount, npcoffset;
+	int varcount, varoffset;
+	int killvarcount, killvaroffset;
+	int staticcount, staticoffset;
+	int journalcount, journaloffset;
+	int mazeoffset, beastoffset;
+	int extensionoffset;
+	int familiaroffset;
+	int extensioncount;
+	bool bg1,pst,iwd,iwd2;
+	int i,j;
+	char tmpstr[20];
+
+	extensionoffset=0;
+	iwd2=os.signature[7]=='2';
+	pst=os.signature[7]=='1';
+	iwd=pst;
+	bg1=0;
+	os.AddDword("Gametime");
+	os.AddWord("Active formation");
+	i=os.AddWord("Formation 1");
+	//pst and iwd are the same version
+	if(iwd)
+	{
+		if(i) pst=0;
+		else iwd=0;
+	}
+	os.AddWord("Formation 2");
+	os.AddWord("Formation 3");
+	os.AddWord("Formation 4");
+	os.AddWord("Formation 5");
+	os.AddDword("Party gold");
+	os.AddWord("UNKNOWN");
+	os.AddWord("Weather");
+	pcoffset=os.AddDword("PC offset");
+	pccount=os.AddDword("PC count");
+	if(!pccount) pcoffset=0;
+	staticoffset=os.AddDword("Unknown offset");
+	staticcount=os.AddDword("Unknown count");
+	if(!staticcount) staticoffset=0;
+	staticcount*=20; //sizeof this unknown area
+	npcoffset=os.AddDword("NPC offset");
+	npccount=os.AddDword("NPC count");
+	if(!npccount) npcoffset=0;
+	varoffset=os.AddDword("Variable offset");
+	varcount=os.AddDword("Variable count");
+	if(!varcount) varoffset=0;
+	os.AddString(8,"Area");
+	os.AddDword("UNKNOWN");
+	journalcount=os.AddDword("Journal count");
+	journaloffset=os.AddDword("Journal offset");
+	if(!journalcount) journaloffset=0;
+	if(pst)
+	{
+		mazeoffset=os.AddDword("Maze offset");
+		os.AddDword("Reputation");
+		os.AddString(8,"Current area");
+		killvaroffset=os.AddDword("Killvar offset");
+		killvarcount=os.AddDword("Killvar count");
+		if(!killvarcount) killvaroffset=0;
+		beastoffset=os.AddDword("Bestiary offset");
+		os.AddString(8,"Current area");
+		familiaroffset=0;
+	}
+	else
+	{
+		beastoffset=mazeoffset=0;
+		killvarcount=killvaroffset=0;
+		os.AddDword("Reputation");
+		os.AddString(8,"Current area");
+		os.AddDword("GUI flags");
+		os.AddDword("UNKNOWN");
+		familiaroffset=os.AddDword("Familiar offset");
+		if(familiaroffset==0)
+		{
+			iwd=0; //bg1
+			bg1=1;
+		}
+		os.AddDword("Saved loc. offset");
+		os.AddDword("Saved loc. count");
+	}
+	for(i=0;i<16;i++)
+	{
+		os.AddDword("UNKNOWN");
+	}
+	for(i=0;i<9;i++)
+	{
+retry:
+		if(staticcount && (staticoffset == os.fileoffset) )
+		{
+			os.AddBitmap(staticcount,"Unknown area");
+			staticoffset=0;
+			continue;
+		}
+		if(pccount && (pcoffset == os.fileoffset) )
+		{
+			os.AddString(0, "PCs");
+			for(j=0;j<pccount;j++)
+			{
+				CreateOutputGAMActor(os,pst,iwd,iwd2);
+			}
+			pcoffset=0;
+			continue;
+		}
+		if(npccount && (npcoffset == os.fileoffset) )
+		{
+			os.AddString(0, "NPCs");
+			for(j=0;j<npccount;j++)
+			{
+				CreateOutputGAMActor(os,pst,iwd,iwd2);
+			}
+			npcoffset=0;
+			continue;
+		}
+		if(varcount && (varoffset == os.fileoffset) )
+		{
+			os.AddString(0, "Variables");
+			for(j=0;j<varcount;j++)
+			{
+				CreateOutputVariable(os);
+			}
+			varoffset=0;
+			continue;
+		}
+		if(killvarcount && (killvaroffset == os.fileoffset) )
+		{
+			os.AddString(0, "Kill variables");
+			for(j=0;j<killvarcount;j++)
+			{
+				CreateOutputVariable(os);
+			}
+			killvaroffset=0;
+			continue;
+		}
+		if(journalcount && (journaloffset == os.fileoffset) )
+		{
+			os.AddString(0, "Journal");
+			for(j=0;j<journalcount;j++)
+			{
+				os.AddDword("Journal strref");
+				os.AddDword("Time");
+				if(bg1)
+				{
+					os.AddDword("Chapter");
+				}
+				else
+				{
+					os.AddByte("Chapter");
+					os.AddByte("Group");
+					os.AddByte("Section");
+					os.AddByte("User entry?");
+				}
+			}
+			journaloffset=0;
+			continue;
+		}
+		if(mazeoffset == os.fileoffset )
+		{
+			os.AddString(0, "Maze data");
+			for(j=0;j<64;j++)
+			{
+				sprintf(tmpstr,"AR13%02d",j+1);
+				os.AddWord(tmpstr);
+			}
+			for(j=0;j<398;j++)
+			{
+				os.AddDword("UNKNOWN");
+			}
+			//os.AddBitmap(1720,"Unknown area");
+			mazeoffset=0;
+			continue;
+		}
+		if(beastoffset==os.fileoffset)
+		{
+			os.AddString(0, "Beast data");
+			for(j=0;j<260;j++)
+			{
+				sprintf(tmpstr,"Bestiary %d",j+1);
+				os.AddByte(tmpstr);
+			}
+			beastoffset=0;
+			continue;
+		}
+		if(familiaroffset==os.fileoffset)
+		{
+			for(j=0;j<9;j++)
+			{
+				os.AddString(8,"Familiar");
+			}
+			extensionoffset=os.AddDword("Extension offset");
+			for(j=0;j<81;j++)
+			{
+				os.AddDword("UNKNOWN");
+			}
+			familiaroffset=0;
+			continue;
+		}
+		if(os.Prefetch("CRE ",4))
+		{
+			os.AddString(0,"Embedded CRE");
+			int z=os.fileoffset;
+			os.fileoffset=0;      
+			os.AddIndent();
+			os.AddSignature();
+			CreateOutputCRE(os);
+			os.EndIndent();
+			os.fileoffset+=z;
+			goto retry;
+		}
+
+		if(staticoffset || pcoffset || npcoffset || varoffset || killvaroffset ||
+			journaloffset || mazeoffset || familiaroffset || beastoffset)
+		{
+			os.AddString(0, "**Error**");
+			return;
+		}
+	}
+	if (!iwd2)
+	{
+		return;
+	}
+	if (extensionoffset!=os.fileoffset)
+	{
+		os.AddString(0, "**Error**");
+		return;
+	}
+	extensioncount = os.AddDword("Extension #");
+	while(extensioncount--)
+	{
+		os.AddDword("Header length");
+		i=os.AddDword("String length");
+		for(j=0;j<5;j++)
+		{
+			os.AddDword("UNKNOWN");
+		}
+		os.AddString(i,"Area");
+	}
+}
+
+void CreateOutput(int filetype, OutStream &os)
+{
+	os.AddSignature();
+	switch(filetype)
+	{
+	case FT_ITM:
+		CreateOutputITM(os);
+		break;
+	case FT_SPL:
+		CreateOutputSPL(os);
+		break;
+	case FT_STO:
+		CreateOutputSTO(os);
+		break;
+	case FT_CRE:
+		CreateOutputCRE(os);
+		break;
+	case FT_ARE:
+		CreateOutputARE(os);
+		break;
+	case FT_WED:
+		CreateOutputWED(os);
+		break;
+	case FT_WMP:
+		CreateOutputWMP(os);
+		break;
+	case FT_CHU:
+		CreateOutputCHU(os);
+		break;
+	case FT_EFF:
+		CreateOutputEFF(os);
+		break;
+	case FT_VVC:
+		CreateOutputVVC(os);
+		break;
+	case FT_PRO:
+		CreateOutputPRO(os);
+		break;
+	case FT_DLG:
+		CreateOutputDLG(os);
+		break;
+	case FT_GAM:
+		CreateOutputGAM(os);
+		break;
+	case FT_CHR:
+		CreateOutputCHR(os);
+		break;
+	}
+}
+
+#ifdef WIN32
+int lastloadtime=0;   // Workaround to RichEdit bug
+
+int __stdcall ListNotificationReceived(HWND ListWin,int Message,WPARAM wParam,LPARAM lParam)
+{
+	switch (Message) {
+	case WM_COMMAND:
+		if ((HIWORD(wParam)==EN_UPDATE) && (abs((int) (GetCurrentTime()-lastloadtime) )>10) ) {
+			int firstvisible=SendMessage(ListWin,EM_GETFIRSTVISIBLELINE,0,0);
+			int linecount=SendMessage(ListWin,EM_GETLINECOUNT,0,0);
+			if (linecount>0) {
+				int percent=MulDiv(firstvisible,100,linecount);
+				PostMessage(GetParent(ListWin),WM_COMMAND,MAKELONG(percent,itm_percent),(LPARAM)ListWin);
+			}
+			return 0;
+		}
+		break;
+	case WM_NOTIFY:
+		break;
+	case WM_MEASUREITEM:
+		break;
+	case WM_DRAWITEM:
+		break;
+	}
+	return 0;
+}
+#endif
+
+#ifdef WIN32
+HWND __stdcall ListLoad(HWND ParentWin,char* FileToLoad,int ShowFlags)
+#else
+void *DumpFile(char* FileToLoad)
+#endif
+{
+#ifdef WIN32
+	HWND hwnd;
+	RECT r;
+	BOOL success=false;
+#endif
+	char *p = NULL;
+	int filetype;
+
+#ifdef WIN32
+	p=strrchr(FileToLoad,'\\');
+	if (!p)
+		return NULL;
+#else
+	p=strrchr(FileToLoad,'/');
+	if (!p) p=FileToLoad;
+#endif
+	p=strrchr(p,'.');
+	if( !p ) return NULL;
+	if(stricmp(p,supportedextension1)==0) {
+		filetype = FT_ITM;
+		goto ok;
+	}
+	if(stricmp(p,supportedextension2)==0) {
+		filetype = FT_SPL;
+		goto ok;
+	}
+	if(stricmp(p,supportedextension3)==0) {
+		filetype = FT_CRE;
+		goto ok;
+	}
+	if(stricmp(p,supportedextension4)==0) {
+		filetype = FT_STO;
+		goto ok;
+	}
+	if(stricmp(p,supportedextension5)==0) {
+		filetype = FT_ARE;
+		goto ok;
+	}
+	if(stricmp(p,supportedextension6)==0) {
+		filetype = FT_CHU;
+		goto ok;
+	}
+	if(stricmp(p,supportedextension7)==0) {
+		filetype = FT_EFF;
+		goto ok;
+	}
+	if(stricmp(p,supportedextension8)==0) {
+		filetype = FT_VVC;
+		goto ok;
+	}
+	if(stricmp(p,supportedextension9)==0) {
+		filetype = FT_PRO;
+		goto ok;
+	}
+	if(stricmp(p,supportedextension10)==0) {
+		filetype = FT_DLG;
+		goto ok;
+	}
+	if(stricmp(p,supportedextension11)==0) {
+		filetype = FT_CHR;
+		goto ok;
+	}
+	if(stricmp(p,supportedextension12)==0) {
+		filetype = FT_GAM;
+		goto ok;
+	}
+	if(stricmp(p,supportedextension13)==0) {
+		filetype = FT_WED;
+		goto ok;
+	}
+	if(stricmp(p,supportedextension14)==0) {
+		filetype = FT_WMP;
+		goto ok;
+	}
+#ifndef WIN32
+	printf("Unsupported filetype!\n");
+#endif
+	return NULL;
+ok:
+	p=NULL;
+	// Extension is supported -> load file
+	OutStream os;
+	if(!os.OpenStream(FileToLoad))
+	{
+#ifndef WIN32
+		printf("Can't open file: %s\n",FileToLoad);
+#endif
+		goto result;
+	}
+#ifdef WIN32
+	if (!FLibHandle) {
+		int OldError = SetErrorMode(SEM_NOOPENFILEERRORBOX);
+		FLibHandle = LoadLibrary("Riched20.dll");
+		if ((int)FLibHandle < HINSTANCE_ERROR) 
+			FLibHandle = LoadLibrary("RICHED32.DLL");
+		if ((int)FLibHandle < HINSTANCE_ERROR) 
+			FLibHandle = NULL;
+		SetErrorMode(OldError);
+	}
+
+	lastloadtime=GetCurrentTime();
+
+	GetClientRect(ParentWin,&r);
+	// Create window invisible, only show when data fully loaded!
+
+	hwnd=CreateWindow("RichEdit20A","",WS_CHILD | ES_MULTILINE | ES_READONLY |
+		WS_HSCROLL | WS_VSCROLL | ES_NOHIDESEL,
+		r.left,r.top,r.right-r.left,
+		r.bottom-r.top,ParentWin,NULL,hinst,NULL);
+	
+	if (!hwnd)
+		hwnd=CreateWindow("RichEdit","",WS_CHILD | ES_MULTILINE | ES_READONLY |
+		WS_HSCROLL | WS_VSCROLL | ES_NOHIDESEL,
+		r.left,r.top,r.right-r.left,
+		r.bottom-r.top,ParentWin,NULL,hinst,NULL);
+
+	if (hwnd) {
+		SendMessage(hwnd, EM_SETMARGINS, EC_LEFTMARGIN, 8);
+		SendMessage(hwnd, EM_SETEVENTMASK, 0, ENM_UPDATE); //ENM_SCROLL doesn't work for thumb movements!
+
+		HFONT font=CreateFontA(15,0,0,0,0,0,0,0,0,0,0,0,0,"Courier New");
+		SendMessage(hwnd, WM_SETFONT, (WPARAM)font, MAKELPARAM(true, 0));
+		DeleteObject(font);
+
+		PostMessage(ParentWin,WM_COMMAND,MAKELONG(lcp_ansi,itm_fontstyle),(LPARAM)hwnd);
+		if (os.poi) {
+			CreateOutput(filetype,os);
+			SetWindowText(hwnd,os.poi);
+			PostMessage(ParentWin,WM_COMMAND,MAKELONG(0,itm_percent),(LPARAM)hwnd);
+			success=true;
+		}
+		if (!success) {
+			DestroyWindow(hwnd);
+			hwnd=NULL;
+			MessageBox(0,"Cannot display file","IELister",MB_OK);
+		}
+	}	
+#else
+	CreateOutput(filetype,os);
+#endif
+	os.CloseStream();
+result:
+#ifdef WIN32
+	lastloadtime=GetCurrentTime();
+	if (hwnd)
+		ShowWindow(hwnd,SW_SHOW);
+	return hwnd;
+#else
+	return NULL;
+#endif
+}
+
+#ifdef WIN32
+int __stdcall ListSendCommand(HWND ListWin,int Command,int Parameter)
+{
+	switch (Command) {
+	case lc_copy:
+		SendMessage(ListWin,WM_COPY,0,0);
+		return LISTPLUGIN_OK;
+	case lc_newparams:
+		return LISTPLUGIN_ERROR;
+	case lc_selectall:
+		SendMessage(ListWin,EM_SETSEL,0,-1);
+		return LISTPLUGIN_OK;
+	case lc_setpercent:
+		int firstvisible=SendMessage(ListWin,EM_GETFIRSTVISIBLELINE,0,0);
+		int linecount=SendMessage(ListWin,EM_GETLINECOUNT,0,0);
+		if (linecount>0) {
+			int pos=MulDiv(Parameter,linecount,100);
+			SendMessage(ListWin,EM_LINESCROLL,0,pos-firstvisible);
+			firstvisible=SendMessage(ListWin,EM_GETFIRSTVISIBLELINE,0,0);
+			// Place caret on first visible line!
+			int firstchar=SendMessage(ListWin,EM_LINEINDEX,firstvisible,0);
+			SendMessage(ListWin,EM_SETSEL,firstchar,firstchar);
+			pos=MulDiv(firstvisible,100,linecount);
+			// Update percentage display
+			PostMessage(GetParent(ListWin),WM_COMMAND,MAKELONG(pos,itm_percent),(LPARAM)ListWin);
+			return LISTPLUGIN_OK;
+		}
+		break;
+	}
+	return LISTPLUGIN_ERROR;
+}
+
+int _stdcall ListSearchText(HWND ListWin,char* SearchString,int SearchParameter)
+{
+	return LISTPLUGIN_ERROR;
+}
+
+void __stdcall ListCloseWindow(HWND ListWin)
+{
+	DestroyWindow(ListWin);
+	return;
+}
+
+int __stdcall ListPrint(HWND ListWin,char* FileToPrint,char* DefPrinter,int PrintFlags,RECT* Margins)
+{
+	return LISTPLUGIN_ERROR;
+}
+
+void __stdcall ListGetDetectString(char* DetectString,int maxlen)
+{
+	strlcpy(DetectString,parsefunction,maxlen);
+}
+
+void __stdcall ListSetDefaultParams(ListDefaultParamStruct* dps)
+{
+	strlcpy(inifilename,dps->DefaultIniName,MAX_PATH-1);
+}
+
+#endif