Wing Commander II
Reconstructed Win32 source (1996)
Loading...
Searching...
No Matches
fleetvw.c
Go to the documentation of this file.
1/*
2 * Fleet overview view.
3 *
4 * Retail object 0x44ADE0-0x44B1FF (link order; see docs/ORDER.md).
5 */
6#include "game.h"
7
8/* Function start: 0x44ADE0 */
9void SetFleetOverviewView(short initializeCockpit)
10{
11 FixedVector centre;
12 FixedVector axes;
13 FixedVector viewOffset;
14 short shipCount;
15 int range;
16 int playerRange;
17 int cameraDistance;
18 int furthestRange;
19 short shipSlot;
20
21 axes.x = 0xff;
22 axes.y = 0xff;
23 axes.z = 0xff;
24 shipCount = 0;
25 if (initializeCockpit != 0) {
27 if ((int)GetLargestFreeMemoryBlockByType(0) < 66000)
29 else
32 }
33
34 for (shipSlot = 0; shipSlot < 10; shipSlot++) {
35 if (g_aeObjectClass[shipSlot] >= OBJECT_CLASS_SHIP)
36 shipCount++;
37 }
38
39 if (shipCount > 1) {
40 zero_vector(&centre);
41 for (shipSlot = 0; shipSlot < 10; shipSlot++) {
42 if (g_aeObjectClass[shipSlot] >= OBJECT_CLASS_SHIP) {
43 centre.x += g_aShipPosition[shipSlot].x / shipCount;
44 centre.y += g_aShipPosition[shipSlot].y / shipCount;
45 centre.z += g_aShipPosition[shipSlot].z / shipCount;
46 }
47 }
48
49 furthestRange = 0x4b000;
50 for (shipSlot = 9; shipSlot >= 0; shipSlot--) {
51 if (g_aeObjectClass[shipSlot] >= OBJECT_CLASS_SHIP) {
52 ComputeVectorDelta(&centre,
53 &g_aShipPosition[shipSlot],
54 &viewOffset);
55 range = Vector_magnitude(&viewOffset);
56 if (furthestRange < range)
57 furthestRange = range;
58 if (shipSlot == 0)
59 playerRange = range;
60 }
61 }
62 if (furthestRange > 0x1f4000)
63 cameraDistance = playerRange;
64 else
65 cameraDistance = furthestRange;
66 } else {
67 cameraDistance = furthestRange = playerRange = 0x4b000;
68 position_relative_ijk(&centre, 0, 400, 400, 400);
69 }
70
71 cameraDistance = (cameraDistance >> 3) * 9 + 0x2bc00;
76
79 cameraDistance >> 2, &viewOffset);
81 &viewOffset,
84 0x9600, &viewOffset);
86 &viewOffset,
90 cameraDistance, &viewOffset);
92 &viewOffset,
94
99 if (furthestRange < 0x271000)
100 point_at(EYE_OBJECT, centre);
101 else
103}
void ComputeVectorDelta(FixedVector *from, FixedVector *to, FixedVector *delta)
Definition geom.c:229
long Vector_magnitude(const FixedVector *vector)
Definition eventmgr.c:157
void AddFixedVectors(const FixedVector *left, const FixedVector *right, FixedVector *sum)
Definition geom.c:211
void position_relative_ijk(FixedVector *position, short obj, short right, short up, short forward)
Definition geom.c:112
void ScaleFixedVector(FixedVector *vector, int scale, FixedVector *result)
Definition geom.c:237
unsigned int GetLargestFreeMemoryBlockByType(short memoryType)
Definition memapi.c:139
void SetFleetOverviewView(short initializeCockpit)
Definition fleetvw.c:9
void zero_vector(FixedVector *vector)
Definition geom.c:197
void initialize_cockpit(signed char mode)
Definition fltsetup.c:100
void point_at(short obj, FixedVector point)
Definition geom.c:84
void free_view_buffer(void)
Definition main.c:208
Shared Win32 declarations, types and library interfaces.
#define SCRATCH_VIEW_OBJECT
Definition game_data.h:1581
#define EYE_OBJECT
Definition game_data.h:1580
@ OBJECT_CLASS_SHIP
Definition game_data.h:49
short g_aeObjectClass[SPACE_OBJECT_COUNT]
Definition viewrect.c:125
FixedVector g_aShipForwardVector[SPACE_OBJECT_COUNT]
Definition viewrect.c:107
FixedVector g_aShipRightVector[SPACE_OBJECT_COUNT]
Definition viewrect.c:105
FixedVector g_aShipPosition[SPACE_OBJECT_COUNT]
Definition viewrect.c:108
FixedVector g_aShipUpVector[SPACE_OBJECT_COUNT]
Definition viewrect.c:106
FixedVector g_aShipVelocity[SPACE_OBJECT_COUNT]
Definition viewrect.c:109