From 6a34b0f2bf4ab48b26d34bb7c126c5c3eeb6b4b9 Mon Sep 17 00:00:00 2001 From: Nicolay Korslund Date: Mon, 4 Jan 2010 18:49:23 +0100 Subject: [PATCH] Split nif_file in h/cpp --- nif/nif_file.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++++++ nif/nif_file.h | 34 +-------------------------- nif/tests/Makefile | 2 +- 3 files changed, 59 insertions(+), 34 deletions(-) create mode 100644 nif/nif_file.cpp diff --git a/nif/nif_file.cpp b/nif/nif_file.cpp new file mode 100644 index 000000000..fd7a38b3b --- /dev/null +++ b/nif/nif_file.cpp @@ -0,0 +1,57 @@ +/* + OpenMW - The completely unofficial reimplementation of Morrowind + Copyright (C) 2008-2010 Nicolay Korslund + Email: < korslund@gmail.com > + WWW: http://openmw.sourceforge.net/ + + This file (nif_file.cpp) is part of the OpenMW package. + + OpenMW is distributed as free software: you can redistribute it + and/or modify it under the terms of the GNU General Public License + version 3, as published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + version 3 along with this program. If not, see + http://www.gnu.org/licenses/ . + + */ + +#include "nif_file.h" + +#include "../tools/stringops.h" + +#include +using namespace std; + +void NIFFile::parse() +{ + // Check the header string + const char* head = getString(40); + if(!begins(head, "NetImmerse File Format")) + fail("Invalid NIF header"); + + // Get BCD version + ver = getInt(); + if(ver != VER_MW) + fail("Unsupported NIF version"); + + // Number of records + int recNum = getInt(); + records.resize(recNum); + + for(int i=0;i -// Only used during development. Remove later. -#include -using namespace std; - using namespace Mangle::Stream; // A simple array implementation containing a pointer and a @@ -105,33 +100,7 @@ class NIFFile } /// Parse the file - void parse() - { - // Check the header string - const char* head = getString(40); - if(!begins(head, "NetImmerse File Format")) - fail("Invalid NIF header"); - - // Get BCD version - ver = getInt(); - if(ver != VER_MW) - fail("Unsupported NIF version"); - - // Number of records - int recNum = getInt(); - records.resize(recNum); - - for(int i=0;igetPtr(size); } }; - #endif diff --git a/nif/tests/Makefile b/nif/tests/Makefile index cf5ccf390..196ce26e2 100644 --- a/nif/tests/Makefile +++ b/nif/tests/Makefile @@ -3,7 +3,7 @@ GCC=g++ all: niftool niftool: niftool.cpp ../nif_file.h - $(GCC) $< ../../tools/stringops.cpp -o $@ + $(GCC) $< ../nif_file.cpp ../../tools/stringops.cpp -o $@ clean: rm niftool