101 |
|
sprintf(errmsg, "duplicate modifier '%s'", modn); |
102 |
|
error(USER, errmsg); |
103 |
|
} |
104 |
< |
if (nmods >= MAXMODLIST) |
105 |
< |
error(INTERNAL, "too many modifiers"); |
104 |
> |
if (nmods >= MAXMODLIST) { |
105 |
> |
sprintf(errmsg, "too many modifiers (%d limit)", MAXMODLIST); |
106 |
> |
error(INTERNAL, errmsg); |
107 |
> |
} |
108 |
|
if (!strcmp(modn, VOIDID)) { |
109 |
|
sprintf(errmsg, "cannot track '%s' modifier", VOIDID); |
110 |
|
error(USER, errmsg); |
133 |
|
error(SYSTEM, "out of memory in addmodifier"); |
134 |
|
mp->outspec = outf; /* XXX assumes static string */ |
135 |
|
mp->modname = modn; /* XXX assumes static string */ |
136 |
< |
mp->params = prms; |
136 |
> |
mp->params = prms; /* XXX assumes static string */ |
137 |
|
mp->binv = ebinv; |
138 |
+ |
mp->bin0 = 0; |
139 |
|
mp->nbins = bincnt; |
140 |
|
memset(mp->cbin, 0, sizeof(DCOLOR)*bincnt); |
141 |
< |
/* allocate output streams */ |
142 |
< |
for (i = bincnt; i-- > 0; ) |
143 |
< |
getostream(mp->outspec, mp->modname, i, 1); |
141 |
> |
/* figure out starting bin */ |
142 |
> |
while (!getostream(mp->outspec, mp->modname, mp->bin0, 1)) |
143 |
> |
mp->bin0++; |
144 |
> |
/* allocate other output streams */ |
145 |
> |
for (i = 0; ++i < mp->nbins; ) |
146 |
> |
getostream(mp->outspec, mp->modname, mp->bin0+i, 1); |
147 |
|
lep->data = (char *)mp; |
148 |
|
return(mp); |
149 |
|
} |
156 |
|
char *mname[MAXMODLIST]; |
157 |
|
int i; |
158 |
|
/* find the file & store strings */ |
159 |
< |
if (wordfile(mname, getpath(fname, getrlibpath(), R_OK)) < 0) { |
159 |
> |
i = wordfile(mname, MAXMODLIST, getpath(fname, getrlibpath(), R_OK)); |
160 |
> |
if (i < 0) { |
161 |
|
sprintf(errmsg, "cannot find modifier file '%s'", fname); |
162 |
|
error(SYSTEM, errmsg); |
163 |
|
} |
164 |
+ |
if (i >= MAXMODLIST-1) { |
165 |
+ |
sprintf(errmsg, "too many modifiers (%d limit) in file '%s'", |
166 |
+ |
MAXMODLIST-1, fname); |
167 |
+ |
error(INTERNAL, errmsg); |
168 |
+ |
} |
169 |
|
for (i = 0; mname[i]; i++) /* add each one */ |
170 |
|
addmodifier(mname[i], outf, prms, binv, bincnt); |
171 |
|
} |
184 |
|
|
185 |
|
/* Initialize our process(es) */ |
186 |
|
static void |
187 |
< |
rcinit() |
187 |
> |
rcinit(void) |
188 |
|
{ |
189 |
|
int i; |
190 |
|
|
305 |
|
|
306 |
|
/* Accumulate and/or output ray contributions (child or only process) */ |
307 |
|
static void |
308 |
< |
done_contrib() |
308 |
> |
done_contrib(void) |
309 |
|
{ |
310 |
|
MODCONT *mp; |
311 |
|
int i; |
326 |
|
|
327 |
|
/* Principal calculation loop (called by main) */ |
328 |
|
void |
329 |
< |
rcontrib() |
329 |
> |
rcontrib(void) |
330 |
|
{ |
331 |
|
static int ignore_warning_given = 0; |
332 |
|
FVECT orig, direc; |