Rise
The Vieneo Province
Toggle main menu visibility
Loading...
Searching...
No Matches
ContactList.cpp
Go to the documentation of this file.
1
#include "
Instrument.h
"
2
#include "
../Bus.h
"
3
#include "
../MathUtilities.h
"
4
5
ContactList::ContactList
(
int
prmX,
int
prmY,
float
prmXScale,
float
prmYScale,
Bus
* prmBus,
Logger
* prmLogger,
DeviceObject
* prmDevice, std::vector<Font*> prmFonts) :
6
Instrument
(prmX, prmY, prmXScale, prmYScale, prmBus, prmLogger, prmDevice, prmFonts)
7
{
8
logger
->
AddToCallStack
(
"ContactList::ctor"
);
9
defaultFont
= 1;
10
cacheFixedText
=
true
;
11
}
12
13
void
ContactList::Render
()
14
{
15
WCHAR str[99];
16
RiseMath::Vector3
result;
17
18
/*if (!playerships[0].groundvehicle || ourcockpit.texturelib == VehicleType::T27)
19
{
20
21
bus->m_spriteVector->Begin(Rendering::SpriteFlags::AlphaBlend | Rendering::SpriteFlags::SortTexture);
22
23
if (ourcockpit.nextgen)
24
{
25
RiseMath::Matrix transform;
26
RiseMath::MatrixTranslation(&transform, 207, 0, 0); // 773 by default
27
bus->m_spriteVector->SetTransform(&transform);
28
}*/
29
30
long
yText = 11;
// start 11 down from top
31
const
long
yTextIncr = 11;
// each line
32
RiseMath::Color
hi;
33
if
(!
ourcockpit
.
spaceCapable
)
// not spaceships
34
{
35
if
(
bus
->
targetC
< -1)
36
{
37
bus
->
targetC
= -1;
// if stations, select user WP
38
Command
command;
39
command.
name
=
"EventSelectTarget"
;
40
bus
->
AddCommand
(command,
false
);
41
}
42
}
43
44
if
(
bus
->
scanscroll
> 0)
45
DrawTextW(L
" ^^^ MORE ^^^"
, 22, yText, 0, DT_NOCLIP,
Rendering::ColorARGB
(255, 255, 255, 0));
46
// Last waypoint
47
else
if
(
bus
->
lastWaypointLocation
.x != 0.0f &&
ourcockpit
.
power
> 0.5f)
48
{
49
static
bool
tripped =
true
;
50
const
float
lastWaypointDistance =
GetArcDist
(
playerships
[0].position,
bus
->
lastWaypointLocation
,
true
);
51
if
(lastWaypointDistance >
bus
->
waypointDistanceKm
&& !tripped)
52
{
53
// tripped
54
flashtime
= 3.0f;
55
Command
command;
56
command.
name
=
"SoundMidwayTarget"
;
57
bus
->
AddCommand
(command,
false
);
58
tripped =
true
;
59
}
60
else
if
(lastWaypointDistance < bus->waypointDistanceKm)
61
{
62
tripped =
false
;
63
}
64
65
if
(lastWaypointDistance > 10000.0f)
66
swprintf_s(str, 99, L
" LAST %.3f kkm"
, lastWaypointDistance * 0.001f);
67
else
68
swprintf_s(str, 99, L
" LAST %.3f km"
, lastWaypointDistance);
69
70
if
(
flashtime
> 0.0f)
71
{
72
if
(fmodf(
flashtime
, 1.0f) > 0.5f)
73
hi =
Rendering::ColorARGB
(255, 255, 255, 255);
// white
74
else
75
hi =
Rendering::ColorARGB
(255, 0, 127, 127);
// dark cyan
76
}
77
else
78
hi =
Rendering::ColorARGB
(255, 0, 127, 127);
// dark cyan
79
80
DrawTextW(str, 0, yText, 0, DT_NOCLIP, hi);
81
}
82
yText += yTextIncr;
83
84
char
thji;
85
if
(
bus
->
targetC
== -1)
86
thji =
'>'
;
87
else
88
thji =
' '
;
89
90
// User Waypoint
91
if
(
bus
->
WPtargetC
< 0 ||
bus
->
WPtargetC
>=
static_cast<
long
>
(
bus
->
waypoint
.size()))
92
{
93
char
msg[199];
94
sprintf_s(msg,
sizeof
msg,
"Trying to display AV/SV contact list with a waypoint that doesn't exist in collection: %i (%zu)"
,
bus
->
WPtargetC
,
bus
->
waypoint
.size());
95
logger
->
Log
(msg,
Logger::Level::Error
);
96
bus
->
WPtargetC
= 0;
97
strcpy_s(
bus
->
TimeToNextFix
, 6,
"--:--"
);
98
}
99
else
100
{
101
if
(
bus
->
GroundSpeedKms
< 0.0005f)
102
strcpy_s(
bus
->
TimeToNextFix
, 6,
"--:--"
);
103
else
104
{
105
const
float
hours =
bus
->
waypointDistanceKm
/
bus
->
GroundSpeedKms
/ 60.0f / 60.0f;
106
const
float
minutes = floorf((hours - floorf(hours)) * 60.0f);
107
if
(hours > 99.0f)
108
strcpy_s(
bus
->
TimeToNextFix
, 6,
"++:++"
);
109
else
110
sprintf_s(
bus
->
TimeToNextFix
, 6,
"%02.0f:%02.0f"
, floorf(hours), minutes);
111
}
112
}
113
114
if
(
bus
->
waypointDistanceKm
>= 0)
115
{
116
if
(
bus
->
waypointDistanceKm
> 10000.0f)
117
swprintf_s(str, 99, L
"%CWAYPT %.3f kkm"
, thji,
bus
->
waypointDistanceKm
* 0.001f);
118
else
119
swprintf_s(str, 99, L
"%CWAYPT %.3f km"
, thji,
bus
->
waypointDistanceKm
);
120
}
121
else
122
swprintf_s(str, 99, L
"%CWAYPT Unused"
, thji);
123
124
hi =
Rendering::ColorARGB
(255, 0, 255, 255);
// cyan
125
DrawTextW(str, 0, yText, 0, DT_NOCLIP, hi);
126
yText += yTextIncr;
127
128
129
for
(
short
t = 0; t <
ourcockpit
.
scanDisplayVesselLimit
; t++)
130
{
131
if
(
playerships
[
bus
->
scanslot
[t +
bus
->
scanscroll
]].
active
&&
132
playerships
[
bus
->
scanslot
[t +
bus
->
scanscroll
]].
visible
&&
133
playerships
[
bus
->
scanslot
[t +
bus
->
scanscroll
]].
isOnScanner
)
134
{
135
if
(
playerships
[
bus
->
scanslot
[t +
bus
->
scanscroll
]].
battleRoyale
)
136
hi =
Rendering::ColorARGB
(255, 255, 127, 0);
// orange
137
else
if
(!
playerships
[
bus
->
scanslot
[t +
bus
->
scanscroll
]].
transponder
)
138
hi =
Rendering::ColorARGB
(255, 192, 192, 192);
// white
139
else
140
{
141
// blue is a color that is available but the concern is that it is hard to see
142
if
(
playerships
[
bus
->
scanslot
[t +
bus
->
scanscroll
]].
align
== 4)
// owned
143
hi =
Rendering::ColorARGB
(255, 192, 192, 0);
// yellow
144
else
if
(
playerships
[
bus
->
scanslot
[t +
bus
->
scanscroll
]].
align
== 3)
// partner
145
hi =
Rendering::ColorARGB
(255, 192, 0, 192);
// purple
146
else
if
(
playerships
[
bus
->
scanslot
[t +
bus
->
scanscroll
]].
align
== 2)
// ally
147
hi =
Rendering::ColorARGB
(255, 0, 192, 0);
// green
148
else
if
(
playerships
[
bus
->
scanslot
[t +
bus
->
scanscroll
]].
align
== 0)
// enemy
149
hi =
Rendering::ColorARGB
(255, 192, 0, 0);
// red
150
else
151
hi =
Rendering::ColorARGB
(255, 192, 192, 192);
// white
152
if
(
playerships
[
bus
->
scanslot
[t +
bus
->
scanscroll
]].
logolight
)
153
{
154
hi.
r
*= 1.328125f;
155
hi.
g
*= 1.328125f;
156
hi.
b
*= 1.328125f;
157
}
158
}
159
160
char
ivr[7];
161
if
(
playerships
[
bus
->
scanslot
[t +
bus
->
scanscroll
]].
transponder
&&
playerships
[0].
transponder
)
162
strcpy_s(ivr,
sizeof
ivr,
playerships
[
bus
->
scanslot
[t +
bus
->
scanscroll
]].
IVR
);
163
else
164
strcpy_s(ivr,
sizeof
ivr,
"PRONLY"
);
165
166
if
((t +
bus
->
scanscroll
) ==
bus
->
targetC
)
167
swprintf_s(str, 99, L
">%-6S %.3f km"
, ivr,
bus
->
scandist
[t +
bus
->
scanscroll
]);
168
else
169
swprintf_s(str, 99, L
" %-6S %.3f km"
, ivr,
bus
->
scandist
[t +
bus
->
scanscroll
]);
170
DrawTextW(str, 0, yText, 0, DT_NOCLIP, hi);
171
yText += yTextIncr;
172
}
173
}
174
175
if
(
ourcockpit
.
spaceCapable
)
176
{
177
if
(
bus
->
targetC
== -4)
178
{
179
thji =
'>'
;
180
bus
->
TargetDistanceKm
=
allobjects
[2].
distance
;
181
}
182
else
183
thji =
' '
;
184
// SENTRY STATION
185
if
(
playerships
[0].portassigned != -1 &&
playerships
[0].reference ==
REF_DOCKYSP
)
186
{
187
if
(
playerships
[0].docked)
188
result =
playerships
[0].
dockoffset
-
dockInterface
;
189
else
190
result =
playerships
[0].
dockoffset
-
dockMarker
;
191
swprintf_s(str, 99, L
"%CYSP%i %.3f km"
, thji,
playerships
[0].portassigned,
RiseMath::Vec3Length
(&result));
192
}
193
else
194
{
195
if
(
allobjects
[2].distance > 10000.0f)
196
swprintf_s(str, 99, L
"%CYSP %.3f kkm"
, thji,
allobjects
[2].distance * 0.001f);
197
else
198
swprintf_s(str, 99, L
"%CYSP %.3f km"
, thji,
allobjects
[2].distance);
199
}
200
201
hi =
Rendering::ColorARGB
(255, 0, 255, 255);
// cyan
202
DrawTextW(str, 0, yText, 0, DT_NOCLIP, hi);
203
yText += yTextIncr;
204
205
206
if
(
bus
->
targetC
== -3)
207
{
208
thji =
'>'
;
209
bus
->
TargetDistanceKm
=
allobjects
[1].
distance
;
210
}
211
else
212
thji =
' '
;
213
// EASYDOCK
214
if
(
playerships
[0].portassigned != -1 &&
playerships
[0].reference ==
REF_DOCKTAC
)
215
{
216
if
(
playerships
[0].docked)
217
result =
playerships
[0].
dockoffset
-
dockInterface
;
218
else
219
result =
playerships
[0].
dockoffset
-
dockMarker
;
220
swprintf_s(str, 99, L
"%CTAC%i %.3f km"
, thji,
playerships
[0].portassigned + 1,
RiseMath::Vec3Length
(&result));
221
}
222
else
223
{
224
if
(
allobjects
[1].distance > 10000.0f)
225
swprintf_s(str, 99, L
"%CTAC %.3f kkm"
, thji,
allobjects
[1].distance * 0.001f);
226
else
227
swprintf_s(str, 99, L
"%CTAC %.3f km"
, thji,
allobjects
[1].distance);
228
}
229
230
hi =
Rendering::ColorARGB
(255, 0, 255, 255);
// cyan
231
DrawTextW(str, 0, yText, 0, DT_NOCLIP, hi);
232
yText += yTextIncr;
233
234
235
236
if
(
bus
->
targetC
== -2)
237
{
238
thji =
'>'
;
239
bus
->
TargetDistanceKm
=
allobjects
[0].
distance
;
240
}
241
else
242
thji =
' '
;
243
// Cutter's Port
244
if
(
playerships
[0].portassigned != -1 &&
playerships
[0].reference ==
REF_DOCKENUMCPOC
)
245
{
246
if
(
playerships
[0].docked)
247
result =
playerships
[0].
dockoffset
-
dockInterface
;
248
else
249
result =
playerships
[0].
dockoffset
-
dockMarker
;
250
if
(
playerships
[0].portassigned == 6)
// deluge
251
swprintf_s(str, 99, L
"%CCPOCd %.3f km"
, thji,
RiseMath::Vec3Length
(&result));
252
else
253
swprintf_s(str, 99, L
"%CCPOC%i %.3f km"
, thji,
playerships
[0].portassigned + 1,
RiseMath::Vec3Length
(&result));
254
}
255
else
256
{
257
if
(
allobjects
[0].distance > 10000.0f)
258
swprintf_s(str, 99, L
"%CCPOC %.3f kkm"
, thji,
allobjects
[0].distance * 0.001f);
259
else
260
swprintf_s(str, 99, L
"%CCPOC %.3f km"
, thji,
allobjects
[0].distance);
261
}
262
263
hi =
Rendering::ColorARGB
(255, 0, 255, 255);
// cyan
264
DrawTextW(str, 0, yText, 0, DT_NOCLIP, hi);
265
yText += yTextIncr;
266
}
// end of sv
267
268
269
if
(
bus
->
scanscroll
< (
bus
->
topscroll
- (
ourcockpit
.
scanDisplayVesselLimit
- 1)))
270
DrawTextW(L
" vvv MORE vvv"
, 22, yText, 0, DT_NOCLIP,
Rendering::ColorARGB
(255, 255, 255, 0));
271
273
//if (ourcockpit.nextgen)
274
//{
275
// RiseMath::Matrix transform;
276
// RiseMath::MatrixIdentity(&transform);
277
// bus->m_spriteVector->SetTransform(&transform);
278
//}
279
280
//bus->m_spriteVector->End();
281
// }
282
}
283
284
void
ContactList::FrameMove
(
float
fElapsed)
285
{
286
flashtime
-= fElapsed;
287
288
}
Bus.h
Instrument.h
MathUtilities.h
GetArcDist
float GetArcDist(RiseMath::Vector3 from, RiseMath::Vector3 to, bool includeAltDiff)
Definition
MathUtilities.h:38
REF_DOCKTAC
@ REF_DOCKTAC
Definition
ServerTypes.h:54
REF_DOCKENUMCPOC
@ REF_DOCKENUMCPOC
Definition
ServerTypes.h:53
REF_DOCKYSP
@ REF_DOCKYSP
Definition
ServerTypes.h:55
Bus
Definition
Bus.h:20
Bus::TargetDistanceKm
float TargetDistanceKm
Definition
Bus.h:502
Bus::GroundSpeedKms
float GroundSpeedKms
Definition
Bus.h:179
Bus::TimeToNextFix
char TimeToNextFix[6]
Definition
Bus.h:505
Bus::targetC
short targetC
Definition
Bus.h:480
Bus::topscroll
long topscroll
Definition
Bus.h:483
Bus::lastWaypointLocation
RiseMath::Vector3 lastWaypointLocation
Definition
Bus.h:501
Bus::scandist
float scandist[MAX_SCAN]
Definition
Bus.h:486
Bus::waypoint
std::vector< Swaypoint > waypoint
Definition
Bus.h:500
Bus::AddCommand
void AddCommand(const Command &command, bool onlyOne)
Definition
Bus.cpp:5
Bus::scanslot
short scanslot[MAX_SCAN]
Definition
Bus.h:485
Bus::WPtargetC
int WPtargetC
Definition
Bus.h:499
Bus::scanscroll
long scanscroll
Definition
Bus.h:483
Bus::waypointDistanceKm
float waypointDistanceKm
Definition
Bus.h:482
ContactList::FrameMove
void FrameMove(float fElapsed) override
Definition
ContactList.cpp:284
ContactList::Render
void Render() override
Definition
ContactList.cpp:13
ContactList::flashtime
float flashtime
Definition
Instrument.h:709
ContactList::ContactList
ContactList(int prmX, int prmY, float prmXScale, float prmYScale, Bus *prmBus, Logger *prmLogger, DeviceObject *prmDevice, std::vector< Font * > prmFonts)
Definition
ContactList.cpp:5
DeviceObject
Definition
DeviceObject.h:8
Instrument::bus
Bus * bus
Definition
Instrument.h:22
Instrument::cacheFixedText
bool cacheFixedText
Definition
Instrument.h:26
Instrument::Instrument
Instrument(int prmX, int prmY, float prmXScale, float prmYScale, Bus *prmBus, Logger *prmLogger, DeviceObject *prmDevice, std::vector< Font * > prmFonts)
Definition
Instrument.h:36
Instrument::logger
Logger * logger
Definition
Instrument.h:23
Instrument::defaultFont
UINT defaultFont
Definition
Instrument.h:24
Logger
Definition
Logger.h:11
Logger::Log
void Log(const char *msg, Level level=Info, int errorCode=0)
Definition
Logger.cpp:283
Logger::AddToCallStack
void AddToCallStack(const char *msg)
Definition
Logger.cpp:355
Logger::Error
@ Error
Definition
Logger.h:28
playerships
s_network_objects playerships[MAX_SCAN]
Definition
globals.cpp:112
dockMarker
RiseMath::Vector3 dockMarker
Definition
globals.cpp:34
allobjects
s_universe_object allobjects[maxstarC]
Definition
globals.cpp:108
ourcockpit
Scockpit ourcockpit
Definition
globals.cpp:114
dockInterface
RiseMath::Vector3 dockInterface
Definition
globals.cpp:35
Rendering::ColorARGB
constexpr PackedColor ColorARGB(unsigned a, unsigned r, unsigned g, unsigned b)
Definition
ClientTypes11.h:305
RiseMath::Vec3Length
float Vec3Length(const Vector3 *a)
Definition
ClientMath.h:95
Command
Definition
Command.h:6
Command::name
std::string name
Definition
Command.h:11
RiseMath::Color
Definition
ClientMath.h:67
RiseMath::Color::b
float b
Definition
ClientMath.h:68
RiseMath::Color::g
float g
Definition
ClientMath.h:68
RiseMath::Color::r
float r
Definition
ClientMath.h:68
RiseMath::Vector3
Definition
ClientMath.h:38
Scockpit::scanDisplayVesselLimit
short scanDisplayVesselLimit
Definition
globals.h:725
Scockpit::power
float power
Definition
globals.h:599
Scockpit::spaceCapable
bool spaceCapable
Definition
globals.h:596
s_network_objects::active
bool active
Definition
globals.h:528
s_network_objects::IVR
char IVR[7]
Definition
globals.h:494
s_network_objects::transponder
bool transponder
Definition
globals.h:529
s_network_objects::isOnScanner
bool isOnScanner
Definition
globals.h:541
s_network_objects::dockoffset
RiseMath::Vector3 dockoffset
Definition
globals.h:511
s_network_objects::align
char align
Definition
globals.h:530
s_network_objects::battleRoyale
bool battleRoyale
Definition
globals.h:570
s_network_objects::logolight
bool logolight
Definition
globals.h:528
s_network_objects::visible
bool visible
Definition
globals.h:528
s_universe_object::distance
float distance
Definition
globals.h:462
Instruments
ContactList.cpp
Generated on
for Rise by
1.18.0