Commits

iru  committed 4c51435 Draft

Make debug prints a compile-time thing, not runtime

  • Participants
  • Parent commits c261561

Comments (0)

Files changed (3)

 };
 
 extern Partsys *sys;
-extern int debug;
 #include "dat.h"
 #include "fns.h"
 
+enum {
+	Debug = 0,
+};
+
 void
 display(void)
 {
 void
 update(void)
 {
-	if(debug)
+	if(Debug)
 		printparts(sys);
 	timestep(sys);
 	
 #include "fns.h"
 
 Partsys *sys;
-int debug;
+
+enum {
+	Debug = 1
+};
 
 void*
 emalloc(ulong size)
 		v = &part->v;
 		a = &part->a;
 
-		if(debug)
+		if(Debug)
 			printf("motion: r(%g,%g,%g) a(%g,%g,%g)\n", r->x, r->y, r->z, a->x, a->y, a->z);
 	
 		/* velocity verlet */
 		k = sys->part[i].k;
 		if(sys->part[i].r.y+3*k >= sys->box[1].y ||
 			sys->part[i].r.y-3*k <= sys->box[0].y){
-			if(debug)
+			if(Debug)
 				printf("diff: %g\n", fabs(sys->part[i].r.y - sys->box[1].y));
 			if(fabs(sys->part[i].r.y - sys->box[1].y) < 4*k)
 				if(k > 0)
 		}
 		if(sys->part[i].r.x+3*k >= sys->box[1].x ||
 			sys->part[i].r.x-3*k <= sys->box[0].x){
-			if(debug)
+			if(Debug)
 				printf("diff: %g\n", fabs(sys->part[i].r.x - sys->box[1].x));
 			if(fabs(sys->part[i].r.x - sys->box[1].x) < 4*k)
 				if(k > 0)
 		vmin(&r, &max, &sys->box[1]);
 		vcopy(&sys->part[i].r, &r);
 		
-		if(debug)
+		if(Debug)
 			printf("cons: (%g,%g,%g)\n", r.x, r.y, r.z);
 		sys->part[i].k = k;
 	}
 		vcopy(&sys->part[i].a, &sys->grav);
 		sys->part[i].m = 1;
 		sys->part[i].k = k;
-		if(debug)
+		if(Debug)
 			printf("%d (%g,%g)\n", i, sys->part[i].r.x, sys->part[i].r.y);
 	}