--- ray/src/common/readoct.c 1989/09/19 13:40:48 1.6 +++ ray/src/common/readoct.c 1991/02/07 11:00:42 1.11 @@ -18,11 +18,11 @@ static char SCCSid[] = "$SunId$ LBL"; #include "otypes.h" -double atof(); -double getflt(); -long getint(); -char *getstr(); -OCTREE getfullnode(), gettree(); +extern double atof(); +static double getflt(); +static long getint(); +static char *getstr(); +static OCTREE getfullnode(), gettree(); static char *infn; /* input file name */ static FILE *infp; /* input file stream */ @@ -37,8 +37,9 @@ int load; CUBE *scene; char *ofn[]; { - char sbuf[128]; + char sbuf[512]; int nf; + OBJECT fnobjects; register int i; if (fname == NULL) { @@ -80,6 +81,8 @@ char *ofn[]; } if (load & IO_FILES) ofn[nf] = NULL; + /* get number of objects */ + fnobjects = getint(sizeof(OBJECT)); if (load & IO_TREE) { /* get the octree */ @@ -97,6 +100,15 @@ char *ofn[]; } } fclose(infp); + /* consistency checks */ + if (load & IO_SCENE) { + /* check object count */ + if (nobjects != objorig+fnobjects) + octerror(USER, "bad object count; octree stale?"); + /* check for non-surfaces */ + if (nonsurfinset(objorig, fnobjects)) + octerror(USER, "non-surface in set; octree stale?"); + } return(nf); } @@ -161,7 +173,7 @@ getflt() /* get a floating point number */ double d; d = (double)getint(4)/0x7fffffff; - return(ldexp(d, getint(1))); + return(ldexp(d, (int)getint(1))); }