--- ray/src/common/readoct.c 1991/10/23 11:53:38 1.14 +++ ray/src/common/readoct.c 1992/03/12 12:18:18 2.3 @@ -18,10 +18,10 @@ static char SCCSid[] = "$SunId$ LBL"; #include "otypes.h" -extern double atof(); static double getflt(); static long getint(); static char *getstr(); +static int getobj(), octerror(); static OCTREE getfullnode(), gettree(); static char *infn; /* input file name */ @@ -43,6 +43,7 @@ char *ofn[]; int nf; OBJECT fnobjects; register int i; + long m; if (fname == NULL) { infn = "standard input"; @@ -83,13 +84,15 @@ char *ofn[]; if (load & IO_FILES) ofn[nf] = NULL; /* get number of objects */ - fnobjects = getint(objsize); + fnobjects = m = getint(objsize); + if (fnobjects != m) + octerror(USER, "too many objects"); if (load & IO_TREE) { /* get the octree */ scene->cutree = gettree(); - /* get the scene */ - if (nf == 0 && load & IO_SCENE) { + if (load & IO_SCENE) /* get the scene */ + if (nf == 0) { for (i = 0; *getstr(sbuf); i++) if ((otypmap[i] = otype(sbuf)) < 0) { sprintf(errmsg, "unknown type \"%s\"", @@ -98,14 +101,14 @@ char *ofn[]; } while (getobj() != OVOID) ; - } else if (load & IO_SCENE) { /* consistency checks */ - /* check object count */ + } else { /* consistency checks */ + /* check object count */ if (nobjects != objorig+fnobjects) octerror(USER, "bad object count; octree stale?"); - /* check for non-surfaces */ + /* check for non-surfaces */ if (nonsurfinset(objorig, fnobjects)) - octerror(USER, "non-surface in set; octree stale?"); - } + octerror(USER, "modifier in tree; octree stale?"); + } } fclose(infp); return(nf); @@ -135,15 +138,12 @@ getfullnode() /* get a set, return fullnode */ register int i; register long m; - m = getint(objsize); - if (m > MAXSET) + if ((set[0] = getint(objsize)) > MAXSET) octerror(USER, "bad set in getfullnode"); - set[0] = m; for (i = 1; i <= set[0]; i++) { m = getint(objsize) + objorig; - if ((OBJECT)m != m) + if ((set[i] = m) != m) octerror(USER, "too many objects"); - set[i] = m; } return(fullnode(set)); } @@ -252,8 +252,8 @@ getobj() /* get next object */ objp->oargs.iarg = NULL; #endif if (objp->oargs.nfargs = getint(2)) { - objp->oargs.farg = (double *)bmalloc - (objp->oargs.nfargs*sizeof(double)); + objp->oargs.farg = (FLOAT *)bmalloc + (objp->oargs.nfargs*sizeof(FLOAT)); if (objp->oargs.farg == NULL) goto memerr; for (i = 0; i < objp->oargs.nfargs; i++)