12 |
|
#include "rhdisp.h" |
13 |
|
#include "rhdriver.h" |
14 |
|
|
15 |
+ |
#ifndef MAXDIST |
16 |
+ |
#define MAXDIST 13 /* maximum distance outside section */ |
17 |
+ |
#endif |
18 |
+ |
|
19 |
|
extern GCOORD *getviewcells(); |
20 |
|
|
21 |
|
static VIEW dvw; /* current view corresponding to beam list */ |
162 |
|
} |
163 |
|
|
164 |
|
|
165 |
+ |
cbeamadj(v, hr, vr) /* adjust our beam list */ |
166 |
+ |
VIEW *v; |
167 |
+ |
int hr, vr; |
168 |
+ |
{ |
169 |
+ |
register PACKHEAD *pa; |
170 |
+ |
register int i; |
171 |
+ |
int n; |
172 |
+ |
/* first handle additions */ |
173 |
+ |
pa = (PACKHEAD *)malloc(xcbeams*sizeof(PACKHEAD)); |
174 |
+ |
if (xcbeams && pa == NULL) |
175 |
+ |
goto memerr; |
176 |
+ |
for (i = xcbeams; i--; ) { |
177 |
+ |
pa[i].hd = cbeam[ncbeams+i].hd; |
178 |
+ |
pa[i].bi = cbeam[ncbeams+i].bi; |
179 |
+ |
pa[i].nr = npixels(v, hr, vr, hdlist[pa[i].hd], pa[i].bi); |
180 |
+ |
} |
181 |
+ |
n = xcbeams; /* now sort list for deletions */ |
182 |
+ |
cbeamsort(0); |
183 |
+ |
pa = (PACKHEAD *)realloc((char *)pa, (n+xcbeams)*sizeof(PACKHEAD)); |
184 |
+ |
if (n+xcbeams && pa == NULL) |
185 |
+ |
goto memerr; |
186 |
+ |
for (i = xcbeams; i--; ) { |
187 |
+ |
pa[n+i].hd = cbeam[ncbeams+i].hd; |
188 |
+ |
pa[n+i].bi = cbeam[ncbeams+i].bi; |
189 |
+ |
pa[n+i].nr = 0; |
190 |
+ |
} |
191 |
+ |
n += xcbeams; |
192 |
+ |
xcbeams = 0; /* delete orphans */ |
193 |
+ |
serv_request(DR_ADJSET, n*sizeof(PACKHEAD), (char *)pa); |
194 |
+ |
free((char *)pa); |
195 |
+ |
return; |
196 |
+ |
memerr: |
197 |
+ |
error(SYSTEM, "out of memory in cbeamadj"); |
198 |
+ |
} |
199 |
+ |
|
200 |
+ |
|
201 |
|
cbeamop(op, bl, n, v, hr, vr) /* update beams on server list */ |
202 |
|
int op; |
203 |
|
register struct beamcomp *bl; |
299 |
|
n++; |
300 |
|
} |
301 |
|
} |
302 |
+ |
/* check for really stupid move */ |
303 |
+ |
if (bestd > MAXDIST) { |
304 |
+ |
error(WARNING, "move to outer solar system"); |
305 |
+ |
return(0); |
306 |
+ |
} |
307 |
|
/* warn of dangerous moves */ |
308 |
|
if (n < lastn && bestd >= lastd) |
309 |
|
error(WARNING, "moving outside holodeck section"); |
451 |
|
} |
452 |
|
|
453 |
|
|
454 |
< |
beam_view(vn) /* change beam view */ |
454 |
> |
beam_view(vn) /* change beam view (if advisable) */ |
455 |
|
VIEW *vn; |
456 |
|
{ |
457 |
|
struct cellact ca; |
463 |
|
cbeamop(DR_DELSET, cbeam, ncbeams, NULL, 0, 0); |
464 |
|
ncbeams = 0; |
465 |
|
copystruct(&dvw, vn); |
466 |
< |
return; |
466 |
> |
return(1); |
467 |
|
} |
468 |
|
/* find our new voxels */ |
469 |
|
n = get_voxels(vlnew, vn->vp); |
470 |
+ |
if (dvw.type && !n) { |
471 |
+ |
copystruct(vn, &dvw); /* cancel move */ |
472 |
+ |
return(0); |
473 |
+ |
} |
474 |
|
/* set the new voxels */ |
475 |
|
comn = set_voxels(vlnew, n); |
476 |
|
if (!dvw.type) |
481 |
|
mvview(ca.vi, &dvw, vn); |
482 |
|
else /* else add all new cells */ |
483 |
|
doview(&ca, vn); |
484 |
+ |
#if 1 |
485 |
+ |
cbeamadj(vn, odev.hres, odev.vres); |
486 |
+ |
#else |
487 |
|
/* inform server of new beams */ |
488 |
|
cbeamop(DR_ADDSET, cbeam+ncbeams, xcbeams, vn, odev.hres, odev.vres); |
489 |
|
/* sort list to put orphans at end */ |
491 |
|
/* tell server to delete orphans */ |
492 |
|
cbeamop(DR_DELSET, cbeam+ncbeams, xcbeams, NULL, 0, 0); |
493 |
|
xcbeams = 0; /* truncate our list */ |
494 |
+ |
#endif |
495 |
|
copystruct(&dvw, vn); /* record new view */ |
496 |
+ |
return(1); |
497 |
|
} |