1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 11:53:53 +00:00

Added nif_bsa_test, tested nif reader on Morrowind.bsa

This commit is contained in:
Nicolay Korslund 2010-01-07 20:33:29 +01:00
parent 7191c51828
commit d6e4dc0b2a
8 changed files with 5910 additions and 65 deletions

View file

@ -52,8 +52,68 @@ struct Named : Controlled
Controlled::read(nif); Controlled::read(nif);
} }
}; };
typedef Named NiSequenceStreamHelper; 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 } // Namespace
#endif #endif

View file

@ -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 } // Namespace
#endif #endif

View file

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

View file

@ -1,9 +1,12 @@
GCC=g++ GCC=g++
all: niftool all: niftool nif_bsa_test
niftool: niftool.cpp ../nif_file.h ../nif_file.cpp ../record.h niftool: niftool.cpp ../nif_file.h ../nif_file.cpp ../record.h
$(GCC) $< ../nif_file.cpp ../../tools/stringops.cpp -o $@ $(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: clean:
rm niftool rm niftool *_test

View file

@ -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

View file

@ -1,6 +1,7 @@
#include "stringops.h" #include "stringops.h"
/// Returns true if str1 begins with substring str2 #include <string.h>
bool begins(const char* str1, const char* str2) bool begins(const char* str1, const char* str2)
{ {
while(*str2) while(*str2)
@ -12,3 +13,13 @@ bool begins(const char* str1, const char* str2)
} }
return true; 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;
}

View file

@ -4,4 +4,7 @@
/// Returns true if str1 begins with substring str2 /// Returns true if str1 begins with substring str2
bool begins(const char* str1, const char* 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 #endif