- Joined
- Jun 15, 2009
- Messages
- 107
- Reaction score
- 37
in case someone wants to mess with cflyff maps:
cflyff wdf file format. dont really want to start explaining. heres the code
Seems like it doesnt contain any filenames...
as for the lnd files, they are preatty similar.
the first 3 integers (version, x, y) are skipped, only 1 character is there, wich is constant 2.
the water-heigth table's size is 0x500 instead of 0x300
couldnt find the texture id-s, and theres no model or sfx data at the end of the file.
EDIT:
- better file extension guessing
- decodes voq files
cflyff wdf file format. dont really want to start explaining. heres the code
Seems like it doesnt contain any filenames...
Code:
#include <stdio.h>
void decode(unsigned char *p, int h)
{
for(int a=0;a<h;a++)
{
p[a]^=(unsigned char)194;
p[a]=(p[a]<<4)|(p[a]>>4);
}
}
int main(int argc, char* argv[])
{
char fname[256];
FILE *f1, *f2;
char *p;
int *fsizes, *startpos;
int a,b,n,h;
f1=fopen(argv[1], "rb");
fseek(f1, 4, SEEK_SET);
fread(&n, 1, 4, f1); //number of files
fsizes=new int[n];
startpos=new int[n];
fread(&a, 1, 4, f1); //offset of file table
fseek(f1, a, SEEK_SET);
h=0;
for(a=0;a<n;a++)
{
fread(&b, 1, 4, f1);
fread(&startpos[a], 1, 4, f1);
fread(&fsizes[a], 1, 4, f1);
fread(&b, 1, 4, f1);
h+=fsizes[a];
}
char *guess[12]={"DAT","dds", "wav", "lnd", "voq", "tga", "bmp", "sp", "jpg", "rt", "mp3", "LND"};
for(a=0;a<n;a++)
{
fseek(f1, startpos[a], SEEK_SET);
fread(&b, 1, 4, f1);
switch(b)
{
case 0x20534444: b=1; break; //DDS
case 0x46464952: b=2; break; //WAVE
case 0xd736a713: b=4; break; //voq
case 0x00020000: b=5; break; //tga
case 0x65636152: b=9; break; //
case 0xe0ffd8ff: b=8; break; //
default:
if((b&0xffff)==0x4d42)b=6;
else if((b&0xffff)==0x5053)b=7;
else if((b&0xffff)==0x4449)b=10;
else if((b&0xffff)==0xfbff)b=10;
else if((b&0xff)==2)b=3;
else if((b&0xff)==1)b=11; //sometimes its lnd, sometimes its not...
else
{
b=0;
// printf("unknown type %d %c\n", (int)ch, ch);
}
};
sprintf(fname, "F%d.%s", a, guess[b]);
f2=fopen(fname, "w+b");
p=new char[fsizes[a]];
fseek(f1, startpos[a], SEEK_SET);
fread(p, 1, fsizes[a], f1);
if(b==4)decode((unsigned char*)p, fsizes[a]);
fwrite(p, 1, fsizes[a], f2);
delete[] p;
fclose(f2);
}
fclose(f1);
delete[] fsizes;
delete[] startpos;
printf("%d files\n%d bytes\n", n, h);
return 0;
};
as for the lnd files, they are preatty similar.
the first 3 integers (version, x, y) are skipped, only 1 character is there, wich is constant 2.
the water-heigth table's size is 0x500 instead of 0x300
couldnt find the texture id-s, and theres no model or sfx data at the end of the file.
EDIT:
- better file extension guessing
- decodes voq files
Last edited:

