Wing Commander II
Reconstructed Win32 source (1996)
Toggle main menu visibility
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 */
9
void
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) {
26
free_view_buffer
();
27
if
((
int
)
GetLargestFreeMemoryBlockByType
(0) < 66000)
28
initialize_cockpit
(4);
29
else
30
initialize_cockpit
(6);
31
zero_vector
(&
g_aShipVelocity
[
EYE_OBJECT
]);
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
(¢re);
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
(¢re,
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
(¢re, 0, 400, 400, 400);
69
}
70
71
cameraDistance = (cameraDistance >> 3) * 9 + 0x2bc00;
72
g_aShipPosition
[
SCRATCH_VIEW_OBJECT
] = centre;
73
g_aShipRightVector
[
SCRATCH_VIEW_OBJECT
] = axes;
74
g_aShipUpVector
[
SCRATCH_VIEW_OBJECT
] = axes;
75
point_at
(
SCRATCH_VIEW_OBJECT
,
g_aShipPosition
[0]);
76
77
ScaleFixedVector
(
78
&
g_aShipRightVector
[
SCRATCH_VIEW_OBJECT
],
79
cameraDistance >> 2, &viewOffset);
80
AddFixedVectors
(&
g_aShipPosition
[
SCRATCH_VIEW_OBJECT
],
81
&viewOffset,
82
&
g_aShipPosition
[
SCRATCH_VIEW_OBJECT
]);
83
ScaleFixedVector
(&
g_aShipUpVector
[
SCRATCH_VIEW_OBJECT
],
84
0x9600, &viewOffset);
85
AddFixedVectors
(&
g_aShipPosition
[
SCRATCH_VIEW_OBJECT
],
86
&viewOffset,
87
&
g_aShipPosition
[
SCRATCH_VIEW_OBJECT
]);
88
ScaleFixedVector
(
89
&
g_aShipForwardVector
[
SCRATCH_VIEW_OBJECT
],
90
cameraDistance, &viewOffset);
91
AddFixedVectors
(&
g_aShipPosition
[
SCRATCH_VIEW_OBJECT
],
92
&viewOffset,
93
&
g_aShipPosition
[
SCRATCH_VIEW_OBJECT
]);
94
95
g_aShipPosition
[
EYE_OBJECT
] =
96
g_aShipPosition
[
SCRATCH_VIEW_OBJECT
];
97
g_aShipRightVector
[
EYE_OBJECT
] = axes;
98
g_aShipUpVector
[
EYE_OBJECT
] = axes;
99
if
(furthestRange < 0x271000)
100
point_at
(
EYE_OBJECT
, centre);
101
else
102
point_at
(
EYE_OBJECT
,
g_aShipPosition
[0]);
103
}
ComputeVectorDelta
void ComputeVectorDelta(FixedVector *from, FixedVector *to, FixedVector *delta)
Definition
geom.c:229
Vector_magnitude
long Vector_magnitude(const FixedVector *vector)
Definition
eventmgr.c:157
AddFixedVectors
void AddFixedVectors(const FixedVector *left, const FixedVector *right, FixedVector *sum)
Definition
geom.c:211
position_relative_ijk
void position_relative_ijk(FixedVector *position, short obj, short right, short up, short forward)
Definition
geom.c:112
ScaleFixedVector
void ScaleFixedVector(FixedVector *vector, int scale, FixedVector *result)
Definition
geom.c:237
GetLargestFreeMemoryBlockByType
unsigned int GetLargestFreeMemoryBlockByType(short memoryType)
Definition
memapi.c:139
SetFleetOverviewView
void SetFleetOverviewView(short initializeCockpit)
Definition
fleetvw.c:9
zero_vector
void zero_vector(FixedVector *vector)
Definition
geom.c:197
initialize_cockpit
void initialize_cockpit(signed char mode)
Definition
fltsetup.c:100
point_at
void point_at(short obj, FixedVector point)
Definition
geom.c:84
free_view_buffer
void free_view_buffer(void)
Definition
main.c:208
game.h
Shared Win32 declarations, types and library interfaces.
SCRATCH_VIEW_OBJECT
#define SCRATCH_VIEW_OBJECT
Definition
game_data.h:1581
EYE_OBJECT
#define EYE_OBJECT
Definition
game_data.h:1580
OBJECT_CLASS_SHIP
@ OBJECT_CLASS_SHIP
Definition
game_data.h:49
g_aeObjectClass
short g_aeObjectClass[SPACE_OBJECT_COUNT]
Definition
viewrect.c:125
g_aShipForwardVector
FixedVector g_aShipForwardVector[SPACE_OBJECT_COUNT]
Definition
viewrect.c:107
g_aShipRightVector
FixedVector g_aShipRightVector[SPACE_OBJECT_COUNT]
Definition
viewrect.c:105
g_aShipPosition
FixedVector g_aShipPosition[SPACE_OBJECT_COUNT]
Definition
viewrect.c:108
g_aShipUpVector
FixedVector g_aShipUpVector[SPACE_OBJECT_COUNT]
Definition
viewrect.c:106
g_aShipVelocity
FixedVector g_aShipVelocity[SPACE_OBJECT_COUNT]
Definition
viewrect.c:109
FixedVector
Definition
game_data.h:318
FixedVector::z
int z
Definition
game_data.h:321
FixedVector::y
int y
Definition
game_data.h:320
FixedVector::x
int x
Definition
game_data.h:319
src
fleetvw.c
Generated by
1.18.0