From a516680f4fd35d4897d790a04a74a6e591deea40 Mon Sep 17 00:00:00 2001
From: johns <>
Date: Wed, 5 Apr 2000 23:32:32 +0000
Subject: [PATCH] Started removing animation tables

---
 src/include/unittype.h       |  8 --------
 src/unit/script_unittype.cpp | 37 +++++++++++++++++++-----------------
 2 files changed, 20 insertions(+), 25 deletions(-)

diff --git a/src/include/unittype.h b/src/include/unittype.h
index ad822385c..7193e7e9d 100644
--- a/src/include/unittype.h
+++ b/src/include/unittype.h
@@ -346,15 +346,7 @@ extern UnitType UnitTypes[UnitTypeInternalMax];	/// all unit types
 #ifdef USE_CCL2
 extern Animation ** UnitDie;
 extern Animation ** UnitCorpse;
-extern Animation ** UnitMoveAnimation;
 extern Animation ** UnitStillAnimation;
-extern Animation ** UnitAttack;
-#else
-extern Animation* UnitDie[];
-//extern Animation* UnitCorpse[];
-extern Animation* UnitMoveAnimation[];
-extern Animation* UnitStillAnimation[];
-extern Animation* UnitAttack[];
 #endif
 
 /*----------------------------------------------------------------------------
diff --git a/src/unit/script_unittype.cpp b/src/unit/script_unittype.cpp
index 8da908eff..596bf62e4 100644
--- a/src/unit/script_unittype.cpp
+++ b/src/unit/script_unittype.cpp
@@ -652,9 +652,7 @@ local Animation * GetSingleAnimation(SCM list){
 
 global Animation ** UnitDie;
 global Animation ** UnitCorpse;
-global Animation ** UnitMoveAnimation;
 global Animation ** UnitStillAnimation;
-global Animation ** UnitAttack;
 
 /**
  ** Get animation data
@@ -682,26 +680,27 @@ local SCM CclAnimType(SCM list)
       
     }
     
-    switch( type){
+    switch( type ){
     case 0:
       UnitStillAnimation = whole_animation;
       for( i=0; i<UnitTypeInternalMax; ++i ) {
 	unittype=UnitTypeByWcNum(i);
-	if( unittype->Animations ) {
-	  //CclFree(unittype->Animations->Still);
-	  unittype->Animations->Still=whole_animation[i];
+	if( !unittype->Animations ) {
+	    unittype->Animations=calloc(sizeof(*unittype->Animations),1);
 	}
+	CclFree(unittype->Animations->Still);
+        unittype->Animations->Still=whole_animation[i];
       }
       DebugLevel2("Loading UnitStillAnimation\n");
       break;
     case 1:
-      UnitMoveAnimation = whole_animation;
       for( i=0; i<UnitTypeInternalMax; ++i ) {
 	unittype=UnitTypeByWcNum(i);
-	if( unittype->Animations ) {
-	  //CclFree(unittype->Animations->Move);
-	  unittype->Animations->Move=whole_animation[i];
+	if( !unittype->Animations ) {
+	    unittype->Animations=calloc(sizeof(*unittype->Animations),1);
 	}
+	CclFree(unittype->Animations->Move);
+	unittype->Animations->Move=whole_animation[i];
       }
       DebugLevel2("Loading UnitMoveAnimation\n");
       break;
@@ -709,10 +708,11 @@ local SCM CclAnimType(SCM list)
       UnitDie = whole_animation;
       for( i=0; i<UnitTypeInternalMax; ++i ) {
 	unittype=UnitTypeByWcNum(i);
-	if( unittype->Animations ) {
-	  //CclFree(unittype->Animations->Die);
-	  unittype->Animations->Die=whole_animation[i];
+	if( !unittype->Animations ) {
+	    unittype->Animations=calloc(sizeof(*unittype->Animations),1);
 	}
+	CclFree(unittype->Animations->Die);
+	unittype->Animations->Die=whole_animation[i];
       }
       DebugLevel2("Loading UnitDie\n");
       break;
@@ -720,18 +720,21 @@ local SCM CclAnimType(SCM list)
       UnitCorpse = whole_animation;
       for( i=0; i<UnitTypeInternalMax; ++i ) {
 	unittype=UnitTypeByWcNum(i);
+	if( !unittype->Animations ) {
+	    unittype->Animations=calloc(sizeof(*unittype->Animations),1);
+	}
 	// FIXME: corpse
       }
       DebugLevel2("Loading UnitCorpse\n");
       break;
     case 4:
-      UnitAttack = whole_animation;
       for( i=0; i<UnitTypeInternalMax; ++i ) {
 	unittype=UnitTypeByWcNum(i);
-	if( unittype->Animations ) {
-	  //CclFree(unittype->Animations->Attack);
-	  unittype->Animations->Attack=whole_animation[i];
+	if( !unittype->Animations ) {
+	    unittype->Animations=calloc(sizeof(*unittype->Animations),1);
 	}
+	CclFree(unittype->Animations->Attack);
+	unittype->Animations->Attack=whole_animation[i];
       }
       DebugLevel2("Loading UnitAttack\n");
       break;