diff --git a/nif/controlled.h b/nif/controlled.h index d15c53961..25a65d8ad 100644 --- a/nif/controlled.h +++ b/nif/controlled.h @@ -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 diff --git a/nif/extra.h b/nif/extra.h index 2fdc03de9..c37a87d74 100644 --- a/nif/extra.h +++ b/nif/extra.h @@ -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 diff --git a/nif/nif_file.cpp b/nif/nif_file.cpp index 291d3950d..32b26eb06 100644 --- a/nif/nif_file.cpp +++ b/nif/nif_file.cpp @@ -56,7 +56,6 @@ void NIFFile::parse() for(int i=0;i + +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 + 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; +} diff --git a/tools/stringops.h b/tools/stringops.h index 575791dff..30c6c1f10 100644 --- a/tools/stringops.h +++ b/tools/stringops.h @@ -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