| 1 |
< |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
| 1 |
> |
/* Copyright (c) 1999 Silicon Graphics, Inc. */ |
| 2 |
|
|
| 3 |
|
#ifndef lint |
| 4 |
|
static char SCCSid[] = "$SunId$ SGI"; |
| 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 |
|
|
| 40 |
|
FILE *sstdin, *sstdout; /* server's standard input and output */ |
| 41 |
|
|
| 42 |
|
#ifdef DEBUG |
| 42 |
– |
#include <sys/types.h> |
| 43 |
|
extern time_t time(); |
| 44 |
|
static time_t tmodesw; |
| 45 |
|
static time_t timm, tadd; |
| 154 |
|
int n; |
| 155 |
|
register int i; |
| 156 |
|
/* see if we can avoid select call */ |
| 157 |
+ |
if (hdlist[0] == NULL) |
| 158 |
+ |
return(RDY_SRV); /* initialize first */ |
| 159 |
|
flgs = 0; /* flag what's ready already */ |
| 160 |
|
if (imm_mode || stdin->_cnt > 0) |
| 161 |
|
flgs |= RDY_SRV; |
| 197 |
|
} |
| 198 |
|
|
| 199 |
|
|
| 200 |
< |
add_holo(hdg, ofn) /* register a new holodeck section */ |
| 200 |
> |
add_holo(hdg, gfn, pfn) /* register a new holodeck section */ |
| 201 |
|
HDGRID *hdg; |
| 202 |
< |
char *ofn; |
| 202 |
> |
char *gfn, *pfn; |
| 203 |
|
{ |
| 204 |
|
VIEW nv; |
| 205 |
|
double d; |
| 214 |
|
error(SYSTEM, "out of memory in add_holo"); |
| 215 |
|
bcopy((char *)hdg, (char *)hdlist[hd], sizeof(HDGRID)); |
| 216 |
|
hdcompgrid(hdlist[hd]); |
| 217 |
< |
hdofn[hd] = savestr(ofn); |
| 217 |
> |
hdgfn[hd] = savestr(gfn); |
| 218 |
> |
hdpfn[hd] = pfn && *pfn ? savestr(pfn) : (char *)NULL; |
| 219 |
|
if (hd) |
| 220 |
|
return; |
| 221 |
|
/* set initial viewpoint */ |
| 270 |
|
static VIEW viewhist[VIEWHISTLEN]; |
| 271 |
|
static unsigned nhist; |
| 272 |
|
VIEW *dv; |
| 273 |
< |
int i, res[2], *slist; |
| 273 |
> |
int i, res[2]; |
| 274 |
> |
int2 *slist; |
| 275 |
|
char *err; |
| 276 |
|
/* restore previous view? */ |
| 277 |
|
if (v == NULL) { |
| 304 |
|
goto again; /* poss. overloading dev_section()? */ |
| 305 |
|
} |
| 306 |
|
DCHECK(*slist < 0, WARNING, "no visible sections in new_view"); |
| 307 |
< |
while (*slist >= 0) |
| 308 |
< |
dev_section(hdofn[*slist++]); |
| 307 |
> |
for ( ; *slist >= 0; slist++) |
| 308 |
> |
dev_section(hdgfn[*slist], hdpfn[*slist]); |
| 309 |
|
} |
| 310 |
< |
dev_section(NULL); /* end section list */ |
| 310 |
> |
dev_section(NULL,NULL); /* end section list */ |
| 311 |
|
dev_flush(); /* update display */ |
| 312 |
|
/* update server */ |
| 313 |
|
imm_mode = beam_sync(odev.firstuse) > 0; |
| 490 |
|
disp_bundle((PACKHEAD *)buf); |
| 491 |
|
break; |
| 492 |
|
case DS_ADDHOLO: |
| 493 |
< |
if (msg.nbytes <= sizeof(HDGRID)) |
| 493 |
> |
if (msg.nbytes < sizeof(HDGRID)+2) |
| 494 |
|
error(INTERNAL, "bad holodeck record from server"); |
| 495 |
< |
add_holo((HDGRID *)buf, buf+sizeof(HDGRID)); |
| 495 |
> |
add_holo((HDGRID *)buf, buf+sizeof(HDGRID), |
| 496 |
> |
buf+sizeof(HDGRID)+strlen(buf+sizeof(HDGRID))+1); |
| 497 |
|
break; |
| 498 |
|
case DS_OUTSECT: |
| 499 |
|
do_outside = 1; |
| 504 |
|
break; |
| 505 |
|
case DS_STARTIMM: |
| 506 |
|
case DS_ENDIMM: |
| 507 |
+ |
if (!(imm_mode = msg.type==DS_STARTIMM)) |
| 508 |
+ |
dev_flush(); |
| 509 |
|
#ifdef DEBUG |
| 510 |
|
{ |
| 511 |
|
time_t tnow = time(NULL); |
| 514 |
|
tmodesw = tnow; |
| 515 |
|
} |
| 516 |
|
#endif |
| 510 |
– |
if (!(imm_mode = msg.type==DS_STARTIMM)) |
| 511 |
– |
dev_flush(); |
| 517 |
|
goto noargs; |
| 518 |
|
case DS_ACKNOW: |
| 519 |
|
case DS_SHUTDOWN: |
| 584 |
|
quit(code) /* clean up and exit */ |
| 585 |
|
int code; |
| 586 |
|
{ |
| 587 |
+ |
if (code) |
| 588 |
+ |
exit(code); |
| 589 |
|
if (odev.v.type) |
| 590 |
|
dev_close(); |
| 591 |
< |
exit(code); |
| 591 |
> |
exit(0); |
| 592 |
|
} |