From 63fe367c6647b97b423fc0de240948c4699cfb11 Mon Sep 17 00:00:00 2001
From: Shon Ferguson <shonferg@users.sourceforge.net>
Date: Sat, 12 Nov 2005 23:16:05 +0000
Subject: [PATCH] Sped up CreateBlock and AddAttr functions.

---
 NIF_Blocks.cpp |  52 ++++----
 NIF_Blocks.h   |  44 +++----
 niflib.cpp     | 332 ++++++++++++++++++++++++++-----------------------
 niflib.h       |  10 ++
 4 files changed, 236 insertions(+), 202 deletions(-)

diff --git a/NIF_Blocks.cpp b/NIF_Blocks.cpp
index 1852a05f..6a2dd534 100644
--- a/NIF_Blocks.cpp
+++ b/NIF_Blocks.cpp
@@ -64,57 +64,57 @@ ABlock::~ABlock() {
 	}
 }
 
-void ABlock::AddAttr( string type, string name, unsigned int first_ver, unsigned int last_ver ) {
+void ABlock::AddAttr( AttrTypes type, string name, unsigned int first_ver, unsigned int last_ver ) {
 	IAttr * attr;
-	if ( type == "int" ) {
+	if ( type == attr_int ) {
 		attr = new IntAttr( name, this, first_ver, last_ver );
-	} else if ( type == "short" ) {
+	} else if ( type == attr_short ) {
 		attr = new ShortAttr( name, this, first_ver, last_ver );
-	} else if ( type == "byte" ) {
+	} else if ( type == attr_byte ) {
 		attr = new ByteAttr( name, this, first_ver, last_ver );
-	} else if ( type == "float" ) {
+	} else if ( type == attr_float ) {
 		attr = new FloatAttr( name, this, first_ver, last_ver );
-	} else if ( type == "float3" ) {
+	} else if ( type == attr_float3 ) {
 		attr = new Float3Attr( name, this, first_ver, last_ver );
-	} else if ( type == "string" ) {
+	} else if ( type == attr_string ) {
 		attr = new StringAttr( name, this, first_ver, last_ver );
-	} else if ( type == "link" ) {
+	} else if ( type == attr_link ) {
 		attr = new LinkAttr( name, this, first_ver, last_ver );
-	} else if ( type == "flags" ) {
+	} else if ( type == attr_flags ) {
 		attr = new FlagsAttr( name, this, first_ver, last_ver );
-	} else if ( type == "matrix33" ) {
+	} else if ( type == attr_matrix33 ) {
 		attr = new MatrixAttr( name, this, first_ver, last_ver );
-	} else if ( type == "linkgroup" ) {
+	} else if ( type == attr_linkgroup ) {
 		attr = new LinkGroupAttr( name, this, first_ver, last_ver );
-	} else if ( type == "bones" ) {
+	} else if ( type == attr_bones ) {
 		attr = new BoneAttr( name, this, first_ver, last_ver );
-	} else if ( type == "bbox" ) {
+	} else if ( type == attr_bbox ) {
 		attr = new BBoxAttr( name, this, first_ver, last_ver );
-	} else if ( type == "condint" ) {
+	} else if ( type == attr_condint ) {
 		attr = new CIntAttr( name, this, first_ver, last_ver );
-	} else if ( type == "vertmode" ) {
+	} else if ( type == attr_vertmode ) {
 		attr = new VertModeAttr( name, this, first_ver, last_ver );
-	} else if ( type == "lightmode" ) {
+	} else if ( type == attr_lightmode ) {
 		attr = new LightModeAttr( name, this, first_ver, last_ver );
-	} else if ( type == "texture" ) {
+	} else if ( type == attr_texture ) {
 		attr = new TextureAttr( name, this, first_ver, last_ver, false );
-	} else if ( type == "bumpmap" ) {
+	} else if ( type == attr_bumpmap ) {
 		attr = new TextureAttr( name, this, first_ver, last_ver, true );
-	} else if ( type == "applymode" ) {
+	} else if ( type == attr_applymode ) {
 		attr = new ApplyModeAttr( name, this, first_ver, last_ver );
-	} else if ( type == "texsource" ) {
+	} else if ( type == attr_texsource ) {
 		attr = new TexSourceAttr( name, this, first_ver, last_ver );
-	} else if ( type == "pixellayout" ) {
+	} else if ( type == attr_pixellayout ) {
 		attr = new PixelLayoutAttr( name, this, first_ver, last_ver );
-	} else if ( type == "mipmapformat" ) {
+	} else if ( type == attr_mipmapformat ) {
 		attr = new MipMapFormatAttr( name, this, first_ver, last_ver );
-	} else if ( type == "alphaformat" ) {
+	} else if ( type == attr_alphaformat ) {
 		attr = new AlphaFormatAttr( name, this, first_ver, last_ver );
-	} else if ( type == "nodeancestor" ) {
+	} else if ( type == attr_nodeancestor ) {
 		attr = new NodeAncestorAttr( name, this, first_ver, last_ver );
-	} else if ( type == "skeletonroot" ) {
+	} else if ( type == attr_skeletonroot ) {
 		attr = new SkeletonRootAttr( name, this, first_ver, last_ver );
-	} else if ( type == "particlegroup" ) {
+	} else if ( type == attr_particlegroup ) {
 		attr = new ParticleGroupAttr( name, this, first_ver, last_ver );
 	} else {
 		cout << type << endl;
diff --git a/NIF_Blocks.h b/NIF_Blocks.h
index 739dfdaa..f19d0bc6 100644
--- a/NIF_Blocks.h
+++ b/NIF_Blocks.h
@@ -79,7 +79,7 @@ class ABlock : public IBlock, public IBlockInternal {
 public:
 	ABlock();
 	~ABlock();
-	void AddAttr( string type, string name, unsigned int first_ver = 0, unsigned int last_ver = 0xFFFFFFFF );
+	void AddAttr( AttrTypes type, string name, unsigned int first_ver = 0, unsigned int last_ver = 0xFFFFFFFF );
 	attr_ref GetAttr(string attr_name);
 	vector<attr_ref> GetAttrs();
 	int GetBlockNum() { return _block_num; }
@@ -216,7 +216,7 @@ public:
 	AExtraData() {
 		_namable = true;
 		_first_named_ver = 0x10000100;
-		AddAttr( "link", "Next Extra Data", 0, 0x04020200 );
+		AddAttr( attr_link, "Next Extra Data", 0, 0x04020200 );
 	}
 	~AExtraData() {};
 };
@@ -456,7 +456,7 @@ public:
 class NiPixelData : public AData {
 public:
 	NiPixelData() {
-		AddAttr( "link", "Unknown Index" );
+		AddAttr( attr_link, "Unknown Index" );
 		data = NULL; }
 	~NiPixelData() { if (data != NULL) delete [] data; }
 
@@ -528,8 +528,8 @@ public:
 class AShapeData : public AData, public IShapeData {
 public:
 	AShapeData() {
-		AddAttr( "float3", "Center" );
-		AddAttr( "float", "Radius" );
+		AddAttr( attr_float3, "Center" );
+		AddAttr( attr_float, "Radius" );
 	}
 	~AShapeData() {}
 	void Read( ifstream& in, unsigned int version );
@@ -568,8 +568,8 @@ protected:
 class AParticlesData : public AShapeData {
 public:
 	AParticlesData() {
-		AddAttr( "float", "Active Radius" );
-		AddAttr( "short", "Unknown Short", 0x0401000C );
+		AddAttr( attr_float, "Active Radius" );
+		AddAttr( attr_short, "Unknown Short", 0x0401000C );
 	}
 	~AParticlesData() {}
 	void Read( ifstream& in, unsigned int version );
@@ -604,7 +604,7 @@ protected:
 class NiParticleMeshesData : public ARotatingParticlesData {
 public:
 	NiParticleMeshesData() {
-		AddAttr( "link", "Unknown Link" );
+		AddAttr( attr_link, "Unknown Link" );
 	}
 	~NiParticleMeshesData() {}
 	void Read( ifstream& in, unsigned int version );
@@ -680,12 +680,12 @@ private:
 class NiCollisionData : public AData {
 public:
 	NiCollisionData() {
-		AddAttr( "int", "Unknown Int 1" );
-		AddAttr( "int", "Unknown Int 2" );
-		AddAttr( "byte", "Unknown Byte" );
-		AddAttr( "int", "Unknown Int 3" );
-		AddAttr( "int", "Unknown Int 4" );
-		AddAttr( "float3", "Radius" );
+		AddAttr( attr_int, "Unknown Int 1" );
+		AddAttr( attr_int, "Unknown Int 2" );
+		AddAttr( attr_byte, "Unknown Byte" );
+		AddAttr( attr_int, "Unknown Int 3" );
+		AddAttr( attr_int, "Unknown Int 4" );
+		AddAttr( attr_float3, "Radius" );
 	}
 	~NiCollisionData() {}
 
@@ -1059,9 +1059,9 @@ public:
 class NiSkinInstance : public AData, public ISkinInstInternal {
 public:
 	NiSkinInstance(){
-		AddAttr( "link", "Data" );
-		AddAttr( "skeletonroot", "Skeleton Root" );
-		AddAttr( "bones", "Bones" );
+		AddAttr( attr_link, "Data" );
+		AddAttr( attr_skeletonroot, "Skeleton Root" );
+		AddAttr( attr_bones, "Bones" );
 	}
 	~NiSkinInstance() {}
 	string GetBlockType() { return "NiSkinInstance"; }
@@ -1208,7 +1208,7 @@ private:
 class NiStringExtraData : public AExtraData {
 public:
 	NiStringExtraData() {
-		AddAttr( "string", "String Data" );
+		AddAttr( attr_string, "String Data" );
 	}
 	~NiStringExtraData() {}
 
@@ -1221,7 +1221,7 @@ public:
 class NiBooleanExtraData : public AExtraData {
 public:
 	NiBooleanExtraData() {
-		AddAttr( "byte", "Boolean Data" );
+		AddAttr( attr_byte, "Boolean Data" );
 	}
 	~NiBooleanExtraData() {}
 
@@ -1231,7 +1231,7 @@ public:
 class NiIntegerExtraData : public AExtraData {
 public:
 	NiIntegerExtraData() {
-		AddAttr( "int", "Integer Data" );
+		AddAttr( attr_int, "Integer Data" );
 	}
 	~NiIntegerExtraData() {}
 
@@ -1241,7 +1241,7 @@ public:
 class NiMorphData : public AData, public IMorphData {
 public:
 	NiMorphData() {
-		AddAttr( "byte", "Unknown Byte" );
+		AddAttr( attr_byte, "Unknown Byte" );
 	}
 	~NiMorphData() {}
 
@@ -1307,7 +1307,7 @@ public:
 class NiTextKeyExtraData : public AExtraData, public ITextKeyExtraData {
 public:
 	NiTextKeyExtraData() {
-		AddAttr( "int", "Unknown Int", 0, 0x04020200 );
+		AddAttr( attr_int, "Unknown Int", 0, 0x04020200 );
 	}
 	~NiTextKeyExtraData() {}
 
diff --git a/niflib.cpp b/niflib.cpp
index 45077ade..53186b00 100644
--- a/niflib.cpp
+++ b/niflib.cpp
@@ -40,6 +40,11 @@ using namespace std;
 
 bool verbose = false;
 
+//Stores the mapping between block names and factory function pointers to create them
+typedef IBlock * (*blk_factory_func)();
+bool global_block_map_init = false;
+map<string, blk_factory_func> global_block_map;
+
 //Temporary Global to test reference counting
 unsigned int blocks_in_memory = 0;
 
@@ -47,163 +52,182 @@ unsigned int blocks_in_memory = 0;
 void ReorderNifTree( vector<blk_ref> & blk_list, blk_ref block );
 void BuildUpBindPositions( blk_ref block );
 blk_ref FindRoot( vector<blk_ref> & blocks );
+void RegisterBlockFactories ();
 
 //--Function Bodies--//
 void SetVerboseMode( bool val ) { verbose = val; }
 
 blk_ref CreateBlock( string block_type ) {
+	
+	//Initialize the global block list if it hasn't been done yet
+	if ( global_block_map_init == false ) {
+		RegisterBlockFactories();
+		global_block_map_init = true;
+	}
+
 	IBlock * block = NULL;
 
-	if (block_type == "AvoidNode") {
-		block = new AvoidNode;
-	} else if (block_type == "NiAlphaController") {
-		block = new NiAlphaController;
-	} else if (block_type == "NiAlphaProperty") {
-		block = new NiAlphaProperty;
-	} else if (block_type == "NiAmbientLight") {
-		block = new NiAmbientLight;
-	} else if (block_type == "NiAutoNormalParticles") {
-		block = new NiAutoNormalParticles;
-		} else if (block_type == "NiAutoNormalParticlesData") {
-		block = new NiAutoNormalParticlesData;
-	} else if (block_type == "NiBillboardNode") {
-		block = new NiBillboardNode;
-	} else if (block_type == "NiBooleanExtraData") {
-		block = new NiBooleanExtraData;
-	} else if (block_type == "NiBSAnimationNode") {
-		block = new NiBSAnimationNode;
-	} else if (block_type == "NiBSPArrayController") {
-		block = new NiBSPArrayController;
-	} else if (block_type == "NiBSParticleNode") {
-		block = new NiBSParticleNode;
-	} else if (block_type == "NiCamera") {
-		block = new NiCamera;
-	} else if (block_type == "NiCollisionData") {
-		block = new NiCollisionData;
-	} else if (block_type == "NiColorData") {
-		block = new NiColorData;
-	//} else if (block_type == "NiControllerSequence") {
-	//	block = new NiControllerSequence;
-	} else if (block_type == "NiDirectionalLight") {
-		block = new NiDirectionalLight;
-	} else if (block_type == "NiDitherProperty") {
-		block = new NiDitherProperty;
-	} else if (block_type == "NiFlipController") {
-		block = new NiFlipController;
-	} else if (block_type == "NiFloatData") {
-		block = new NiFloatData;
-	} else if (block_type == "NiGeomMorpherController") {
-		block = new NiGeomMorpherController;
-	} else if (block_type == "NiGravity") {
-		block = new NiGravity;
-	} else if (block_type == "NiIntegerExtraData") {
-		block = new NiIntegerExtraData;
-	} else if (block_type == "NiKeyframeController") {
-		block = new NiKeyframeController;
-	} else if (block_type == "NiKeyframeData") {
-		block = new NiKeyframeData;
-	} else if (block_type == "NiLODNode") {
-		block = new NiLODNode;
-	} else if (block_type == "NiLookAtController") {
-		block = new NiLookAtController;
-	} else if (block_type == "NiMaterialColorController") {
-		block = new NiMaterialColorController;
-	} else if (block_type == "NiMaterialProperty") {
-		block = new NiMaterialProperty;
-	} else if (block_type == "NiMorphData") {
-		block = new NiMorphData;
-	} else if (block_type == "NiNode") {
-		block = new NiNode;
-	} else if (block_type == "NiPalette") {
-		block = new NiPalette;
-	} else if (block_type == "NiParticleBomb") {
-		block = new NiParticleBomb;
-	} else if (block_type == "NiParticleColorModifier") {
-		block = new NiParticleColorModifier;
-	} else if (block_type == "NiParticleGrowFade") {
-		block = new NiParticleGrowFade;
-	} else if (block_type == "NiParticleMeshes") {
-		block = new NiParticleMeshes;
-	} else if (block_type == "NiParticleMeshesData") {
-		block = new NiParticleMeshesData;
-	} else if (block_type == "NiParticleMeshModifier") {
-		block = new NiParticleMeshModifier;
-	} else if (block_type == "NiParticleRotation") {
-		block = new NiParticleRotation;
-	} else if (block_type == "NiParticleSystemController") {
-		block = new NiParticleSystemController;
-	} else if (block_type == "NiPathController") {
-		block = new NiPathController;
-	} else if (block_type == "NiPixelData") {
-		block = new NiPixelData;
-	} else if (block_type == "NiPlanarCollider") {
-		block = new NiPlanarCollider;
-	} else if (block_type == "NiPosData") {
-		block = new NiPosData;
-	} else if (block_type == "NiRotatingParticles") {
-		block = new NiRotatingParticles;
-	} else if (block_type == "NiRotatingParticlesData") {
-		block = new NiRotatingParticlesData;
-	} else if ( block_type == "NiSequenceStreamHelper") {
-		block = new NiSequenceStreamHelper;
-	} else if (block_type == "NiShadeProperty") {
-		block = new NiShadeProperty;
-	} else if (block_type == "NiSkinData") {
-		block = new NiSkinData;
-	} else if (block_type == "NiSkinInstance") {
-		block = new NiSkinInstance;
-	//} else if (block_type == "NiSkinPartition") {
-	//	block = new NiSkinPartition;
-	} else if (block_type == "NiSourceTexture") {
-		block = new NiSourceTexture;
-	} else if (block_type == "NiSpecularProperty") {
-		block = new NiSpecularProperty;
-	} else if (block_type == "NiSphericalCollider") {
-		block = new NiSphericalCollider;
-	} else if (block_type == "NiStencilProperty") {
-		block = new NiStencilProperty;
-	} else if (block_type == "NiStringExtraData") {
-		block = new NiStringExtraData;
-	} else if (block_type == "NiTextKeyExtraData") {
-		block = new NiTextKeyExtraData;
-	} else if (block_type == "NiTextureEffect") {
-		block = new NiTextureEffect;
-	} else if (block_type == "NiTexturingProperty") {
-		block = new NiTexturingProperty;
-	} else if (block_type == "NiTriShape") {
-		block = new NiTriShape;
-	} else if (block_type == "NiTriStrips") {
-		block = new NiTriStrips;
-	} else if (block_type == "NiTriShapeData") {
-		block = new NiTriShapeData;
-	} else if ( block_type == "NiUVController") {
-		block = new NiUVController;
-	} else if (block_type == "NiUVData") {
-		block = new NiUVData;
-	} else if ( block_type == "NiVertexColorProperty") {
-		block = new NiVertexColorProperty;
-	} else if (block_type == "NiVertWeightsExtraData") {
-		block = new NiVertWeightsExtraData;
-	} else if (block_type == "NiVisController") {
-		block = new NiVisController;
-	} else if (block_type == "NiVisData") {
-		block = new NiVisData;
-	} else if (block_type == "NiWireframeProperty") {
-		block = new NiWireframeProperty;
-	} else if (block_type == "NiZBufferProperty") {
-		block = new NiZBufferProperty;
-	} else if (block_type == "RootCollisionNode") {
-		block = new RootCollisionNode;
-	// Unknown Blocks
-	} else if ( block_type == "NiRendererSpecificProperty" ) {
-		block = new UnknownPropertyBlock( block_type );
-	} else if ( block_type == "NiBSPArrayController" || block_type == "NiParticleSystemController" ) {
-		block = new UnknownControllerBlock( block_type );
+	map<string, blk_factory_func>::iterator it;
+	it = global_block_map.find(block_type);
+
+	if ( it != global_block_map.end() ) {
+		//Requested type has been registered
+		block = it->second();
 	} else {
+		//An unknown type has been encountered
 		block = new UnknownBlock( block_type );
 	}
-
+	
 	return blk_ref(block);
+
+	//if (block_type == "AvoidNode") {
+	//	block = new AvoidNode;
+	//} else if (block_type == "NiAlphaController") {
+	//	block = new NiAlphaController;
+	//} else if (block_type == "NiAlphaProperty") {
+	//	block = new NiAlphaProperty;
+	//} else if (block_type == "NiAmbientLight") {
+	//	block = new NiAmbientLight;
+	//} else if (block_type == "NiAutoNormalParticles") {
+	//	block = new NiAutoNormalParticles;
+	//	} else if (block_type == "NiAutoNormalParticlesData") {
+	//	block = new NiAutoNormalParticlesData;
+	//} else if (block_type == "NiBillboardNode") {
+	//	block = new NiBillboardNode;
+	//} else if (block_type == "NiBooleanExtraData") {
+	//	block = new NiBooleanExtraData;
+	//} else if (block_type == "NiBSAnimationNode") {
+	//	block = new NiBSAnimationNode;
+	//} else if (block_type == "NiBSPArrayController") {
+	//	block = new NiBSPArrayController;
+	//} else if (block_type == "NiBSParticleNode") {
+	//	block = new NiBSParticleNode;
+	//} else if (block_type == "NiCamera") {
+	//	block = new NiCamera;
+	//} else if (block_type == "NiCollisionData") {
+	//	block = new NiCollisionData;
+	//} else if (block_type == "NiColorData") {
+	//	block = new NiColorData;
+	////} else if (block_type == "NiControllerSequence") {
+	////	block = new NiControllerSequence;
+	//} else if (block_type == "NiDirectionalLight") {
+	//	block = new NiDirectionalLight;
+	//} else if (block_type == "NiDitherProperty") {
+	//	block = new NiDitherProperty;
+	//} else if (block_type == "NiFlipController") {
+	//	block = new NiFlipController;
+	//} else if (block_type == "NiFloatData") {
+	//	block = new NiFloatData;
+	//} else if (block_type == "NiGeomMorpherController") {
+	//	block = new NiGeomMorpherController;
+	//} else if (block_type == "NiGravity") {
+	//	block = new NiGravity;
+	//} else if (block_type == "NiIntegerExtraData") {
+	//	block = new NiIntegerExtraData;
+	//} else if (block_type == "NiKeyframeController") {
+	//	block = new NiKeyframeController;
+	//} else if (block_type == "NiKeyframeData") {
+	//	block = new NiKeyframeData;
+	//} else if (block_type == "NiLODNode") {
+	//	block = new NiLODNode;
+	//} else if (block_type == "NiLookAtController") {
+	//	block = new NiLookAtController;
+	//} else if (block_type == "NiMaterialColorController") {
+	//	block = new NiMaterialColorController;
+	//} else if (block_type == "NiMaterialProperty") {
+	//	block = new NiMaterialProperty;
+	//} else if (block_type == "NiMorphData") {
+	//	block = new NiMorphData;
+	//} else if (block_type == "NiNode") {
+	//	block = new NiNode;
+	//} else if (block_type == "NiPalette") {
+	//	block = new NiPalette;
+	//} else if (block_type == "NiParticleBomb") {
+	//	block = new NiParticleBomb;
+	//} else if (block_type == "NiParticleColorModifier") {
+	//	block = new NiParticleColorModifier;
+	//} else if (block_type == "NiParticleGrowFade") {
+	//	block = new NiParticleGrowFade;
+	//} else if (block_type == "NiParticleMeshes") {
+	//	block = new NiParticleMeshes;
+	//} else if (block_type == "NiParticleMeshesData") {
+	//	block = new NiParticleMeshesData;
+	//} else if (block_type == "NiParticleMeshModifier") {
+	//	block = new NiParticleMeshModifier;
+	//} else if (block_type == "NiParticleRotation") {
+	//	block = new NiParticleRotation;
+	//} else if (block_type == "NiParticleSystemController") {
+	//	block = new NiParticleSystemController;
+	//} else if (block_type == "NiPathController") {
+	//	block = new NiPathController;
+	//} else if (block_type == "NiPixelData") {
+	//	block = new NiPixelData;
+	//} else if (block_type == "NiPlanarCollider") {
+	//	block = new NiPlanarCollider;
+	//} else if (block_type == "NiPosData") {
+	//	block = new NiPosData;
+	//} else if (block_type == "NiRotatingParticles") {
+	//	block = new NiRotatingParticles;
+	//} else if (block_type == "NiRotatingParticlesData") {
+	//	block = new NiRotatingParticlesData;
+	//} else if ( block_type == "NiSequenceStreamHelper") {
+	//	block = new NiSequenceStreamHelper;
+	//} else if (block_type == "NiShadeProperty") {
+	//	block = new NiShadeProperty;
+	//} else if (block_type == "NiSkinData") {
+	//	block = new NiSkinData;
+	//} else if (block_type == "NiSkinInstance") {
+	//	block = new NiSkinInstance;
+	////} else if (block_type == "NiSkinPartition") {
+	////	block = new NiSkinPartition;
+	//} else if (block_type == "NiSourceTexture") {
+	//	block = new NiSourceTexture;
+	//} else if (block_type == "NiSpecularProperty") {
+	//	block = new NiSpecularProperty;
+	//} else if (block_type == "NiSphericalCollider") {
+	//	block = new NiSphericalCollider;
+	//} else if (block_type == "NiStencilProperty") {
+	//	block = new NiStencilProperty;
+	//} else if (block_type == "NiStringExtraData") {
+	//	block = new NiStringExtraData;
+	//} else if (block_type == "NiTextKeyExtraData") {
+	//	block = new NiTextKeyExtraData;
+	//} else if (block_type == "NiTextureEffect") {
+	//	block = new NiTextureEffect;
+	//} else if (block_type == "NiTexturingProperty") {
+	//	block = new NiTexturingProperty;
+	//} else if (block_type == "NiTriShape") {
+	//	block = new NiTriShape;
+	//} else if (block_type == "NiTriStrips") {
+	//	block = new NiTriStrips;
+	//} else if (block_type == "NiTriShapeData") {
+	//	block = new NiTriShapeData;
+	//} else if ( block_type == "NiUVController") {
+	//	block = new NiUVController;
+	//} else if (block_type == "NiUVData") {
+	//	block = new NiUVData;
+	//} else if ( block_type == "NiVertexColorProperty") {
+	//	block = new NiVertexColorProperty;
+	//} else if (block_type == "NiVertWeightsExtraData") {
+	//	block = new NiVertWeightsExtraData;
+	//} else if (block_type == "NiVisController") {
+	//	block = new NiVisController;
+	//} else if (block_type == "NiVisData") {
+	//	block = new NiVisData;
+	//} else if (block_type == "NiWireframeProperty") {
+	//	block = new NiWireframeProperty;
+	//} else if (block_type == "NiZBufferProperty") {
+	//	block = new NiZBufferProperty;
+	//} else if (block_type == "RootCollisionNode") {
+	//	block = new RootCollisionNode;
+	//// Unknown Blocks
+	//} else if ( block_type == "NiRendererSpecificProperty" ) {
+	//	block = new UnknownPropertyBlock( block_type );
+	//} else if ( block_type == "NiBSPArrayController" || block_type == "NiParticleSystemController" ) {
+	//	block = new UnknownControllerBlock( block_type );
+	//} else {
+	//	block = new UnknownBlock( block_type );
+	//}
 }
 
 //Reads the given file by file name and returns a reference to the root block
@@ -249,12 +273,12 @@ vector<blk_ref> ReadNifList( string file_name ) {
 	uint version = ReadUInt( in );
 	uint numBlocks = ReadUInt( in );
 
-	//Output
-	cout << endl << endl 
-		 << "====[ " << file_name << " | File Header ]====" << endl
-		 << "Header:  " << header_string << endl
-		 << "Version:  " << Hex(version) << endl
-		 << "Number of blocks: " << int(numBlocks) << endl;
+	////Output
+	//cout << endl << endl 
+	//	 << "====[ " << file_name << " | File Header ]====" << endl
+	//	 << "Header:  " << header_string << endl
+	//	 << "Version:  " << Hex(version) << endl
+	//	 << "Number of blocks: " << int(numBlocks) << endl;
 
 	//vector<blk_ref> v;
 	//return v;
@@ -290,7 +314,7 @@ vector<blk_ref> ReadNifList( string file_name ) {
 			throw runtime_error("Read failue - Bad block position");
 		}
 
-		cout << endl << i << ":  " << blockName;
+		//cout << endl << i << ":  " << blockName;
 
 		//Create Block of the type that was found
 		blocks[i] = CreateBlock(blockName);
@@ -315,7 +339,7 @@ vector<blk_ref> ReadNifList( string file_name ) {
 			delete [] blockName;
 	}
 
-	cout << endl;
+	//cout << endl;
 
 	//--Read Footer--//
 	uint unknownInt = ReadUInt( in );
diff --git a/niflib.h b/niflib.h
index 931e6200..bd0d5ed9 100644
--- a/niflib.h
+++ b/niflib.h
@@ -79,6 +79,16 @@ const int ID_TEXT_KEY_EXTRA_DATA = 4;
 const int ID_MORPH_DATA = 5;
 const int ID_SHAPE_DATA = 6;
 
+//Attribute types
+const enum AttrTypes {
+	attr_int, attr_short, attr_byte, attr_float, attr_float3, attr_string,
+	attr_link, attr_flags, attr_matrix33, attr_linkgroup, attr_bones,
+	attr_bbox, attr_condint, attr_vertmode, attr_lightmode, attr_texture,
+	attr_bumpmap, attr_applymode, attr_texsource, attr_pixellayout,
+	attr_mipmapformat, attr_alphaformat, attr_nodeancestor,
+	attr_skeletonroot, attr_particlegroup, attr_lodrangegroup
+};
+
 //NIF Versions
 const int VER_4_0_0_2 = 0x04000002;
 const int VER_4_2_0_2 = 0x04020002;
-- 
GitLab