22 |
|
|
23 |
|
VIEWPOINT cureye; /* current eye position */ |
24 |
|
|
25 |
+ |
static int newcbeam(void); |
26 |
+ |
static int cbeamcmp(const void *cb1, const void *cb2); |
27 |
+ |
static int cbeamcmp2(const void *cb1, const void *cb2); |
28 |
+ |
static int findcbeam(int hd, int bi); |
29 |
+ |
static int getcbeam(int hd, int bi); |
30 |
+ |
static void cbeamsort(int adopt); |
31 |
|
|
32 |
< |
int |
33 |
< |
newcbeam() /* allocate new entry at end of cbeam array */ |
32 |
> |
|
33 |
> |
static int |
34 |
> |
newcbeam(void) /* allocate new entry at end of cbeam array */ |
35 |
|
{ |
36 |
|
int i; |
37 |
|
|
50 |
|
} |
51 |
|
|
52 |
|
|
53 |
< |
int |
54 |
< |
cbeamcmp(cb1, cb2) /* compare two cbeam entries for sort: keep orphans */ |
55 |
< |
register PACKHEAD *cb1, *cb2; |
53 |
> |
static int |
54 |
> |
cbeamcmp( /* compare two cbeam entries for sort: keep orphans */ |
55 |
> |
const void *cb1, |
56 |
> |
const void *cb2 |
57 |
> |
) |
58 |
|
{ |
59 |
< |
register int c; |
59 |
> |
int c; |
60 |
|
|
61 |
< |
if ((c = cb1->bi - cb2->bi)) /* sort on beam index first */ |
61 |
> |
if ((c = ((PACKHEAD*)cb1)->bi - ((PACKHEAD*)cb2)->bi)) /* sort on beam index first */ |
62 |
|
return(c); |
63 |
< |
return(cb1->hd - cb2->hd); /* use hd to resolve matches */ |
63 |
> |
return(((PACKHEAD*)cb1)->hd - ((PACKHEAD*)cb2)->hd); /* use hd to resolve matches */ |
64 |
|
} |
65 |
|
|
66 |
|
|
67 |
< |
int |
68 |
< |
cbeamcmp2(cb1, cb2) /* compare two cbeam entries for sort: no orphans */ |
69 |
< |
register PACKHEAD *cb1, *cb2; |
67 |
> |
static int |
68 |
> |
cbeamcmp2( /* compare two cbeam entries for sort: no orphans */ |
69 |
> |
const void *cb1, |
70 |
> |
const void *cb2 |
71 |
> |
) |
72 |
|
{ |
73 |
< |
register int c; |
73 |
> |
int c; |
74 |
|
|
75 |
< |
if (!cb1->nr) /* put orphans at the end, unsorted */ |
76 |
< |
return(cb2->nr); |
77 |
< |
if (!cb2->nr) |
75 |
> |
if (!((PACKHEAD*)cb1)->nr) /* put orphans at the end, unsorted */ |
76 |
> |
return(((PACKHEAD*)cb2)->nr); |
77 |
> |
if (!((PACKHEAD*)cb2)->nr) |
78 |
|
return(-1); |
79 |
< |
if ((c = cb1->bi - cb2->bi)) /* sort on beam index first */ |
79 |
> |
if ((c = ((PACKHEAD*)cb1)->bi - ((PACKHEAD*)cb2)->bi)) /* sort on beam index first */ |
80 |
|
return(c); |
81 |
< |
return(cb1->hd - cb2->hd); /* use hd to resolve matches */ |
81 |
> |
return(((PACKHEAD*)cb1)->hd - ((PACKHEAD*)cb2)->hd); /* use hd to resolve matches */ |
82 |
|
} |
83 |
|
|
84 |
|
|
85 |
< |
int |
86 |
< |
findcbeam(hd, bi) /* find the specified beam in our sorted list */ |
87 |
< |
int hd, bi; |
85 |
> |
static int |
86 |
> |
findcbeam( /* find the specified beam in our sorted list */ |
87 |
> |
int hd, |
88 |
> |
int bi |
89 |
> |
) |
90 |
|
{ |
91 |
|
PACKHEAD cb; |
92 |
< |
register PACKHEAD *p; |
92 |
> |
PACKHEAD *p; |
93 |
|
|
94 |
|
if (ncbeams <= 0) |
95 |
|
return(-1); |
102 |
|
} |
103 |
|
|
104 |
|
|
105 |
< |
int |
106 |
< |
getcbeam(hd, bi) /* get the specified beam, allocating as necessary */ |
107 |
< |
register int hd; |
108 |
< |
int bi; |
105 |
> |
static int |
106 |
> |
getcbeam( /* get the specified beam, allocating as necessary */ |
107 |
> |
int hd, |
108 |
> |
int bi |
109 |
> |
) |
110 |
|
{ |
111 |
< |
register int n; |
111 |
> |
int n; |
112 |
|
/* first, look in sorted list */ |
113 |
|
if ((n = findcbeam(hd, bi)) >= 0) |
114 |
|
return(n); |
117 |
|
if (cbeam[n].bi == bi && cbeam[n].hd == hd) |
118 |
|
return(n); |
119 |
|
/* check legality */ |
120 |
< |
if (hd < 0 | hd >= HDMAX || hdlist[hd] == NULL) |
120 |
> |
if ((hd < 0) | (hd >= HDMAX) || hdlist[hd] == NULL) |
121 |
|
error(INTERNAL, "illegal holodeck number in getcbeam"); |
122 |
< |
if (bi < 1 | bi > nbeams(hdlist[hd])) |
122 |
> |
if ((bi < 1) | (bi > nbeams(hdlist[hd]))) |
123 |
|
error(INTERNAL, "illegal beam index in getcbeam"); |
124 |
|
n = newcbeam(); /* allocate and assign */ |
125 |
|
cbeam[n].hd = hd; cbeam[n].bi = bi; cbeam[n].nr = cbeam[n].nc = 0; |
127 |
|
} |
128 |
|
|
129 |
|
|
130 |
< |
cbeamsort(adopt) /* sort our beam list, possibly turning out orphans */ |
131 |
< |
int adopt; |
130 |
> |
static void |
131 |
> |
cbeamsort( /* sort our beam list, possibly turning out orphans */ |
132 |
> |
int adopt |
133 |
> |
) |
134 |
|
{ |
135 |
< |
register int i; |
135 |
> |
int i; |
136 |
|
|
137 |
|
if (!(ncbeams += xcbeams)) |
138 |
|
return; |
149 |
|
} |
150 |
|
|
151 |
|
|
152 |
< |
beam_init(fresh) /* clear beam list for new view(s) */ |
153 |
< |
int fresh; |
152 |
> |
void |
153 |
> |
beam_init( /* clear beam list for new view(s) */ |
154 |
> |
int fresh |
155 |
> |
) |
156 |
|
{ |
157 |
< |
register int i; |
157 |
> |
int i; |
158 |
|
|
159 |
|
if (fresh) /* discard old beams? */ |
160 |
|
ncbeams = xcbeams = 0; |
165 |
|
} |
166 |
|
|
167 |
|
|
168 |
< |
int2 * |
169 |
< |
beam_view(vn, hr, vr) /* add beam view (if advisable) */ |
170 |
< |
VIEW *vn; |
171 |
< |
int hr, vr; |
168 |
> |
int16 * |
169 |
> |
beam_view( /* add beam view (if advisable) */ |
170 |
> |
VIEW *vn, |
171 |
> |
int hr, |
172 |
> |
int vr |
173 |
> |
) |
174 |
|
{ |
175 |
< |
int2 *slist; |
175 |
> |
int16 *slist; |
176 |
|
BEAMLIST blist; |
177 |
|
double eravg, d; |
178 |
< |
register HOLO *hp; |
179 |
< |
register int i, n; |
178 |
> |
HOLO *hp; |
179 |
> |
int i, n; |
180 |
|
/* compute beams for view */ |
181 |
|
slist = viewbeams(vn, hr, vr, &blist); |
182 |
|
if (*slist < 0) { |
217 |
|
|
218 |
|
|
219 |
|
int |
220 |
< |
beam_sync(all) /* update beam list on server */ |
221 |
< |
int all; |
220 |
> |
beam_sync( /* update beam list on server */ |
221 |
> |
int all |
222 |
> |
) |
223 |
|
{ |
224 |
|
/* set new eye position */ |
225 |
|
serv_request(DR_VIEWPOINT, sizeof(VIEWPOINT), (char *)&cureye); |
229 |
|
if (all) { |
230 |
|
if (ncbeams > 0) |
231 |
|
serv_request(DR_NEWSET, |
232 |
< |
ncbeams*sizeof(PACKHEAD), cbeam); |
232 |
> |
ncbeams*sizeof(PACKHEAD), (char *)cbeam); |
233 |
|
} else { |
234 |
|
if (ncbeams+xcbeams > 0) |
235 |
|
serv_request(DR_ADJSET, |
236 |
< |
(ncbeams+xcbeams)*sizeof(PACKHEAD), cbeam); |
236 |
> |
(ncbeams+xcbeams)*sizeof(PACKHEAD), (char *)cbeam); |
237 |
|
} |
238 |
|
xcbeams = 0; /* truncate our list */ |
239 |
|
return(ncbeams); |
240 |
|
} |
241 |
|
|
242 |
|
|
243 |
< |
gridlines(f) /* run through holodeck section grid lines */ |
244 |
< |
int (*f)(); |
243 |
> |
void |
244 |
> |
gridlines( /* run through holodeck section grid lines */ |
245 |
> |
void (*f)(FVECT wp[2]) |
246 |
> |
) |
247 |
|
{ |
248 |
< |
register int hd, w, i; |
248 |
> |
int hd, w, i; |
249 |
|
int g0, g1; |
250 |
|
FVECT wp[2], mov; |
251 |
|
double d; |