Debian Codegraph @

Descent3/SmallViews.cpp

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/main/SmallViews.cpp $
21 * $Revision: 33 $
22 * $Date: 4/19/00 5:07p $
23 * $Author: Matt $
24 *
25 * System to draw small 3D views on the screen
26 *
27 * $Log: /DescentIII/main/SmallViews.cpp $
28 *
29 * 33 4/19/00 5:07p Matt
30 * From Duane for 1.4
31 * Added checks, asserts, and fixes for bad return values
32 *
33 * 32 4/06/00 9:25a Matt
34 * Fixed a screen clear problem on at ATI Rage Fury Maxx in dual-chip mode
35 * by forcing the screen to clear four times (instead of three).
36 *
37 * 31 5/17/99 11:19a Samir
38 * scale small views in full hud when shrinking screen.
39 *
40 * 30 5/08/99 1:06a Samir
41 * shrink font according to screen size.
42 *
43 * 29 5/01/99 12:41a Matt
44 * Added static when a small viewer object dies.
45 *
46 * 28 4/29/99 2:00a Jason
47 * fixed guided missile zbuffer problem
48 *
49 * 27 4/19/99 1:31p Matt
50 * Made guided missile small view use title and crosshairs flag, instead
51 * of doing special check for guided missile.
52 *
53 * 26 4/14/99 3:57a Jeff
54 * fixed case mismatch in #includes
55 *
56 * 25 4/12/99 1:10a Matt
57 * Added labels for small views.
58 *
59 * 24 3/31/99 3:01p Jason
60 * fixed bug with guided missile
61 *
62 * 23 3/22/99 4:26p Samir
63 * added toggles for guided missile view and reticle.
64 *
65 * 22 3/04/99 2:56p Samir
66 * clear out flags for displaying small views for cockpit in
67 * ResetSmallViews.
68 *
69 * 21 2/27/99 5:09p Jason
70 * clear screen 3 times with z buffer
71 *
72 * 20 2/10/99 1:47p Matt
73 * Changed object handle symbolic constants
74 *
75 * 19 2/08/99 5:37p Jason
76 * added comment
77 *
78 * 18 1/31/99 7:26p Matt
79 * Renamed a bunch of functions to have HUD capitalized
80 *
81 * 17 1/13/99 12:42p Matt
82 * Added code to close a popup view
83 *
84 * 16 1/08/99 4:34p Matt
85 * Added an Int3()
86 *
87 * 15 12/08/98 1:47p Matt
88 * If the main view is showing the rear view, make the small rear views
89 * show the forward view (got it?)
90 *
91 * 14 10/23/98 12:05p Matt
92 * Position the small views in the cockpit relative to the window
93 * position.
94 *
95 * 13 10/21/98 10:18a Matt
96 * Don't do small views in letterbox mode
97 *
98 * 12 10/20/98 9:23p Matt
99 * When rendering the small views, set Viewer_object to the local viewer,
100 * to keep the player ship from rendering in the small views when using
101 * the external camera.
102 *
103 * 11 10/20/98 12:42p Matt
104 * Made the small views work on the cockpit.
105 *
106 * 10 10/20/98 12:28a Matt
107 * When turning off a small view, redraw the background screen.
108 *
109 * 9 10/14/98 6:01p Jason
110 * fixed small views going too high on the terrain
111 *
112 * 8 10/08/98 5:59p Jason
113 * fixed object and room popping with small views
114 *
115 * 7 5/26/98 11:36a Matt
116 * Changed small view system to allow the popup window in any of the three
117 * positions, to allow any window to be the "bigger" size, and to restore
118 * the old view when a popup view goes away.
119 *
120 * 6 4/30/98 6:46p Jason
121 * more framerate testing
122 *
123 * 5 2/09/98 3:19p Matt
124 * Added function to return the viewer object for a small view
125 *
126 * 4 2/04/98 6:09p Matt
127 * Changed object room number to indicate a terrain cell via a flag. Got
128 * rid of the object flag which used to indicate terrain.
129 *
130 * 3 2/04/98 12:50a Matt
131 * Added ability to view from a gun point in small views.
132 * Made pop-up view separate from and bigger than other small views.
133 * Added real keys to set view mode in the three small views.
134 * Changed rendering functions a bit to accommodate smallview changes.
135 *
136 * 2 1/30/98 2:55p Matt
137 * Added SmallViews system
138 *
139 * 1 1/29/98 11:15a Matt
140 *
141 */
142
143 #include "SmallViews.h"cxx . . $ `<file>/Descent3/SmallViews.h`/
144
145 #include "descent.h"cxx . . $ `<file>/Descent3/descent.h`/
146 #include "pserror.h"cxx . . $ `<file>/misc/pserror.h`/
147
148 #include "game.h"cxx . . $ `<file>/Descent3/game.h`/
149 #include "object.h"cxx . . $ `<file>/Descent3/object.h`/
150 #include "terrain.h"cxx . . $ `<file>/Descent3/terrain.h`/
151 #include "render.h"cxx . . $ `<file>/Descent3/render.h`/
152 #include "gameloop.h"cxx . . $ `<file>/Descent3/gameloop.h`/
153 #include "weapon.h"cxx . . $ `<file>/Descent3/weapon.h`/
154 #include "findintersection.h"cxx . . $ `<file>/physics/findintersection.h`/
155 #include "config.h"cxx . . $ `<file>/Descent3/config.h`/
156 #include "terrain.h"cxx . . $ `<file>/Descent3/terrain.h`/
157 #include "gauges.h"cxx . . $ `<file>/Descent3/gauges.h`/
158 #include "cockpit.h"cxx . . $ `<file>/Descent3/cockpit.h`/
159 #include "player.h"cxx . . $ `<file>/Descent3/player.h`/
160 #include "grtext.h"cxx . . $ `<file>/grtext/grtext.h`/
161 #include "stringtable.h"cxx . . $ `<file>/Descent3/stringtable.h`/
162 #include "gamefont.h"cxx . . $ `<file>/Descent3/gamefont.h`/
163
164 // How many small views
165 #define NUM_SMALL_VIEWScxx . . $ `Descent3/SmallViews.cpp:165:9`! 3
166
167 // How many chars to allow for the window label
168 #define LABEL_LENcxx . . $ `Descent3/SmallViews.cpp:168:9`! 19
169
170 // Struct to keep data for small views
171 struct small_viewcxx . . $ small_view# {
172 int objhandlecxx . . $ small_view#objhandle.; // the object we're viewing from, or OBJECT_HANDLE_NONE if view not active
173 int flagscxx . . $ small_view#flags.; // various flags
174 float timercxx . . $ small_view#timer.; // how much longer time window stays alive, if SVF_TIMED flag is set
175 float zoomcxx . . $ small_view#zoom.; // the zoom for this window
176 int gun_numcxx . . $ small_view#gun_num.; // which gun to view from, or -1 if none
177 char labelcxx . . $ small_view#label.[LABEL_LENcxx . . $ `Descent3/SmallViews.cpp:168:9`! + 1]; // the label for the window
178 };
179
180 // The array of small views
181 static small_viewcxx . . $ small_view# Small_viewscxx . . $ Small_views.[NUM_SMALL_VIEWScxx . . $ `Descent3/SmallViews.cpp:165:9`!];
182
183 // Saved copies of small views for while a pop-up is active
184 static small_viewcxx . . $ small_view# Small_views_savecxx . . $ Small_views_save.[NUM_SMALL_VIEWScxx . . $ `Descent3/SmallViews.cpp:165:9`!];
185
186 // guided missile in small view? if so, then true.
187 bool Guided_missile_smallviewcxx . . $ Guided_missile_smallview. = false;
188 static int Guided_missile_objhandlecxx . . $ Guided_missile_objhandle. = OBJECT_HANDLE_NONEcxx . . $ `Descent3/object_external.h:156:9`!;
189
190 // Returns the viewer object for the specified small view.
191 // If the view isn't active, returns OBJECT_HANDLE_NONE.
192 int GetSmallViewercxx . . $ GetSmallViewer(7864480464b09eea).(int window) {
193 ASSERTcxx . . $ `misc/pserror.h:246:9`!((window >= 0) && (window < NUM_SMALL_VIEWScxx . . $ `Descent3/SmallViews.cpp:165:9`!));
194
195 return Small_viewscxx . . $ Small_views.[window].objhandlecxx . . $ small_view#objhandle.;
196 }
197
198 // Create a new small view. If there is already a view in the given window, the old view gets blown away.
199 // Parameters: window - which window to open. See constants in SmallViews.h
200 // objhandle - handle for the object to view from
201 // flags - various view attributes. See defines in header file.
202 // time - how long to keep the window up. If 0, keep up indefinitely
203 // zoom - the zoom for this window. If 0, use the default zoom
204 // gun_num - which gun to view from. if -1, use viewer's center and orientation.
205 // label - the label for the window
206 // Returns: which window was opened, or -1 if window couldn't be created
207 int CreateSmallViewcxx . . $ CreateSmallView(114097c446ee1c3e).(int window, int objhandle, int flags, float time, float zoom, int gun_num, const char *label) {
208 small_viewcxx . . $ small_view# *svp;
209
210 // Check for valid window
211 if ((window < 0) || (window >= NUM_SMALL_VIEWScxx . . $ `Descent3/SmallViews.cpp:165:9`!)) {
212 Int3cxx . . $ `misc/pserror.h:247:9`!();
213 window = SVW_LEFTcxx . . $ `Descent3/SmallViews.h:72:9`!;
214 }
215
216 // Make sure the object exists
217 if (!ObjGetcxx . . $ ObjGet(11672e354c0b263a).(objhandle))
218 return -1;
219
220 svp = &Small_viewscxx . . $ Small_views.[window];
221
222 // If this is a pop-up, and there was a non-popup active, save previous view
223 if ((flags & SVF_POPUPcxx . . $ `Descent3/SmallViews.h:77:9`!) && (svp->objhandlecxx . . $ small_view#objhandle. != OBJECT_HANDLE_NONEcxx . . $ `Descent3/object_external.h:156:9`!) && !(svp->flagscxx . . $ small_view#flags. & SVF_POPUPcxx . . $ `Descent3/SmallViews.h:77:9`!))
224 Small_views_savecxx . . $ Small_views_save.[window] =cxx . . $ small_view#`operator=`(54534f1f0435e199). *svp;
225
226 // Set vars for new view
227 svp->objhandlecxx . . $ small_view#objhandle. = objhandle;
228 svp->zoomcxx . . $ small_view#zoom. = zoom;
229 svp->gun_numcxx . . $ small_view#gun_num. = gun_num;
230 svp->flagscxx . . $ small_view#flags. = flags;
231 svp->timercxx . . $ small_view#timer. = time;
232 if (time != 0.0)
233 svp->flagscxx . . $ small_view#flags. |= SVF_TIMEDcxx . . $ `Descent3/SmallViews.h:80:9`!;
234
235 strncpy(svp->labelcxx . . $ small_view#label., label ? label : "", LABEL_LENcxx . . $ `Descent3/SmallViews.cpp:168:9`!);
236 svp->labelcxx . . $ small_view#label.[LABEL_LENcxx . . $ `Descent3/SmallViews.cpp:168:9`!] = 0; // strncpy won't terminate if at max len
237
238 if (window == SVW_LEFTcxx . . $ `Descent3/SmallViews.h:72:9`!)
239 Disable_primary_monitorcxx . . $ Disable_primary_monitor. = 1;
240 else if (window == SVW_RIGHTcxx . . $ `Descent3/SmallViews.h:74:9`!)
241 Disable_secondary_monitorcxx . . $ Disable_secondary_monitor. = 1;
242
243 // if guided view, set flag to true
244 if (ObjGetcxx . . $ ObjGet(11672e354c0b263a).(objhandle) == Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].guided_objcxx . . $ player#guided_obj.) {
245 Guided_missile_smallviewcxx . . $ Guided_missile_smallview. = true;
246 Guided_missile_objhandlecxx . . $ Guided_missile_objhandle. = objhandle;
247 }
248
249 return window;
250 }
251
252 // Called to get rid of all the small views & init system
253 void ResetSmallViewscxx . . $ ResetSmallViews(49f6e7a06ebc5aa8).() {
254 for (int v = 0; v < NUM_SMALL_VIEWScxx . . $ `Descent3/SmallViews.cpp:165:9`!; v++) {
255 Small_viewscxx . . $ Small_views.[v].objhandlecxx . . $ small_view#objhandle. = OBJECT_HANDLE_NONEcxx . . $ `Descent3/object_external.h:156:9`!;
256 Small_views_savecxx . . $ Small_views_save.[v].objhandlecxx . . $ small_view#objhandle. = OBJECT_HANDLE_NONEcxx . . $ `Descent3/object_external.h:156:9`!;
257 }
258 Disable_primary_monitorcxx . . $ Disable_primary_monitor. = 0;
259 Disable_secondary_monitorcxx . . $ Disable_secondary_monitor. = 0;
260 Guided_missile_smallviewcxx . . $ Guided_missile_smallview. = false;
261 Guided_missile_objhandlecxx . . $ Guided_missile_objhandle. = OBJECT_HANDLE_NONEcxx . . $ `Descent3/object_external.h:156:9`!;
262 }
263
264 #include "vclip.h"cxx . . $ `<file>/Descent3/vclip.h`/
265
266 // How long the static is visbile
267 #define STATIC_TIMEcxx . . $ `Descent3/SmallViews.cpp:267:9`! 0.25f
268
269 // Render into one of the small windows
270 void RenderSmallWindowcxx . . $ RenderSmallWindow(a888004daeb0019).(int left, int top, int right, int bot, objectcxx . . $ object# *viewer, vectorcxx . . $ vector# *viewer_eye, int viewer_roomnum,
271 matrixcxx . . $ matrix# *viewer_orient, int flags, float zoom, ddgr_colorcxx . . $ ddgr_color# outline_color, char *label,
272 float timer) {
273 int width = right - left, height = bot - top;
274
275 // Set up for rendering
276 StartFramecxx . . $ StartFrame(3285c9bef785d51c).(left, top, right, bot);
277
278 // scale font according to screen size
279 float font_aspect_x = (float)Game_window_wcxx . . $ Game_window_w. / Max_window_wcxx . . $ Max_window_w.;
280
281 if (font_aspect_x <= 0.60f) {
282 grtext_SetFontScalecxx . . $ grtext_SetFontScale(9364e6e7bff7660).(0.60f);
283 } else if (font_aspect_x <= 0.80f) {
284 grtext_SetFontScalecxx . . $ grtext_SetFontScale(9364e6e7bff7660).(0.80f);
285 } else {
286 grtext_SetFontScalecxx . . $ grtext_SetFontScale(9364e6e7bff7660).(1.0f);
287 }
288
289 // Draw either static or 3D
290 if (flags & SVF_STATICcxx . . $ `Descent3/SmallViews.h:82:9`!) {
291 // draw static
292 static int handle = -1;
293 if (handle == -1)
294 handle = FindTextureNamecxx . . $ FindTextureName(5c4306d8553b3696).("Static");
295
296 ASSERTcxx . . $ `misc/pserror.h:246:9`!(handle != -1); // DAJ -1FIX
297
298 PageInVClipcxx . . $ PageInVClip(d4f767463ce0a6b3).(GameTexturescxx . . $ GameTextures.[handle].bm_handlecxx . . $ texture#bm_handle.);
299 vclipcxx . . $ vclip# *vc = &GameVClipscxx . . $ GameVClips.[GameTexturescxx . . $ GameTextures.[handle].bm_handlecxx . . $ texture#bm_handle.];
300
301 int frame = vc->num_framescxx . . $ vclip#num_frames. * (STATIC_TIMEcxx . . $ `Descent3/SmallViews.cpp:267:9`! - timer) / STATIC_TIMEcxx . . $ `Descent3/SmallViews.cpp:267:9`!;
302 if (frame == vc->num_framescxx . . $ vclip#num_frames.)
303 frame--;
304 int bm_handle = vc->framescxx . . $ vclip#frames.[frame];
305
306 rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_CONSTANT_TEXTUREcxx . . $ `lib/renderer.h:402:9`!);
307 rend_SetAlphaValuecxx . . $ rend_SetAlphaValue(ac50b47256ae7414).(255);
308 rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_NONEcxx . . $ LS_NONE.);
309 rend_SetColorModelcxx . . $ rend_SetColorModel(e3c5062d5af601c7).(CM_MONOcxx . . $ CM_MONO.);
310 rend_SetOverlayTypecxx . . $ rend_SetOverlayType(ac50b47256ae7414).(OT_NONEcxx . . $ `lib/renderer.h:333:9`!);
311 rend_SetWrapTypecxx . . $ rend_SetWrapType(da524b148887c0e7).(WT_CLAMPcxx . . $ WT_CLAMP.);
312 rend_SetFilteringcxx . . $ rend_SetFiltering(4af4fd0e2b26c4ac).(0);
313
314 rend_DrawScaledBitmapcxx . . $ rend_DrawScaledBitmap(bffd21ce5f93b71b).(0, 0, width - 1, height - 1, bm_handle, 0.0, 0.0, 1.0, 1.0);
315 } else {
316 // draw 3D view
317 ASSERTcxx . . $ `misc/pserror.h:246:9`!(viewer != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
318 ASSERTcxx . . $ `misc/pserror.h:246:9`!(viewer_eye != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
319 objectcxx . . $ object# *save_viewer_object = Viewer_objectcxx . . $ Viewer_object.;
320 bool rear_view = ((flags & SVF_REARVIEWcxx . . $ `Descent3/SmallViews.h:79:9`!) != 0);
321
322 // Reset facings for mine stuff
323 ResetFacingscxx . . $ ResetFacings(49f6e7a06ebc5aa8).();
324
325 // Set the viewer for this render
326 Viewer_objectcxx . . $ Viewer_object. = viewer;
327
328 // Render the world
329 GameRenderWorldcxx . . $ GameRenderWorld(68d409d91ffdd12f).(viewer, viewer_eye, viewer_roomnum, viewer_orient, zoom, rear_view);
330
331 // Restore the viewer
332 Viewer_objectcxx . . $ Viewer_object. = save_viewer_object;
333 }
334
335 // Draw window outline
336 if (outline_color != -1) {
337 rend_SetFlatColorcxx . . $ rend_SetFlatColor(cb2f890c2fdad230).(outline_color);
338 rend_DrawLinecxx . . $ rend_DrawLine(748afa4755bc9595).(0, 0, width - 1, 0);
339 rend_DrawLinecxx . . $ rend_DrawLine(748afa4755bc9595).(width - 1, 0, width - 1, height - 1);
340 rend_DrawLinecxx . . $ rend_DrawLine(748afa4755bc9595).(width - 1, height - 1, 0, height - 1);
341 rend_DrawLinecxx . . $ rend_DrawLine(748afa4755bc9595).(0, height - 1, 0, 0);
342 }
343
344 // Draw the label
345 if (label[0]) {
346 int w = grtext_GetLineWidthcxx . . $ `grtext/grtext.h:172:9`!(label);
347 grtext_SetFontcxx . . $ grtext_SetFont(d4f767463ce0a6b3).(HUD_FONTcxx . . $ `Descent3/gamefont.h:105:9`!);
348 grtext_SetColorcxx . . $ grtext_SetColor(cb2f890c2fdad230).(HUD_COLORcxx . . $ `Descent3/hud.h:307:9`!);
349 grtext_SetAlphacxx . . $ grtext_SetAlpha(ac50b47256ae7414).(255);
350 grtext_SetFlagscxx . . $ grtext_SetFlags(d4f767463ce0a6b3).(0);
351 grtext_Putscxx . . $ grtext_Puts(3139f19a0dbb8edf).((width - w) / 2, 2, label);
352 grtext_Flushcxx . . $ grtext_Flush(49f6e7a06ebc5aa8).();
353 }
354
355 // Draw the crosshairs
356 if (flags & SVF_CROSSHAIRScxx . . $ `Descent3/SmallViews.h:81:9`!) {
357 int cx = width / 2, cy = height / 2;
358 int line_w = width / 50, line_h = height / 50;
359 rend_SetZBufferStatecxx . . $ rend_SetZBufferState(4af4fd0e2b26c4ac).(0);
360 rend_SetFlatColorcxx . . $ rend_SetFlatColor(cb2f890c2fdad230).(GR_GREENcxx . . $ GR_GREEN.);
361 rend_DrawLinecxx . . $ rend_DrawLine(748afa4755bc9595).(cx - line_w, cy, cx + line_w, cy);
362 rend_DrawLinecxx . . $ rend_DrawLine(748afa4755bc9595).(cx, cy - line_h, cx, cy + line_h);
363 rend_SetZBufferStatecxx . . $ rend_SetZBufferState(4af4fd0e2b26c4ac).(1);
364 }
365
366 // Done rendering
367 EndFramecxx . . $ EndFrame(49f6e7a06ebc5aa8).();
368 }
369
370 // Find the room number of a gun point
371 int GetGunRoomcxx . . $ GetGunRoom(30599b1ef56d1b76).(vectorcxx . . $ vector# *p0, int roomnum, int objnum, vectorcxx . . $ vector# *p1) {
372 fvi_querycxx . . $ fvi_query# fq;
373 fvi_infocxx . . $ fvi_info# hit_data;
374 int fate;
375
376 fq.p0cxx . . $ fvi_query#p0. = p0;
377 fq.startroomcxx . . $ fvi_query#startroom. = roomnum;
378 fq.p1cxx . . $ fvi_query#p1. = p1;
379 fq.radcxx . . $ fvi_query#rad. = 0;
380 fq.thisobjnumcxx . . $ fvi_query#thisobjnum. = objnum;
381 fq.ignore_obj_listcxx . . $ fvi_query#ignore_obj_list. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
382 fq.flagscxx . . $ fvi_query#flags. = 0;
383
384 fate = fvi_FindIntersectioncxx . . $ fvi_FindIntersection(e1c4d7bd350effc8).(&fq, &hit_data);
385 if (fate != HIT_NONEcxx . . $ `lib/findintersection_external.h:45:9`!)
386 Int3cxx . . $ `misc/pserror.h:247:9`!();
387
388 return hit_data.hit_roomcxx . . $ fvi_info#hit_room.;
389 }
390
391 #define SMALL_WINDOW_Wcxx . . $ `Descent3/SmallViews.cpp:391:9`! 120
392 #define SMALL_WINDOW_Hcxx . . $ `Descent3/SmallViews.cpp:392:9`! 120
393 #define SPACE_BETWEEN_WINDOWScxx . . $ `Descent3/SmallViews.cpp:393:9`! ((640 - 3 * SMALL_WINDOW_W) / 3)
394
395 extern int Point_visible_last_framecxx . . $ Point_visible_last_frame.;
396
397 // Draw all the active small views
398 void DrawSmallViewscxx . . $ DrawSmallViews(49f6e7a06ebc5aa8).() {
399 int v;
400 small_viewcxx . . $ small_view# *svp;
401 int left, top, right, bot;
402 ddgr_colorcxx . . $ ddgr_color# outline_color;
403 vectorcxx . . $ vector# *viewer_eye, gun_pos;
404 matrixcxx . . $ matrix# *viewer_orient, gun_orient;
405 matrixcxx . . $ matrix# save_orient;
406 vectorcxx . . $ vector# save_eye;
407 int viewer_roomnum;
408
409 // if letterbox, don't draw the small views
410 if (GetHUDModecxx . . $ GetHUDMode(d2d05048dda10524).() == HUD_LETTERBOXcxx . . $ HUD_LETTERBOX.)
411 return;
412
413 bool lsave = Detail_settingscxx . . $ Detail_settings..Dynamic_lightingcxx . . $ tDetailSettings#Dynamic_lighting.;
414
415 g3_GetUnscaledMatrixcxx . . $ g3_GetUnscaledMatrix(dca75c48c9ab5b54).(&save_orient);
416 g3_GetViewPositioncxx . . $ g3_GetViewPosition(ec8cf6451c36d470).(&save_eye);
417
418 Detail_settingscxx . . $ Detail_settings..Dynamic_lightingcxx . . $ tDetailSettings#Dynamic_lighting. = false;
419
420 for (v = 0, svp = Small_viewscxx . . $ Small_views.; v < NUM_SMALL_VIEWScxx . . $ `Descent3/SmallViews.cpp:165:9`!; v++, svp++) {
421 if (svp->objhandlecxx . . $ small_view#objhandle. == OBJECT_HANDLE_NONEcxx . . $ `Descent3/object_external.h:156:9`!)
422 continue;
423
424 objectcxx . . $ object# *viewer = ObjGetcxx . . $ ObjGet(11672e354c0b263a).(svp->objhandlecxx . . $ small_view#objhandle.);
425 bool kill_viewer = false;
426
427 // Bail if object not around any more, or if its gone too high
428 if (!viewer || (viewer->typecxx . . $ object#type. == OBJ_DUMMYcxx . . $ `Descent3/object_external.h:181:9`!))
429 kill_viewer = true;
430
431 if (viewer && OBJECT_OUTSIDEcxx . . $ `lib/object_external_struct.h:130:9`!(viewer) && viewer->poscxx . . $ object#pos..ycxx . . $ vector#y. >= MAX_TERRAIN_HEIGHTcxx . . $ `Descent3/terrain.h:46:9`!)
432 kill_viewer = true;
433
434 // If not view & not already static, switch to static
435 if (kill_viewer && !(svp->flagscxx . . $ small_view#flags. & SVF_STATICcxx . . $ `Descent3/SmallViews.h:82:9`!)) {
436 // Viewer is dead, so switch to static
437 svp->flagscxx . . $ small_view#flags. |= SVF_STATICcxx . . $ `Descent3/SmallViews.h:82:9`! | SVF_TIMEDcxx . . $ `Descent3/SmallViews.h:80:9`!;
438 svp->timercxx . . $ small_view#timer. = STATIC_TIMEcxx . . $ `Descent3/SmallViews.cpp:267:9`!;
439 svp->gun_numcxx . . $ small_view#gun_num. = -1;
440 }
441
442 if (v == SVW_CENTERcxx . . $ `Descent3/SmallViews.h:73:9`!) // no center window for now
443 Int3cxx . . $ `misc/pserror.h:247:9`!();
444
445 if (CockpitStatecxx . . $ CockpitState(b126dc7c1de90089).() == COCKPIT_STATE_QUASIcxx . . $ `Descent3/cockpit.h:110:9`!) {
446 continue;
447 }
448
449 else if (CockpitStatecxx . . $ CockpitState(b126dc7c1de90089).() == COCKPIT_STATE_FUNCTIONALcxx . . $ `Descent3/cockpit.h:111:9`!) {
450 // draw on the cockpit
451 if (!GetCockpitWindowCoordscxx . . $ GetCockpitWindowCoords(a9756ee215d9d271).((v == SVW_LEFTcxx . . $ `Descent3/SmallViews.h:72:9`!) ? 0 : 1, &left, &top, &right, &bot)) {
452 continue;
453 }
454
455 // Move relative to the current window
456 left += Game_window_xcxx . . $ Game_window_x.;
457 right += Game_window_xcxx . . $ Game_window_x.;
458 top += Game_window_ycxx . . $ Game_window_y.;
459 bot += Game_window_ycxx . . $ Game_window_y.;
460
461 outline_color = -1;
462 } else {
463 // draw windows on HUD based on the screen size
464 ASSERTcxx . . $ `misc/pserror.h:246:9`!(CockpitState() == COCKPIT_STATE_DORMANTcxx . . $ `Descent3/cockpit.h:109:9`!);
465
466 // Compute size of window
467 int x, y, w, h, spacing;
468 w = Game_window_hcxx . . $ Game_window_h. / 4;
469 spacing = ((Game_window_wcxx . . $ Game_window_w. - (NUM_SMALL_VIEWScxx . . $ `Descent3/SmallViews.cpp:165:9`!)*w) / 3);
470 x = ((spacing + w) / 2) + (v * (spacing + w)) + Game_window_xcxx . . $ Game_window_x.;
471 h = w;
472 y = Game_window_ycxx . . $ Game_window_y. + (Game_window_hcxx . . $ Game_window_h. - h / 2 - Game_window_hcxx . . $ Game_window_h. / 24);
473
474 // If bigger window, increase size
475 if (svp->flagscxx . . $ small_view#flags. & SVF_BIGGERcxx . . $ `Descent3/SmallViews.h:78:9`!) {
476 w += w / 4;
477 h += h / 4;
478 }
479
480 left = x - (w / 2);
481 top = y - (h / 2);
482 right = x + (w / 2);
483 bot = y + (h / 2);
484
485 // Set window color
486 outline_color = (svp->flagscxx . . $ small_view#flags. & SVF_POPUPcxx . . $ `Descent3/SmallViews.h:77:9`!) ? GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(255, 0, 0) : GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(0, 0, 255);
487 }
488
489 // Get view info from the gun or from the object itself
490 if (svp->gun_numcxx . . $ small_view#gun_num. != -1) {
491 // using a gun
492 vectorcxx . . $ vector# gun_vector;
493 WeaponCalcGuncxx . . $ WeaponCalcGun(85e3752e9562a225).(&gun_pos, &gun_vector, viewer, svp->gun_numcxx . . $ small_view#gun_num.);
494 vm_VectorToMatrixcxx . . $ vm_VectorToMatrix(543233b88555916d).(&gun_orient, &gun_vector, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
495 viewer_eye = &gun_pos;
496 viewer_orient = &gun_orient;
497 viewer_roomnum = GetGunRoomcxx . . $ GetGunRoom(30599b1ef56d1b76).(&viewer->poscxx . . $ object#pos., viewer->roomnumcxx . . $ object#roomnum., OBJNUMcxx . . $ `Descent3/object.h:700:9`!(viewer), &gun_pos);
498 } else if (viewer) {
499 // no gun, so just use the object
500 viewer_eye = &viewer->poscxx . . $ object#pos.;
501 viewer_orient = &viewer->orientcxx . . $ object#orient.;
502 viewer_roomnum = viewer->roomnumcxx . . $ object#roomnum.;
503 } else {
504 ASSERTcxx . . $ `misc/pserror.h:246:9`!(svp->flags & SVF_STATICcxx . . $ `Descent3/SmallViews.h:82:9`!);
505 viewer_eye = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
506 viewer_orient = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
507 viewer_roomnum = -1;
508 }
509
510 // Determine whether to draw rear view. If view has rear view set and the viewer is
511 // a player and the player has rear view on, then draw forward view
512 int flags = svp->flagscxx . . $ small_view#flags.;
513 if ((flags & SVF_REARVIEWcxx . . $ `Descent3/SmallViews.h:79:9`!) && (viewer == Viewer_objectcxx . . $ Viewer_object.) && (viewer->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!) &&
514 (Playerscxx . . $ Players.[viewer->idcxx . . $ object#id.].flagscxx . . $ player#flags. & PLAYER_FLAGS_REARVIEWcxx . . $ `Descent3/player_external.h:97:9`!))
515 flags &= ~SVF_REARVIEWcxx . . $ `Descent3/SmallViews.h:79:9`!;
516
517 // Let's render
518 Point_visible_last_framecxx . . $ Point_visible_last_frame. = -1;
519 RenderSmallWindowcxx . . $ RenderSmallWindow(a888004daeb0019).(left, top, right, bot, viewer, viewer_eye, viewer_roomnum, viewer_orient, flags, svp->zoomcxx . . $ small_view#zoom.,
520 outline_color, svp->labelcxx . . $ small_view#label., svp->timercxx . . $ small_view#timer.);
521 Point_visible_last_framecxx . . $ Point_visible_last_frame. = -1;
522
523 // Update time for this view
524 if (svp->flagscxx . . $ small_view#flags. & SVF_TIMEDcxx . . $ `Descent3/SmallViews.h:80:9`!) {
525 svp->timercxx . . $ small_view#timer. -= Frametimecxx . . $ Frametime.;
526 if (svp->timercxx . . $ small_view#timer. < 0.0) {
527 CloseSmallViewcxx . . $ CloseSmallView(d4f767463ce0a6b3).(v);
528 }
529 }
530 }
531
532 Detail_settingscxx . . $ Detail_settings..Dynamic_lightingcxx . . $ tDetailSettings#Dynamic_lighting. = lsave;
533
534 // Resets aspect ratio
535 g3_StartFramecxx . . $ g3_StartFrame(e35d136ceab5c8a2).(&save_eye, &save_orient, Render_zoomcxx . . $ Render_zoom.);
536 g3_EndFramecxx . . $ g3_EndFrame(49f6e7a06ebc5aa8).();
537 }
538
539 // Parameters: window - the window to get rid of
540 void CloseSmallViewcxx . . $ CloseSmallView(d4f767463ce0a6b3).(int window) {
541 // Mark the window as inactive
542 if (Small_viewscxx . . $ Small_views.[window].objhandlecxx . . $ small_view#objhandle. == Guided_missile_objhandlecxx . . $ Guided_missile_objhandle.) {
543 // mark guided missile small view as inactive.
544 Guided_missile_objhandlecxx . . $ Guided_missile_objhandle. = OBJECT_HANDLE_NONEcxx . . $ `Descent3/object_external.h:156:9`!;
545 Guided_missile_smallviewcxx . . $ Guided_missile_smallview. = false;
546 }
547
548 Small_viewscxx . . $ Small_views.[window].objhandlecxx . . $ small_view#objhandle. = OBJECT_HANDLE_NONEcxx . . $ `Descent3/object_external.h:156:9`!;
549
550 // Restore old view if there was one
551 if (Small_views_savecxx . . $ Small_views_save.[window].objhandlecxx . . $ small_view#objhandle. != OBJECT_HANDLE_NONEcxx . . $ `Descent3/object_external.h:156:9`!) {
552 Small_viewscxx . . $ Small_views.[window] =cxx . . $ small_view#`operator=`(54534f1f0435e199). Small_views_savecxx . . $ Small_views_save.[window];
553 Small_views_savecxx . . $ Small_views_save.[window].objhandlecxx . . $ small_view#objhandle. = OBJECT_HANDLE_NONEcxx . . $ `Descent3/object_external.h:156:9`!;
554 } else {
555 Clear_screencxx . . $ Clear_screen. = 4; // force background redraw
556
557 if (window == SVW_LEFTcxx . . $ `Descent3/SmallViews.h:72:9`!)
558 Disable_primary_monitorcxx . . $ Disable_primary_monitor. = 0;
559 else if (window == SVW_RIGHTcxx . . $ `Descent3/SmallViews.h:74:9`!)
560 Disable_secondary_monitorcxx . . $ Disable_secondary_monitor. = 0;
561 }
562 }
563
564 // Get rid of a small view if it's a popup window
565 // Parameters: window - the window to get rid of
566 void ClosePopupViewcxx . . $ ClosePopupView(d4f767463ce0a6b3).(int window) {
567 if (Small_viewscxx . . $ Small_views.[window].flagscxx . . $ small_view#flags. & SVF_POPUPcxx . . $ `Descent3/SmallViews.h:77:9`!)
568 CloseSmallViewcxx . . $ CloseSmallView(d4f767463ce0a6b3).(window);
569 }