--- ray/src/hd/rhdisp.c 1998/12/18 11:56:10 3.37 +++ ray/src/hd/rhdisp.c 1999/03/04 10:14:52 3.40 @@ -24,7 +24,8 @@ static char SCCSid[] = "$SunId$ SGI"; HOLO *hdlist[HDMAX+1]; /* global holodeck list */ -char *hdofn[HDMAX+1]; /* holodeck section octree list */ +char *hdgfn[HDMAX]; /* holodeck section geometry list */ +char *hdpfn[HDMAX]; /* section portal list */ char cmdlist[DC_NCMDS][8] = DC_INIT; @@ -154,6 +155,8 @@ disp_wait() /* wait for more input */ int n; register int i; /* see if we can avoid select call */ + if (hdlist[0] == NULL) + return(RDY_SRV); /* initialize first */ flgs = 0; /* flag what's ready already */ if (imm_mode || stdin->_cnt > 0) flgs |= RDY_SRV; @@ -195,9 +198,9 @@ disp_wait() /* wait for more input */ } -add_holo(hdg, ofn) /* register a new holodeck section */ +add_holo(hdg, gfn, pfn) /* register a new holodeck section */ HDGRID *hdg; -char *ofn; +char *gfn, *pfn; { VIEW nv; double d; @@ -212,7 +215,8 @@ char *ofn; error(SYSTEM, "out of memory in add_holo"); bcopy((char *)hdg, (char *)hdlist[hd], sizeof(HDGRID)); hdcompgrid(hdlist[hd]); - hdofn[hd] = savestr(ofn); + hdgfn[hd] = savestr(gfn); + hdpfn[hd] = pfn && *pfn ? savestr(pfn) : (char *)NULL; if (hd) return; /* set initial viewpoint */ @@ -267,7 +271,8 @@ register VIEW *v; static VIEW viewhist[VIEWHISTLEN]; static unsigned nhist; VIEW *dv; - int i, res[2], *slist; + int i, res[2]; + int2 *slist; char *err; /* restore previous view? */ if (v == NULL) { @@ -300,10 +305,10 @@ again: goto again; /* poss. overloading dev_section()? */ } DCHECK(*slist < 0, WARNING, "no visible sections in new_view"); - while (*slist >= 0) - dev_section(hdofn[*slist++]); + for ( ; *slist >= 0; slist++) + dev_section(hdgfn[*slist], hdpfn[*slist]); } - dev_section(NULL); /* end section list */ + dev_section(NULL,NULL); /* end section list */ dev_flush(); /* update display */ /* update server */ imm_mode = beam_sync(odev.firstuse) > 0; @@ -486,9 +491,10 @@ serv_result() /* get next server result and process disp_bundle((PACKHEAD *)buf); break; case DS_ADDHOLO: - if (msg.nbytes <= sizeof(HDGRID)) + if (msg.nbytes < sizeof(HDGRID)+2) error(INTERNAL, "bad holodeck record from server"); - add_holo((HDGRID *)buf, buf+sizeof(HDGRID)); + add_holo((HDGRID *)buf, buf+sizeof(HDGRID), + buf+sizeof(HDGRID)+strlen(buf+sizeof(HDGRID))+1); break; case DS_OUTSECT: do_outside = 1; @@ -499,6 +505,8 @@ serv_result() /* get next server result and process break; case DS_STARTIMM: case DS_ENDIMM: + if (!(imm_mode = msg.type==DS_STARTIMM)) + dev_flush(); #ifdef DEBUG { time_t tnow = time(NULL); @@ -507,8 +515,6 @@ serv_result() /* get next server result and process tmodesw = tnow; } #endif - if (!(imm_mode = msg.type==DS_STARTIMM)) - dev_flush(); goto noargs; case DS_ACKNOW: case DS_SHUTDOWN: @@ -579,7 +585,9 @@ register char *s; quit(code) /* clean up and exit */ int code; { + if (code) + exit(code); if (odev.v.type) dev_close(); - exit(code); + exit(0); }