| 24 |  |  | 
| 25 |  | HOLO    *hdlist[HDMAX+1];       /* global holodeck list */ | 
| 26 |  |  | 
| 27 | < | char    *hdofn[HDMAX+1];        /* holodeck section octree list */ | 
| 27 | > | char    *hdgfn[HDMAX];          /* holodeck section geometry list */ | 
| 28 | > | char    *hdpfn[HDMAX];          /* section portal list */ | 
| 29 |  |  | 
| 30 |  | char    cmdlist[DC_NCMDS][8] = DC_INIT; | 
| 31 |  |  | 
| 155 |  | int     n; | 
| 156 |  | register int    i; | 
| 157 |  | /* see if we can avoid select call */ | 
| 158 | + | if (hdlist[0] == NULL) | 
| 159 | + | return(RDY_SRV);        /* initialize first */ | 
| 160 |  | flgs = 0;               /* flag what's ready already */ | 
| 161 |  | if (imm_mode || stdin->_cnt > 0) | 
| 162 |  | flgs |= RDY_SRV; | 
| 198 |  | } | 
| 199 |  |  | 
| 200 |  |  | 
| 201 | < | add_holo(hdg, ofn)              /* register a new holodeck section */ | 
| 201 | > | add_holo(hdg, gfn, pfn)         /* register a new holodeck section */ | 
| 202 |  | HDGRID  *hdg; | 
| 203 | < | char    *ofn; | 
| 203 | > | char    *gfn, *pfn; | 
| 204 |  | { | 
| 205 |  | VIEW    nv; | 
| 206 |  | double  d; | 
| 215 |  | error(SYSTEM, "out of memory in add_holo"); | 
| 216 |  | bcopy((char *)hdg, (char *)hdlist[hd], sizeof(HDGRID)); | 
| 217 |  | hdcompgrid(hdlist[hd]); | 
| 218 | < | hdofn[hd] = savestr(ofn); | 
| 218 | > | hdgfn[hd] = savestr(gfn); | 
| 219 | > | hdpfn[hd] = pfn && *pfn ? savestr(pfn) : (char *)NULL; | 
| 220 |  | if (hd) | 
| 221 |  | return; | 
| 222 |  | /* set initial viewpoint */ | 
| 271 |  | static VIEW     viewhist[VIEWHISTLEN]; | 
| 272 |  | static unsigned nhist; | 
| 273 |  | VIEW    *dv; | 
| 274 | < | int     i, res[2], *slist; | 
| 274 | > | int     i, res[2]; | 
| 275 | > | int2    *slist; | 
| 276 |  | char    *err; | 
| 277 |  | /* restore previous view? */ | 
| 278 |  | if (v == NULL) { | 
| 305 |  | goto again;     /* poss. overloading dev_section()? */ | 
| 306 |  | } | 
| 307 |  | DCHECK(*slist < 0, WARNING, "no visible sections in new_view"); | 
| 308 | < | while (*slist >= 0) | 
| 309 | < | dev_section(hdofn[*slist++]); | 
| 308 | > | for ( ; *slist >= 0; slist++) | 
| 309 | > | dev_section(hdgfn[*slist], hdpfn[*slist]); | 
| 310 |  | } | 
| 311 | < | dev_section(NULL);      /* end section list */ | 
| 311 | > | dev_section(NULL,NULL); /* end section list */ | 
| 312 |  | dev_flush();            /* update display */ | 
| 313 |  | /* update server */ | 
| 314 |  | imm_mode = beam_sync(odev.firstuse) > 0; | 
| 491 |  | disp_bundle((PACKHEAD *)buf); | 
| 492 |  | break; | 
| 493 |  | case DS_ADDHOLO: | 
| 494 | < | if (msg.nbytes <= sizeof(HDGRID)) | 
| 494 | > | if (msg.nbytes < sizeof(HDGRID)+2) | 
| 495 |  | error(INTERNAL, "bad holodeck record from server"); | 
| 496 | < | add_holo((HDGRID *)buf, buf+sizeof(HDGRID)); | 
| 496 | > | add_holo((HDGRID *)buf, buf+sizeof(HDGRID), | 
| 497 | > | buf+sizeof(HDGRID)+strlen(buf+sizeof(HDGRID))+1); | 
| 498 |  | break; | 
| 499 |  | case DS_OUTSECT: | 
| 500 |  | do_outside = 1; | 
| 505 |  | break; | 
| 506 |  | case DS_STARTIMM: | 
| 507 |  | case DS_ENDIMM: | 
| 508 | + | if (!(imm_mode = msg.type==DS_STARTIMM)) | 
| 509 | + | dev_flush(); | 
| 510 |  | #ifdef DEBUG | 
| 511 |  | { | 
| 512 |  | time_t  tnow = time(NULL); | 
| 515 |  | tmodesw = tnow; | 
| 516 |  | } | 
| 517 |  | #endif | 
| 510 | – | if (!(imm_mode = msg.type==DS_STARTIMM)) | 
| 511 | – | dev_flush(); | 
| 518 |  | goto noargs; | 
| 519 |  | case DS_ACKNOW: | 
| 520 |  | case DS_SHUTDOWN: | 
| 585 |  | quit(code)                      /* clean up and exit */ | 
| 586 |  | int     code; | 
| 587 |  | { | 
| 588 | + | if (code) | 
| 589 | + | exit(code); | 
| 590 |  | if (odev.v.type) | 
| 591 |  | dev_close(); | 
| 592 | < | exit(code); | 
| 592 | > | exit(0); | 
| 593 |  | } |