21 |
|
static double ogetflt(); |
22 |
|
static long ogetint(); |
23 |
|
static char *ogetstr(); |
24 |
< |
static int getobj(), octerror(); |
24 |
> |
static int nonsurfinset(); |
25 |
> |
static int getobj(), octerror(), skiptree(); |
26 |
|
static OCTREE getfullnode(), gettree(); |
27 |
|
|
28 |
|
static char *infn; /* input file name */ |
29 |
|
static FILE *infp; /* input file stream */ |
30 |
|
static int objsize; /* size of stored OBJECT's */ |
31 |
|
static OBJECT objorig; /* zeroeth object */ |
32 |
+ |
static OBJECT fnobjects; /* number of objects in this file */ |
33 |
|
static short otypmap[NUMOTYPE+8]; /* object type map */ |
34 |
|
|
35 |
|
|
40 |
|
CUBE *scene; |
41 |
|
char *ofn[]; |
42 |
|
{ |
41 |
– |
extern int fputs(); |
43 |
|
char sbuf[512]; |
44 |
|
int nf; |
44 |
– |
OBJECT fnobjects; |
45 |
|
register int i; |
46 |
|
long m; |
47 |
|
|
56 |
|
error(SYSTEM, errmsg); |
57 |
|
} |
58 |
|
} |
59 |
+ |
#ifdef MSDOS |
60 |
+ |
setmode(fileno(infp), O_BINARY); |
61 |
+ |
#endif |
62 |
|
/* get header */ |
63 |
< |
if (checkheader(infp, OCTFMT, load&IO_INFO ? stdout : NULL) < 0) |
63 |
> |
if (checkheader(infp, OCTFMT, load&IO_INFO ? stdout : (FILE *)NULL) < 0) |
64 |
|
octerror(USER, "not an octree"); |
65 |
|
/* check format */ |
66 |
|
if ((objsize = ogetint(2)-OCTMAGIC) <= 0 || |
110 |
|
if (nobjects != objorig+fnobjects) |
111 |
|
octerror(USER, "bad object count; octree stale?"); |
112 |
|
/* check for non-surfaces */ |
113 |
< |
if (nonsurfinset(objorig, fnobjects)) |
113 |
> |
if (dosets(nonsurfinset)) |
114 |
|
octerror(USER, "modifier in tree; octree stale?"); |
115 |
|
} |
116 |
|
fclose(infp); |
133 |
|
static OCTREE |
134 |
|
getfullnode() /* get a set, return fullnode */ |
135 |
|
{ |
136 |
< |
OBJECT set[MAXSET+1]; |
136 |
> |
OBJECT set[MAXSET+1]; |
137 |
|
register int i; |
138 |
|
register long m; |
139 |
|
|
166 |
|
ogetflt() /* get a floating point number */ |
167 |
|
{ |
168 |
|
extern double getflt(); |
169 |
< |
double r; |
169 |
> |
double r; |
170 |
|
|
171 |
|
r = getflt(infp); |
172 |
|
if (feof(infp)) |
178 |
|
static OCTREE |
179 |
|
gettree() /* get a pre-ordered octree */ |
180 |
|
{ |
181 |
< |
register OCTREE ot; |
181 |
> |
register OCTREE ot; |
182 |
|
register int i; |
183 |
|
|
184 |
|
switch (getc(infp)) { |
200 |
|
} |
201 |
|
|
202 |
|
|
203 |
+ |
static int |
204 |
+ |
nonsurfinset(os) /* check set for modifier */ |
205 |
+ |
register OBJECT *os; |
206 |
+ |
{ |
207 |
+ |
register OBJECT s; |
208 |
+ |
register int i; |
209 |
+ |
|
210 |
+ |
for (i = *os; i-- > 0; ) |
211 |
+ |
if ((s = *++os) >= objorig && s < objorig+fnobjects && |
212 |
+ |
ismodifier(objptr(s)->otype)) |
213 |
+ |
return(1); |
214 |
+ |
return(0); |
215 |
+ |
} |
216 |
+ |
|
217 |
+ |
|
218 |
|
static |
219 |
|
skiptree() /* skip octree on input */ |
220 |
|
{ |
224 |
|
case OT_EMPTY: |
225 |
|
return; |
226 |
|
case OT_FULL: |
227 |
< |
for (i = ogetint(objsize); i-- > 0; ) |
228 |
< |
ogetint(objsize); |
227 |
> |
for (i = ogetint(objsize)*objsize; i-- > 0; ) |
228 |
> |
if (getc(infp) == EOF) |
229 |
> |
octerror(USER, "truncated octree"); |
230 |
|
return; |
231 |
|
case OT_TREE: |
232 |
|
for (i = 0; i < 8; i++) |
247 |
|
int obj; |
248 |
|
register int i; |
249 |
|
register long m; |
250 |
< |
register OBJREC *objp; |
250 |
> |
register OBJREC *objp; |
251 |
|
|
252 |
|
i = ogetint(1); |
253 |
|
if (i == -1) |
273 |
|
objp->oargs.sarg[i] = savestr(ogetstr(sbuf)); |
274 |
|
} else |
275 |
|
objp->oargs.sarg = NULL; |
276 |
< |
#ifdef IARGS |
276 |
> |
#ifdef IARGS |
277 |
|
if (objp->oargs.niargs = ogetint(2)) { |
278 |
|
objp->oargs.iarg = (long *)bmalloc |
279 |
|
(objp->oargs.niargs*sizeof(long)); |
295 |
|
objp->oargs.farg = NULL; |
296 |
|
/* initialize */ |
297 |
|
objp->os = NULL; |
279 |
– |
objp->lastrno = -1; |
298 |
|
/* insert */ |
299 |
|
insertobject(obj); |
300 |
|
return(obj); |