Added nif_bsa_test, tested nif reader on Morrowind.bsa

actorid
Nicolay Korslund 15 years ago
parent 7191c51828
commit d6e4dc0b2a

@ -52,8 +52,68 @@ struct Named : Controlled
Controlled::read(nif);
}
};
typedef Named NiSequenceStreamHelper;
struct NiParticleGrowFade : Controlled
{
void read(NIFFile *nif)
{
Controlled::read(nif);
// Two floats.
nif->skip(8);
}
};
struct NiParticleColorModifier : Controlled
{
NiColorDataPtr data;
void read(NIFFile *nif)
{
Controlled::read(nif);
data.read(nif);
}
};
struct NiGravity : Controlled
{
void read(NIFFile *nif)
{
Controlled::read(nif);
// two floats, one int, six floats
nif->skip(9*4);
}
};
// NiPinaColada
struct NiPlanarCollider : Controlled
{
void read(NIFFile *nif)
{
Controlled::read(nif);
// (I think) 4 floats + 4 vectors
nif->skip(4*16);
}
};
struct NiParticleRotation : Controlled
{
void read(NIFFile *nif)
{
Controlled::read(nif);
/*
byte (0 or 1)
float (1)
float*3
*/
nif->skip(17);
}
};
} // Namespace
#endif

@ -91,65 +91,5 @@ struct NiStringExtraData : Extra
}
};
struct NiParticleGrowFade : Extra
{
void read(NIFFile *nif)
{
Extra::read(nif);
// Two floats.
nif->skip(8);
}
};
struct NiParticleColorModifier : Extra
{
NiColorDataPtr data;
void read(NIFFile *nif)
{
Extra::read(nif);
data.read(nif);
}
};
struct NiGravity : Extra
{
void read(NIFFile *nif)
{
Extra::read(nif);
// two floats, one int, six floats
nif->skip(9*4);
}
};
// NiPinaColada
struct NiPlanarCollider : Extra
{
void read(NIFFile *nif)
{
Extra::read(nif);
// (I think) 4 floats + 4 vectors
nif->skip(4*16);
}
};
struct NiParticleRotation : Extra
{
void read(NIFFile *nif)
{
Extra::read(nif);
/*
byte (0 or 1)
float (1)
float*3
*/
nif->skip(17);
}
};
} // Namespace
#endif

@ -56,7 +56,6 @@ void NIFFile::parse()
for(int i=0;i<recNum;i++)
{
SString rec = getString();
//cout << i << ": " << rec.toString() << endl;
Record *r;

@ -1,9 +1,12 @@
GCC=g++
all: niftool
all: niftool nif_bsa_test
niftool: niftool.cpp ../nif_file.h ../nif_file.cpp ../record.h
$(GCC) $< ../nif_file.cpp ../../tools/stringops.cpp -o $@
nif_bsa_test: nif_bsa_test.cpp ../nif_file.cpp ../../bsa/bsa_file.cpp ../../tools/stringops.cpp
$(GCC) $^ -o $@
clean:
rm niftool
rm niftool *_test

@ -0,0 +1,30 @@
/*
Runs NIFFile through all the NIFs in Morrowind.bsa.
*/
#include "../nif_file.h"
#include "../../bsa/bsa_file.h"
#include "../../tools/stringops.h"
#include <iostream>
using namespace Mangle::Stream;
using namespace std;
using namespace Nif;
int main(int argc, char **args)
{
BSAFile bsa;
cout << "Reading Morrowind.bsa\n";
bsa.open("../../data/Morrowind.bsa");
const BSAFile::FileList &files = bsa.getList();
for(int i=0; i<files.size(); i++)
{
const char *n = files[i].name;
if(!ends(n, ".nif")) continue;
cout << "Decoding " << n << endl;
NIFFile nif(bsa.getFile(n), n);
}
}

File diff suppressed because it is too large Load Diff

@ -1,6 +1,7 @@
#include "stringops.h"
/// Returns true if str1 begins with substring str2
#include <string.h>
bool begins(const char* str1, const char* str2)
{
while(*str2)
@ -12,3 +13,13 @@ bool begins(const char* str1, const char* str2)
}
return true;
}
bool ends(const char* str1, const char* str2)
{
int len1 = strlen(str1);
int len2 = strlen(str2);
if(len1 < len2) return false;
return strcmp(str2, str1+len1-len2) == 0;
}

@ -4,4 +4,7 @@
/// Returns true if str1 begins with substring str2
bool begins(const char* str1, const char* str2);
/// Returns true if str1 ends with substring str2
bool ends(const char* str1, const char* str2);
#endif

Loading…
Cancel
Save