1 |
< |
/* Copyright (c) 1986 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1991 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
26 |
|
|
27 |
|
static char *infn; /* input file name */ |
28 |
|
static FILE *infp; /* input file stream */ |
29 |
+ |
static int objsize; /* size of stored OBJECT's */ |
30 |
|
static OBJECT objorig; /* zeroeth object */ |
31 |
|
static short otypmap[NUMOTYPE+8]; /* object type map */ |
32 |
|
|
38 |
|
CUBE *scene; |
39 |
|
char *ofn[]; |
40 |
|
{ |
41 |
+ |
extern int fputs(); |
42 |
|
char sbuf[512]; |
43 |
|
int nf; |
44 |
|
OBJECT fnobjects; |
56 |
|
} |
57 |
|
} |
58 |
|
/* get header */ |
59 |
< |
if (load & IO_INFO) |
60 |
< |
copyheader(infp, stdout); |
59 |
< |
else |
60 |
< |
getheader(infp, NULL); |
59 |
> |
if (checkheader(infp, OCTFMT, load&IO_INFO ? stdout : NULL) < 0) |
60 |
> |
octerror(USER, "not an octree"); |
61 |
|
/* check format */ |
62 |
< |
if (getint(2) != OCTMAGIC) |
63 |
< |
octerror(USER, "invalid octree format"); |
62 |
> |
if ((objsize = getint(2)-OCTMAGIC) <= 0 || |
63 |
> |
objsize > MAXOBJSIZ || objsize > sizeof(long)) |
64 |
> |
octerror(USER, "incompatible octree format"); |
65 |
|
/* get boundaries */ |
66 |
|
if (load & IO_BOUNDS) { |
67 |
|
for (i = 0; i < 3; i++) |
83 |
|
if (load & IO_FILES) |
84 |
|
ofn[nf] = NULL; |
85 |
|
/* get number of objects */ |
86 |
< |
fnobjects = getint(sizeof(OBJECT)); |
86 |
> |
fnobjects = getint(objsize); |
87 |
|
|
88 |
|
if (load & IO_TREE) { |
89 |
|
/* get the octree */ |
98 |
|
} |
99 |
|
while (getobj() != OVOID) |
100 |
|
; |
101 |
+ |
} else if (load & IO_SCENE) { /* consistency checks */ |
102 |
+ |
/* check object count */ |
103 |
+ |
if (nobjects != objorig+fnobjects) |
104 |
+ |
octerror(USER, "bad object count; octree stale?"); |
105 |
+ |
/* check for non-surfaces */ |
106 |
+ |
if (nonsurfinset(objorig, fnobjects)) |
107 |
+ |
octerror(USER, "non-surface in set; octree stale?"); |
108 |
|
} |
109 |
|
} |
110 |
|
fclose(infp); |
103 |
– |
/* consistency checks */ |
104 |
– |
if (load & IO_SCENE) { |
105 |
– |
/* check object count */ |
106 |
– |
if (nobjects != objorig+fnobjects) |
107 |
– |
octerror(USER, "bad object count; octree stale?"); |
108 |
– |
/* check for non-surfaces */ |
109 |
– |
if (nonsurfinset(objorig, fnobjects)) |
110 |
– |
octerror(USER, "non-surface in set; octree stale?"); |
111 |
– |
} |
111 |
|
return(nf); |
112 |
|
} |
113 |
|
|
133 |
|
{ |
134 |
|
OBJECT set[MAXSET+1]; |
135 |
|
register int i; |
136 |
+ |
register long m; |
137 |
|
|
138 |
< |
set[0] = getint(sizeof(OBJECT)); |
139 |
< |
if (set[0] > MAXSET) |
138 |
> |
m = getint(objsize); |
139 |
> |
if (m > MAXSET) |
140 |
|
octerror(USER, "bad set in getfullnode"); |
141 |
< |
for (i = 1; i <= set[0]; i++) |
142 |
< |
set[i] = getint(sizeof(OBJECT)) + objorig; |
141 |
> |
set[0] = m; |
142 |
> |
for (i = 1; i <= set[0]; i++) { |
143 |
> |
m = getint(objsize) + objorig; |
144 |
> |
if ((OBJECT)m != m) |
145 |
> |
octerror(USER, "too many objects"); |
146 |
> |
set[i] = m; |
147 |
> |
} |
148 |
|
return(fullnode(set)); |
149 |
|
} |
150 |
|
|
213 |
|
char sbuf[MAXSTR]; |
214 |
|
int obj; |
215 |
|
register int i; |
216 |
+ |
register long m; |
217 |
|
register OBJREC *objp; |
218 |
|
|
219 |
|
i = getint(1); |
224 |
|
objp = objptr(obj); |
225 |
|
if ((objp->otype = otypmap[i]) < 0) |
226 |
|
octerror(USER, "reference to unknown type"); |
227 |
< |
if ((objp->omod = getint(sizeof(OBJECT))) != OVOID) |
228 |
< |
objp->omod += objorig; |
227 |
> |
if ((m = getint(objsize)) != OVOID) { |
228 |
> |
m += objorig; |
229 |
> |
if ((OBJECT)m != m) |
230 |
> |
octerror(USER, "too many objects"); |
231 |
> |
} |
232 |
> |
objp->omod = m; |
233 |
|
objp->oname = savqstr(getstr(sbuf)); |
234 |
|
if (objp->oargs.nsargs = getint(2)) { |
235 |
|
objp->oargs.sarg = (char **)bmalloc |