git » fp-git.git » commit 122a76b

added a union in the time attribute in tDanger

author ecalot
2005-01-30 23:00:53 UTC
committer ecalot
2005-01-30 23:00:53 UTC
parent 6a8f211cedacfaabbc787df06a466f75d5a2a54e

added a union in the time attribute in tDanger

FP/src/include/types.h +4 -1
FP/src/res/maps.c +9 -9

diff --git a/FP/src/include/types.h b/FP/src/include/types.h
index b8f8ebd..5c89c88 100644
--- a/FP/src/include/types.h
+++ b/FP/src/include/types.h
@@ -77,7 +77,10 @@ typedef struct {
 typedef struct {
 	int frame;
 	enum {eChoActive,eChoInactive,eSpiUp,eSpiWaitUp,eSpiDown,eSpiStuck} action;
-	int time;
+	union {
+		int time;
+		unsigned char back;
+	} more;
 } tDanger;
 
 typedef struct {
diff --git a/FP/src/res/maps.c b/FP/src/res/maps.c
index e132bf6..3d5ce21 100644
--- a/FP/src/res/maps.c
+++ b/FP/src/res/maps.c
@@ -137,7 +137,7 @@ void* mapLoadLevel(tMemory level) {
 				tDanger newDanger;
 				/* initialize the tDanger object*/
 	 			newDanger.frame=0;
-	 			newDanger.time=1;
+	 			newDanger.more.time=1;
 				newDanger.action=((map->fore[i*30+j]&0x1f)==TILE_CHOPPER)?eChoInactive:eSpiDown;
 				map->back[i*30+j]=dangerInRoom;
 				map->screenDangers[i][dangerInRoom]=map->dangers+dangers;
@@ -392,7 +392,7 @@ void  mapMove(tMap* map) {
 
 	/* check out and update all the spikes and choppers */
 #ifdef DEBUGMAPS
-	printf("chopper act=%d tim=%d fra=%d\n",map->dangers[i].time,map->dangers[i].action,map->dangers[i].frame);
+	printf("chopper act=%d tim=%d fra=%d\n",map->dangers[i].more.time,map->dangers[i].action,map->dangers[i].frame);
 #endif
 	for (i=0;i<slevel(totalDangers);i++) { 
 		switch (map->dangers[i].action) {
@@ -401,12 +401,12 @@ void  mapMove(tMap* map) {
 			if (map->dangers[i].frame>4) {
 				map->dangers[i].frame=4;
 				map->dangers[i].action=eSpiWaitUp;
-				map->dangers[i].time=30;
+				map->dangers[i].more.time=30;
 			}
 			break;
 		case eSpiWaitUp:
-			map->dangers[i].time--;
-			if (!map->dangers[i].time) {
+			map->dangers[i].more.time--;
+			if (!map->dangers[i].more.time) {
 				map->dangers[i].action=eSpiDown;
 			}
 			break;
@@ -417,19 +417,19 @@ void  mapMove(tMap* map) {
 		case eChoInactive:
 			if (map->dangers[i].frame) map->dangers[i].frame++;
 			if (map->dangers[i].frame==6) map->dangers[i].frame=0;
-			map->dangers[i].time=1;
+			map->dangers[i].more.time=1;
 			break;
 		case eChoActive:
 			if (map->dangers[i].frame) {
 				map->dangers[i].frame++;
 			} else {
-				map->dangers[i].time--;
+				map->dangers[i].more.time--;
 			}
 			if (map->dangers[i].frame==6) {
 				map->dangers[i].frame=0;
-				map->dangers[i].time=10;
+				map->dangers[i].more.time=10;
 			}
-			if (!map->dangers[i].time) map->dangers[i].frame++;
+			if (!map->dangers[i].more.time) map->dangers[i].frame++;
 			break;
 		default:
 			break;