--- ray/src/rt/ambient.c 2003/06/05 19:29:34 2.50 +++ ray/src/rt/ambient.c 2003/07/27 22:12:03 2.54 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: ambient.c,v 2.50 2003/06/05 19:29:34 schorsch Exp $"; +static const char RCSid[] = "$Id: ambient.c,v 2.54 2003/07/27 22:12:03 schorsch Exp $"; #endif /* * ambient.c - routines dealing with ambient (inter-reflected) component. @@ -9,6 +9,8 @@ static const char RCSid[] = "$Id: ambient.c,v 2.50 200 #include "copyright.h" +#include + #include "platform.h" #include "ray.h" #include "otypes.h" @@ -163,7 +165,9 @@ setambient() /* initialize calculation */ (flen - pos)/AMBVALSIZ); error(WARNING, errmsg); fseek(ambfp, pos, 0); +#ifndef _WIN32 /* XXX we need a replacement for that one */ ftruncate(fileno(ambfp), (off_t)pos); +#endif } } else if ((ambfp = fopen(ambfile, "w+")) != NULL) { initambfile(1); /* else create new file */ @@ -276,7 +280,7 @@ FVECT nrm; return; dumbamb: /* return global value */ copycolor(acol, ambval); - if (ambvwt <= 0 | navsum == 0) + if ((ambvwt <= 0) | (navsum == 0)) return; l = bright(ambval); /* average in computations */ if (l > FTINY) { @@ -525,7 +529,7 @@ register AMBVAL *aval; if ((av = newambval()) == NULL) error(SYSTEM, "out of memory in avstore"); - copystruct(av, aval); + *av = *aval; av->latick = ambclock; av->next = NULL; nambvals++; @@ -560,7 +564,7 @@ newambtree() /* allocate 8 ambient tree structs */ } atp = atfreelist; atfreelist = atp->kid; - bzero((char *)atp, 8*sizeof(AMBTREE)); + memset((char *)atp, '\0', 8*sizeof(AMBTREE)); return(atp); } @@ -737,7 +741,7 @@ int always; if (avlist2 != NULL) free((void *)avlist2); if (always) { /* rebuild without sorting */ - copystruct(&oldatrunk, &atrunk); + oldatrunk = atrunk; atrunk.alist = NULL; atrunk.kid = NULL; unloadatree(&oldatrunk, avinsert); @@ -768,14 +772,14 @@ int always; if (avlist1[i].p == NULL) continue; tap = avlist2[i]; - copystruct(&tav, tap); + tav = *tap; for (j = i; (pnext = avlist1[j].p) != tap; j = avlmemi(pnext)) { - copystruct(avlist2[j], pnext); + *(avlist2[j]) = *pnext; avinsert(avlist2[j]); avlist1[j].p = NULL; } - copystruct(avlist2[j], &tav); + *(avlist2[j]) = tav; avinsert(avlist2[j]); avlist1[j].p = NULL; } @@ -827,7 +831,7 @@ ambsync() /* synchronize ambient file */ /* see if file has grown */ if ((flen = lseek(fileno(ambfp), (off_t)0L, 2)) < 0) goto seekerr; - if (n = flen - lastpos) { /* file has grown */ + if ( (n = flen - lastpos) ) { /* file has grown */ if (ambinp == NULL) { /* use duplicate filedes */ ambinp = fdopen(dup(fileno(ambfp)), "r"); if (ambinp == NULL)