ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/rhdisp.c
(Generate patch)

Comparing ray/src/hd/rhdisp.c (file contents):
Revision 3.37 by gwlarson, Fri Dec 18 11:56:10 1998 UTC vs.
Revision 3.42 by gwlarson, Thu Jul 29 15:38:40 1999 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1998 Silicon Graphics, Inc. */
1 > /* Copyright (c) 1999 Silicon Graphics, Inc. */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ SGI";
# Line 22 | Line 22 | static char SCCSid[] = "$SunId$ SGI";
22   #define FSIZDEF         0.125   /* default focus frame size */
23   #endif
24  
25 + #ifdef linux
26 + #define fbufcnt(f)      ((f)->_IO_read_end - (f)->_IO_read_ptr)
27 + #else
28 + #define fbufcnt(f)      ((f)->_cnt)
29 + #endif
30 +
31   HOLO    *hdlist[HDMAX+1];       /* global holodeck list */
32  
33 < char    *hdofn[HDMAX+1];        /* holodeck section octree list */
33 > char    *hdgfn[HDMAX];          /* holodeck section geometry list */
34 > char    *hdpfn[HDMAX];          /* section portal list */
35  
36   char    cmdlist[DC_NCMDS][8] = DC_INIT;
37  
# Line 39 | Line 46 | char   *progname;              /* global argv[0] */
46   FILE    *sstdin, *sstdout;      /* server's standard input and output */
47  
48   #ifdef DEBUG
42 #include <sys/types.h>
49   extern time_t   time();
50   static time_t   tmodesw;
51   static time_t   timm, tadd;
# Line 154 | Line 160 | disp_wait()                    /* wait for more input */
160          int     n;
161          register int    i;
162                                  /* see if we can avoid select call */
163 +        if (hdlist[0] == NULL)
164 +                return(RDY_SRV);        /* initialize first */
165          flgs = 0;               /* flag what's ready already */
166 <        if (imm_mode || stdin->_cnt > 0)
166 >        if (imm_mode || fbufcnt(stdin) > 0)
167                  flgs |= RDY_SRV;
168 <        if (sstdin != NULL && sstdin->_cnt > 0)
168 >        if (sstdin != NULL && fbufcnt(sstdin) > 0)
169                  flgs |= RDY_SIN;
170          if (odev.inpready)
171                  flgs |= RDY_DEV;
# Line 195 | Line 203 | disp_wait()                    /* wait for more input */
203   }
204  
205  
206 < add_holo(hdg, ofn)              /* register a new holodeck section */
206 > add_holo(hdg, gfn, pfn)         /* register a new holodeck section */
207   HDGRID  *hdg;
208 < char    *ofn;
208 > char    *gfn, *pfn;
209   {
210          VIEW    nv;
211          double  d;
# Line 212 | Line 220 | char   *ofn;
220                  error(SYSTEM, "out of memory in add_holo");
221          bcopy((char *)hdg, (char *)hdlist[hd], sizeof(HDGRID));
222          hdcompgrid(hdlist[hd]);
223 <        hdofn[hd] = savestr(ofn);
223 >        hdgfn[hd] = savestr(gfn);
224 >        hdpfn[hd] = pfn && *pfn ? savestr(pfn) : (char *)NULL;
225          if (hd)
226                  return;
227                                          /* set initial viewpoint */
# Line 267 | Line 276 | register VIEW  *v;
276          static VIEW     viewhist[VIEWHISTLEN];
277          static unsigned nhist;
278          VIEW    *dv;
279 <        int     i, res[2], *slist;
279 >        int     i, res[2];
280 >        int2    *slist;
281          char    *err;
282                                  /* restore previous view? */
283          if (v == NULL) {
# Line 300 | Line 310 | again:
310                          goto again;     /* poss. overloading dev_section()? */
311                  }
312                  DCHECK(*slist < 0, WARNING, "no visible sections in new_view");
313 <                while (*slist >= 0)
314 <                        dev_section(hdofn[*slist++]);
313 >                for ( ; *slist >= 0; slist++)
314 >                        dev_section(hdgfn[*slist], hdpfn[*slist]);
315          }
316 <        dev_section(NULL);      /* end section list */
316 >        dev_section(NULL,NULL); /* end section list */
317          dev_flush();            /* update display */
318                                  /* update server */
319          imm_mode = beam_sync(odev.firstuse) > 0;
# Line 486 | Line 496 | serv_result()                  /* get next server result and process
496                  disp_bundle((PACKHEAD *)buf);
497                  break;
498          case DS_ADDHOLO:
499 <                if (msg.nbytes <= sizeof(HDGRID))
499 >                if (msg.nbytes < sizeof(HDGRID)+2)
500                          error(INTERNAL, "bad holodeck record from server");
501 <                add_holo((HDGRID *)buf, buf+sizeof(HDGRID));
501 >                add_holo((HDGRID *)buf, buf+sizeof(HDGRID),
502 >                        buf+sizeof(HDGRID)+strlen(buf+sizeof(HDGRID))+1);
503                  break;
504          case DS_OUTSECT:
505                  do_outside = 1;
# Line 499 | Line 510 | serv_result()                  /* get next server result and process
510                  break;
511          case DS_STARTIMM:
512          case DS_ENDIMM:
513 +                if (!(imm_mode = msg.type==DS_STARTIMM))
514 +                        dev_flush();
515   #ifdef DEBUG
516                  {
517                          time_t  tnow = time(NULL);
# Line 507 | Line 520 | serv_result()                  /* get next server result and process
520                          tmodesw = tnow;
521                  }
522   #endif
510                if (!(imm_mode = msg.type==DS_STARTIMM))
511                        dev_flush();
523                  goto noargs;
524          case DS_ACKNOW:
525          case DS_SHUTDOWN:
# Line 579 | Line 590 | register char  *s;
590   quit(code)                      /* clean up and exit */
591   int     code;
592   {
593 +        if (code)
594 +                exit(code);
595          if (odev.v.type)
596                  dev_close();
597 <        exit(code);
597 >        exit(0);
598   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines