Rise
The Vieneo Province
Loading...
Searching...
No Matches
Networking.cpp
Go to the documentation of this file.
1#include "Networking.h"
2#include <RakNetStatistics.h>
3#include "packetpriority.h"
4
5#include "GameClass.h"
9#include "RakSleep.h"
11#include "MathUtilities.h"
14#include "TelemetrySnapshot.h"
17
18#include <io.h>
19#include <cmath>
20#include <vector>
21#include <cstddef>
22
23static_assert(sizeof(SPacketBig) == 92, "City logo assignment payload size");
24static_assert(offsetof(SPacketBig, type) == 0 && offsetof(SPacketBig, msg) == 4 &&
25 offsetof(SPacketBig, vehicleId) == 88, "City logo assignment wire offsets");
26
27namespace
28{
29 bool ApplyImmediateContainedVehicleTelemetry(unsigned char slot, Telemetry::MotionSnapshot snapshot)
30 {
31 if (!Telemetry::IsFinite(snapshot.position) || !Telemetry::IsFinite(snapshot.velocity) ||
34 !std::isfinite(snapshot.steerDeflection) || !Telemetry::NormalizeQuaternion(snapshot.orientation))
35 {
36 return false;
37 }
38
39 s_network_objects& vehicle = playerships[slot];
40 vehicle.acc = RiseMath::Vector3(static_cast<float>(snapshot.acceleration.x),
41 static_cast<float>(snapshot.acceleration.y), static_cast<float>(snapshot.acceleration.z));
42 vehicle.dockoffset = RiseMath::Vector3(static_cast<float>(snapshot.position.x),
43 static_cast<float>(snapshot.position.y), static_cast<float>(snapshot.position.z));
44 vehicle.dockingvel = RiseMath::Vector3(static_cast<float>(snapshot.velocity.x),
45 static_cast<float>(snapshot.velocity.y), static_cast<float>(snapshot.velocity.z));
46 vehicle.orientation = RiseMath::Quaternion(static_cast<float>(snapshot.orientation.x),
47 static_cast<float>(snapshot.orientation.y), static_cast<float>(snapshot.orientation.z),
48 static_cast<float>(snapshot.orientation.w));
49 vehicle.pitch = static_cast<float>(snapshot.angularVelocity.x);
50 vehicle.yawRadPerSec = static_cast<float>(snapshot.angularVelocity.y);
51 vehicle.rollRadPerSec = static_cast<float>(snapshot.angularVelocity.z);
52 vehicle.tx = static_cast<float>(snapshot.thrust.x);
53 vehicle.ty = static_cast<float>(snapshot.thrust.y);
54 vehicle.tz = static_cast<float>(snapshot.thrust.z);
55 vehicle.pitchdeflect = static_cast<float>(snapshot.controlDeflection.x);
56 vehicle.rolldeflect = static_cast<float>(snapshot.controlDeflection.y);
57 vehicle.yawdeflect = static_cast<float>(snapshot.controlDeflection.z);
58 vehicle.steerdeflect = static_cast<float>(snapshot.steerDeflection);
59
60 vehicle.positer = vehicle.posleft = vehicle.veliter = vehicle.velleft = centerC;
61 vehicle.acciter = vehicle.accleft = centerC;
62 vehicle.orientiter = vehicle.orientleft = RiseMath::Quaternion(0, 0, 0, 0);
63 vehicle.pitchleft = vehicle.pitchiter = vehicle.rollleft = vehicle.rolliter = 0.0f;
64 vehicle.yawleft = vehicle.yawiter = 0.0f;
65 vehicle.txleft = vehicle.tyleft = vehicle.tzleft = 0.0f;
66 vehicle.txiter = vehicle.tyiter = vehicle.tziter = 0.0f;
67 return true;
68 }
69}
70
72{
73 game = g;
74
75 serverC = RakNet::UNASSIGNED_SYSTEM_ADDRESS;
76 patchbytes = 0L;
77 rcvdbytes = 0L;
78 retryconnect = 0;
79 p = nullptr;
80
81 rakPeer = RakNet::RakPeerInterface::GetInstance();
82
83 RakNet::SocketDescriptor socketdesc;
84 socketdesc.port = 0; // anything else locks more than one client from connecting
85 socketdesc.hostAddress[0] = 0; // INADDR_ANY
86 const RakNet::StartupResult startupResult = rakPeer->Startup(1, &socketdesc, 1);
87 if (startupResult != RakNet::StartupResult::RAKNET_STARTED)
88 game->logger->Log("NetFactory->Startup", Logger::Level::Fatal);
89
90 Trace("Connecting to server...");
91 const RakNet::ConnectionAttemptResult connectResult = Connect();
92 if (connectResult != RakNet::ConnectionAttemptResult::CONNECTION_ATTEMPT_STARTED)
93 Rendering::TraceFailure(L"NetFactory->Connect", NULL);
95}
96
97void Networking::Trace(const char* msg, Logger::Level severity) const
98{
99 char newmsg[999];
100 sprintf_s(newmsg, sizeof newmsg, "NETWORK: %s", msg);
101 game->logger->Log(newmsg, severity);
102}
103
105{
107 if (!rakPeer)
108 return;
109
110 Trace("Shutting down network factory...");
111 const ULONGLONG shutdownStarted = GetTickCount64();
112 rakPeer->Shutdown(5000);
113 RakNet::RakPeerInterface::DestroyInstance(rakPeer);
114 rakPeer = nullptr;
115 char timing[96];
116 sprintf_s(timing, "Network factory stopped after %llu ms", GetTickCount64() - shutdownStarted);
117 Trace(timing);
118}
119
121{
122 bool nowHasRevenuePax = false;
123
124 for (int i = 0; i < ourcockpit.bays; i++)
125 {
126 if (game->bus->CargoBays[i] != 0)
127 {
128 const Sscan cargobay = game->bus->Scanner.Get(game->bus->CargoBays[i]);
129 if (cargobay.initialized)
130 {
132 {
133 if (cargobay.scandata.modeX.load_type.is_set())
134 {
135 if (cargobay.scandata.modeX.load_quantity.is_set())
136 {
138 {
139 nowHasRevenuePax = true;
140 break;
141 }
142 }
143 }
144 }
145 }
146 }
147 }
148
149 if (nowHasRevenuePax && !game->bus->RevenuePassengers)
150 {
151 game->bus->RevenuePassengers = true; // have to do this first or boarding announcement won't play
153 }
154 else if (!nowHasRevenuePax && game->bus->RevenuePassengers)
155 {
156 game->bus->RevenuePassengers = false;
157 }
158}
159
160void Networking::SendToServer(void* pData, DWORD dwSize, bool bGuaranteed, PacketOrdering order) const
161{
162 // Optional integrations can finish callbacks after Close releases RakNet.
163 if (!rakPeer)
164 return;
165
166 if (dwSize > 998)
167 {
168 Trace("SendToServer payload too large", Logger::Error);
169 return;
170 }
171
172 char newdata[999];
173#pragma warning( disable : 4309 )
174 newdata[0] = static_cast<char>(ID_USER_PACKET_ENUM);
175#pragma warning( disable : 4309 )
176 memcpy_s(&newdata[1], 998, pData, dwSize);
177
178 PacketReliability reliability;
179 if (bGuaranteed)
180 {
181 if (order == ORDERING_NONE)
182 reliability = RELIABLE;
183 else
184 reliability = RELIABLE_ORDERED;
185 }
186 else
187 {
188 reliability = UNRELIABLE;
189 }
190
191 rakPeer->Send(newdata, dwSize + 1, MEDIUM_PRIORITY, reliability, order, serverC, false);
192}
193
195{
196 char newdata[999];
197#pragma warning( disable : 4309 )
198 newdata[0] = static_cast<char>(ID_USER_PACKET_TELEMETRY);
199#pragma warning( disable : 4309 )
200 memcpy_s(&newdata[1], 998, pData, sizeof SClientPacketNew);
201 rakPeer->Send(newdata, sizeof SClientPacketNew + 1, MEDIUM_PRIORITY, UNRELIABLE_SEQUENCED, ORDERING_TELEMETRY, serverC, false);
203}
204
206{
207 if (!rakPeer || rakPeer->GetConnectionState(serverC) != RakNet::IS_CONNECTED)
208 return false;
209
210 char newdata[999];
211#pragma warning( disable : 4309 )
212 newdata[0] = static_cast<char>(ID_USER_PACKET_ERROR);
213#pragma warning( disable : 4309 )
214 memcpy_s(&newdata[1], 998, pData, sizeof SErrorPacket);
215 return rakPeer->Send(newdata, sizeof SErrorPacket + 1, IMMEDIATE_PRIORITY, RELIABLE_ORDERED, ORDERING_ERRORS, serverC, false) != 0;
216}
217
219{
220 return rakPeer->GetLastPing(serverC);
221}
222
223void Networking::SendEvent(EventType eventType, float extent) const
224{
225 if (playerships[0].isSimulator)
226 return;
227
228 SClientPacket outpacket; // NOLINT
229 outpacket.type = 12; // events
230 outpacket.f_x = extent;
231 outpacket.f_y = 0.0f; // NULL
232 outpacket.f_w = static_cast<float>(eventType);
233 outpacket.f_z = 0.0f; // NULL
234 const auto ordering = eventType == EVENT_WIPERS || eventType == EVENT_WINDSHIELD_FAULT
235 || eventType == EVENT_HORN_START || eventType == EVENT_HORN_STOP
237 SendToServer(&outpacket, sizeof(SClientPacket), true, ordering);
238
239 if (eventType == EventType::EVENT_LOGOLIGHT_OFF && ourcockpit.gearshift == -1)
240 {
245 }
246 else if (eventType == EventType::EVENT_LOGOLIGHT_ON && ourcockpit.gearshift == -1)
247 {
249 game->sound->PlayEx(SOUND_BACKUP, true);
252 }
253}
254
255std::uint32_t Networking::SendTraceFile(const char* fileContents, bool requestReceipt) const
256{
257 if (!rakPeer || rakPeer->GetConnectionState(serverC) != RakNet::IS_CONNECTED)
258 return 0;
259
260 const int length = strlen(fileContents);
261 std::vector<char> newdata(length + 2);
262 newdata[0] = static_cast<char>(ID_USER_PACKET_LOGFILE);
263 memcpy_s(&newdata[1], length, fileContents, length);
264 newdata[length + 1] = 0; // include null terminator
265 // The server pairs trace files with preceding error reports in receive order.
266 return rakPeer->Send(newdata.data(), length + 2, IMMEDIATE_PRIORITY,
267 requestReceipt ? RELIABLE_ORDERED_WITH_ACK_RECEIPT : RELIABLE_ORDERED, ORDERING_ERRORS, serverC, false);
268}
269
270RakNet::RakNetStatistics* Networking::GetStatistics() const
271{
272 return rakPeer->GetStatistics(serverC);
273}
274
275RakNet::ConnectionAttemptResult Networking::Connect() const
276{
277 return rakPeer->Connect(hostC, portC, nullptr, 0, nullptr);
278}
279
281{
282 const ULONGLONG deadline = GetTickCount64() + 5000;
283 do
284 {
285 RakSleep(10);
286 if (!rakPeer || rakPeer->GetConnectionState(serverC) != RakNet::IS_CONNECTED)
287 return false;
288 RakNet::RakNetStatistics stats = {};
289 if (!rakPeer->GetStatistics(serverC, &stats))
290 return false;
291 if (!stats.messageInSendBuffer[0] && !stats.messageInSendBuffer[1] &&
292 !stats.messageInSendBuffer[2] && !stats.messageInSendBuffer[3] && !stats.bytesInResendBuffer)
293 return true;
294 } while (GetTickCount64() < deadline);
295 return false;
296}
297
298void Networking::RequestVerbiage(const int helpId) const
299{
300 SClientPacket outpacket;
301 outpacket.type = 40; // request help verbiage
302 outpacket.f_x = static_cast<float>(helpId);
303 outpacket.f_y = static_cast<float>(game->config.language);
304 outpacket.f_z = 0.0f; // NULL
305 outpacket.f_w = 0.0f; // NULL
306 SendToServer(&outpacket, sizeof(SClientPacket), true);
307}
308
309void Networking::SendChatMessage(unsigned char channel, unsigned char player, const WCHAR* message) const
310{
311 char newdata[TRANSMIT_CHAT_SIZE * 2 + 3]; // for WCHAR to char, and type, and channel
312#pragma warning( disable : 4309 )
313 newdata[0] = static_cast<char>(ID_USER_PACKET_CHAT);
314#pragma warning( disable : 4309 )
315 newdata[1] = channel;
316 newdata[2] = player; // obviously the server is going to know who we are but to regurgitate this we need the server to update the player ID
317 size_t msgLen = wcslen(message);
318 if (msgLen >= TRANSMIT_CHAT_SIZE)
319 msgLen = TRANSMIT_CHAT_SIZE - 1;
320 memcpy_s(&newdata[3], TRANSMIT_CHAT_SIZE * 2, message, (msgLen + 1) * 2); // include null and convert to char
321 rakPeer->Send(newdata, static_cast<int>((msgLen + 1) * 2 + 3), MEDIUM_PRIORITY, RELIABLE_ORDERED, ORDERING_CHAT, serverC, false);
322}
323
325{
326 char msg[199];
327 sprintf_s(msg, sizeof msg, "Networking::FrameMove (displaystage %i)", displaystage);
329
330 if (!rakPeer)
331 return;
332
333 const auto cloudSnapshot=cloudWeather.Latest();
334 if (cloudSnapshot && cloudSnapshot->revision!=cloudWeatherLoggedRevision)
335 {
336 cloudWeatherLoggedRevision=cloudSnapshot->revision;
337 sprintf_s(msg,sizeof msg,"Global cloud convection received: %ux%u revision %llu",
338 cloudSnapshot->mips.front().width,cloudSnapshot->mips.front().height,
339 static_cast<unsigned long long>(cloudSnapshot->revision));
340 Trace(msg);
341 }
342
343 p = rakPeer->Receive();
344 while (p)
345 {
346 // Bulk cloud data can arrive during splash/login. Never route it through
347 // the legacy size-based dispatcher or perform decoding on this thread.
348 if (p->length && p->data[0] == ID_USER_PACKET_CLOUD_WEATHER)
349 {
350 if (p->systemAddress == serverC) cloudWeather.Submit(p->data,p->length);
351 rakPeer->DeallocatePacket(p);
352 p = rakPeer->Receive();
353 continue;
354 }
355 if (p->length && (p->data[0] == ID_CONNECTION_REQUEST_ACCEPTED ||
356 p->data[0] == ID_DISCONNECTION_NOTIFICATION || p->data[0] == ID_CONNECTION_LOST))
357 {
360 if (p->data[0] == ID_CONNECTION_REQUEST_ACCEPTED)
361 {
362 serverC=p->systemAddress;
363 g_bGotConclusion = false;
365 }
366 }
367 if (p->data[0] == ID_SND_RECEIPT_ACKED)
368 {
369 if (p->length == 5)
370 {
371 std::uint32_t receipt;
372 memcpy(&receipt, p->data + 1, sizeof receipt);
374 }
375 rakPeer->DeallocatePacket(p);
376 p = rakPeer->Receive();
377 continue;
378 }
379 switch (displaystage)
380 {
382 switch (p->data[0])
383 {
384 case ID_CONNECTION_REQUEST_ACCEPTED:
385 {
386 Trace("Connected!");
387 serverC = p->systemAddress;
388 rakPeer->SetOccasionalPing(true);
389 rakPeer->SetTimeoutTime(30000, RakNet::UNASSIGNED_SYSTEM_ADDRESS);
390 }
391 break;
392
393 case ID_USER_PACKET_ENUM:
394 {
395 switch (p->length - 1)
396 {
397 case sizeof SServerPacket:
398 {
399 SServerPacket datapacket;
400 memcpy_s(&datapacket, sizeof SServerPacket, &p->data[1], p->length - 1);
401 switch (datapacket.type)
402 {
403 case 0: // Configuration packet received
404 {
406
407 const float average_ping = static_cast<float>(rakPeer->GetAveragePing(serverC)) * 0.001f;
408 g_UniverseTime = datapacket.f_x + average_ping * 0.5f;
410 //Rendering::ClientHost()->ResetFrameClock();
411 Trace("Configuration received!");
412 sprintf_s(msg, sizeof msg, " g_UniverseTime: %f", datapacket.f_x);
413 Trace(msg);
414 sprintf_s(msg, sizeof msg, " ping to server: %f", average_ping);
415 Trace(msg);
416 sprintf_s(msg, sizeof msg, " server says: %f", datapacket.f_y);
417 Trace(msg);
418 sprintf_s(msg, sizeof msg, " adjustment: %f", average_ping * 0.5f);
419 Trace(msg);
420 sprintf_s(msg, sizeof msg, " f_Uphours: %f", datapacket.f_z);
421 Trace(msg);
422
423 f_Uphours = datapacket.f_z;
424
425 game->GUI->ourplayerC = datapacket.array;
426 ourcockpit.ourplyrC = datapacket.array;
427
428 sprintf_s(msg, sizeof msg, "Our slot number: %i", ourcockpit.ourplyrC);
429 Trace(msg);
430
431 sprintf_s(msg, sizeof msg, "Requesting MOTD language: %i", game->config.language);
432 Trace(msg);
433
436 }
437 break;
438
439 case 3: // Conclusion (version too old) moved here in 2.2.16.6 on 6/26/2020
440 {
441 if (datapacket.f_y == 4.0f) // incompatible version
442 {
443 if (!game->GUI->isSteam)
444 MessageBoxW(Rendering::ClientWindow(), game->GUI->strings[L_LOGIN_VERSIONTOOOLD].c_str(), game->GUI->strings[L_SPLASH_VALIDATINGINSTALL].c_str(), MB_ICONHAND | MB_OK);
445 else
446 MessageBoxW(Rendering::ClientWindow(), game->GUI->strings[L_LOGIN_VERSIONTOOOLDSTEAM].c_str(), game->GUI->strings[L_SPLASH_VALIDATINGINSTALL].c_str(), MB_ICONHAND | MB_OK);
447 PostQuitMessage(0);
448 }
449 else
450 {
451 sprintf_s(msg, sizeof msg, "Unexpected conclusion Y type: %.0f", datapacket.f_y);
453 }
454 }
455 break;
456
457 case 30: // dock positions
458 {
459 const float average_ping = static_cast<float>(rakPeer->GetAveragePing(serverC)) * 0.001f;
460 allobjects[0].revoffset = datapacket.f_x + allobjects[0].revolution * average_ping * 0.5f;
461 allobjects[1].revoffset = datapacket.f_y + allobjects[1].revolution * average_ping * 0.5f;
462 allobjects[2].revoffset = datapacket.f_z + allobjects[2].revolution * average_ping * 0.5f;
463
464 sprintf_s(msg, sizeof msg, "Received facility CPOC revolutionProgress %.3f with ping adjustment %.3fs",
465 datapacket.f_x, average_ping * 0.5f);
466 Trace(msg);
467 sprintf_s(msg, sizeof msg, "Received facility TAC revolutionProgress %.3f with ping adjustment %.3fs",
468 datapacket.f_y, average_ping * 0.5f);
469 Trace(msg);
470 sprintf_s(msg, sizeof msg, "Received facility YSP revolutionProgress %.3f with ping adjustment %.3fs",
471 datapacket.f_z, average_ping * 0.5f);
472 Trace(msg);
473 }
474 break;
475
476 case 34: // ignore radio transmissions in Splash
477 break;
478
479 case 38: // patch information
480 {
481 patchbytes = static_cast<unsigned long>(datapacket.f_x);
482 rcvdbytes = 0L;
483 sprintf_s(msg, sizeof msg, "STATUS_SPLASH autopatcher expecting total bytes: %i", patchbytes);
484 Trace(msg);
485 }
486 break;
487
488 default:
489 {
490 sprintf_s(msg, sizeof msg, "STATUS_SPLASH unknown SServerPacket packet type: %i", datapacket.type);
492 }
493 break;
494 }
495 }
496 break;
497
498 case sizeof SPacketBig:
499 {
500 SPacketBig datapacket;
501 memcpy_s(&datapacket, sizeof SPacketBig, &p->data[1], p->length - 1);
502 switch (datapacket.type)
503 {
504 case 14: // dock data ignored?
505 break;
506
507 case 29: // patching finished
508 {
509 Trace("Patching finished!");
510
512 rcvdbytes = patchbytes = 0L;
513
514 strcpy_s(game->config.patchdate, 24, datapacket.msg);
515 int patchDateError = 0;
516 unsigned long patchDateOsError = 0;
517 if (game->config.SavePatchDate(patchDateError, patchDateOsError))
518 {
519 char newpatchdate[99];
520 sprintf_s(newpatchdate, sizeof newpatchdate, "STATUS_SPLASH autopatcher patchdate.txt now: %s", game->config.patchdate);
521 Trace(newpatchdate);
522 }
523 else
524 {
525 char patchDateErrorMessage[199];
526 sprintf_s(patchDateErrorMessage, sizeof patchDateErrorMessage,
527 "Could not save patchdate.txt after retrying (CRT %i, Windows %lu); continuing and will retry next startup.",
528 patchDateError, patchDateOsError);
529 Trace(patchDateErrorMessage, Logger::Level::Warn);
530 }
531
533 {
534 Trace("The Rise binaries have been updated and must be restarted!");
535 MessageBox(Rendering::ClientWindow(), L"The Rise binaries have been updated and must be restarted!", L"Finished Patching", MB_ICONINFORMATION | MB_OK);
536#ifndef _DEBUG
537 PostQuitMessage(0);
538#endif
539 }
540
541 break;
542 }
543
544 default:
545 sprintf_s(msg, sizeof msg, "STATUS_SPLASH unknown SPacketBig packet type: %i", datapacket.type);
547 break;
548 }
549 break;
550 }
551
552 default:
553 sprintf_s(msg, sizeof msg, "STATUS_SPLASH unknown packet length: %i", p->length - 1);
555 break;
556 }
557 break;
558 }
559
560 case ID_CONNECTION_ATTEMPT_FAILED:
561 case ID_NO_FREE_INCOMING_CONNECTIONS:
562 {
563 const RakNet::ConnectionAttemptResult result = Connect();
564 if (result != RakNet::ConnectionAttemptResult::CONNECTION_ATTEMPT_STARTED)
565 game->logger->Log("NetFactory->Connect", Logger::Level::Fatal);
566 else
567 {
568 if (p->data[0] == ID_CONNECTION_ATTEMPT_FAILED)
569 Trace("Retrying (ID_CONNECTION_ATTEMPT_FAILED)...", Logger::Level::Info);
570 else
571 Trace("Retrying (ID_NO_FREE_INCOMING_CONNECTIONS)...", Logger::Level::Info);
572 }
573 retryconnect++;
574 break;
575 }
576
578 {
579 // 0 position is patch packet identifier
580
581 // 1 position is action 0 is delete otherwise add/modify
582 const char actionCode = p->data[1];
583
584 // 2 position is pathAndFileName, 128 total length
585 char pathAndFileName[128];
586 memcpy_s(pathAndFileName, sizeof pathAndFileName - 1, &p->data[2], sizeof pathAndFileName - 1);
587 pathAndFileName[sizeof pathAndFileName - 1] = '\0';
588
589 // 3 position starts the data to length - 130
590 const int fileLength = p->length - 130;
591 rcvdbytes += fileLength;
592
593 if (actionCode == 0) // delete
594 {
595 sprintf_s(msg, sizeof msg, "Autopatcher delete: %s", pathAndFileName);
596 Trace(msg);
597
598 const int result = _unlink(pathAndFileName);
599 if (result == -1 && errno != ENOENT) // if it isn't there we got no problem!
600 {
601 sprintf_s(msg, sizeof msg, "Autopatcher could not delete file \"%s\": %i", pathAndFileName, errno);
603 }
604 }
605 else // add or update
606 {
607 sprintf_s(msg, sizeof msg, "Autopatcher add/update bytes %i: %s", fileLength, pathAndFileName);
608 Trace(msg);
609
610 if (strcmp(pathAndFileName, "Rise.exe") == 0)
611 {
613 strcpy_s(pathAndFileName, 128, "Rise1.exe");
614 }
615 if (_stricmp(pathAndFileName, "CrashHandler.exe") == 0)
616 {
618 strcpy_s(pathAndFileName, 128, "CrashHandler1.exe");
619 }
620 if (_stricmp(pathAndFileName, "steam_api64.dll") == 0)
621 {
623 strcpy_s(pathAndFileName, 128, "steam_api641.dll");
624 }
625 if (strcmp(pathAndFileName, "steam_api.dll") == 0)
626 {
628 strcpy_s(pathAndFileName, 128, "steam_api1.dll");
629 }
630 if (strcmp(pathAndFileName, "bass.dll") == 0)
631 {
633 strcpy_s(pathAndFileName, 128, "bass1.dll");
634 }
635 if (strcmp(pathAndFileName, "bass_fx.dll") == 0)
636 {
638 strcpy_s(pathAndFileName, 128, "bass_fx1.dll");
639 }
640 if (strcmp(pathAndFileName, "RakNet.dll") == 0)
641 {
643 strcpy_s(pathAndFileName, 128, "RakNet1.dll");
644 }
645 if (strcmp(pathAndFileName, "discord_partner_sdk.dll") == 0)
646 {
648 strcpy_s(pathAndFileName, 128, "discord_partner_sdk1.dll");
649 }
650 if (strcmp(pathAndFileName, "FreeTrackClient.dll") == 0)
651 {
653 strcpy_s(pathAndFileName, 128, "FreeTrackClient1.dll");
654 }
655
656 const size_t pathLen = strlen(pathAndFileName);
657 for (size_t endIndex = 1; endIndex < pathLen; ++endIndex)
658 {
659 if (pathAndFileName[endIndex] == '\\')
660 {
661 pathAndFileName[endIndex] = 0;
662 _mkdir(pathAndFileName);
663 pathAndFileName[endIndex] = '\\';
664 }
665 }
666
667 int file;
668 _sopen_s(&file, pathAndFileName, _O_WRONLY | _O_CREAT | _O_TRUNC | _O_BINARY | _O_SEQUENTIAL, _SH_DENYNO, _S_IWRITE);
669 if (file == -1)
670 {
671 switch (errno)
672 {
673 case EACCES: sprintf_s(msg, sizeof msg, "Autopatcher could not access file \"%s\": EACCES", pathAndFileName); break;
674 case EEXIST: sprintf_s(msg, sizeof msg, "Autopatcher could not access file \"%s\": EEXIST", pathAndFileName); break;
675 case EINVAL: sprintf_s(msg, sizeof msg, "Autopatcher could not access file \"%s\": EINVAL", pathAndFileName); break;
676 case EMFILE: sprintf_s(msg, sizeof msg, "Autopatcher could not access file \"%s\": EMFILE", pathAndFileName); break;
677 case ENOENT: sprintf_s(msg, sizeof msg, "Autopatcher could not access file \"%s\": ENOENT", pathAndFileName); break;
678 default: sprintf_s(msg, sizeof msg, "Autopatcher could not access file \"%s\": %i", pathAndFileName, errno);
679 }
681 }
682
683 _write(file, &p->data[130], fileLength);
684 _close(file);
685 }
686 break;
687 }
688
690 {
691 Trace("Got MOTD through ID_USER_PACKET_HELP!");
692 WCHAR newchat[510];
693 memcpy_s(newchat, sizeof newchat, &p->data[1], sizeof newchat);
694
695 HRESULT hr;
696
697 // MOTD text
698 game->GUI->motd.clear();
699 size_t startOfLine = 0;
700 size_t lastGoodSpaceIndex = 0;
701 const size_t newchatLen = wcslen(newchat);
702 for (size_t i = 0; i < newchatLen - startOfLine; i++)
703 {
704 size_t i1 = newchatLen - startOfLine - 1;
705 // taking substring from startOfLine for X characters
706 WCHAR tempStr[510];
707 wcscpy_s(tempStr, 510, &newchat[startOfLine]);
708 // truncate
709 tempStr[i + 1] = 0;
710 // render and calculate
711 RECT rect = RECT();
712 try
713 {
714 V(game->GUI->g_pFont->DrawTextW(game->GUI->g_pTextSprite, tempStr, -1, &rect, DT_CALCRECT, 0xFFFFFFFF));
715 }
716 catch (...)
717 {
718 // apparently we get an exception trying to calculate "\n "?
719 }
720 // evaluate
721 if (rect.right < 210 && i != i1)
722 {
723 if (tempStr[i] == L' ' || tempStr[i] == L'\xff01' || tempStr[i] == L'\x3002' || tempStr[i] == L'\xff0c')
724 lastGoodSpaceIndex = i;
725 }
726 else
727 {
728 // back up to lastGoodSpaceIndex and push
729 if (lastGoodSpaceIndex != 0 && i != i1)
730 {
731 if (tempStr[lastGoodSpaceIndex] == L' ')
732 tempStr[lastGoodSpaceIndex] = 0;
733 else
734 tempStr[lastGoodSpaceIndex + 1] = 0;
735 }
736 game->GUI->motd.emplace_back(tempStr);
737 if (i == i1)
738 break;
739 if (lastGoodSpaceIndex != 0)
740 startOfLine += lastGoodSpaceIndex + 1;
741 else
742 startOfLine += wcslen(tempStr) + 1;
743 i = 0;
744 lastGoodSpaceIndex = 0;
745 }
746 }
747 }
748 break;
749
750 case ID_RAKVOICE_DATA: // Ignoring in Splash page
751 break;
752
753 default:
754 {
755 sprintf_s(msg, sizeof msg, "STATUS_SPLASH unknown packet ID: %i", p->data[0]);
757 break;
758 }
759 }
760 break;
761
763 {
764 switch (p->data[0])
765 {
766 case ID_USER_PACKET_ENUM:
767 {
768 switch (p->length - 1)
769 {
770 case sizeof SServerPacket:
771 {
772 SServerPacket datapacket;
773 memcpy_s(&datapacket, sizeof SServerPacket, &p->data[1], p->length - 1);
774 switch (datapacket.type)
775 {
776 case 24: // Result of immigration request
777 {
778 game->GUI->rxbuffer += p->length;
779 // 24=immigration x=validationtest(0=newhandle,1=referral), y=validationpass1fail0, z=, array=(0=done! 1=handle taken 2=can'tfindreferral, 3=updated, 4=validation)
780 if (datapacket.array == 0 || datapacket.array == 3)
781 {
782 if (!game->GUI->emailValidation.PendingSave() || !game->GUI->pBuffer) break;
783 char savedEmail[32];
784 if (game->GUI->GetImmigrationEmail(savedEmail))
785 strcpy_s(game->GUI->player[game->GUI->ourplayerC].email, savedEmail);
786 // These form values become saved state only after the server accepts them.
787 sprintf_s(game->GUI->player[game->GUI->ourplayerC].characterName, 30, "%.29S",
789 game->GUI->player[game->GUI->ourplayerC].heightCm = static_cast<unsigned char>(
791 ourcockpit.chaireye.z = static_cast<float>(game->GUI->player[game->GUI->ourplayerC].heightCm - 12) * 0.00001f;
793 std::vector<char> newdata(game->GUI->pBuffer->GetBufferSize() + 1);
794 newdata[0] = static_cast<char>(ID_USER_PACKET_AVATAR);
795 // include null and convert to char
796 memcpy_s(&newdata[1], game->GUI->pBuffer->GetBufferSize(), game->GUI->pBuffer->GetBufferPointer(), game->GUI->pBuffer->GetBufferSize());
797 rakPeer->Send(newdata.data(), game->GUI->pBuffer->GetBufferSize() + 1, MEDIUM_PRIORITY, RELIABLE, ORDERING_NONE, serverC, false);
798 game->GUI->txbuffer += static_cast<short>(game->GUI->pBuffer->GetBufferSize()) + 1;
800 game->UpdateTrackedResource("pBuffer", 3);
801
802 game->sound->loopintro = false;
803 game->GUI->immigrationPassed = true;
804
805 if (datapacket.array == 0)
806 {
807 SClientPacket outpacket;
808 outpacket.type = 3; // Request completion of data (online player data and immigration info)
809 outpacket.f_x = 0.0f; // NULL
810 outpacket.f_y = 0.0f; // NULL
811 outpacket.f_z = 0.0f; // NULL
812 outpacket.f_w = 0.0f; // NULL
813 SendToServer(&outpacket, sizeof(SClientPacket), true);
814
816 }
817 }
818 else if (datapacket.array == 4) // validator
819 {
820 game->GUI->rxbuffer += p->length;
821 if (datapacket.f_x == 0.0f) // handle
822 {
823 if (datapacket.f_y == 1.0f)
824 game->GUI->handleValid = 2; // passed
825 else
826 {
827 game->GUI->handleValid = 0; // failed
828 if (datapacket.f_z == 1.0f)
829 MessageBoxW(Rendering::ClientWindow(), game->GUI->strings[L_MESSAGE_RESERVED].c_str(), game->GUI->strings[L_MESSAGE_CALLSIGN].c_str(), MB_ICONHAND | MB_OK);
830 else if (datapacket.f_z == 2.0f)
831 MessageBoxW(Rendering::ClientWindow(), game->GUI->strings[L_MESSAGE_VULGARITY].c_str(), game->GUI->strings[L_MESSAGE_CALLSIGN].c_str(), MB_ICONHAND | MB_OK);
832 else if (datapacket.f_z == 3.0f)
833 MessageBoxW(Rendering::ClientWindow(), game->GUI->strings[L_MESSAGE_DUPLICATE].c_str(), game->GUI->strings[L_MESSAGE_CALLSIGN].c_str(), MB_ICONHAND | MB_OK);
834 else if (datapacket.f_z == 4.0f)
835 MessageBoxW(Rendering::ClientWindow(), game->GUI->strings[L_MESSAGE_SPACES].c_str(), game->GUI->strings[L_MESSAGE_CALLSIGN].c_str(), MB_ICONHAND | MB_OK);
836 else if (datapacket.f_z == 6.0f)
837 MessageBoxW(Rendering::ClientWindow(), game->GUI->strings[L_MESSAGE_SYMBOLS].c_str(), game->GUI->strings[L_MESSAGE_CALLSIGN].c_str(), MB_ICONHAND | MB_OK);
838 else if (datapacket.f_z == 9.0f)
839 MessageBoxW(Rendering::ClientWindow(), game->GUI->strings[L_MESSAGE_TOOSHORT].c_str(), game->GUI->strings[L_MESSAGE_CALLSIGN].c_str(), MB_ICONHAND | MB_OK);
840 }
841 }
842 else if (datapacket.f_x == 1.0f) // referral
843 {
844 if (datapacket.f_y == 1.0f)
845 game->GUI->referralValid = 2; // passed
846 else
847 {
848 game->GUI->referralValid = 0; // failed
849 if (datapacket.f_z == 5.0f)
850 MessageBoxW(Rendering::ClientWindow(), game->GUI->strings[L_MESSAGE_NOTFOUND].c_str(), game->GUI->strings[L_MESSAGE_REFERRAL].c_str(), MB_ICONHAND | MB_OK);
851 }
852 }
853 else if (datapacket.f_x == 2.0f) // charname
854 {
855 if (datapacket.f_y == 1.0f)
856 game->GUI->charnameValid = 2; // passed
857 else
858 {
859 game->GUI->charnameValid = 0; // failed
860 if (datapacket.f_z == 2.0f)
861 MessageBoxW(Rendering::ClientWindow(), game->GUI->strings[L_MESSAGE_VULGARITY].c_str(), game->GUI->strings[L_MESSAGE_CHARNAME].c_str(), MB_ICONHAND | MB_OK);
862 else if (datapacket.f_z == 3.0f)
863 MessageBoxW(Rendering::ClientWindow(), game->GUI->strings[L_MESSAGE_DUPLICATE].c_str(), game->GUI->strings[L_MESSAGE_CHARNAME].c_str(), MB_ICONHAND | MB_OK);
864 else if (datapacket.f_z == 6.0f)
865 MessageBoxW(Rendering::ClientWindow(), game->GUI->strings[L_MESSAGE_SYMBOLS].c_str(), game->GUI->strings[L_MESSAGE_CHARNAME].c_str(), MB_ICONHAND | MB_OK);
866 else if (datapacket.f_z == 7.0f)
867 MessageBoxW(Rendering::ClientWindow(), game->GUI->strings[L_MESSAGE_NUMBERS].c_str(), game->GUI->strings[L_MESSAGE_CALLSIGN].c_str(), MB_ICONHAND | MB_OK);
868 }
869 }
870 else if (datapacket.f_x == 3.0f) // email
871 game->GUI->ReceiveEmailValidation(datapacket.f_w, datapacket.f_y == 1.0f, datapacket.f_z);
872 }
873 else
874 {
876 }
877 break;
878 }
879 default:
881 break;
882 }
883 break;
884 }
885
886 case sizeof SPacketBig:
887 {
888 // ignoring a reference frame packet for now
889 SPacketBig datapacket;
890 memcpy_s(&datapacket, sizeof(SPacketBig), &p->data[1], p->length - 1);
891 switch (datapacket.type)
892 {
893 case 12: // Suggested name
894 {
895 game->GUI->rxbuffer += p->length;
897 game->GUI->charnameValid = 2;
898 game->GUI->g_HUD.GetRadioButton(IDC_MALE)->SetChecked(datapacket.array == 1);
900 game->GUI->player[game->GUI->ourplayerC].voice = datapacket.ship;
901 game->GUI->SexChangeOperation(datapacket.array, true);
902 WCHAR str[199];
903 swprintf_s(str, 199, L"%S", datapacket.msg);
906 break;
907 }
908 case 13: // Suggested callsign
909 {
910 game->GUI->rxbuffer += p->length;
911 game->GUI->handleValid = 2;
912 WCHAR str[199];
913 swprintf_s(str, 199, L"%S", datapacket.msg);
915 break;
916 }
917 default:
918 {
920 //char msg[199];
921 //sprintf_s(msg, sizeof msg, "STATUS_CREATE unknown SPacketBig packet type: %i", datapacket.type);
922 //Trace(msg, Logger::Level::Warn);
923 break;
924 }
925 }
926 break;
927 }
928 default:
930 break;
931 }
932 }
933 break;
934
935 default:
937 break;
938 }
939 }
940 break;
941
943 //if (p->data[0] == ID_USER_PACKET_HELP)
944 //{
945 // Trace("Got verbiage in STATUS_LOGIN phase!");
946 // WCHAR chat[512];
947 // memcpy_s(chat, 1024, &p->data[1], 1024); // 512 * 2 bytes
948 // for (size_t i = 0; i < wcslen(chat) - 1; i++)
949 // {
950 // if (chat[i] == 92 && chat[i + 1] == 'n')
951 // {
952 // chat[i] = L' ';
953 // chat[i + 1] = L'\n'; // no idea why I have to do this on some but not all \n coming from server lol
954 // }
955 // }
956 // MessageBox(Rendering::ClientWindow(), chat, L"Login Response", MB_OK);
957 //}
958 //else
960 break;
961
962 default: // loading and game
964 break;
965 }
966
967 rakPeer->DeallocatePacket(p);
968 p = rakPeer->Receive();
969 }
970
971 RakSleep(0); // must be here to give the RakNet thread a chance to do work
972
973 // Stage 80 can run before the password/completion exchange finishes. Poll
974 // after receiving packets so a late conclusion releases the queued request.
975 if (displaystage == GameState::STATUS_LOADING || displaystage == GameState::STATUS_GAME)
977
978 if (displaystage == GameState::STATUS_GAME)
979 {
980 for (UINT i = 0; i < game->bus->commandStream.size(); i++)
981 {
982 const Command command = game->bus->commandStream.at(i);
983
984 if (command.name == "UnloadCargoBay")
985 {
986 SClientPacket outpacket = SClientPacket();
987 outpacket.type = 18; // cargo ops
988 outpacket.f_x = 0.0f; // unload
989 outpacket.f_y = static_cast<float>(command.ivalues[0]); // bay number
990 outpacket.f_z = 0.0f; // NULL
991 outpacket.f_w = static_cast<float>(command.ivalues[1]); // vehicle id
992 game->networking->SendToServer(&outpacket, sizeof(SClientPacket), true);
993
994 game->bus->commandStream.erase(game->bus->commandStream.begin() + i);
995 i--; // adjust index after erase
996 }
997 else if (command.name == "UpdateMfdPage")
998 {
999 game->networking->SendEvent(EventType::EVENT_SELECT_PAGE, static_cast<float>(command.ivalues[0]));
1000 // @todo we aren't sending ivalues[1] which is the "last page"
1001
1002 game->bus->commandStream.erase(game->bus->commandStream.begin() + i);
1003 i--; // adjust index after erase
1004 }
1005 else if (command.name == "EventSelectTarget")
1006 {
1008
1009 game->bus->commandStream.erase(game->bus->commandStream.begin() + i);
1010 i--; // adjust index after erase
1011 }
1012 }
1013 }
1014
1015 sprintf_s(msg, sizeof msg, "Networking::FrameMove END (displaystage %i)", displaystage);
1016 game->logger->AddToCallStack(msg);
1017}
1018
1019void Networking::RakNetMessageHandler(RakNet::Packet* packet)
1020{
1021 char msg[999];
1022
1023 sprintf_s(msg, sizeof msg, "Networking::RakNetMessageHandler (type %i)", packet->data[0]);
1024 game->logger->AddToCallStack(msg);
1025
1026 switch (packet->data[0])
1027 {
1029 {
1030 if (packet->length < 5) break;
1031 int32_t index;
1032 memcpy(&index, packet->data + 1, sizeof index);
1033 if (index < 0)
1034 {
1035 // Negative tokens exclusively correlate proposed type-32 GIF replies.
1036 // An empty body is a retryable not-found/failure response.
1038 packet->data + 5, packet->length - 5, GetTickCount64());
1039 break;
1040 }
1041 if (packet->length == 5 || static_cast<size_t>(index) >= game->viewscreen->m_pddsLogos.size()) break;
1042 // Existing vehicle PNG ordinals retain the same wire format.
1043 HRESULT hr;
1044 V(Rendering::LoadTextureMemory(Rendering::ClientRenderer(), packet->data + 5, packet->length - 5, &game->viewscreen->m_pddsLogos.at(index)));
1045
1046 sprintf_s(msg, sizeof msg, "m_pddsLogos[%i]", index);
1047 game->UpdateTrackedResource(msg, 3);
1048 }
1049 break;
1050
1051 case ID_RAKVOICE_DATA:
1052 {
1053 if (packet->length <= 1)
1054 {
1055 Trace("Rejected empty audio packet", Logger::Warn);
1056 break;
1057 }
1059 {
1060 Trace("Received audio data (voice samples on immigration)! Playing...");
1061 try
1062 {
1065 game->sound->PlayAudioData(&packet->data[1], packet->length - 1);
1066 }
1067 catch (...)
1068 {
1069 Trace("Ignored an untyped exception playing audio data!", Logger::Warn);
1070 }
1071 break;
1072 }
1073
1074 if (ourcockpit.power <= 0.5f)
1075 break;
1076 if (playerships[0].isSimulator)
1077 break;
1079 (game->GUI->player[ourcockpit.ourplyrC].frame == REF_BUILDING && game->GUI->player[ourcockpit.ourplyrC].bldg == 2)) // vehicle or control tower
1080 {
1081 Trace("Received audio data! Playing...");
1082 game->sound->PlayAudioData(&packet->data[1], packet->length - 1);
1083 }
1084 }
1085 break;
1086
1087 case ID_USER_PACKET_SUPER: // when we log in, when we get in and out of ships, loaded and unloaded in bays, in and out of interiors
1088 {
1089 Trace("ID_USER_PACKET_SUPER received!");
1090 if (packet->length != sizeof(SSuperPacket) + 1)
1091 {
1092 sprintf_s(msg, sizeof msg, "Rejected SUPER packet size %u; expected %u", packet->length, static_cast<unsigned int>(sizeof(SSuperPacket) + 1));
1094 break;
1095 }
1096
1097 SSuperPacket datapacket = {};
1098 memcpy_s(&datapacket, sizeof datapacket, &packet->data[1], sizeof datapacket);
1099
1100 const bool invalidMotion =
1101 !std::isfinite(datapacket.positionx) || !std::isfinite(datapacket.positiony) || !std::isfinite(datapacket.positionz) ||
1102 !std::isfinite(datapacket.velocityx) || !std::isfinite(datapacket.velocityy) || !std::isfinite(datapacket.velocityz) ||
1103 !std::isfinite(datapacket.orientationx) || !std::isfinite(datapacket.orientationy) ||
1104 !std::isfinite(datapacket.orientationz) || !std::isfinite(datapacket.orientationw) ||
1105 !std::isfinite(datapacket.flapsDown) || !std::isfinite(datapacket.spoilersUp) ||
1106 !std::isfinite(datapacket.pitchDeflect) || !std::isfinite(datapacket.rollDeflect) ||
1107 !std::isfinite(datapacket.yawDeflect) || !std::isfinite(datapacket.steerDeflect);
1108 const bool invalidMetadata = datapacket.reference <= REF_ENUMMIN || datapacket.reference >= REF_ENUMMAX ||
1109 datapacket.vehicleType < VehicleType::C98 || datapacket.vehicleType > VehicleType::Estate ||
1110 (datapacket.reference == REF_INANOTHER &&
1111 (datapacket.inarray == 0 || datapacket.inarray >= MAX_SCAN ||
1112 datapacket.parentReference <= REF_ENUMMIN || datapacket.parentReference >= REF_ENUMMAX));
1113 if (invalidMotion || invalidMetadata || strnlen_s(datapacket.oldShipData, sizeof datapacket.oldShipData) == sizeof datapacket.oldShipData)
1114 {
1115 sprintf_s(msg, sizeof msg, "Rejected SUPER packet metadata ref %i parent %i slot %u vehicle %u motion %i",
1116 datapacket.reference, datapacket.parentReference, datapacket.inarray, datapacket.vehicleType, invalidMotion);
1118 break;
1119 }
1120
1121 deathinhibit = 5.0f;
1122
1123 sprintf_s(msg, sizeof msg, " Our reference %i!", datapacket.reference);
1124 Trace(msg);
1125 playerships[0].reference = datapacket.reference;
1126 if (datapacket.reference >= REF_DOCKENUMCPOC)
1127 {
1128 playerships[0].dockoffset.x = datapacket.positionx;
1129 playerships[0].dockoffset.y = datapacket.positiony;
1130 playerships[0].dockoffset.z = datapacket.positionz;
1131 playerships[0].dockingvel.x = datapacket.velocityx;
1132 playerships[0].dockingvel.y = datapacket.velocityy;
1133 playerships[0].dockingvel.z = datapacket.velocityz;
1134 RiseMath::Vec3Add(&playerships[0].position, &playerships[0].dockoffset, &allobjects[datapacket.reference - REF_DOCKENUMCPOC].position);
1135 RiseMath::Vec3Add(&playerships[0].velocity, &playerships[0].dockingvel, &allobjects[datapacket.reference - REF_DOCKENUMCPOC].velocity);
1136 sprintf_s(msg, sizeof msg, " Dock positionX %.3f Y %.3f Z %.3f (%.3f)!", allobjects[datapacket.reference - REF_DOCKENUMCPOC].position.x, allobjects[datapacket.reference - REF_DOCKENUMCPOC].position.y, allobjects[datapacket.reference - REF_DOCKENUMCPOC].position.z, RiseMath::Vec3Length(&allobjects[datapacket.reference - REF_DOCKENUMCPOC].position));
1137 Trace(msg);
1138 sprintf_s(msg, sizeof msg, " Dock velocityX %.3f Y %.3f Z %.3f (%.3f)!", allobjects[datapacket.reference - REF_DOCKENUMCPOC].velocity.x, allobjects[datapacket.reference - REF_DOCKENUMCPOC].velocity.y, allobjects[datapacket.reference - REF_DOCKENUMCPOC].velocity.z, RiseMath::Vec3Length(&allobjects[datapacket.reference - REF_DOCKENUMCPOC].velocity));
1139 Trace(msg);
1140 }
1141 else
1142 {
1143 playerships[0].position.x = datapacket.positionx;
1144 playerships[0].position.y = datapacket.positiony;
1145 playerships[0].position.z = datapacket.positionz;
1146 playerships[0].velocity.x = datapacket.velocityx;
1147 playerships[0].velocity.y = datapacket.velocityy;
1148 playerships[0].velocity.z = datapacket.velocityz;
1149 }
1150
1151 playerships[0].precisionx = static_cast<double>(playerships[0].position.x);
1152 playerships[0].precisiony = static_cast<double>(playerships[0].position.y);
1153 playerships[0].precisionz = static_cast<double>(playerships[0].position.z);
1154
1158 // gjenner found that repositioning from orbit to ground made it evaluate the air/ground friction
1161 datapacket.reference == REF_ONGROUND || datapacket.reference == REF_APNMODE);
1162
1163 sprintf_s(msg, sizeof msg, " Our positionX %.3f Y %.3f Z %.3f (%.3f)!", playerships[0].position.x, playerships[0].position.y, playerships[0].position.z, RiseMath::Vec3Length(&playerships[0].position));
1164 Trace(msg);
1165 sprintf_s(msg, sizeof msg, " Our velocityX %.3f Y %.3f Z %.3f (%.3f)!", playerships[0].velocity.x, playerships[0].velocity.y, playerships[0].velocity.z, RiseMath::Vec3Length(&playerships[0].velocity));
1166 Trace(msg);
1167
1168 RiseMath::Vector3 gthrust;
1169 float radius;
1170 playerships[0].barycentric = Viewscreen::CalculateBarycentric(&playerships[0].position, &gthrust, &radius);
1171 sprintf_s(msg, sizeof msg, " Our barycentX %.3f Y %.3f Z %.3f (%.3f)!", playerships[0].barycentric.x, playerships[0].barycentric.y, playerships[0].barycentric.z, RiseMath::Vec3Length(&playerships[0].barycentric));
1172 Trace(msg);
1173
1174 playerships[0].orientation.x = datapacket.orientationx;
1175 playerships[0].orientation.y = datapacket.orientationy;
1176 playerships[0].orientation.z = datapacket.orientationz;
1177 playerships[0].orientation.w = datapacket.orientationw;
1179
1180 game->viewscreen->rooms.clear();
1181
1183
1184#pragma region Old ship type = 9 data
1185
1186 int vehicleType, allegiance;
1187 unsigned int vehicleId;
1188 char bitstring[16], trimcolor[8];
1189
1190 playerships[0].hullname[0] = 0;
1192 {
1193 sprintf_s(msg, sizeof msg, "Released m_pddsHullDynamicTexture slot %i!", 0);
1194 Trace(msg);
1196 sprintf_s(msg, sizeof msg, "m_pddsHullDynamicTexture[%i]", 0);
1197 game->UpdateTrackedResource(msg, 3);
1198 }
1199
1200 Trace(datapacket.oldShipData);
1201
1202 int reference;
1203 char logofile[9] = { "_" };
1204 const int results = sscanf_s(datapacket.oldShipData, "%[^,],%[^,],%d,%[^,],%[^,],%[^,],%d,%u,%d,%d,%[^\n]",
1205 playerships[0].IVR, 6, bitstring, static_cast<unsigned>(sizeof bitstring), &vehicleType, ourcockpit.owner, 13, trimcolor, 8, logofile, 9, &reference, &vehicleId, &allegiance, &ourcockpit.ownerId, playerships[0].hullname, 23);
1206 // 53267, 001001001000, 3, rana, #FFFFFF, fedex, -1, 462, 0, 123, GEORGE WASHINGTON
1207 if (results < 10)
1208 {
1209 Trace(datapacket.oldShipData, Logger::Error);
1210 sprintf_s(msg, sizeof msg, "Could only parse %i of 10 required (11 optional) items from type 9 data SUPER_PACKET!", results);
1211 Trace(msg, Logger::Fatal);
1212 return;
1213 }
1214
1215 playerships[0].sequence = 0;
1216
1217 game->viewscreen->CheckLogo(0, logofile);
1218
1219 _strupr_s(playerships[0].hullname, sizeof playerships[0].hullname);
1220
1221 if (datapacket.vehicleType == VehicleType::C98 ||
1222 datapacket.vehicleType == VehicleType::C2 ||
1223 datapacket.vehicleType == VehicleType::T27 ||
1224 datapacket.vehicleType == VehicleType::C2A ||
1225 datapacket.vehicleType == VehicleType::T120 ||
1226 datapacket.vehicleType == VehicleType::T121)
1227 playerships[0].groundvehicle = true;
1228 else
1229 playerships[0].groundvehicle = false;
1230
1231 char hexcolor[11];
1232 sprintf_s(hexcolor, 11, "0x00%s", &trimcolor[1]);
1233 playerships[0].trimcolor = strtol(hexcolor, nullptr, 0);
1234
1235 if (playerships[0].vehicleId != vehicleId)
1236 {
1237 // Wait for the new vehicle's vdat without resetting lamps on a same-vehicle teleport.
1244 playerships[0].crashHornFault = false;
1245 playerships[0].hornPressed = false;
1247 playerships[0].wipers = {};
1248 }
1249 playerships[0].vehicleId = static_cast<unsigned short>(vehicleId);
1250
1251 sprintf_s(msg, sizeof msg, "ship data IVR %s vehicleId %i slot %i", playerships[0].IVR, vehicleId, 0);
1252 Trace(msg);
1253
1254 const Sscan scan = game->bus->Scanner.Get(vehicleId);
1255 if (scan.initialized)
1256 {
1258 // check that he isn't listed as a parent id of a vehicle we previously scanned
1259 if (playerships[0].reference != REF_INANOTHER)
1260 game->bus->Scanner.InsertUpdateParent(vehicleId, 0);
1261 }
1262 else
1263 playerships[0].align = 1;
1264
1265 ourcockpit.allegiance = allegiance;
1266
1267 playerships[0].police = bitstring[0] == '1';
1268 playerships[0].specialight = bitstring[1] == '1';
1269 playerships[0].transponder = bitstring[2] == '1';
1270 playerships[0].docked = bitstring[3] == '1';
1271 dockprogress = playerships[0].docked ? 1.0f : 0.0f; // if they send that we are docked it must be on startup or on transfer
1272 playerships[0].logolight = bitstring[4] == '1';
1273 bool wasSimulator = playerships[0].isSimulator;
1274 playerships[0].isSimulator = bitstring[5] == '1';
1275 if (playerships[0].isSimulator)
1276 {
1278 // Clear on receipt, including enter/exit packets between frame updates.
1283 }
1284 playerships[0].geardown = bitstring[6] == '1';
1285 playerships[0].headlight = bitstring[7] == '1';
1286 playerships[0].baydoor = bitstring[8] == '1';
1287 playerships[0].domelight = bitstring[9] == '1';
1288 playerships[0].rainProtectionEnabled = bitstring[10] == '1';
1289 if (wasSimulator || playerships[0].isSimulator) game->viewscreen->ClearCollisionEffects();
1290 //playerships[0].stolen = bitstring[11] == '1';
1291 if (bitstring[12] == '1' && !playerships[0].battleRoyale)
1292 {
1293 playerships[0].battleRoyale = true;
1294 sprintf_s(msg, sizeof msg, "BATTLE ROYALE - Vehicle slot %i (%s) is now a participant (type 9)!", 0, playerships[0].IVR);
1296 }
1297 else if (bitstring[12] == '0' && playerships[0].battleRoyale)
1298 {
1299 playerships[0].battleRoyale = false;
1300 sprintf_s(msg, sizeof msg, "BATTLE ROYALE - Vehicle slot %i (%s) was eliminated (type 9)!", 0, playerships[0].IVR);
1302 }
1303
1304 playerships[0].active = true;
1305 playerships[0].visible = true;
1306 playerships[0].online = true;
1307
1308 game->viewscreen->SetProjectionMatrices(); // for if simulator changes
1309
1310#pragma endregion
1311
1312 unsigned char wasType = playerships[0].type;
1313 playerships[0].type = datapacket.vehicleType;
1314 playerships[0].inarray = datapacket.reference == REF_INANOTHER ? datapacket.inarray : 255;
1315 if (datapacket.playerFrame == REF_INANOTHER) // means we are in a vehicle
1316 {
1317 game->viewscreen->ptrCockpit->Load(datapacket.vehicleType);
1319 playerships[0].pitch = datapacket.pitch1 / 32767.0f * rotlimitC;
1320 playerships[0].rollRadPerSec = datapacket.roll1 / 32767.0f * rotlimitC;
1321 playerships[0].yawRadPerSec = datapacket.yaw1 / 32767.0f * rotlimitC;
1322 playerships[0].bay = datapacket.bay;
1323
1324 // gjenner found that we weren't clearing this for the tower
1326 }
1327 else // in a building
1328 {
1329 ourcockpit.power = 1.0f;
1333
1335 // Fix for @sumta getting 150 mph wind in the apartment first time he starts
1337
1339 //game->GUI->player[ourcockpit.ourplyrC].floor = static_cast<int>(datapacket.floor);
1341
1342 if (datapacket.playerFrame == REF_WINDOWLESS)
1343 {
1344 switch (datapacket.playerBldg)
1345 {
1346 case 1: // Simulator Bay
1347 {
1348 if (!wasSimulator)
1349 {
1350 game->GUI->player[ourcockpit.ourplyrC].hdg = static_cast<float>(90); // entrance facing the room
1351 game->GUI->player[ourcockpit.ourplyrC].x = -948;
1352 game->GUI->player[ourcockpit.ourplyrC].y = -228;
1353 }
1354 else if (wasType == VehicleType::W6Manx)
1355 {
1356 game->GUI->player[ourcockpit.ourplyrC].hdg = RiseMath::HalfPi; // right outside simulator facing simulator
1357 game->GUI->player[ourcockpit.ourplyrC].x = 2500;
1358 game->GUI->player[ourcockpit.ourplyrC].y = -114;
1359 }
1360 else if (wasType == VehicleType::T19)
1361 {
1362 game->GUI->player[ourcockpit.ourplyrC].hdg = RiseMath::HalfPi; // right outside simulator facing simulator
1363 game->GUI->player[ourcockpit.ourplyrC].x = 1500;
1364 game->GUI->player[ourcockpit.ourplyrC].y = -114;
1365 }
1366 else if (wasType == VehicleType::E11)
1367 {
1368 game->GUI->player[ourcockpit.ourplyrC].hdg = RiseMath::HalfPi; // right outside simulator facing simulator
1370 game->GUI->player[ourcockpit.ourplyrC].y = -114;
1371 }
1372
1374
1375 // 300x222 boxes for foyers and sim bay entrances
1376 RECT westEntrance; // 0
1377 westEntrance.left = -948; westEntrance.right = -648;
1378 westEntrance.bottom = -336; westEntrance.top = -114;
1379 game->viewscreen->rooms.emplace_back(westEntrance);
1380 RECT westHall; // 1
1381 westHall.left = -648; westHall.right = 350;
1382 westHall.bottom = -336; westHall.top = -114;
1383 game->viewscreen->rooms.emplace_back(westHall);
1384 RECT bay1; // 2
1385 bay1.left = 350; bay1.right = 650;
1386 bay1.bottom = -336; bay1.top = -114;
1387 game->viewscreen->rooms.emplace_back(bay1);
1388 RECT hall2; // 3
1389 hall2.left = 650; hall2.right = 1350;
1390 hall2.bottom = -336; hall2.top = -114;
1391 game->viewscreen->rooms.emplace_back(hall2);
1392 RECT bay2; // 4
1393 bay2.left = 1350; bay2.right = 1650;
1394 bay2.bottom = -336; bay2.top = -114;
1395 game->viewscreen->rooms.emplace_back(bay2);
1396 RECT hall3;
1397 hall3.left = 1650; hall3.right = 2350;
1398 hall3.bottom = -336; hall3.top = -114;
1399 game->viewscreen->rooms.emplace_back(hall3);
1400 RECT bay3;
1401 bay3.left = 2350; bay3.right = 2650;
1402 bay3.bottom = -336; bay3.top = -114;
1403 game->viewscreen->rooms.emplace_back(bay3);
1404 RECT eastHall;
1405 eastHall.left = 2650; eastHall.right = 3670;
1406 eastHall.bottom = -336; eastHall.top = -114;
1407 game->viewscreen->rooms.emplace_back(eastHall);
1408 RECT eastEntrance;
1409 eastEntrance.left = 3670; eastEntrance.right = 3970;
1410 eastEntrance.bottom = -336; eastEntrance.top = -114;
1411 game->viewscreen->rooms.emplace_back(eastEntrance);
1412 break;
1413 }
1414 case 2: // Hangar
1415 {
1417
1418 RECT platform;
1419 platform.left = -7801; platform.right = -7350;
1420 platform.bottom = -8182; platform.top = 8182;
1421 int margin = 50;
1422 platform.left += margin;
1423 platform.right -= margin;
1424 platform.bottom += margin;
1425 platform.top -= margin;
1426 game->viewscreen->rooms.emplace_back(platform);
1427
1428 game->GUI->player[ourcockpit.ourplyrC].hdg = static_cast<float>(45); // south end facing NE
1429 game->GUI->player[ourcockpit.ourplyrC].x = platform.left;
1430 game->GUI->player[ourcockpit.ourplyrC].y = platform.bottom + 200;
1431
1432 break;
1433 }
1434 }
1435 }
1436 else if (datapacket.playerFrame == REF_BUILDING)
1437 {
1438 switch (datapacket.playerBldg)
1439 {
1440 case 1:
1441 {
1443
1444 if (oldPlayerFrame != -1) // they came from a car or something
1445 {
1446 game->GUI->player[ourcockpit.ourplyrC].hdg = static_cast<float>(-45);
1448 game->GUI->player[ourcockpit.ourplyrC].y = -1671;
1449 }
1450 else // start them in bedroom
1451 {
1452 game->GUI->player[ourcockpit.ourplyrC].hdg = static_cast<float>(-63);
1453 game->GUI->player[ourcockpit.ourplyrC].x = -193;
1454 game->GUI->player[ourcockpit.ourplyrC].y = -446;
1455 }
1456
1457 const LONG buffer = 31;
1458 const LONG centerX = 0;
1459 const LONG centerY = -129;
1460
1461 RECT livingRoom;
1462 livingRoom.left = -1042 + buffer + centerX; livingRoom.right = 100 - buffer + centerX;
1463 livingRoom.top = 739 - buffer + centerY; livingRoom.bottom = 51 + buffer + centerY;
1464 game->viewscreen->rooms.emplace_back(livingRoom);
1465 RECT hall;
1466 hall.left = -100 + buffer + centerX; hall.right = 100 - buffer + centerX;
1467 hall.top = 51 + buffer + centerY; hall.bottom = -862 + buffer + centerY;
1468 game->viewscreen->rooms.emplace_back(hall);
1469 RECT hallToKitchen;
1470 hallToKitchen.left = -124 - buffer + centerX; hallToKitchen.right = -100 + buffer + centerX;
1471 hallToKitchen.top = -662 - buffer + centerY; hallToKitchen.bottom = -862 + buffer + centerY;
1472 game->viewscreen->rooms.emplace_back(hallToKitchen);
1473 RECT northKitchen;
1474 northKitchen.left = -1042 + buffer + centerX; northKitchen.right = -124 - buffer + centerX;
1475 northKitchen.top = -662 - buffer + centerY; northKitchen.bottom = -968 + buffer + centerY;
1476 game->viewscreen->rooms.emplace_back(northKitchen);
1477 RECT middleKitchen;
1478 middleKitchen.left = -932 + buffer + centerX; middleKitchen.right = -124 - buffer + centerX;
1479 middleKitchen.top = -968 + buffer + centerY; middleKitchen.bottom = -1115 - buffer + centerY;
1480 game->viewscreen->rooms.emplace_back(middleKitchen);
1481 RECT leftKitchen;
1482 leftKitchen.left = -932 + centerX; leftKitchen.right = -589 + buffer + centerX;
1483 leftKitchen.top = -1115 - buffer + centerY; leftKitchen.bottom = -1456 + centerY;
1484 game->viewscreen->rooms.emplace_back(leftKitchen);
1485 RECT rightKitchen;
1486 rightKitchen.left = -589 + buffer + centerX; rightKitchen.right = -124 - buffer + centerX;
1487 rightKitchen.top = -1115 - buffer + centerY; rightKitchen.bottom = -1573 + buffer + centerY;
1488 game->viewscreen->rooms.emplace_back(rightKitchen);
1489 RECT foyer; // entrance is 0, -1671
1490 foyer.left = -124 - buffer + centerX; foyer.right = 100 - buffer + centerX;
1491 foyer.top = -1373 - buffer + centerY; foyer.bottom = -1573 + buffer + centerY;
1492 game->viewscreen->rooms.emplace_back(foyer);
1493 RECT livingToBedroom;
1494 livingToBedroom.left = -825 + buffer + centerX; livingToBedroom.right = -659 - buffer + centerX;
1495 livingToBedroom.top = 51 + buffer + centerY; livingToBedroom.bottom = 27 - buffer + centerY;
1496 game->viewscreen->rooms.emplace_back(livingToBedroom);
1497 RECT northBedroom;
1498 northBedroom.left = -903 + buffer + centerX; northBedroom.right = -547 + centerX; // no buffer to chair on right
1499 northBedroom.top = 27 - buffer + centerY; northBedroom.bottom = -106 + centerY; // no buffer to line up with chair leg
1500 game->viewscreen->rooms.emplace_back(northBedroom);
1501 RECT midBedroom;
1502 midBedroom.left = -903 + buffer + centerX; midBedroom.right = -442 + centerX;
1503 midBedroom.top = -106 + centerY; midBedroom.bottom = -255 + centerY;
1504 game->viewscreen->rooms.emplace_back(midBedroom);
1505 RECT dresser;
1506 dresser.left = -903 + buffer + centerX; dresser.right = -684 + centerX;
1507 dresser.top = -255 + centerY; dresser.bottom = -321 + centerY;
1508 game->viewscreen->rooms.emplace_back(dresser);
1509 RECT southBedroom;
1510 southBedroom.left = -684 + centerX; southBedroom.right = -183 + centerX;
1511 southBedroom.top = -255 + centerY; southBedroom.bottom = -387 + buffer + centerY;
1512 game->viewscreen->rooms.emplace_back(southBedroom);
1513 RECT bedToBath;
1514 bedToBath.left = -632 + buffer + centerX; bedToBath.right = -495 - buffer + centerX;
1515 bedToBath.top = -387 + centerY; bedToBath.bottom = -556 + centerY;
1516 game->viewscreen->rooms.emplace_back(bedToBath);
1517 RECT toilet;
1518 toilet.left = -495 - buffer + centerX; toilet.right = -396 + centerX;
1519 toilet.top = -411 - buffer + centerY; toilet.bottom = -523 + centerY;
1520 game->viewscreen->rooms.emplace_back(toilet);
1521 RECT shower;
1522 shower.left = -396 + centerX; shower.right = -252 - buffer + centerX;
1523 shower.top = -411 - buffer + centerY; shower.bottom = -638 + buffer + centerY;
1524 game->viewscreen->rooms.emplace_back(shower);
1525 }
1526 break;
1527 case 2:
1529
1530 game->GUI->player[ourcockpit.ourplyrC].hdg = static_cast<float>(-360);
1531 game->GUI->player[ourcockpit.ourplyrC].x = -107;
1532 game->GUI->player[ourcockpit.ourplyrC].y = -258;
1533 break; // control tower
1534 case 3:
1536
1537 game->GUI->player[ourcockpit.ourplyrC].hdg = static_cast<float>(-360);
1538 game->GUI->player[ourcockpit.ourplyrC].x = 1485;
1539 game->GUI->player[ourcockpit.ourplyrC].y = -2015;
1540 RECT foyer;
1541 foyer.left = 1195; foyer.right = 1876;
1542 foyer.top = -979; foyer.bottom = -2022;
1543 game->viewscreen->rooms.emplace_back(foyer);
1544 RECT frontHall;
1545 frontHall.left = 1195; frontHall.right = 2190;
1546 frontHall.top = -456; frontHall.bottom = -979;
1547 game->viewscreen->rooms.emplace_back(frontHall);
1548 RECT kitchen;
1549 kitchen.left = 2190; kitchen.right = 2591;
1550 kitchen.top = -911; kitchen.bottom = -1886;
1551 game->viewscreen->rooms.emplace_back(kitchen);
1552 RECT leftHall;
1553 leftHall.left = 1195; leftHall.right = 1517;
1554 leftHall.top = 484; leftHall.bottom = -456;
1555 game->viewscreen->rooms.emplace_back(leftHall);
1556 RECT centerHall;
1557 centerHall.left = 1517; centerHall.right = 2190;
1558 centerHall.top = 135; centerHall.bottom = -103;
1559 game->viewscreen->rooms.emplace_back(centerHall);
1560 RECT rightHall;
1561 rightHall.left = 2018; rightHall.right = 2190;
1562 rightHall.top = 484; rightHall.bottom = -456;
1563 game->viewscreen->rooms.emplace_back(rightHall);
1564 RECT backHall;
1565 backHall.left = 1195; backHall.right = 2190;
1566 backHall.top = 889; backHall.bottom = 484;
1567 game->viewscreen->rooms.emplace_back(backHall);
1568 RECT elevatorStaging;
1569 elevatorStaging.left = 1195; elevatorStaging.right = 1969;
1570 elevatorStaging.top = 1658; elevatorStaging.bottom = 889;
1571 game->viewscreen->rooms.emplace_back(elevatorStaging);
1572 RECT link;
1573 link.left = 1969; link.right = 2190;
1574 link.top = 1658; link.bottom = 1105;
1575 game->viewscreen->rooms.emplace_back(link);
1576 RECT sneak;
1577 sneak.left = 2117; sneak.right = 2190;
1578 sneak.top = 1165; sneak.bottom = 889;
1579 game->viewscreen->rooms.emplace_back(sneak);
1580 RECT garden;
1581 garden.left = 2190; garden.right = 2669;
1582 garden.top = 1474; garden.bottom = 972;
1583 game->viewscreen->rooms.emplace_back(garden);
1584 break; // estate
1585 default:
1586 Trace("Unhandled building number!", Logger::Level::Error);
1587 break;
1588 }
1589 }
1590
1592 //&game->GUI->player[ourcockpit.ourplyrC].x, &game->GUI->player[ourcockpit.ourplyrC].y,
1593 //&game->viewscreen->leftright, &game->viewscreen->updown, &game->viewscreen->rolltilt);
1594
1598 game->GUI->player[ourcockpit.ourplyrC].startx = static_cast<float>(game->GUI->player[ourcockpit.ourplyrC].x);
1599 game->GUI->player[ourcockpit.ourplyrC].starty = static_cast<float>(game->GUI->player[ourcockpit.ourplyrC].y);
1600 }
1601
1602 // take 12 cm off for eye height from top of head
1603 ourcockpit.chaireye.z = static_cast<float>(game->GUI->player[ourcockpit.ourplyrC].heightCm - 12) * 0.00001f;
1604
1605 ourcockpit.bmi = static_cast<float>(game->GUI->player[ourcockpit.ourplyrC].weightKg) / powf(static_cast<float>(game->GUI->player[ourcockpit.ourplyrC].heightCm) * 0.01f, 2.0f);
1606 ourcockpit.maxBPM = 206.9f - 0.67f * static_cast<float>(game->GUI->player[ourcockpit.ourplyrC].age);
1607 switch (ourcockpit.texturelib)
1608 {
1609 case VehicleType::Apartment: ourcockpit.adrenolinBPM = 20.0f; break;
1610 case VehicleType::SimBay: ourcockpit.adrenolinBPM = 20.0f; break;
1612 case VehicleType::Estate: ourcockpit.adrenolinBPM = 20.0f; break;
1613 case VehicleType::Hangar: ourcockpit.adrenolinBPM = 25.0f; break;
1614 case VehicleType::C2: ourcockpit.adrenolinBPM = 20.0f; break;
1615 case VehicleType::C2A: ourcockpit.adrenolinBPM = 20.0f; break;
1616 case VehicleType::C98: ourcockpit.adrenolinBPM = 20.0f; break;
1617 case VehicleType::T120: ourcockpit.adrenolinBPM = 25.0f; break;
1618 case VehicleType::T121: ourcockpit.adrenolinBPM = 25.0f; break;
1619 case VehicleType::A4: ourcockpit.adrenolinBPM = 27.0f; break;
1620 case VehicleType::T19: ourcockpit.adrenolinBPM = 27.0f; break;
1621 case VehicleType::W6Manx: ourcockpit.adrenolinBPM = 30.0f; break;
1622 case VehicleType::E10: ourcockpit.adrenolinBPM = 40.0f; break;
1623 case VehicleType::E11: ourcockpit.adrenolinBPM = 40.0f; break;
1624 case VehicleType::P13: ourcockpit.adrenolinBPM = 40.0f; break;
1625 case VehicleType::T27: ourcockpit.adrenolinBPM = 25.0f; break;
1626 default:ourcockpit.adrenolinBPM = 0.0f; break;
1627 }
1628
1629 oldPlayerFrame = datapacket.playerFrame;
1630
1631 if (datapacket.reference == REF_INANOTHER)
1632 {
1633 // we may not have the type information yet, and this slot may not be visible yet, but we can assume that the information we got about our vehicle
1634 // is same as the parent!
1635
1636 playerships[datapacket.inarray].position.x = datapacket.positionx;
1637 playerships[datapacket.inarray].position.y = datapacket.positiony;
1638 playerships[datapacket.inarray].position.z = datapacket.positionz;
1639 playerships[datapacket.inarray].precisionx = static_cast<double>(datapacket.positionx);
1640 playerships[datapacket.inarray].precisiony = static_cast<double>(datapacket.positiony);
1641 playerships[datapacket.inarray].precisionz = static_cast<double>(datapacket.positionz);
1642 playerships[datapacket.inarray].velocity.x = datapacket.velocityx;
1643 playerships[datapacket.inarray].velocity.y = datapacket.velocityy;
1644 playerships[datapacket.inarray].velocity.z = datapacket.velocityz;
1645 playerships[datapacket.inarray].orientation.x = datapacket.orientationx;
1646 playerships[datapacket.inarray].orientation.y = datapacket.orientationy;
1647 playerships[datapacket.inarray].orientation.z = datapacket.orientationz;
1648 playerships[datapacket.inarray].orientation.w = datapacket.orientationw;
1649
1650 playerships[datapacket.inarray].positer = playerships[datapacket.inarray].posleft = centerC;
1651 playerships[datapacket.inarray].veliter = playerships[datapacket.inarray].velleft = centerC;
1652 playerships[datapacket.inarray].orientiter = playerships[datapacket.inarray].orientleft = RiseMath::Quaternion(0, 0, 0, 0);
1653 playerships[datapacket.inarray].acciter = playerships[datapacket.inarray].accleft = centerC;
1654
1655 playerships[datapacket.inarray].pitch = datapacket.pitch1 / 32767.0f * rotlimitC;
1656 playerships[datapacket.inarray].rollRadPerSec = datapacket.roll1 / 32767.0f * rotlimitC;
1657 playerships[datapacket.inarray].yawRadPerSec = datapacket.yaw1 / 32767.0f * rotlimitC;
1658 playerships[datapacket.inarray].reference = datapacket.parentReference;
1659 playerships[datapacket.inarray].pitchdeflect = datapacket.pitchDeflect;
1660 playerships[datapacket.inarray].rolldeflect = datapacket.rollDeflect;
1661 playerships[datapacket.inarray].yawdeflect = datapacket.yawDeflect;
1662 playerships[datapacket.inarray].steerdeflect = datapacket.steerDeflect;
1663 }
1664
1665#pragma region Things the server persists about our vehicle
1666
1669 else
1670 ourcockpit.parkingBrake = false;
1671
1672 game->bus->YawDamperStatus = datapacket.yawDamper;
1673 game->bus->AntiIce = datapacket.antiIce;
1674 ourcockpit.radioPower = datapacket.radioPower;
1675 game->bus->station = datapacket.radioChannel;
1678 game->viewscreen->ptrPropulsion->airframeTempCelsius = static_cast<float>(datapacket.hullTempCelsius) * 0.1f;
1681 game->bus->PitchTrimScalar = static_cast<float>(datapacket.pitchTrim) / 32767.0f;
1682 sprintf_s(msg, sizeof msg, "SuperPacket cabin pressure Mb was %.0f now %i", game->bus->CabinPressureMb, datapacket.cabinPressureMb);
1683 Trace(msg);
1684 game->bus->CabinPressureMb = static_cast<float>(datapacket.cabinPressureMb);
1685 playerships[0].spoilersUp = datapacket.spoilersUp;
1689
1690#pragma endregion
1691
1693
1694 // @warn Flaps have to be done AFTER LoadVehicleProfile is called
1695 playerships[0].flapdown = 0;
1696
1697 // I think the problem was that we don't have any settings for E-11 and we weren't clearing these
1698 game->bus->flapSettingTE = 0;
1699 game->bus->flapSettingLE = 0;
1703
1704 sprintf_s(msg, sizeof msg, "Looking for a flap setting %.3f (%zu settings)", datapacket.flapsDown, ourcockpit.flapSettings.size());
1705 Trace(msg);
1706
1707 for (size_t i = 0; i < ourcockpit.flapSettings.size(); i++)
1708 {
1709 if (fabsf(datapacket.flapsDown * ourcockpit.flapMaxDegrees - ourcockpit.flapSettings.at(i).degrees) < 1.0f)
1710 {
1711 sprintf_s(msg, sizeof msg, "Found a flap setting %zu (%.0f degrees)", i, ourcockpit.flapSettings.at(i).degrees);
1712 Trace(msg);
1713 game->bus->flapSettingTE = i;
1715 for (unsigned short s = 0; s < playerships[0].components; s++)
1716 {
1717 // ReSharper disable once CppDefaultCaseNotHandledInSwitchStatement
1718 switch (playerships[0].componentarray[s].type)
1719 {
1720 case 16: // flaps (TE)
1721 case 68: // flaps (LE)
1722 {
1727 }
1728 break;
1729 }
1730 }
1731 break;
1732 }
1733 }
1734
1735#pragma region Things that are not saved on the server that need to be persisted!
1736
1737 for (int i = 0; i < MAX_ENGINES; i++)
1738 {
1739 game->bus->EngineThrustLever[i] = 0.0f;
1740 game->bus->EngineThrustOutput[i] = 0.0f;
1741 game->bus->ThrustReverserCommand[i] = false;
1742 }
1743
1744 g_bAugment = true;
1745
1746 game->bus->messages.clear();
1747 game->bus->commandStream.clear();
1748
1749#pragma endregion
1750
1751#pragma region Things that are not saved on the server that need to be reset!
1752
1753 game->bus->SpeedometerKPH = 0.0f;
1754 game->bus->GroundSpeedKms = 0.0f;
1755 ourcockpit.tach = 0.0f;
1756
1759
1760 if (playerships[0].isSimulator)
1761 {
1763 game->bus->FlightFreeze = true;
1765 }
1766 else
1767 game->bus->FlightFreeze = false;
1768
1769 // Simulator entry also doffs personal NVG; vehicle-held items are doffed on every transfer.
1774
1775#pragma endregion
1776
1777 // Stuff added 12/09/2020
1778 if (datapacket.selectedTarget >= 0)
1779 {
1780 // got to find it
1781 bool found = false;
1782 for (short i = 0; i < MAX_SCAN; i++)
1783 {
1784 if (playerships[game->bus->scanslot[i]].vehicleId == datapacket.selectedTarget)
1785 {
1786 found = true;
1787 game->bus->targetC = i;
1788 break;
1789 }
1790 }
1791 if (!found)
1792 {
1793 game->bus->targetC = -1;
1795 }
1796 }
1797 else
1798 game->bus->targetC = static_cast<short>(datapacket.selectedTarget);
1799
1800 game->displays->ChangePage("MFD", datapacket.selectedPage);
1801
1802 game->ChangeGear(datapacket.currentGear, true);
1803
1804 game->bus->MapScaleInnerRingKm = datapacket.mapZoom;
1805 if (datapacket.mapZoom != 5 && datapacket.mapZoom != 10 && datapacket.mapZoom != 20 &&
1806 datapacket.mapZoom != 40 && datapacket.mapZoom != 80 && datapacket.mapZoom != 160)
1807 game->bus->MapScaleInnerRingKm = 5.0f;
1808
1809 playerships[0].pitchdeflect = datapacket.pitchDeflect;
1810 playerships[0].rolldeflect = datapacket.rollDeflect;
1811 playerships[0].yawdeflect = datapacket.yawDeflect;
1812 playerships[0].steerdeflect = datapacket.yawDeflect; // @TODO BREAKING CHANGE
1814 }
1815 break;
1816
1818 {
1819 if (!Telemetry::HasExactPayloadLength(packet->length, sizeof(SServerPacketNew) + 1))
1820 {
1821 sprintf_s(msg, sizeof msg, "Rejected malformed vehicle telemetry length %u (expected %zu)",
1822 packet->length, sizeof(SServerPacketNew) + 1);
1824 break;
1825 }
1826
1827 SServerPacketNew datapacket = {};
1828 memcpy_s(&datapacket, sizeof datapacket, &packet->data[1], sizeof datapacket);
1829 if (datapacket.array == 0 || datapacket.array >= MAX_SCAN || datapacket.onlyOne > 1)
1830 {
1831 sprintf_s(msg, sizeof msg, "Rejected vehicle telemetry slot/flag %u/%u", datapacket.array, datapacket.onlyOne);
1833 break;
1834 }
1835
1836 const unsigned char slot = datapacket.array;
1837 if (playerships[slot].active &&
1838 (playerships[slot].reference <= REF_ENUMMIN || playerships[slot].reference >= REF_ENUMMAX ||
1839 (playerships[slot].reference == REF_INANOTHER && playerships[slot].inarray >= MAX_SCAN)))
1840 {
1841 sprintf_s(msg, sizeof msg, "Rejected vehicle telemetry with invalid frame metadata for slot %u", slot);
1843 break;
1844 }
1845
1847 snapshot.position = {datapacket.position.x, datapacket.position.y, datapacket.position.z};
1848 snapshot.velocity = {datapacket.velocity.x, datapacket.velocity.y, datapacket.velocity.z};
1849 if (playerships[slot].reference < REF_INANOTHER &&
1850 RiseMath::Vec3LengthSq(&datapacket.position) > FLT_EPSILON)
1851 {
1852 RiseMath::Vector3 packetPosition = datapacket.position;
1853 RiseMath::Vector3 gravityDirection;
1854 float radius;
1855 const RiseMath::Vector3 barycentric =
1856 Viewscreen::CalculateBarycentric(&packetPosition, &gravityDirection, &radius);
1857 snapshot.positionDerivative = {
1858 datapacket.velocity.x - barycentric.x,
1859 datapacket.velocity.y - barycentric.y,
1860 datapacket.velocity.z - barycentric.z};
1861 snapshot.hasPositionDerivative = true;
1862 }
1863 snapshot.orientation = {datapacket.orientation.x, datapacket.orientation.y, datapacket.orientation.z, datapacket.orientation.w};
1864 snapshot.angularVelocity = {
1865 static_cast<double>(datapacket.pitch1) / 32767.0 * rotlimitC,
1866 static_cast<double>(datapacket.yaw1) / 32767.0 * rotlimitC,
1867 static_cast<double>(datapacket.roll1) / 32767.0 * rotlimitC};
1868 snapshot.acceleration = {
1869 static_cast<double>(datapacket.ai) / 32767.0 * MaxAcceleration,
1870 static_cast<double>(datapacket.aj) / 32767.0 * MaxAcceleration,
1871 static_cast<double>(datapacket.ak) / 32767.0 * MaxAcceleration};
1872 snapshot.thrust = {
1873 static_cast<double>(datapacket.tx) / 127.0,
1874 static_cast<double>(datapacket.ty) / 127.0,
1875 static_cast<double>(datapacket.tz) / 127.0};
1876 snapshot.controlDeflection = {
1877 static_cast<double>(datapacket.pitchdeflect) / 127.0,
1878 static_cast<double>(datapacket.rolldeflect) / 127.0,
1879 static_cast<double>(datapacket.yawdeflect) / 127.0};
1880 snapshot.steerDeflection = static_cast<double>(datapacket.steerdeflect) / 127.0;
1881 snapshot.expectedIntervalSeconds = static_cast<double>(datapacket.tenthsMs) * 0.1;
1882 snapshot.sequence = datapacket.sequence;
1883 snapshot.sampleTimeMs = datapacket.sampleTimeMs;
1884 snapshot.sourceRevision = datapacket.sourceRevision;
1885 snapshot.reference = playerships[slot].reference;
1886 snapshot.parentSlot = playerships[slot].reference == REF_INANOTHER ? playerships[slot].inarray : -1;
1887 snapshot.identity = playerships[slot].vehicleId;
1888 snapshot.finalSample = datapacket.onlyOne != 0;
1889
1892 {
1893 if (!ApplyImmediateContainedVehicleTelemetry(slot, snapshot))
1894 acceptance = Telemetry::Acceptance::Invalid;
1895 else
1897 snapshot.parentSlot, false);
1898 }
1899 else
1900 {
1902 slot, snapshot, Telemetry::MonotonicSeconds());
1903 }
1904 if (acceptance != Telemetry::Acceptance::Accepted)
1905 {
1906 sprintf_s(msg, sizeof msg, "Rejected vehicle telemetry slot %u sequence %u (reason %u)",
1907 slot, datapacket.sequence, static_cast<unsigned>(acceptance));
1909 break;
1910 }
1911
1912 playerships[slot].sequence = datapacket.sequence;
1913 if (!playerships[slot].active)
1914 {
1915 sprintf_s(msg, sizeof msg, "Buffered telemetry before metadata for slot %u", slot);
1917 playerships[slot].clientinit = true;
1918 }
1919 else
1920 {
1921 playerships[slot].clientinit = false;
1922 if (!playerships[slot].inhibitvisibility)
1923 playerships[slot].visible = true;
1924 }
1925 }
1926 break;
1927
1928 case ID_USER_PACKET_ENUM: // Custom message from server
1929 {
1930 sprintf_s(msg, sizeof msg, "RakNetMessageHandler ID_USER_PACKET_ENUM (size %i)", packet->length - 1);
1931 game->logger->AddToCallStack(msg);
1932
1933 switch (packet->length - 1)
1934 {
1935 case sizeof SServerPacket:
1936 {
1937 SServerPacket datapacket;
1938 memcpy_s(&datapacket, sizeof SServerPacket, &packet->data[1], packet->length - 1);
1939
1940 sprintf_s(msg, sizeof msg, "SServerPacket %i %.1f %.1f %.1f %.1f %i", datapacket.type, datapacket.f_x, datapacket.f_y, datapacket.f_z, datapacket.f_w, datapacket.array);
1941 game->logger->AddToCallStack(msg);
1942
1943 switch (datapacket.type)
1944 {
1945 case 1: // Server removes online player
1946 // went offline
1947 if (datapacket.array == 255) // support
1948 {
1949 // if (datapacket.f_x==0.0f) // offline
1950 // {
1951 // strcpy_s(msg, sizeof(msg), "Support logged off");
1952 }
1953 else
1954 game->GUI->PlayerOffline(datapacket.array);
1955 break;
1956
1957 case 2: // docking status
1958 sprintf_s(msg, sizeof msg, "Server sent dock assignment (%.0f, %.0f)", datapacket.f_x, datapacket.f_y);
1959 Trace(msg);
1960 playerships[0].portassigned = static_cast<char>(datapacket.f_x);
1961 playerships[0].docked = datapacket.f_y == 1.0f;
1962 dockprogress = playerships[0].docked ? 1.0f : 0.0f; // if they send that we are docked it must be on startup or on transfer
1963 break;
1964
1965 case 3: // Server sends conclusion of data
1966
1967 game->GUI->loginstr[0] = 0; // clear error text
1968 if (datapacket.f_y == 0.0f) // EOT
1969 {
1970 sprintf_s(msg, sizeof msg, "Server sent data conclusion (ourshipC %.0f, g_bEnabled %i)", datapacket.f_x, g_bEnabled);
1971 Trace(msg);
1972 game->GUI->isInjected = datapacket.f_z == 1.0f;
1973 game->GUI->IsAdmin = datapacket.f_w == 1.0f;
1974 g_bGotConclusion = true;
1975
1976 SClientPacket outpacket;
1977 outpacket.type = 7;
1978 outpacket.f_x = 1.0f; // add client
1979 outpacket.f_y = 0.0f; // UNUSED
1980 outpacket.f_z = 0.0f; // UNUSED
1981 outpacket.f_w = 0.0f; // UNUSED
1982 SendToServer(&outpacket, sizeof SClientPacket, true);
1983
1984 // send all the player devices
1985 for (size_t device = 0; device < game->viewscreen->ptrJoystick->deviceList.size(); device++)
1986 {
1987 SDeviceMessage deviceMessage;
1988 ZeroMemory(&deviceMessage, sizeof SDeviceMessage);
1989 const DIDEVICEINSTANCE deviceInstance = game->viewscreen->ptrJoystick->deviceList.at(device);
1990 wcscpy_s(deviceMessage.name, 160, deviceInstance.tszInstanceName);
1991 deviceMessage.deviceType = LOBYTE(deviceInstance.dwDevType);
1992 deviceMessage.deviceSubtype = HIBYTE(deviceInstance.dwDevType);
1993 deviceMessage.forceFeedback = deviceInstance.guidFFDriver != MYGUID_NULL ? 1 : 0;
1994
1995 if (game->config.inputConfigLookLateral.guid == deviceInstance.guidInstance)
1996 {
1999 }
2000 else
2001 deviceMessage.channelAxisLookLateral = -1; // not configured
2002
2003 if (game->config.inputConfigLookVertical.guid == deviceInstance.guidInstance)
2004 {
2007 }
2008 else
2009 deviceMessage.channelAxisLookVertical = -1; // not configured
2010
2011 if (game->config.inputConfigWalkLateral.guid == deviceInstance.guidInstance)
2012 {
2014 deviceMessage.channelInvTurn = game->config.inputConfigWalkLateral.invert ? 1 : 0;
2015 }
2016 else
2017 deviceMessage.channelAxisTurn = -1; // not configured
2018
2019 if (game->config.inputConfigWalkVertical.guid == deviceInstance.guidInstance)
2020 {
2022 deviceMessage.channelInvWalk = game->config.inputConfigWalkVertical.invert ? 1 : 0;
2023 }
2024 else
2025 deviceMessage.channelAxisWalk = -1; // not configured
2026
2027 if (game->config.inputConfigPitch.guid == deviceInstance.guidInstance)
2028 {
2030 deviceMessage.channelInvPitch = game->config.inputConfigPitch.invert ? 1 : 0;
2031 }
2032 else
2033 deviceMessage.channelAxisPitch = -1; // not configured
2034
2035 if (game->config.inputConfigPitchTrim.guid == deviceInstance.guidInstance)
2036 {
2039 }
2040 else
2041 deviceMessage.channelAxisPitchTrim = -1; // not configured
2042
2043 if (game->config.inputConfigRoll.guid == deviceInstance.guidInstance)
2044 {
2046 deviceMessage.channelInvRoll = game->config.inputConfigRoll.invert ? 1 : 0;
2047 }
2048 else
2049 deviceMessage.channelAxisRoll = -1; // not configured
2050
2051 if (game->config.inputConfigYaw.guid == deviceInstance.guidInstance)
2052 {
2053 deviceMessage.channelAxisYaw = game->config.inputConfigYaw.axis;
2054 deviceMessage.channelInvYaw = game->config.inputConfigYaw.invert ? 1 : 0;
2055 deviceMessage.channelSplitYaw = game->config.inputConfigYaw.split ? 1 : 0;
2056 }
2057 else
2058 deviceMessage.channelAxisYaw = -1; // not configured
2059
2060 if (game->config.inputConfigThrustLeft.guid == deviceInstance.guidInstance)
2061 {
2065 }
2066 else
2067 deviceMessage.channelAxisThrustLeft = -1; // not configured
2068
2069 if (game->config.inputConfigThrustRight.guid == deviceInstance.guidInstance)
2070 {
2074 }
2075 else
2076 deviceMessage.channelAxisThrustRight = -1; // not configured
2077
2078 if (game->config.inputConfigLeftToeBrake.guid == deviceInstance.guidInstance)
2079 {
2083 }
2084 else
2085 deviceMessage.channelAxisLeftToeBrake = -1; // not configured
2086
2087 if (game->config.inputConfigRightToeBrake.guid == deviceInstance.guidInstance)
2088 {
2092 }
2093 else
2094 deviceMessage.channelAxisRightToeBrake = -1; // not configured
2095
2096 if (game->config.inputConfigSteer.guid == deviceInstance.guidInstance)
2097 {
2099 deviceMessage.channelInvSteer = game->config.inputConfigSteer.invert ? 1 : 0;
2100 }
2101 else
2102 deviceMessage.channelAxisSteer = -1; // not configured
2103
2104
2105 if (game->config.inputConfigGas.guid == deviceInstance.guidInstance)
2106 {
2107 deviceMessage.channelAxisGas = game->config.inputConfigGas.axis;
2108 deviceMessage.channelInvGas = game->config.inputConfigGas.invert ? 1 : 0;
2109 deviceMessage.channelSplitGas = game->config.inputConfigGas.split ? 1 : 0;
2110 }
2111 else
2112 deviceMessage.channelAxisGas = -1; // not configured
2113
2114 if (game->config.inputConfigBrake.guid == deviceInstance.guidInstance)
2115 {
2117 deviceMessage.channelInvBrake = game->config.inputConfigBrake.invert ? 1 : 0;
2118 deviceMessage.channelSplitBrake = game->config.inputConfigBrake.split ? 1 : 0;
2119 }
2120 else
2121 deviceMessage.channelAxisBrake = -1; // not configured
2122
2123 char newdata[sizeof SDeviceMessage + 1];
2124#pragma warning( disable : 4309 )
2125 newdata[0] = static_cast<char>(ID_USER_PACKET_DEVICE);
2126#pragma warning( disable : 4309 )
2127 memcpy_s(&newdata[1], sizeof SDeviceMessage, &deviceMessage, sizeof deviceMessage);
2128 rakPeer->Send(newdata, sizeof SDeviceMessage + 1, MEDIUM_PRIORITY, RELIABLE, ORDERING_NONE, serverC, false);
2129 }
2130
2131 // send the video card type
2132 SPacketBig bigpacket;
2133 bigpacket.type = 0;
2134 sprintf_s(bigpacket.msg, 78, "%.77S", Rendering::ClientDeviceStats());
2135 bigpacket.ship = bigpacket.array = bigpacket.inarray = 0; // all unused
2136 SendToServer(&bigpacket, sizeof SPacketBig, true);
2137
2138 // user name and processor information
2139 bigpacket.type = 1;
2140 DWORD bufferSize = 78;
2141 GetUserNameA(bigpacket.msg, &bufferSize);
2142 bigpacket.array = 0; // UNUSED, should be cores
2143 bigpacket.inarray = static_cast<unsigned char>(GetActiveProcessorCount(ALL_PROCESSOR_GROUPS)); // logical processors
2144 bigpacket.ship = static_cast<unsigned char>(game->GetCpuSpeedMhz() / 100.0f); // CPU in GHZ * 10 so we will get 32 which is 3.2 or 24 which is 2.4
2145 SendToServer(&bigpacket, sizeof SPacketBig, true);
2146
2147 // computer name and memory information
2148 bigpacket.type = 3;
2149 bufferSize = 78;
2150 GetComputerNameA(bigpacket.msg, &bufferSize);
2151 MEMORYSTATUSEX statex;
2152 statex.dwLength = sizeof statex;
2153 GlobalMemoryStatusEx(&statex);
2154 bigpacket.array = static_cast<unsigned char>(round(static_cast<double>(statex.ullTotalPhys) / 1073741824)); // 0-255 GB
2155 bigpacket.inarray = static_cast<unsigned char>(round(static_cast<double>(statex.ullAvailPhys) / 1073741824)); // 0-255 GB
2156 bigpacket.ship = static_cast<unsigned char>(statex.dwMemoryLoad); // 0-100%
2157 SendToServer(&bigpacket, sizeof SPacketBig, true);
2158
2159 // monitor information
2160 outpacket.type = 32;
2161 outpacket.f_x = game->displayWidth;
2162 outpacket.f_y = game->displayHeight;
2163 outpacket.f_z = game->dpiscale * 96.0f;
2164 outpacket.f_w = game->config.scale;
2165 SendToServer(&outpacket, sizeof SClientPacket, true);
2166 }
2167 else if (datapacket.f_y == 2.0f) // password context
2168 {
2169 if (datapacket.f_x == 1.0f) // good password
2170 {
2171 SClientPacket outpacket;
2172 outpacket.type = 3; // Request completion of data (online player data and immigration info)
2173 outpacket.f_x = 0.0f; // NULL
2174 outpacket.f_y = 0.0f; // NULL
2175 outpacket.f_z = 0.0f; // NULL
2176 outpacket.f_w = 0.0f; // NULL
2177 SendToServer(&outpacket, sizeof(SClientPacket), true);
2178 }
2179 else if (datapacket.f_x == 0.0f || // bad password
2180 datapacket.f_x == 2.0f || // callsign not found
2181 datapacket.f_x == 3.0f) // too many attempts
2182 {
2184 if (datapacket.f_x == 0.0f)
2185 wcscpy_s(game->GUI->loginstr, 99, game->GUI->strings[L_LOGIN_PASSWORDINCORRECT].c_str());
2186 else if (datapacket.f_x == 2.0f)
2187 wcscpy_s(game->GUI->loginstr, 99, game->GUI->strings[L_LOGIN_CALLSIGNINCORRECT].c_str());
2188 else if (datapacket.f_x == 3.0f)
2189 wcscpy_s(game->GUI->loginstr, 99, game->GUI->strings[L_LOGIN_TOOMANYATTEMPTS].c_str());
2190 }
2191 }
2192 else if (datapacket.f_y == 3.0f) // already logged on
2193 {
2195 wcscpy_s(game->GUI->loginstr, 99, game->GUI->strings[L_LOGIN_ALREADYONLINE].c_str());
2196 }
2197 else
2198 {
2199 sprintf_s(msg, sizeof msg, "Unexpected conclusion Y type: %.0f", datapacket.f_y);
2201 }
2202 break;
2203
2204 case 4: // Server changed payload and fuel loading (in pounds)
2205 {
2206 sprintf_s(msg, sizeof msg, "Type 4 received payload %.1f, fuel %.1f (%.1f), utilization %.1f",
2207 datapacket.f_y, datapacket.f_x, datapacket.f_w, datapacket.f_z);
2208 Trace(msg);
2209
2210 fuel = datapacket.f_x;
2211 payload = datapacket.f_y;
2212 ourcockpit.usage = datapacket.f_z;
2213 deathfuel = datapacket.f_w;
2214
2216
2217 if (fuel <= 0 && game->GUI->player[ourcockpit.ourplyrC].frame == REF_INANOTHER)
2218 {
2219 deathinhibit = FLT_MAX;
2221 }
2222 }
2223 break;
2224
2225 case 5: // Remove vehicle from active memory (out of range)
2226 {
2227 if (datapacket.array == 0 || datapacket.array >= MAX_SCAN)
2228 {
2229 sprintf_s(msg, sizeof msg, "Rejected removal for invalid scanner slot %u", datapacket.array);
2231 break;
2232 }
2233
2234 if (!std::isfinite(datapacket.f_x) || datapacket.f_x < 0.0f || datapacket.f_x > 65535.0f ||
2235 std::floor(datapacket.f_x) != datapacket.f_x)
2236 {
2237 Trace("Rejected removal with malformed sequence", Logger::Level::Warn);
2238 break;
2239 }
2240
2241 const auto sequence = static_cast<unsigned short>(datapacket.f_x);
2242 const Telemetry::ChannelMetrics telemetryMetrics =
2244 if (telemetryMetrics.hasSequence)
2245 {
2246 const unsigned short delta = static_cast<unsigned short>(sequence - telemetryMetrics.lastAcceptedSequence);
2247 if (delta == 0 || delta > 32767)
2248 {
2249 sprintf_s(msg, sizeof msg, "Rejected stale removal for slot %u sequence %u (last %u)",
2250 datapacket.array, sequence, telemetryMetrics.lastAcceptedSequence);
2252 break;
2253 }
2254 }
2255
2256 sprintf_s(msg, sizeof msg, "Server removed slot %i (vehicleId %i) from our scanner!", datapacket.array, playerships[datapacket.array].vehicleId);
2257 Trace(msg);
2258
2259 playerships[datapacket.array].active = false;
2260 playerships[datapacket.array].clientinit = true;
2261 playerships[datapacket.array].visible = false;
2262 playerships[datapacket.array].inhibitvisibility = false;
2263 playerships[datapacket.array].vehicleId = 0;
2264 playerships[datapacket.array].sequence = sequence;
2266
2268 game->bus->ProximityAlert = false;
2269
2270 // to keep me from blinking
2271 playerships[datapacket.array].position = centerC;
2272 playerships[datapacket.array].precisionx = 0.0;
2273 playerships[datapacket.array].precisiony = 0.0;
2274 playerships[datapacket.array].precisionz = 0.0;
2275 RiseMath::MatrixTranslation(&playerships[datapacket.array].matrixWorld, 500.0f, 0.0f, 0.0f);
2276
2277 // release license plate
2279 {
2280 sprintf_s(msg, sizeof msg, "Released m_pddsHullDynamicTexture slot %i!", datapacket.array);
2281 Trace(msg);
2283 sprintf_s(msg, sizeof msg, "m_pddsHullDynamicTexture[%i]", datapacket.array);
2284 game->UpdateTrackedResource(msg, 3);
2285 }
2286
2287 if (game->bus->targetC >= 0 && game->bus->targetC < MAX_SCAN &&
2288 game->bus->scanslot[game->bus->targetC] == datapacket.array)
2289 game->LostScannerTarget("Networking");
2290
2292 }
2293 break;
2294
2295 case 6: // Cosmetic DIHV effect for an existing server-owned scanner contact
2296 {
2297 if (datapacket.f_w != 1.0f || datapacket.array == 0 || datapacket.array >= MAX_SCAN)
2298 break;
2299 auto& contact = playerships[datapacket.array];
2300 if (!contact.active || contact.type != VehicleType::DIHV)
2301 break;
2302 contact.dihvComing = datapacket.f_y != 0.0f;
2303 contact.dihvSequence = datapacket.f_x;
2304 if (contact.dihvComing)
2305 contact.dihvAnimate = datapacket.f_x < 2.0f ? 0 : 64;
2306 else
2307 contact.dihvAnimate = datapacket.f_x <= 0.0f ? 63 : 64;
2308 }
2309 break;
2310
2311 case 7: // Server kicked us
2312 game->ToggleFullScreen(false);
2313
2314 // ReSharper disable CppDefaultCaseNotHandledInSwitchStatement
2315 switch (datapacket.array)
2316 {
2317 case 0:
2318 MessageBoxW(nullptr, L"We are applying a patch to the game server. Please try connecting again in a minute or two.", L"Server Upgrading!", MB_ICONERROR | MB_OK);
2319 break;
2320 case 1:
2321 MessageBoxW(nullptr, L"You have been kicked from the server. Contact support@risetvp for more information.", L"Session Disconnected!", MB_ICONERROR | MB_OK);
2322 break;
2323 case 2:
2324 MessageBoxW(nullptr, L"Sorry, we require a valid email address in order to play Rise: The Vieneo Province.", L"Account Terminated!", MB_ICONERROR | MB_OK);
2325 break;
2326 }
2327
2328#ifndef _DEBUG
2329 PostQuitMessage(0);
2330#endif
2331 break;
2332
2333 case 9: // Dock power and evac status
2334 {
2335 sprintf_s(msg, sizeof msg, "Dock status: %i power %.0f evac %.0f", datapacket.array, datapacket.f_x, datapacket.f_y);
2336 Trace(msg);
2337
2338 allobjects[datapacket.array].powered = datapacket.f_x == 1.0f;
2339 allobjects[datapacket.array].evac = datapacket.f_y == 1.0f;
2340
2341 if (!playerships[0].docked || playerships[0].reference != (datapacket.array + REF_DOCKENUMCPOC))
2342 break;
2343
2344 if (datapacket.f_y == 1.0f)
2345 {
2346 game->sound->PlayEx(SOUND_DOCKEVAC, true, 1, 1, 0, false);
2348 }
2349 else
2351 }
2352 break;
2353
2354 case 10: // Dock announcements x=, y=number, z=, w=, array=
2355 {
2357 int ordinal = static_cast<int>(datapacket.f_y);
2358 game->sound->AddDelayedSound(static_cast<SOUNDS>(SOUND_DOCKANNOUNCE1 + ordinal), 1.5f);
2360 }
2361 break;
2362
2363 case 12: // Event
2364 {
2365 if (datapacket.array >= MAX_SCAN) break;
2366 sprintf_s(msg, sizeof msg, "Event %.0f from server for slot %i!", datapacket.f_w, datapacket.array);
2367 Trace(msg);
2368
2369 if (datapacket.f_w == EventType::EVENT_HEADLIGHT_ON)
2370 playerships[datapacket.array].headlight = true;
2371 else if (datapacket.f_w == EventType::EVENT_HEADLIGHT_OFF)
2372 playerships[datapacket.array].headlight = false;
2373 else if (datapacket.f_w == EventType::EVENT_BAYDOOR_OPEN)
2374 playerships[datapacket.array].baydoor = true;
2375 else if (datapacket.f_w == EventType::EVENT_BAYDOOR_CLOSED)
2376 playerships[datapacket.array].baydoor = false;
2377 else if (datapacket.f_w == EventType::EVENT_LANDINGGEAR_DOWN)
2378 playerships[datapacket.array].geardown = true;
2379 else if (datapacket.f_w == EventType::EVENT_LANDINGGEAR_UP)
2380 playerships[datapacket.array].geardown = false;
2381 else if (datapacket.f_w == EventType::EVENT_DOMELIGHT_ON)
2382 playerships[datapacket.array].domelight = true;
2383 else if (datapacket.f_w == EventType::EVENT_DOMELIGHT_OFF)
2384 playerships[datapacket.array].domelight = false;
2385 else if (datapacket.f_w == EventType::EVENT_POLICELIGHT_ON)
2386 playerships[datapacket.array].specialight = true;
2387 else if (datapacket.f_w == EventType::EVENT_POLICELIGHT_OFF)
2388 playerships[datapacket.array].specialight = false;
2389 else if (datapacket.f_w == EventType::EVENT_LOGOLIGHT_ON)
2390 playerships[datapacket.array].logolight = true;
2391 else if (datapacket.f_w == EventType::EVENT_LOGOLIGHT_OFF)
2392 playerships[datapacket.array].logolight = false;
2393 else if (datapacket.f_w == EventType::EVENT_FLAPSETTING)
2394 playerships[datapacket.array].flapdown = datapacket.f_x;
2395 else if (datapacket.f_w == EventType::EVENT_SPOILERSETTING)
2396 playerships[datapacket.array].spoilersUp = datapacket.f_x;
2397 else if (datapacket.f_w == EventType::EVENT_BRAKELIGHT_ON)
2398 playerships[datapacket.array].brakelight = true;
2399 else if (datapacket.f_w == EventType::EVENT_BRAKELIGHT_OFF)
2400 playerships[datapacket.array].brakelight = false;
2401 else if (datapacket.f_w == EventType::BattleRoyaleParticipant)
2402 {
2403 playerships[datapacket.array].battleRoyale = true;
2404 sprintf_s(msg, sizeof msg, "BATTLE ROYALE - Vehicle slot %i (%s) is now a participant!", datapacket.array, playerships[datapacket.array].IVR);
2406 }
2407 else if (datapacket.f_w == EventType::BattleRoyaleElimination)
2408 {
2409 playerships[datapacket.array].battleRoyale = false;
2410 sprintf_s(msg, sizeof msg, "BATTLE ROYALE - Vehicle slot %i (%s) was eliminated!", datapacket.array, playerships[datapacket.array].IVR);
2412 }
2413 else if (datapacket.f_w == EventType::EVENT_TRANSPONDER)
2414 playerships[datapacket.array].transponder = datapacket.f_x > 0.0f;
2415
2416 else if (datapacket.f_w == EventType::EVENT_WIPERS)
2418 !playerships[datapacket.array].isSimulator && datapacket.f_x > 0.f;
2419 else if (datapacket.f_w == EventType::EVENT_WINDSHIELD_FAULT)
2421 !playerships[datapacket.array].isSimulator && datapacket.f_x == 1.f;
2422 else if (datapacket.f_w == EventType::EVENT_HORN_START)
2424 else if (datapacket.f_w == EventType::EVENT_HORN_STOP)
2425 playerships[datapacket.array].hornPressed = false;
2426
2427 // EVENT_PARKINGBRAKE, EVENT_YAWDAMPER, EVENT_ANTIICE all come from super packet since they are non-visual in nature!
2428 }
2429 break;
2430
2431 case 13: // achievement
2432 {
2433 sprintf_s(msg, sizeof msg, "Achievement ID %.0f level %.0f", datapacket.f_x, datapacket.f_y);
2434 Trace(msg);
2435
2436 if (datapacket.f_x == 15.0f) // odometer check
2437 {
2439 }
2440 else if (datapacket.f_x == 17.0f && datapacket.f_z == 14.0f) // pick up fare to airport
2441 {
2444 }
2445 else if (datapacket.f_x == 18.0f) // drop off taxi fare
2446 {
2449 }
2450 else if (datapacket.f_x == 2.0f) // open a bank account
2451 {
2454 }
2455 else if (datapacket.f_x == 57.0f) // land legs achievement
2456 {
2459 }
2460 }
2461 break;
2462
2463 case 14: // Wx Flag
2464 {
2468 }
2469 break;
2470
2471 case 16: // reference change
2472 {
2473 if (datapacket.array == 0 || datapacket.array >= MAX_SCAN || !std::isfinite(datapacket.f_x) ||
2474 !std::isfinite(datapacket.f_y) || !std::isfinite(datapacket.f_z) || !std::isfinite(datapacket.f_w))
2475 {
2476 Trace("Rejected malformed remote reference change", Logger::Error);
2477 break;
2478 }
2479
2480 char oldReference = playerships[datapacket.array].reference;
2481 const int newReference = static_cast<int>(datapacket.f_x);
2482 const int newParentSlot = static_cast<int>(datapacket.f_y);
2483 if (datapacket.f_x != static_cast<float>(newReference) || newReference <= REF_ENUMMIN ||
2484 newReference >= REF_ENUMMAX || (newReference == REF_INANOTHER &&
2485 (newParentSlot < 0 || newParentSlot >= MAX_SCAN || newParentSlot == datapacket.array)))
2486 {
2487 Trace("Rejected invalid remote reference/parent change", Logger::Error);
2488 break;
2489 }
2490 playerships[datapacket.array].reference = static_cast<char>(newReference);
2491
2492 sprintf_s(msg, sizeof msg, "Change reference of vehicle %i slot %i from %i to %i",
2493 playerships[datapacket.array].vehicleId, datapacket.array, oldReference, playerships[datapacket.array].reference);
2494 Trace(msg);
2495
2496 if (oldReference == playerships[datapacket.array].reference)
2497 {
2498 // reference did not change
2499 if (playerships[datapacket.array].reference != REF_INANOTHER ||
2500 playerships[datapacket.array].inarray == static_cast<short>(datapacket.f_y))
2501 {
2502 Trace("Reference did not change!", Logger::Warn);
2503 return;
2504 }
2505 }
2506
2507 if (playerships[datapacket.array].reference == REF_INANOTHER) // now in another vehicle
2508 playerships[datapacket.array].inarray = static_cast<unsigned char>(newParentSlot);
2509 else
2510 {
2511 const RiseMath::Vector3 position = RiseMath::Vector3(datapacket.f_y, datapacket.f_z, datapacket.f_w);
2512
2513 if (newReference < REF_INANOTHER)
2514 {
2515 playerships[datapacket.array].position = position;
2516 playerships[datapacket.array].precisionx = position.x;
2517 playerships[datapacket.array].precisiony = position.y;
2518 playerships[datapacket.array].precisionz = position.z;
2519 if (oldReference == REF_INANOTHER)
2520 playerships[datapacket.array].velocity = playerships[datapacket.array].barycentric;
2521 }
2522 else
2523 playerships[datapacket.array].dockoffset = position;
2524 }
2525
2527 playerships[datapacket.array].vehicleId, newReference,
2528 newReference == REF_INANOTHER ? newParentSlot : -1, false);
2529 playerships[datapacket.array].sequence = 0;
2530 playerships[datapacket.array].positer = playerships[datapacket.array].posleft = centerC;
2531 playerships[datapacket.array].veliter = playerships[datapacket.array].velleft = centerC;
2532 playerships[datapacket.array].acciter = playerships[datapacket.array].accleft = centerC;
2533 playerships[datapacket.array].orientiter = playerships[datapacket.array].orientleft = RiseMath::Quaternion(0, 0, 0, 0);
2534 }
2535 break;
2536
2537 case 17: // cargo bay clear
2538 {
2539 if (datapacket.array < 1 || datapacket.array > MAX_BAYSPERSHIP)
2540 {
2541 sprintf_s(msg, sizeof msg, "Error! Type 17 tried to clear bay %i", datapacket.array);
2542 Trace(msg);
2543 }
2544 else
2545 {
2546 // update scanner database to say where it is now?
2547 const int bayVehicleId = game->bus->CargoBays[datapacket.array - 1];
2548 if (bayVehicleId != 0)
2549 {
2550 sprintf_s(msg, sizeof msg, "Removed cargo from bay %i", datapacket.array);
2551 Trace(msg);
2552
2553 SmodeAC modeAC = game->bus->Scanner.Get(bayVehicleId).scandata.modeAC;
2554 modeAC.location.x = datapacket.f_x;
2555 modeAC.location.y = datapacket.f_y;
2556 modeAC.location.z = datapacket.f_z;
2557 modeAC.reference = static_cast<char>(datapacket.f_w);
2558 game->bus->Scanner.InsertUpdateModeAC(bayVehicleId, modeAC);
2559
2560 game->bus->CargoBays[datapacket.array - 1] = 0;
2561
2563 }
2564 }
2565 }
2566 break;
2567
2568 case 21: // Battle Royale
2569 {
2570 if (datapacket.array != 0 && datapacket.array < battleRoyaleSequence)
2571 {
2572 sprintf_s(msg, sizeof msg, "BATTLE ROYALE - Ignored an old map packet sequence %i (%i)", datapacket.array, battleRoyaleSequence);
2573 Trace(msg, Logger::Debug);
2574 break;
2575 }
2576
2577 battleRoyaleSequence = datapacket.array;
2578
2579 if (datapacket.f_z != 0.0f)
2580 {
2581 playerships[0].battleRoyale = true;
2582 RiseMath::Vector3 result;
2583 result.y = cosf(RiseMath::ToRadian(-datapacket.f_y)) * cosf(RiseMath::ToRadian(-datapacket.f_x));
2584 result.x = sinf(RiseMath::ToRadian(-datapacket.f_y)) * cosf(RiseMath::ToRadian(-datapacket.f_x));
2585 result.z = sinf(RiseMath::ToRadian(-datapacket.f_x));
2586 RiseMath::Vec3Normalize(&result, &result);
2588 game->bus->waypoint.at(0).location = result;
2589 game->bus->waypoint.at(0).elevationKm = RiseMath::Vec3Length(&result) - radiusC;
2590 game->bus->waypoint.at(0).latlng = RiseMath::Vector2(0, 0); // see if Bill notices
2591 game->bus->BattleRoyaleRingKm = datapacket.f_z;
2592
2593 sprintf_s(msg, sizeof msg, "BATTLE ROYALE - Updated map packet, battle in progress (%i)!", datapacket.array);
2594 Trace(msg);
2595 }
2596 else
2597 {
2598 playerships[0].battleRoyale = false;
2599 sprintf_s(msg, sizeof msg, "BATTLE ROYALE - Shutting down battle based on map packet!");
2600 Trace(msg, Logger::Debug);
2601 }
2602 }
2603 break;
2604
2605 case 22: // Fireworks
2606 {
2607 for (short t = 0; t < fireworksC; t++)
2608 {
2609 if (!fireworks[t].inuse)
2610 {
2611 fireworks[t].inuse = true;
2612 fireworks[t].texture = 0;
2613 float r = floorf(datapacket.f_w / 10000.0f);
2614 datapacket.f_w -= r * 10000.0f;
2615 float g = floorf(datapacket.f_w / 100.0f);
2616 datapacket.f_w -= g * 100.0f;
2617 float b = floorf(datapacket.f_w);
2618
2619 sprintf_s(msg, sizeof msg, "Firework: r%.0f g%.0f b%.0f ", r, g, b);
2620 Trace(msg);
2621
2622 // one of them should be at 255
2623 if (r >= g && r >= b)
2624 {
2625 const float f_temp = 255.0f / r;
2626 r *= f_temp; g *= f_temp; b *= f_temp;
2627 }
2628 else if (g >= r && g >= b)
2629 {
2630 const float f_temp = 255.0f / g;
2631 r *= f_temp; g *= f_temp; b *= f_temp;
2632 }
2633 else if (b >= r && b >= g)
2634 {
2635 const float f_temp = 255.0f / b;
2636 r *= f_temp; g *= f_temp; b *= f_temp;
2637 }
2638
2639 sprintf_s(msg, sizeof msg, "-> r%.0f g%.0f b%.0f ", r, g, b);
2640 Trace(msg);
2641
2642 fireworks[t].color = Rendering::ColorARGB(255, static_cast<unsigned char>(r), static_cast<unsigned char>(g), static_cast<unsigned char>(b));
2643
2644 fireworks[t].position.x = datapacket.f_x;
2645 fireworks[t].position.y = datapacket.f_y;
2646 fireworks[t].position.z = datapacket.f_z;
2647 fireworks[t].type = datapacket.array;
2648
2649
2650 RiseMath::Vector3 result;
2651 result.x = playerships[0].position.x - datapacket.f_x;
2652 result.y = playerships[0].position.y - datapacket.f_y;
2653 result.z = playerships[0].position.z - datapacket.f_z;
2654 float f_temp = RiseMath::Vec3Length(&result);
2655 sprintf_s(msg, sizeof msg, "Fireworks! Distance: %.3f", f_temp);
2656 Trace(msg);
2657 if (f_temp < 6.0f) // 6 km is cutoff
2658 {
2659 f_temp /= 6.0f; // at 6km f_temp is 1 ... at 3km f_temp is 0.5, at 0km f_temp is 0
2660 f_temp = 1.0f - f_temp; // f_temp is now 0 at 6km, 0.5 at 3km, 1.0 at 0km
2661 f_temp *= f_temp; // inverse square of distance ... 0 at 6km ... .25 at 3km, 1.0 at 0km
2662 const float inverse_f_temp = 1.0f - f_temp; // inv is 1 at 6, .5 at 3, 0 at 0
2663 float delay = inverse_f_temp * 14.88201975f;
2664 // 340m/s at sea level
2665 game->sound->AddDelayedSound(static_cast<SOUNDS>(SOUND_FIREWORKLAUNCH1 + rand() % 3), delay, // seconds at 6km
2666 sqrtf(f_temp), 1, true);
2667 delay += 2.75f + RandomFloat() * 0.5f;
2668 game->sound->AddDelayedSound(static_cast<SOUNDS>(SOUND_FIREWORKEXPLODE1 + rand() % 3), delay, // seconds at 6km
2669 sqrtf(f_temp), 1, true);
2670 }
2671
2672 t = fireworksC;
2673 }
2674 }
2675 }
2676 break;
2677
2678 case 23: // outside noises
2680 break;
2681
2682 // x=position.x, y=position.y, z=distanceM, w=durationS, t=(0=clear,1=complete,2=closestApproach)
2683 case 25: // turnbyturn
2684 {
2686 {
2688 break;
2689 }
2690 game->bus->nodes.clear();
2691 game->bus->turnByTurnRoutingType = datapacket.array;
2692 game->bus->turnByTurnExpectedNodes = datapacket.array && datapacket.f_x >= 1 && datapacket.f_x < 100000
2693 ? static_cast<size_t>(datapacket.f_x) + 1 : 0;
2694 if (datapacket.array)
2695 {
2696 sprintf_s(msg, sizeof msg, "TURNBYTURN Got a turn-by-turn type %i: %.0fm (%.0fs)", datapacket.array, datapacket.f_z, datapacket.f_w);
2697 Trace(msg);
2699 game->bus->turnByTurnTotalTimeSeconds = datapacket.f_w;
2700 }
2701 else
2702 {
2703 Trace("TURNBYTURN Got a turn-by-turn CLEAR from the server!");
2706 }
2707 game->bus->turnByTurnDirty = true;
2708 }
2709 break;
2710
2711 // 29=channelctrl, x=tab, y=channel, z=(0=closereq 1=addreq 2=invite 3=joinreq 4=plyrleft 5=newowner), w=ownerslot, array=tempplayer
2712 case 29: // channel control
2713 {
2714 switch (static_cast<short>(datapacket.f_z))
2715 {
2716 case 1: // got channel assignment for new channel request
2717 {
2718 const auto tab = static_cast<short>(datapacket.f_x);
2719 const auto channel = static_cast<unsigned char>(datapacket.f_y);
2720 game->GUI->chatchannel[tab].channel = channel;
2721 sprintf_s(msg, sizeof msg, "Got new channel for tab %i: %i", tab, channel);
2722 Trace(msg);
2723 }
2724 break;
2725 case 2: // got invite (send request only)
2726 break;
2727 case 3: // player joined
2728 game->GUI->PlayerJoinedChannel(static_cast<short>(datapacket.f_x), datapacket.array);
2729 break;
2730 case 4: // player quit
2731 game->GUI->PlayerLeftChannel(static_cast<short>(datapacket.f_x), datapacket.array);
2732 break;
2733 case 5: // new owner (only get if we are not the one who transferred ownership)
2734 game->GUI->ChangeChannelOwner(static_cast<short>(datapacket.f_x), static_cast<unsigned char>(datapacket.f_w));
2735 break;
2736 default:
2737 Trace("Unknown channel control type!", Logger::Level::Error);
2738 break;
2739 }
2740 }
2741 break;
2742
2743 case 34: // comm control
2744 {
2745 if (!playerships[0].groundvehicle && game->GUI->player[ourcockpit.ourplyrC].frame == 0 && ourcockpit.power > 0.5f && !playerships[0].isSimulator)
2746 {
2747 const int radiocut = static_cast<int>(datapacket.f_y);
2748 if (datapacket.array) // BOT
2749 {
2750 game->sound->Play(static_cast<SOUNDS>(SOUND_RADIOCUT1 + radiocut));
2751 const int carrier = static_cast<int>(datapacket.f_x);
2752 game->sound->PlayEx(static_cast<SOUNDS>(SOUND_RADIOCARRIER0 + carrier), true);
2753 }
2754 else // EOT
2755 {
2768 game->sound->Play(static_cast<SOUNDS>(SOUND_RADIOCUT1 + radiocut));
2769
2770 if (ourcockpit.power <= 0.5f)
2771 break;
2772 if (playerships[0].isSimulator)
2773 break;
2775 (game->GUI->player[ourcockpit.ourplyrC].frame == REF_BUILDING && game->GUI->player[ourcockpit.ourplyrC].bldg == 2)) // vehicle or control tower
2776 {
2777 if (!game->GUI->subtitles.empty())
2778 {
2779 size_t length = game->GUI->subtitles.at(game->GUI->subtitles.size() - 1).length();
2780 if (length < subtitleCharLimitC)
2781 game->GUI->subtitles.at(game->GUI->subtitles.size() - 1) += std::wstring(subtitleCharLimitC - length, ' ');
2782 }
2783 }
2784 }
2785 }
2786 }
2787 break;
2788
2789 case 35: // manifest2
2790 {
2791 sprintf_s(msg, sizeof msg, "Type 35 airframeTempCelsius %.1f airIceAccumulationMm %.1f pressureMb %.1f groundIceAccumulationMm %.1f",
2792 datapacket.f_x, datapacket.f_y, datapacket.f_z, datapacket.f_w);
2793 Trace(msg);
2794
2795 game->viewscreen->ptrPropulsion->airframeTempCelsius = datapacket.f_x; // this is the actual floating point number
2796 game->viewscreen->ptrPropulsion->airIceAccumulationMm = datapacket.f_y; // this is the actual floating point number
2797 if (playerships[0].reference == REF_INANOTHER)
2798 game->bus->StaticAirPressureMb = datapacket.f_z; // this is the actual floating point number
2799 else
2800 game->bus->CabinPressureMb = datapacket.f_z; // this is the actual floating point number
2801 game->viewscreen->ptrPropulsion->groundIceAccumulationMm = datapacket.f_w; // this is the actual floating point number
2802
2803 if (datapacket.array) // deiced
2804 {
2805 game->sound->PlayEx(SOUND_DEICE, false, 1, 1, 0, true, true);
2806 game->viewscreen->ptrPropulsion->holdOverTime = datapacket.array * 60.0f;
2807 }
2808 }
2809 break;
2810
2811 case 37: // waypoint management
2812 {
2813 Trace("Current waypoint packet received!");
2814 game->viewscreen->ptrWaypoints->SetCurrentFromServer(static_cast<int>(datapacket.f_y));
2815 }
2816 break;
2817
2818 case 39: // Retired Weather2 packet; all local conditions come from the grid.
2819 break;
2820
2821 case 41: // Help Seen
2822 {
2823 game->vphelp[datapacket.array] = true;
2824 }
2825 break;
2826
2827 case 42: // Lightning
2828 {
2829 if (!std::isfinite(datapacket.f_x) || !std::isfinite(datapacket.f_y)
2830 || datapacket.f_x<-32768 || datapacket.f_x>32767 || datapacket.f_y<-32768 || datapacket.f_y>32767
2831 || floorf(datapacket.f_x)!=datapacket.f_x || floorf(datapacket.f_y)!=datapacket.f_y
2832 || !std::isfinite(datapacket.f_z) || datapacket.f_z<0 || datapacket.f_z>2
2833 || floorf(datapacket.f_z)!=datapacket.f_z || !std::isfinite(datapacket.f_w)
2834 || datapacket.f_w<0 || double(datapacket.f_w)>=2147483648.0) break;
2835 game->viewscreen->ptrWeather->ReceiveGridLightning(static_cast<short>(datapacket.f_x),
2836 static_cast<short>(datapacket.f_y),static_cast<int>(datapacket.f_w),static_cast<int>(datapacket.f_z));
2837 }
2838 break;
2839
2840 default:
2841 sprintf_s(msg, sizeof msg, "Unexpected SServerPacket type: %i", datapacket.type);
2843 break;
2844 }
2845 break;
2846 }
2847
2848 case sizeof SPacketBig:
2849 {
2850 SPacketBig bigdatapacket;
2851 memcpy_s(&bigdatapacket, sizeof SPacketBig, &packet->data[1], packet->length - 1);
2852
2853 sprintf_s(msg, sizeof msg, "SPacketBig %i %i", bigdatapacket.type, bigdatapacket.array);
2854 game->logger->AddToCallStack(msg);
2855
2856 switch (bigdatapacket.type)
2857 {
2859 if (!bigdatapacket.array && !bigdatapacket.ship && !bigdatapacket.inarray)
2861 bigdatapacket.msg, sizeof bigdatapacket.msg);
2862 break;
2863 case 4: // subtitles
2864 {
2865 if (ourcockpit.power <= 0.5f)
2866 break;
2867 if (playerships[0].isSimulator)
2868 break;
2870 (game->GUI->player[ourcockpit.ourplyrC].frame == REF_BUILDING && game->GUI->player[ourcockpit.ourplyrC].bldg == 2)) // vehicle or control tower
2871 {
2872 _wcsupr_s(bigdatapacket.str, sizeof bigdatapacket.str);
2873 game->GUI->AddSubtitle(bigdatapacket.str);
2874 }
2875 }
2876 break;
2877
2878 case 5: // Radio stations
2879 {
2880 strcpy_s(game->sound->stationUrls[bigdatapacket.array], 64, bigdatapacket.msg);
2881 sprintf_s(msg, sizeof msg, "Radio Station URL %i: %s", bigdatapacket.array, bigdatapacket.msg);
2882 Trace(msg);
2883 }
2884 break;
2885
2886 case 6: // Prompt for line input
2887 {
2888 if (ourcockpit.power < 1.0f)
2889 {
2891 // Send it
2892 SPacketBig outpacket;
2893 strcpy_s(outpacket.msg, sizeof outpacket.msg, bigdatapacket.msg);
2894 outpacket.type = 6; // Requested line input
2895 outpacket.array = 0;
2896 game->networking->SendToServer(&outpacket, sizeof(SPacketBig), true);
2897 break;
2898 }
2899
2900 sprintf_s(prompt, sizeof prompt, "%s", bigdatapacket.msg);
2901 g_bTextInput = 2;
2902 if (bigdatapacket.array == 1 && interactive.avail) // copy current plot name
2903 strcpy_s(outgoing, sizeof outgoing, interactive.tempplot.colonyName);
2904 else
2905 outgoing[0] = 0;
2906
2907 game->displays->ChangePage("MFD", "Intermedia");
2909 }
2910 break;
2911
2912 case 7: // add (or change) online player information (including us) (we get it first time and ever time someone logs in after)
2913 {
2914 sprintf_s(msg, sizeof msg, "AddPlayer %i %s", bigdatapacket.array, bigdatapacket.msg);
2915 Trace(msg);
2916 game->GUI->AddPlayer(bigdatapacket.msg, bigdatapacket.array);
2917 if (bigdatapacket.array == game->GUI->ourplayerC)
2918 {
2920
2921 WCHAR str[199];
2922 swprintf_s(str, 199, L"Rise: The Vieneo Province [%S]", game->GUI->player[game->GUI->ourplayerC].callsign);
2923 if (!SetWindowText(Rendering::ClientWindow(), str))
2924 {
2925 sprintf_s(msg, sizeof msg, "Error in SetWindowText: %d", GetLastError());
2926 Trace(msg, Logger::Fatal);
2927 }
2928
2929 if (strcmp("Not registered...", game->GUI->player[game->GUI->ourplayerC].characterName) == 0)
2930 game->GUI->player[game->GUI->ourplayerC].characterName[0] = 0; // clear
2931 }
2932 }
2933 break;
2934
2935 case 8: // cargo data (this is for the stuff inside of our vehicle... nothing else)
2936 {
2937 // @TODO WTH are we sending this old-ass CSV instead of the new ScanData
2938
2939 SmodeAC modeAC;
2940 SmodeX modeX;
2941
2942 modeAC.reference = REF_INANOTHER;
2943 modeAC.location = playerships[0].position;
2944
2945 int bay, pilot;
2946 char bitstring[4];
2947 unsigned char load_type;
2948 unsigned short load_quantity;
2949 int weightLbs, fuel_tank; // can't parse as float because of internationalization
2950 const int elem = sscanf_s(bigdatapacket.msg, "%hd,%[^,],%hhd,%hhd,%hd,%[^,],%d,%d,%[^,],%d,%d,%[^,],%d,%d,%[^,]",
2951 &modeAC.vehicleId, &modeAC.IVR, 6, &modeAC.type, &load_type,
2952 &load_quantity, &modeX.load_dest, 20, &modeAC.allegiance, &bay, &modeAC.owner, 13, &modeAC.ownerId,
2953 &weightLbs, &bitstring, 4,
2954 &fuel_tank, &pilot, &modeAC.hullname, 23);
2955 if (elem >= 14)
2956 {
2957 Trace(bigdatapacket.msg);
2958 }
2959 else
2960 {
2961 sprintf_s(msg, sizeof msg, "Could not parse ARJ (looking for 14 or 15) but %i elements...", elem);
2962 Trace(msg, Logger::Error);
2963 Trace(bigdatapacket.msg, Logger::Error);
2964 break;
2965 }
2966
2967 modeX.load_type = load_type;
2968 modeX.load_quantity = load_quantity;
2969 modeX.weightLbs = static_cast<float>(weightLbs);
2970 modeX.fuel_tank = static_cast<float>(fuel_tank);
2971 modeX.pilot = pilot;
2972
2973 modeAC.tow = bitstring[0] == '1';
2974 modeAC.reposess = bitstring[1] == '1';
2975 modeAC.stolen = bitstring[2] == '1';
2976
2977 game->bus->Scanner.InsertUpdateModeAC(modeAC.vehicleId, modeAC);
2979 game->bus->Scanner.InsertUpdateModeX(modeAC.vehicleId, modeX);
2980
2981 if (bay > 0 && bay <= MAX_BAYSPERSHIP) // in one of our bays
2982 {
2984 // store in bay
2985 game->bus->CargoBays[bay - 1] = modeAC.vehicleId;
2986 }
2987 else
2988 {
2989 sprintf_s(msg, sizeof msg, "Invalid bay %i for cargo data type 8...", bay);
2990 Trace(msg, Logger::Error);
2991 }
2992
2993 Trace("\tDone!");
2994 }
2995 break;
2996
2997 case 9: // ship data (VPT system AND actual visual data for scanner range)
2998 {
2999 if (bigdatapacket.array == 0 || bigdatapacket.array >= MAX_SCAN ||
3000 bigdatapacket.inarray >= MAX_SCAN ||
3001 bigdatapacket.vehicleId <= 0 || bigdatapacket.vehicleId > USHRT_MAX)
3002 {
3003 sprintf_s(msg, sizeof msg, "Rejected type 9 metadata slot %u parent %u vehicleId %i",
3004 bigdatapacket.array, bigdatapacket.inarray, bigdatapacket.vehicleId);
3005 Trace(msg, Logger::Error);
3006 break;
3007 }
3008
3009 char metadataText[sizeof bigdatapacket.msg + 1] = {};
3010 memcpy_s(metadataText, sizeof metadataText, bigdatapacket.msg, sizeof bigdatapacket.msg);
3011 Trace(metadataText);
3012 int vehicleType;
3013 char bitstring[16] = {}, trimcolor[8] = {};
3014 char incomingIvr[7] = {};
3015 char incomingHullName[23] = {};
3016 int incomingTotalWeightLbs = 0;
3017
3018 int reference;
3019 int flapdown;
3020 int spoilersUp;
3021 char logofile[9] = { "_" };
3022 const int results = sscanf_s(metadataText, "%[^,],%[^,],%d,%d,%[^,],%[^,],%d,%d,%d,%[^\n]",
3023 incomingIvr, static_cast<unsigned>(sizeof incomingIvr), bitstring, static_cast<unsigned>(sizeof bitstring), &vehicleType, &incomingTotalWeightLbs,
3024 trimcolor, 8, logofile, 9, &reference, &flapdown, &spoilersUp, incomingHullName, 23);
3025 // 53267, 001001001000101, 3, 101273, #FFFFFF, fedex, -1, 100, 100, GEORGE WASHINGTON
3026 if (results < 9)
3027 {
3028 Trace(metadataText, Logger::Error);
3029 sprintf_s(msg, sizeof msg, "Could only parse %i of 9 required (10th optional) items from type 9 data!", results);
3030 Trace(msg, Logger::Fatal);
3031 break;
3032 }
3033 if (reference <= REF_ENUMMIN || reference >= REF_ENUMMAX ||
3034 vehicleType < VehicleType::C98 || vehicleType > VehicleType::Estate ||
3035 incomingTotalWeightLbs < 0 || strnlen_s(bitstring, sizeof bitstring) < 14 ||
3036 (reference == REF_INANOTHER &&
3037 (bigdatapacket.inarray >= MAX_SCAN || bigdatapacket.inarray == bigdatapacket.array)))
3038 {
3039 sprintf_s(msg, sizeof msg, "Rejected type 9 reference %i for slot %u", reference, bigdatapacket.array);
3040 Trace(msg, Logger::Error);
3041 break;
3042 }
3043
3044 const unsigned char slot = bigdatapacket.array;
3045 const bool identityChanged = !playerships[slot].active ||
3046 playerships[slot].vehicleId != bigdatapacket.vehicleId;
3047 Telemetry::gSnapshotSystem.ResetVehicle(slot, bigdatapacket.vehicleId, reference,
3048 reference == REF_INANOTHER ? bigdatapacket.inarray : -1, identityChanged);
3049
3050 // A full metadata update is a hard replication boundary. Clear every legacy
3051 // correction too, so no state from a previous slot occupant can bleed through.
3052 s_network_objects& vehicle = playerships[slot];
3053 if (identityChanged)
3054 {
3055 vehicle.rainProtectionEnabled = false;
3056 vehicle.crashHornFault = false;
3057 vehicle.hornPressed = false;
3058 vehicle.wipers = {};
3059 }
3060 vehicle.sequence = 0;
3061 vehicle.position = vehicle.dockoffset = centerC;
3062 vehicle.velocity = vehicle.dockingvel = vehicle.barycentric = centerC;
3063 vehicle.positer = vehicle.posleft = vehicle.veliter = vehicle.velleft = centerC;
3064 vehicle.acc = vehicle.acciter = vehicle.accleft = centerC;
3065 vehicle.tx = vehicle.ty = vehicle.tz = 0.0f;
3066 vehicle.txiter = vehicle.tyiter = vehicle.tziter = 0.0f;
3067 vehicle.txleft = vehicle.tyleft = vehicle.tzleft = 0.0f;
3068 vehicle.pitch = vehicle.rollRadPerSec = vehicle.yawRadPerSec = 0.0f;
3069 vehicle.pitchleft = vehicle.pitchiter = vehicle.rollleft = vehicle.rolliter = 0.0f;
3070 vehicle.yawleft = vehicle.yawiter = 0.0f;
3071 vehicle.pitchdeflect = vehicle.rolldeflect = vehicle.yawdeflect = vehicle.steerdeflect = 0.0f;
3072 vehicle.orientation = RiseMath::Quaternion(0, 0, 0, 1);
3073 vehicle.orientiter = vehicle.orientleft = RiseMath::Quaternion(0, 0, 0, 0);
3074 vehicle.precisionx = vehicle.precisiony = vehicle.precisionz = 0.0;
3075 vehicle.visible = false;
3076 vehicle.clientinit = true;
3077 oldreference[slot] = static_cast<char>(reference);
3078 strcpy_s(vehicle.IVR, sizeof vehicle.IVR, incomingIvr);
3079 strcpy_s(vehicle.hullname, sizeof vehicle.hullname, incomingHullName);
3080 vehicle.totalWeightLbs = incomingTotalWeightLbs;
3081
3082 game->viewscreen->CheckLogo(bigdatapacket.array, logofile);
3083
3084 if (game->viewscreen->m_pddsHullDynamicTexture[bigdatapacket.array])
3085 {
3086 sprintf_s(msg, sizeof msg, "Released m_pddsHullDynamicTexture slot %i!", bigdatapacket.array);
3087 Trace(msg);
3089 sprintf_s(msg, sizeof msg, "m_pddsHullDynamicTexture[%i]", bigdatapacket.array);
3090 game->UpdateTrackedResource(msg, 3);
3091 }
3092
3093 playerships[bigdatapacket.array].inarray = bigdatapacket.inarray; // parent ship slot
3094
3095 playerships[bigdatapacket.array].bay = bigdatapacket.ship; // bay of parent ship
3096
3097 _strupr_s(playerships[bigdatapacket.array].hullname, sizeof playerships[bigdatapacket.array].hullname);
3098
3099 playerships[bigdatapacket.array].type = static_cast<unsigned char>(vehicleType);
3100 if (playerships[0].reference == REF_INANOTHER && playerships[0].inarray == slot)
3102 if (playerships[bigdatapacket.array].type == VehicleType::C98 ||
3103 playerships[bigdatapacket.array].type == VehicleType::C2 ||
3104 playerships[bigdatapacket.array].type == VehicleType::T27 ||
3105 playerships[bigdatapacket.array].type == VehicleType::C2A ||
3106 playerships[bigdatapacket.array].type == VehicleType::T120 ||
3107 playerships[bigdatapacket.array].type == VehicleType::T121)
3108 playerships[bigdatapacket.array].groundvehicle = true;
3109 else
3110 playerships[bigdatapacket.array].groundvehicle = false;
3111
3112 char hexcolor[11];
3113 sprintf_s(hexcolor, 11, "0x00%s", &trimcolor[1]);
3114 playerships[bigdatapacket.array].trimcolor = strtol(hexcolor, nullptr, 0);
3115
3116 playerships[bigdatapacket.array].vehicleId = bigdatapacket.vehicleId;
3117
3118 sprintf_s(msg, sizeof msg, "ship data IVR %s vehicleId %i slot %i parent %i bay %i",
3119 playerships[bigdatapacket.array].IVR, bigdatapacket.vehicleId, bigdatapacket.array, bigdatapacket.inarray, bigdatapacket.ship);
3120 Trace(msg);
3121
3122 // see if we previously scanned them
3123 const Sscan scan = game->bus->Scanner.Get(bigdatapacket.vehicleId);
3124 if (scan.initialized)
3125 {
3127 playerships[bigdatapacket.array].tow = scan.scandata.modeAC.tow;
3128 playerships[bigdatapacket.array].reposess = scan.scandata.modeAC.reposess;
3129 playerships[bigdatapacket.array].stolen = scan.scandata.modeAC.stolen;
3130
3131 // check that he isn't listed as a parent id of a vehicle we previously scanned
3132 if (reference != REF_INANOTHER)
3133 game->bus->Scanner.InsertUpdateParent(bigdatapacket.vehicleId, 0);
3134 }
3135 else
3136 playerships[bigdatapacket.array].align = 1; // don't know yet
3137
3138 playerships[bigdatapacket.array].police = bitstring[0] == '1';
3139 playerships[bigdatapacket.array].specialight = bitstring[1] == '1';
3140 playerships[bigdatapacket.array].transponder = bitstring[2] == '1';
3141 playerships[bigdatapacket.array].docked = bitstring[3] == '1';
3142 playerships[bigdatapacket.array].logolight = bitstring[4] == '1';
3143 playerships[bigdatapacket.array].isSimulator = bitstring[5] == '1';
3144 if (playerships[bigdatapacket.array].isSimulator)
3145 playerships[bigdatapacket.array].counterj = 1.14f; // for simulator
3146 playerships[bigdatapacket.array].geardown = bitstring[6] == '1';
3147 playerships[bigdatapacket.array].headlight = bitstring[7] == '1';
3148 playerships[bigdatapacket.array].baydoor = bitstring[8] == '1';
3149 playerships[bigdatapacket.array].domelight = bitstring[9] == '1';
3150 playerships[bigdatapacket.array].rainProtectionEnabled = bitstring[10] == '1';
3151 if (playerships[bigdatapacket.array].isSimulator)
3152 {
3153 auto& vehicle = playerships[bigdatapacket.array];
3154 vehicle.crashHornFault = vehicle.hornPressed = vehicle.rainProtectionEnabled = false;
3155 vehicle.wipers = {};
3156 }
3157 //playerships[bigdatapacket.array].stolen = bitstring[11] == '1'; // UNUSED?
3158 if (bitstring[12] == '1' && !playerships[bigdatapacket.array].battleRoyale)
3159 {
3160 playerships[bigdatapacket.array].battleRoyale = true;
3161 sprintf_s(msg, sizeof msg, "BATTLE ROYALE - Vehicle slot %i (%s) is now a participant (type 9)!", bigdatapacket.array, playerships[bigdatapacket.array].IVR);
3163 }
3164 else if (bitstring[12] == '0' && playerships[bigdatapacket.array].battleRoyale)
3165 {
3166 playerships[bigdatapacket.array].battleRoyale = false;
3167 sprintf_s(msg, sizeof msg, "BATTLE ROYALE - Vehicle slot %i (%s) was eliminated (type 9)!", bigdatapacket.array, playerships[bigdatapacket.array].IVR);
3169 }
3170 playerships[bigdatapacket.array].online = bitstring[13] == '1';
3171
3172 playerships[bigdatapacket.array].reference = reference;
3173 playerships[bigdatapacket.array].active = true;
3174 playerships[bigdatapacket.array].flapdown = static_cast<float>(flapdown) * 0.01f;
3175 playerships[bigdatapacket.array].spoilersUp = static_cast<float>(spoilersUp) * 0.01f;
3176
3177 // visible and active are false when they are offline
3178 if (!playerships[bigdatapacket.array].visible) // haven't already got telemetry
3179 playerships[bigdatapacket.array].clientinit = true;
3180 else
3181 {
3182 // clientinit=false, visible=true, active=true
3183 sprintf_s(msg, sizeof msg, "Initialized after telemetry received (%i)...", bigdatapacket.array);
3184 Trace(msg);
3185 }
3186
3187 game->viewscreen->LoadVehicleProfile(bigdatapacket.array);
3188 }
3189 break;
3190
3191 case 10: // Alignment data
3192 sprintf_s(msg, sizeof msg, "Got alignment data packet about playerIndex %i: %s", bigdatapacket.array, game->GUI->player[bigdatapacket.array].callsign);
3193 Trace(msg);
3194 Trace(bigdatapacket.msg);
3195 game->GUI->SetPlayerAlignment(bigdatapacket.msg, bigdatapacket.array);
3196 break;
3197
3198 case 11: // Damage control
3199 {
3200 // need to check that it is about the correct ship
3201 if (playerships[0].vehicleId != bigdatapacket.vehicleId)
3202 {
3203 Trace("Got damage control for a different vehicle!", Logger::Level::Error);
3204 break;
3205 }
3206
3207 ourcockpit.hitpoints = bigdatapacket.ship;
3208
3209 Trace("Got our damage control...");
3210 ourcockpit.vdat = bigdatapacket.vdat;
3212 {
3213 playerships[0].domelight = false;
3214 // Keep the persisted switch state in sync using the existing event.
3216 }
3218 ourcockpit.scanrange = 0.0f;
3219 ourcockpit.radioEquipped = false;
3222 if (bigdatapacket.array == Reference::REF_INANOTHER)
3223 {
3224 for (short t = 0; t < MAX_AVIOPERSHIP; t++)
3225 {
3226 if (ourcockpit.vdat.avionictype[t] == 1 && ourcockpit.scanrange < 320.0f)
3227 ourcockpit.scanrange = 320.0f;
3228 if (ourcockpit.vdat.avionictype[t] == 2 && ourcockpit.scanrange < 40.0f)
3229 ourcockpit.scanrange = 40.0f;
3230 if (ourcockpit.vdat.avionictype[t] == 3)
3231 {
3234 }
3235 if (ourcockpit.vdat.avionictype[t] == 4)
3237 if (ourcockpit.vdat.avionictype[t] == 5)
3239 }
3240
3241 for (short t = 0; t < MAX_WEAPPERSHIP; t++)
3242 {
3243 if (ourcockpit.vdat.weapontype[t] == 2)
3245 }
3246 }
3247 }
3248 break;
3249
3250 case 12: // Ignore suggested name ... sometimes I think they hit "Back" right after they hit "Suggest"
3251 case 13: // Ignore suggested handle ... I think they hit "Back" right away after they hit "Suggest"
3252 break;
3253
3254 case 19: // inventory (personal?)
3255 {
3256 ourcockpit.stowageLoadType = bigdatapacket.inventory.stowageLoadType;
3257 ourcockpit.stowageQuantity = bigdatapacket.inventory.stowageQuantity;
3258 ourcockpit.stowageDestination = bigdatapacket.inventory.stowageDestination;
3259
3261 for (int i = 0; i < MAX_INVPERPLYR; i++)
3262 {
3263 if (bigdatapacket.inventory.personalobjecttype[i])
3264 {
3265 InventoryHelper inventoryHelper = InventoryHelper();
3266 inventoryHelper.type = bigdatapacket.inventory.personalobjecttype[i];
3267 inventoryHelper.subtype = bigdatapacket.inventory.personalobjectsubtype[i];
3268 ourcockpit.personalInventory.emplace_back(inventoryHelper);
3269 }
3270 }
3271
3272 ourcockpit.polaroid1 = false;
3274 for (int i = 0; i < MAX_INVPERSHIP; i++)
3275 {
3276 if (bigdatapacket.inventory.vehicleobjecttype[i])
3277 {
3278 InventoryHelper inventoryHelper = InventoryHelper();
3279 inventoryHelper.type = bigdatapacket.inventory.vehicleobjecttype[i];
3280 inventoryHelper.subtype = bigdatapacket.inventory.vehicleobjectsubtype[i];
3281 ourcockpit.vehicleInventory.emplace_back(inventoryHelper);
3282 if (inventoryHelper.type == 1 && inventoryHelper.subtype == 13)
3283 ourcockpit.polaroid1 = true;
3284 }
3285 }
3286
3287 // 0=0.5, 10=1.0f, -10=0.0f
3288 ourcockpit.dexterity = Clamp(static_cast<float>(bigdatapacket.inventory.statDex) * 0.05f + 0.5f, -1.0f, 1.0f);
3290 sprintf_s(msg, sizeof msg, "Received personal inventory packet for dexterity (%i): %.1f", bigdatapacket.inventory.statDex, ourcockpit.dexterity);
3291 Trace(msg);
3292
3293 if (game->GUI->ourplayerC == 255 || game->GUI->player[game->GUI->ourplayerC].sex == 0)
3294 game->logger->Log("Character not yet initialized!", Logger::Fatal);
3295
3298
3299 ourcockpit.playerWeightKg = bigdatapacket.inventory.playerWeightKg;
3300
3301 cash = RiseMath::Max(bigdatapacket.inventory.cash, 0.0f);
3302 }
3303 break;
3304
3305 case 22: // new channel name
3306 //22=changechannelname msg=newname, array=channel, ship=, inarray=
3307 game->GUI->ChangeChannelName(bigdatapacket.array, bigdatapacket.msg);
3308 break;
3309
3310 case 23: // channel invite
3311 //23=invitechannel msg=channelname(WCHAR), array=whoinvited, ship=channel, inarray=tab
3312 game->GUI->ChannelInvite(bigdatapacket.msg, bigdatapacket.array, bigdatapacket.ship, bigdatapacket.inarray);
3313 break;
3314
3315 case 25: // turnbyturn
3316 //25=turnbyturn msg=EdgeId,x,y,distanceM,timeS,speedLimitKph,streetName, array=, ship=, inarray=
3317 {
3319 break;
3320 Snode node{};
3321 const int fields = sscanf_s(bigdatapacket.msg, "%i,%f,%f,%f,%f,%f,%31[^\n]",
3322 &node.edgeId, &node.position.x, &node.position.y, &node.distanceM, &node.timeS, &node.speedLimitKph, &node.streetName, 32);
3323 char msg[999];
3324 sprintf_s(msg, sizeof msg, "TURNBYTURN Node: %s", bigdatapacket.msg);
3325 Trace(msg);
3326 if (fields == 7 && game->bus->nodes.size() < game->bus->turnByTurnExpectedNodes)
3327 {
3328 game->bus->nodes.emplace_back(node);
3329 if (game->bus->nodes.size() == game->bus->turnByTurnExpectedNodes)
3330 game->bus->turnByTurnDirty = true;
3331 }
3332 }
3333 break;
3334
3335 case 30: // VPT mode S scan
3336 {
3337 Trace(bigdatapacket.msg);
3338
3339 char bitstring[99];
3340
3341 SmodeAC modeAC;
3342 USHORT parentId;
3343
3344 sscanf_s(bigdatapacket.msg, "%[^,],%[^,],%hhd,%[^,],%d,%hd,%hd,%d,%[^\n]",
3345 modeAC.IVR, 6, bitstring, static_cast<unsigned>(sizeof bitstring), &modeAC.type, modeAC.owner, 13, &modeAC.ownerId, &parentId, &modeAC.vehicleId, &modeAC.allegiance, modeAC.hullname, 23);
3346 // 53267, 001, 3, rana, 123, 1, 462, 0, GEORGE WASHINGTON
3347
3348 _strupr_s(modeAC.hullname, sizeof modeAC.hullname);
3349
3350 if (parentId != modeAC.vehicleId && parentId != 0)
3351 {
3352 Trace("Calling game->bus->Scanner.Get(parentId)");
3353 const Sscan parent_s_scan = game->bus->Scanner.Get(parentId);
3354 Trace("Getting scandata from parent_s_scan");
3355 const Sscandata parent_s_scan_data = parent_s_scan.scandata;
3356 Trace("Getting modeAC from parent_s_scan_data");
3357 const SmodeAC parent = parent_s_scan_data.modeAC;
3358 Trace("Setting location from parent");
3359 modeAC.location = parent.location;
3360 Trace("Setting reference from parent");
3361 modeAC.reference = parent.reference;
3362 }
3363 else
3364 {
3365 // just saved this stuff when we requested the scan
3366 Trace("Calling game->bus->Scanner.Get(vehicleId)");
3367 const Sscan original = game->bus->Scanner.Get(modeAC.vehicleId);
3368 modeAC.reference = original.scandata.modeAC.reference;
3369 modeAC.location = original.scandata.modeAC.location;
3370 }
3371
3372 Trace("Analyzing bitstring");
3373
3374 if (bitstring[0] == '1')
3375 modeAC.tow = true;
3376 else
3377 modeAC.tow = false;
3378 if (bitstring[1] == '1')
3379 modeAC.reposess = true;
3380 else
3381 modeAC.reposess = false;
3382 if (bitstring[2] == '1')
3383 modeAC.stolen = true;
3384 else
3385 modeAC.stolen = false;
3386
3387 Trace("Calling InsertUpdateModeAC");
3388 game->bus->Scanner.InsertUpdateModeAC(modeAC.vehicleId, modeAC);
3389 Trace("Calling InsertUpdateParent");
3390 game->bus->Scanner.InsertUpdateParent(modeAC.vehicleId, parentId);
3391
3392 // some of the data gets copied to the network_objects
3393 for (int t = 1; t < MAX_SCAN; t++)
3394 {
3395 if (playerships[t].active && playerships[t].vehicleId == modeAC.vehicleId)
3396 {
3397 playerships[t].stolen = modeAC.stolen;
3398 playerships[t].tow = modeAC.tow;
3399 playerships[t].reposess = modeAC.reposess;
3401 break;
3402 }
3403 }
3404 }
3405 break;
3406
3407 default:
3408 sprintf_s(msg, sizeof msg, "Unexpected SPacketBig type: %i stage %i", bigdatapacket.type, game->displaystage);
3410 break;
3411 }
3412 break;
3413 }
3414
3415 case sizeof SPacketHuge:
3416 {
3417 SPacketHuge hugedatapacket;
3418 memcpy_s(&hugedatapacket, sizeof SPacketHuge, &p->data[1], p->length - 1);
3419
3420 sprintf_s(msg, sizeof msg, "SPacketHuge %i", hugedatapacket.type);
3421 game->logger->AddToCallStack(msg);
3422
3423 switch (hugedatapacket.type)
3424 {
3425 case 15: // Subscribe data (we get this only if they already have an account)
3426 game->GUI->ChangePlayerProperties(&hugedatapacket.subscribe);
3427 strcpy_s(ourcockpit.handle, 13, hugedatapacket.subscribe.handle);
3428 strcpy_s(ourcockpit.character, 30, hugedatapacket.subscribe.characterName);
3429 break;
3430 case 8: // Dock trade
3431 case 11: // Futures market
3432 {
3433 // interactive menu
3434 interactive.avail = true;
3435 game->displays->ChangePage("MFD", "Intermedia");
3436 interactive.menutype = hugedatapacket.type;
3437 interactive.tempdock = hugedatapacket.tempdock;
3438
3439 // clear values
3440 interactive.colonistsforbuilding = floorf(interactive.tempplot.workingPopulation);
3443 }
3444 break;
3445
3446 case 16: // Colony Territory Inventory
3447 {
3448 // interactive menu
3449 interactive.avail = true;
3450 game->displays->ChangePage("MFD", "Intermedia");
3451 interactive.menutype = hugedatapacket.type;
3452 memcpy_s(interactive.inventory, sizeof SInventoryHelper * 9, hugedatapacket.inventory, sizeof SInventoryHelper * 9);
3453
3454 // clear values
3455 interactive.colonistsforbuilding = floorf(interactive.tempplot.workingPopulation);
3458 }
3459 break;
3460
3461 case 1: // Mining expansion
3462 case 2: // Storefront manager
3463 case 3: // Storefront customer
3464 case 4: // Cargo Operations
3465 case 5: // Farming expansion
3466 case 6: // Mining colony attributes
3467 case 7: // Farming colony attributes
3468 // 8 used above for dock trade
3469 case 9: // Township expansion
3470 case 10: // Township attributes
3471 // 11 used above for futures market
3472 case 12: // Township demolition
3473 case 13: // Mining demolition
3474 case 14: // Farming demolition
3475 // 15 used above for subscribe data
3476 // 16 is reserved
3477 // 17 is reserved
3478 // 18 is used by waypoint data
3479 // 19 is used for scan data TESTMODE
3480 // 20 is used below for scan data
3481 case 21: // Advanced grade A
3482 case 22: // Advanced grade B
3483 case 23: // Advanced grade C
3484 case 24: // Advanced grade D
3485 case 25: // Advanced grade E
3486 case 26: // Advanced grade F
3487 case 27: // Advanced grade G
3488 case 141: // FBO
3489 case 142: // airfield expansion
3490 case 143: // airfield demolition
3491 case 151: // refinery control center
3492 case 152: // refinery expansion
3493 case 153: // refinery demolition
3494 {
3495 // interactive menu
3496 interactive.avail = true;
3497 game->displays->ChangePage("MFD", "Intermedia");
3498 interactive.menutype = hugedatapacket.type;
3499 interactive.tempplot = hugedatapacket.tempplot;
3501
3502 // clear values
3503 interactive.colonistsforbuilding = floorf(interactive.tempplot.workingPopulation);
3506
3507 // open dix file (if applicable)
3508 char file[99];
3509 file[0] = 0;
3510 if (interactive.tempplot.type == PlotType::UserMining)
3511 sprintf_s(file, sizeof file, "meshes\\mining1.dix");
3512 else if (interactive.tempplot.type == PlotType::UserFarming)
3513 sprintf_s(file, sizeof file, "meshes\\farm1.dix");
3514 else if (interactive.tempplot.type == PlotType::UserTownship)
3515 sprintf_s(file, sizeof file, "meshes\\town1.dix");
3516 else if (interactive.tempplot.type == PlotType::UserAirfield)
3517 sprintf_s(file, sizeof file, "meshes\\airfield.dix");
3518 else if (interactive.tempplot.type == PlotType::UserRefinery)
3519 sprintf_s(file, sizeof file, "meshes\\refinery.dix");
3520 if (file[0])
3521 {
3522 int handle;
3523 _sopen_s(&handle, file, _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
3524 if (handle == -1)
3525 {
3526 sprintf_s(msg, sizeof msg, "Peer failed to load \"%s\"!", file);
3528 }
3529
3530 unsigned short filecomponents;
3531 _lseek(handle, 0, SEEK_SET);
3532 _read(handle, &filecomponents, 2);
3533
3534 std::vector<short> buildingIds;
3535
3536 // go through layouts
3537 for (long r = 0; r < filecomponents; r++)
3538 {
3539 unsigned char type = 0;
3540 LOCALGRID2 temp = LOCALGRID2();
3541 temp.layout1 = interactive.tempplot.layout1;
3542 temp.layout2 = interactive.tempplot.layout2;
3543 temp.layout3 = interactive.tempplot.layout3;
3544 temp.layout4 = interactive.tempplot.layout4;
3545 if (buildings::CheckLayout(r, temp))
3546 {
3547 _lseek(handle, r * 100L + 99L + 58L + 4L, SEEK_SET); // To 58
3548 _read(handle, &type, 1); // 58
3549 short attachto;
3550 _lseek(handle, r * 100L + 99L + 91L + 4L, SEEK_SET); // To 91
3551 _read(handle, &attachto, 1); // 91
3552 // if we already have a part of this buildingId then skip
3553 if (std::find(buildingIds.begin(), buildingIds.end(), attachto) != buildingIds.end()) // element found
3554 continue;
3555 if (type != 99) // ignore foundations
3556 buildingIds.emplace_back(attachto);
3557 }
3558
3559 switch (type)
3560 {
3561 case 7: // Seed building
3562 if (interactive.tempplot.type == PlotType::UserMining) // mining command
3563 {
3566 }
3567 else if (interactive.tempplot.type == PlotType::UserFarming) // farmstead
3568 {
3571 }
3572 else if (interactive.tempplot.type == PlotType::UserTownship) // town hall
3573 {
3576 }
3577 else if (interactive.tempplot.type == PlotType::UserAirfield) // FBO
3578 {
3581 }
3582 else if (interactive.tempplot.type == PlotType::UserRefinery) // Control Center
3583 {
3586 }
3588 break;
3589 case 71: // Mine extraction
3590 case 8: // Farm algae fields
3591 case 81: // Town housing or airfield hotel or refinery residences
3592 if (interactive.tempplot.type == PlotType::UserMining)
3593 {
3597 }
3598 else if (interactive.tempplot.type == PlotType::UserFarming)
3599 {
3601 interactive.mincoltorun += 0.1f;
3603 }
3604 else if (interactive.tempplot.type == PlotType::UserTownship)
3605 {
3607 interactive.mincoltorun += 1.5f;
3609 }
3610 else if (interactive.tempplot.type == PlotType::UserAirfield)
3611 {
3615 }
3616 else if (interactive.tempplot.type == PlotType::UserRefinery)
3617 {
3619 interactive.mincoltorun += 1.5f;
3621 }
3622 break;
3623 case 72: // Mine raw storage
3624 case 79: // Farm Greenhouse
3625 case 82: // Town industry
3626 case 90: // Airfield Terminal
3627 if (interactive.tempplot.type == PlotType::UserMining)
3628 {
3631 }
3632 else if (interactive.tempplot.type == PlotType::UserFarming)
3633 {
3635 interactive.mincoltorun += 0.4f;
3636 }
3637 else if (interactive.tempplot.type == PlotType::UserTownship)
3638 {
3640 interactive.mincoltorun += 9.0f;
3641 }
3642 else if (interactive.tempplot.type == PlotType::UserAirfield)
3643 {
3646 }
3647 // Refinery does not have minimum staff at these
3649 break;
3650 case 73: // Mine separators OR refinery refining
3651 case 80: // Farm hydroponics
3652 case 83: // Town research lab
3653 case 93: // Airfield hangar
3654 if (interactive.tempplot.type == PlotType::UserMining)
3655 {
3659 }
3660 else if (interactive.tempplot.type == PlotType::UserFarming)
3661 {
3663 interactive.mincoltorun += 0.4f;
3665 }
3666 else if (interactive.tempplot.type == PlotType::UserTownship)
3667 {
3671 }
3672 else if (interactive.tempplot.type == PlotType::UserAirfield)
3673 {
3677 }
3678 else if (interactive.tempplot.type == PlotType::UserRefinery)
3679 {
3683 }
3684 break;
3685 case 74: // Mine obliteration
3686 // farms skip this one
3687 case 84: // Town recreation
3688 // airfields skip this one
3689 if (interactive.tempplot.type == PlotType::UserMining)
3690 {
3693 }
3694 else if (interactive.tempplot.type == PlotType::UserTownship)
3695 {
3698 }
3700 break;
3701 case 75: // Processed Storage
3702 if (interactive.tempplot.type == PlotType::UserMining)
3703 {
3706 }
3707 else if (interactive.tempplot.type == PlotType::UserFarming)
3708 {
3710 }
3711 else if (interactive.tempplot.type == PlotType::UserTownship)
3712 {
3715 }
3716 else if (interactive.tempplot.type == PlotType::UserAirfield)
3717 {
3719 }
3721 break;
3722 case 76: // Support Structures
3723 if (interactive.tempplot.type == PlotType::UserMining)
3724 {
3727 }
3728 else if (interactive.tempplot.type == PlotType::UserFarming)
3729 {
3732 }
3733 else if (interactive.tempplot.type == PlotType::UserTownship)
3734 {
3736 interactive.mincoltorun += 3.9f;
3737 }
3738 else if (interactive.tempplot.type == PlotType::UserAirfield)
3739 {
3742 }
3743 else if (interactive.tempplot.type == PlotType::UserRefinery)
3744 {
3747 }
3749 break;
3750 case 77: // Power Production
3754 break;
3755 case 78: // Defensive Platforms
3756 case 94: // Airfield Control Tower
3757 case 140: // Off-gas Tower Refinery
3761 break;
3762 case 99:
3763 break; // ignore foundations
3764 case 0:
3765 break; // ignore unassigned
3766 default:
3767 sprintf_s(msg, sizeof msg, "Unknown building component type: %i", type);
3769 break;
3770 }
3771 }
3772 _close(handle);
3775 }
3776 }
3777 break;
3778
3779 case 18: // waypoint data
3780 {
3781 // Merge downloads/retries into the connection's resident collection.
3782 game->viewscreen->ptrWaypoints->AddOrUpdate(hugedatapacket.waypoint);
3783 }
3784 break;
3785
3786 case 20: // sscandata
3787 {
3788 // request clears this collection
3789
3790 SmodeAC modeAC;
3791 modeAC.vehicleId = hugedatapacket.scanData.vehicle_id;
3792 modeAC.reference = static_cast<char>(hugedatapacket.scanData.reference);
3793 strcpy_s(modeAC.IVR, 6, hugedatapacket.scanData.IVR);
3794 modeAC.allegiance = hugedatapacket.scanData.allegiance;
3795 strcpy_s(modeAC.hullname, 23, hugedatapacket.scanData.hullname);
3796 modeAC.location.x = hugedatapacket.scanData.positionx;
3797 modeAC.location.y = hugedatapacket.scanData.positiony;
3798 modeAC.location.z = hugedatapacket.scanData.positionz;
3799 strcpy_s(modeAC.owner, 13, hugedatapacket.scanData.owner);
3800 modeAC.ownerId = hugedatapacket.scanData.ownerId;
3801 modeAC.reposess = hugedatapacket.scanData.reposess;
3802 modeAC.stolen = hugedatapacket.scanData.stolen;
3803 modeAC.tow = hugedatapacket.scanData.tow;
3804 modeAC.type = hugedatapacket.scanData.type;
3805 game->bus->Scanner.InsertUpdateModeAC(modeAC.vehicleId, modeAC);
3806
3807 game->bus->Scanner.InsertUpdateParent(modeAC.vehicleId, hugedatapacket.scanData.parent_vehicle_id);
3808
3809 SmodeX modeX = SmodeX();
3810 if (hugedatapacket.scanData.loadQuantityHasValue)
3811 modeX.load_quantity = hugedatapacket.scanData.load_quantity;
3812 strcpy_s(modeX.load_dest, 20, hugedatapacket.scanData.load_dest);
3813 if (hugedatapacket.scanData.loadTypeHasValue)
3814 modeX.load_type = hugedatapacket.scanData.load_type;
3815 if (hugedatapacket.scanData.weightLbsHasValue)
3816 modeX.weightLbs = hugedatapacket.scanData.weightLbs;
3817 if (hugedatapacket.scanData.pilotHasValue)
3818 modeX.pilot = hugedatapacket.scanData.pilot;
3819 game->bus->Scanner.InsertUpdateModeX(modeAC.vehicleId, modeX);
3820
3821 // if we already have the vehicle data from the server then we have to update it here
3822 for (short t = 0; t < MAX_SCAN; t++)
3823 {
3824 if (playerships[t].active && playerships[t].vehicleId == modeAC.vehicleId)
3825 {
3827 playerships[t].tow = modeAC.tow;
3828 playerships[t].reposess = modeAC.reposess;
3829 playerships[t].stolen = modeAC.stolen;
3830 break;
3831 }
3832 }
3833 }
3834 break;
3835
3836 default:
3837 sprintf_s(msg, sizeof msg, "Unknown HUGE packet type: %i", hugedatapacket.type);
3839 break;
3840 }
3841 }
3842 break;
3843
3844 /* case sizeof SServerPacketChar:
3845 {
3846 SServerPacketChar datapacket;
3847 memcpy_s(&datapacket, sizeof SServerPacketChar, &packet->data[1], packet->length - 1);
3848
3849
3850
3851 game->GUI->player[datapacket.array].frame=datapacket.frame;
3852 // game->GUI->player[datapacket.array].bldg=datapacket.bldg;
3853 //game->GUI->player[datapacket.array].request=datapacket.request; // what button they pushed
3854 //game->GUI->player[datapacket.array].x=datapacket.x;
3855 //game->GUI->player[datapacket.array].y=datapacket.y;
3856 //game->GUI->player[datapacket.array].hdg=datapacket.hdg;
3857 // game->GUI->player[datapacket.array].ani=datapacket.ani;
3858 game->GUI->player[datapacket.array].leftright=datapacket.leftright;
3859 game->GUI->player[datapacket.array].updown=datapacket.updown;
3860 game->GUI->player[datapacket.array].rolltilt=datapacket.rolltilt;
3861 }
3862 break;*/
3863
3864 case sizeof SWeaponPacket:
3865 {
3866 SWeaponPacket datapacket;
3867 memcpy_s(&datapacket, sizeof SWeaponPacket, &packet->data[1], packet->length - 1);
3868
3869 sprintf_s(msg, sizeof msg, "SWeaponPacket %i %i %i", datapacket.type, datapacket.status, datapacket.array);
3870 game->logger->AddToCallStack(msg);
3871
3872 game->viewscreen->ptrWeapon->ProcessPacket(datapacket);
3873 }
3874 break;
3875
3876 case sizeof SPlotWeatherGrid:
3877 case sizeof SPlotWeatherRow:
3878 game->viewscreen->ptrWeather->ReceivePlotWeather(packet->data + 1, packet->length - 1);
3879 break;
3880
3881 case sizeof SRenderPoint:
3882 {
3883 SRenderPoint datapacket;
3884 memcpy(&datapacket, packet->data + 1, sizeof datapacket);
3885
3887 break; // the pending whole grid supersedes incremental terrain data
3888
3889 sprintf_s(msg, sizeof msg, "Received dynamic change for %i,%i", datapacket.tcp.u, datapacket.tcp.v);
3890 Trace(msg);
3891
3892 // A grid cell is center + index - 31, matching CalculateSRV and whole grids.
3893 const int t = 31 + datapacket.tcp.u - game->viewscreen->ptrGrid->tcp.u;
3894 const int s = 31 + datapacket.tcp.v - game->viewscreen->ptrGrid->tcp.v;
3895 if (t >= 0 && t < 64 && s >= 0 && s < 64)
3896 {
3898 if (gridarray[t][s].buildzoneOrdinal != -1)
3899 {
3900 game->viewscreen->ptrGrid->RemoveBuildZone(gridarray[t][s].buildzoneOrdinal);
3901
3902 sprintf_s(msg, sizeof msg, "SRenderPoint released VB slot %i!", gridarray[t][s].buildzoneOrdinal);
3903 Trace(msg);
3904
3905 gridarray[t][s].buildzoneOrdinal = -1; // re-create
3906 }
3907 else
3908 {
3909 Trace("There was no building or RTS at that location before");
3910 }
3913 }
3914 }
3915 break;
3916
3917 // This guy had some inherent problems with coordinating TCP and datapacket.TCP
3918 case sizeof SRenderRow:
3919 {
3921 break; // do not mix previous-face rows into a whole-grid handoff
3922
3923 SRenderRow datapacket;
3924 memcpy(&datapacket, packet->data + 1, sizeof datapacket);
3925 if (datapacket.side < 1 || datapacket.side > 4) break;
3926
3927
3928 const short ewadjust = game->viewscreen->ptrGrid->tcp.u - datapacket.tcp.u;
3929 const short nsadjust = game->viewscreen->ptrGrid->tcp.v - datapacket.tcp.v;
3930 short newt, news;
3931
3932
3933 sprintf_s(msg, sizeof msg, "Received 1.3 data edge %i:%i,%i+(%+i,%+i)=(%i,%i)", datapacket.side - 1, datapacket.tcp.u, datapacket.tcp.v, ewadjust, nsadjust, game->viewscreen->ptrGrid->tcp.u, game->viewscreen->ptrGrid->tcp.v);
3934 Trace(msg);
3935
3937 {
3938 Trace("We received 1.3 data edge but weren't waiting for any!", Logger::Level::Debug);
3939 break;
3940 }
3941
3942 switch (datapacket.side)
3943 {
3944 case 1: // north (l to r)
3945 {
3946 news = 0 - nsadjust;
3947 if (news >= 0 && news < 64)
3948 {
3949 sprintf_s(msg, sizeof msg, "Proc SRV north row %i: ", news);
3950 for (short t = 0; t < 64; t++)
3951 {
3952 newt = t - ewadjust;
3953 if (newt >= 0 && newt < 64)
3954 {
3955 char append[99];
3956 sprintf_s(append, sizeof append, "%2i ", newt);
3957 strcat_s(msg, sizeof msg, append);
3958 gridarray[newt][news] = game->viewscreen->CalculateSRV(newt, news, game->viewscreen->ptrGrid->tcp, game->viewscreen->ptrGrid->cube, datapacket.gridarray[t]);
3959 }
3960 else
3961 strcat_s(msg, sizeof msg, "XX ");
3962 }
3963 Trace(msg);
3964 }
3965 else
3966 Trace("Proc SRV row no longer applies!");
3967 }
3968 break;
3969
3970 case 2: // south (l to r)
3971 {
3972 news = 63 - nsadjust;
3973 if (news >= 0 && news < 64)
3974 {
3975 sprintf_s(msg, sizeof msg, "Proc SRV sourth row %i: ", news);
3976 for (short t = 0; t < 64; t++)
3977 {
3978 newt = t - ewadjust;
3979 if (newt >= 0 && newt < 64)
3980 {
3981 char append[99];
3982 sprintf_s(append, sizeof append, "%2i ", newt);
3983 strcat_s(msg, sizeof msg, append);
3984 gridarray[newt][news] = game->viewscreen->CalculateSRV(newt, news, game->viewscreen->ptrGrid->tcp, game->viewscreen->ptrGrid->cube, datapacket.gridarray[t]);
3985 }
3986 else
3987 strcat_s(msg, sizeof msg, "XX ");
3988 }
3989 Trace(msg);
3990 }
3991 else
3992 Trace("Proc SRV row no longer applies!");
3993 }
3994 break;
3995
3996 case 3: // east (u to d)
3997 {
3998 newt = 63 - ewadjust;
3999 if (newt >= 0 && newt < 64)
4000 {
4001 sprintf_s(msg, sizeof msg, "Proc SRV east column %i: ", newt);
4002 for (short s = 0; s < 64; s++)
4003 {
4004 news = s - nsadjust;
4005 if (news >= 0 && news < 64)
4006 {
4007 char append[99];
4008 sprintf_s(append, sizeof append, "%2i ", news);
4009 strcat_s(msg, sizeof msg, append);
4010 gridarray[newt][news] = game->viewscreen->CalculateSRV(newt, news, game->viewscreen->ptrGrid->tcp, game->viewscreen->ptrGrid->cube, datapacket.gridarray[s]);
4011 }
4012 else
4013 strcat_s(msg, sizeof msg, "XX ");
4014 }
4015 Trace(msg);
4016 }
4017 else
4018 Trace("Proc SRV column no longer applies!");
4019 }
4020 break;
4021
4022 case 4: // west (u to d) news verified 1/3
4023 {
4024 newt = 0 - ewadjust;
4025 if (newt >= 0 && newt < 64)
4026 {
4027 sprintf_s(msg, sizeof msg, "Proc SRV west column %i: ", newt);
4028 for (short s = 0; s < 64; s++)
4029 {
4030 news = s - nsadjust;
4031 if (news >= 0 && news < 64)
4032 {
4033 char append[99];
4034 sprintf_s(append, sizeof append, "%2i ", news);
4035 strcat_s(msg, sizeof msg, append);
4036 gridarray[newt][news] = game->viewscreen->CalculateSRV(newt, news, game->viewscreen->ptrGrid->tcp, game->viewscreen->ptrGrid->cube, datapacket.gridarray[s]);
4037 }
4038 else
4039 strcat_s(msg, sizeof msg, "XX ");
4040 }
4041 Trace(msg);
4042 }
4043 else
4044 Trace("Proc SRV column no longer applies!");
4045 }
4046 break;
4047 default:
4048 Trace("SRV row or column unrecognized!", Logger::Level::Error);
4049 break;
4050 }
4051
4052
4054 game->viewscreen->ptrGrid->geometryReady = false; // need to create new VB
4056 sprintf_s(msg, sizeof msg, "Ground grid is waiting for %i more", game->viewscreen->ptrGrid->dataPending);
4057 Trace(msg);
4058 }
4059 break;
4060
4061 case sizeof SAssayGrid:
4062 {
4063 memcpy_s(&game->bus->assayGrid, sizeof SAssayGrid, &packet->data[1], packet->length - 1);
4065 }
4066 break;
4067
4068 // whole grid, should be clean slate before we get this call
4069 case sizeof SRenderGrid:
4070 {
4071 //Whole grid
4072 auto datapacket = std::make_unique<SRenderGrid>();
4073 memcpy(datapacket.get(), packet->data + 1, sizeof *datapacket);
4074
4075 // calculate and store results
4076 game->viewscreen->ptrGrid->ReceiveWholeGrid(*datapacket);
4077 }
4078 break;
4079
4080 //case sizeof SWeatherGrid:
4081 //{
4082 // memcpy_s(game->viewscreen->ptrWeather->weathergrid, sizeof SWeatherGrid, &packet->data[1], packet->length - 1);
4083 //
4084 // Trace("Received SWeatherGrid");
4085 //}
4086 //break;
4087
4088 case sizeof SRenderBuilding:
4089 {
4090 SRenderBuilding datapacket;
4091 memcpy_s(&datapacket, sizeof SRenderBuilding, &packet->data[1], packet->length - 1);
4092
4093 if (!g_bAboveClouds)
4094 {
4095 // Live colony broadcasts can arrive while the loading screen still has no grid.
4096 // The next whole-grid request includes current building layouts. Once a
4097 // request is pending, keep accepting layouts even before terrain is ready.
4099 {
4100 Trace("SRenderBuilding ignored before terrain request; whole grid will refresh buildings");
4101 break;
4102 }
4103
4104 const short t = datapacket.tcp.u - game->viewscreen->ptrGrid->tcp.u + 31;
4105 const short s = datapacket.tcp.v - game->viewscreen->ptrGrid->tcp.v + 31;
4106
4107 sprintf_s(msg, sizeof msg, "Received SRenderBuilding type %i @ u%i v%i (%i,%i) power %i", datapacket.type, datapacket.tcp.u, datapacket.tcp.v, t, s, datapacket.powered);
4108 Trace(msg);
4109 sprintf_s(msg, sizeof msg, " Zone %i (%08X %08X %08X %08X)", datapacket.zone, datapacket.layout.layout1, datapacket.layout.layout2, datapacket.layout.layout3, datapacket.layout.layout4);
4110 Trace(msg);
4111
4112 int oldlayout4 = 0;
4113
4114 if (t >= 0 && t < 64 && s >= 0 && s < 64)
4115 {
4116 if (gridarray[t][s].buildzoneOrdinal != -1)
4117 {
4118 game->viewscreen->ptrGrid->RemoveBuildZone(gridarray[t][s].buildzoneOrdinal);
4119
4120 sprintf_s(msg, sizeof msg, " SRenderBuilding released VB slot %i!", gridarray[t][s].buildzoneOrdinal);
4121 Trace(msg);
4122
4123 gridarray[t][s].buildzoneOrdinal = -1; // re-create
4124 }
4125
4126 gridarray[t][s].type = static_cast<PlotType>(datapacket.type);
4127 gridarray[t][s].zone = datapacket.zone;
4128 gridarray[t][s].layout1 = datapacket.layout.layout1;
4129 gridarray[t][s].layout2 = datapacket.layout.layout2;
4130 gridarray[t][s].layout3 = datapacket.layout.layout3;
4131 oldlayout4 = gridarray[t][s].layout4;
4132 gridarray[t][s].layout4 = datapacket.layout.layout4;
4133 gridarray[t][s].powered = datapacket.powered;
4134 Trace(" SRenderBuilding is somewhere on grid, stored!");
4135 }
4136 else
4137 {
4138 // Log grid state before Error triggers the client trace upload.
4139 sprintf_s(msg, sizeof msg, " Grid center u%i v%i cube %i ready %i pending %i",
4143 Trace(msg);
4144 Trace(" SRenderBuilding off grid reference, not stored!", Logger::Error);
4145 }
4146
4147 // Pending edge requests do not invalidate the initialized inner grid.
4148 // Use the same data readiness check as grid::Process for rebuilding.
4149 if (t > 15 && t < 48 && s > 15 && s < 48)
4150 {
4152 {
4153 Trace(" SRenderBuilding grid level is initialized, OK!");
4154 // if apn has construction whose VB hasn't been created
4155
4156 if (gridarray[t][s].type > PlotType::NotZoned &&
4157 gridarray[t][s].type < PlotType::PlotTypeEnum &&
4158 gridarray[t][s].buildzoneOrdinal == -1)
4159 {
4160 Trace(" SRenderBuilding type in bounds, OK!");
4161 if (gridarray[t][s].IsUserColony())
4162 {
4163 Trace(" SRenderBuilding layout is user-generated and real, OK!");
4164 // if we got here the grid was ready when we got case 16
4165 if (gridarray[t][s].type != PlotType::UserAirfield || oldlayout4 == gridarray[t][s].layout4)
4167 else
4168 {
4169 Trace(" SRenderBuilding is an airfield and layout4 changed!");
4170 game->viewscreen->ptrGrid->makeBuildings = true; // do we need this?
4171 game->viewscreen->ptrGrid->geometryReady = false; // reload the runway
4172 for (short tt = 16; tt < 48; tt++) // can't do outside edges
4173 {
4174 for (short ss = 16; ss < 48; ss++)
4175 {
4177 }
4178 }
4179 }
4180 }
4181 else
4182 {
4183 Trace(" SRenderBuilding must be gov, OK!");
4186 for (short tt = 16; tt < 48; tt++) // can't do outside edges
4187 {
4188 for (short ss = 16; ss < 48; ss++)
4189 {
4191 }
4192 }
4193 }
4194 }
4195 else
4196 {
4197 sprintf_s(msg, sizeof msg, " SRenderBuilding type (%i) out-of-bounds (or %i), sorry!", gridarray[t][s].type, gridarray[t][s].buildzoneOrdinal);
4198 Trace(msg, Logger::Error);
4199 }
4200 }
4201 else
4202 {
4203 Trace(" SRenderBuilding stored; waiting for initial terrain grid");
4204 }
4205 }
4206 else
4207 {
4208 Trace(" SRenderBuilding not in patch data, OK!");
4209 }
4210 } // !g_bAboveClouds
4211 else
4212 {
4213 Trace("SRenderBuilding received while ACMPL!", Logger::Warn);
4214 }
4215 }
4216 break;
4217
4218 case sizeof SPacketMenu:
4219 {
4221 break;
4222
4223 SPacketMenu datapacket;
4224 memcpy_s(&datapacket, sizeof SPacketMenu, &p->data[1], p->length - 1);
4225
4227 ptr->SetMenu(datapacket);
4228
4229 sprintf_s(msg, sizeof msg, "Received menu for level %i", datapacket.menuLevel);
4230 Trace(msg);
4231
4232
4233 // Battle royale tutorial
4234 if (datapacket.menuLevel == 29 && ourcockpit.ownerId == 65523)
4235 {
4237 if (playerships[0].type == VehicleType::A4)
4240 }
4241
4242 if (!datapacket.interactive && !g_bTextInput && interactive.avail)
4243 {
4244 interactive.avail = false;
4245 game->displays->RestorePage("MFD");
4246 }
4247 else if (datapacket.interactive)
4248 {
4249 interactive.avail = true;
4250 game->displays->ChangePage("MFD", "Intermedia");
4251 }
4252 }
4253 break;
4254
4255 default:
4256 sprintf_s(msg, sizeof msg, "Unknown packet size: %d", p->length - 1);
4258 break;
4259 }
4260 break;
4261 }
4262
4264 {
4265 SVerbiage chat = SVerbiage();
4266 memcpy_s(&chat, sizeof SVerbiage, &packet->data[1], packet->length - 1);
4267 sprintf_s(msg, sizeof msg, "Got verbiage: %i", chat.id);
4268 Trace(msg);
4269
4270 if (chat.id > 0)
4272 else
4273 game->GUI->AddToast(chat.text, static_cast<ActiveHelp>(chat.id));
4274 }
4275 break;
4276
4278 {
4279 WCHAR chat[TRANSMIT_CHAT_SIZE];
4280 const unsigned source_size = RiseMath::Min(packet->length - 3, TRANSMIT_CHAT_SIZE * 2);
4281 memcpy_s(chat, sizeof chat, &packet->data[3], source_size);
4282
4283 if (packet->data[2] == 255)
4285 else if (packet->data[2] == 254)
4287 else
4288 game->GUI->AddChatMessage(chat, packet->data[2], packet->data[1]);
4289
4290 // Wait until we are out of the apartment and only if we haven't already dismissed this help
4291 if (game->GUI->player[game->GUI->ourplayerC].frame == 0 &&
4295
4296 break;
4297 }
4298
4299 case ID_DISCONNECTION_NOTIFICATION:
4300 Trace("ID_DISCONNECTION_NOTIFICATION", Logger::Level::Warn);
4301#ifndef _DEBUG
4302 PostQuitMessage(0);
4303#endif
4304 break;
4305
4306 case ID_CONNECTION_LOST:
4307 Trace("ID_CONNECTION_LOST", Logger::Level::Warn);
4308 game->ToggleFullScreen(false);
4309 MessageBoxW(nullptr, L"Reliable packets cannot be delivered to the game server. Please check your connection and try again.", L"Disconnected from server!", MB_ICONERROR | MB_OK);
4310#ifndef _DEBUG
4311 PostQuitMessage(0);
4312#endif
4313 break;
4314
4315 case ID_CONNECTION_ATTEMPT_FAILED:
4316 Trace("ID_CONNECTION_ATTEMPT_FAILED", Logger::Level::Warn);
4317#ifndef _DEBUG
4318 PostQuitMessage(0);
4319#endif
4320 break;
4321
4322 case ID_NO_FREE_INCOMING_CONNECTIONS:
4323 Trace("ID_NO_FREE_INCOMING_CONNECTIONS", Logger::Level::Warn);
4324#ifndef _DEBUG
4325 PostQuitMessage(0);
4326#endif
4327 break;
4328
4329 /*Trace("Lost connection!", Logger::Level::Warn);
4330 RakNet::ConnectionAttemptResult result = Connect();
4331 if (result != RakNet::ConnectionAttemptResult::CONNECTION_ATTEMPT_STARTED)
4332 Rendering::TraceFailure(L"NetFactory->Connect", 0);
4333 else
4334 {
4335 if (p->data[0] == ID_CONNECTION_ATTEMPT_FAILED)
4336 Trace("Retrying (ID_CONNECTION_ATTEMPT_FAILED)...", Logger::Level::Info);
4337 else if (p->data[0] == ID_NO_FREE_INCOMING_CONNECTIONS)
4338 Trace("Retrying (ID_NO_FREE_INCOMING_CONNECTIONS)...", Logger::Level::Info);
4339 else if (p->data[0] == ID_CONNECTION_LOST)
4340 Trace("Retrying (ID_CONNECTION_LOST)...", Logger::Level::Info);
4341 else if (p->data[0] == ID_DISCONNECTION_NOTIFICATION)
4342 Trace("Retrying (ID_DISCONNECTION_NOTIFICATION)...", Logger::Level::Info);
4343 }*/
4344
4345 case ID_CONNECTION_REQUEST_ACCEPTED:
4346 Trace("ID_CONNECTION_REQUEST_ACCEPTED");
4347 break;
4348
4349 default:
4350 {
4351 sprintf_s(msg, sizeof msg, "Unknown packet ID %i", p->data[0]);
4352 game->logger->Log(msg, Logger::Error);
4353 }
4354 break;
4355 }
4356
4357 game->logger->AddToCallStack("Networking::RakNetMessageHandler DONE");
4358}
ActiveHelp
Definition ActiveHelp.h:4
@ SinkerInstalled
Definition ActiveHelp.h:441
@ HowToUseJVCAudio
Definition ActiveHelp.h:435
@ TaxiService43
Definition ActiveHelp.h:396
@ UserInputOnMFD
Definition ActiveHelp.h:434
@ TaxiService54
Definition ActiveHelp.h:407
@ HowToLeaveArena
Definition ActiveHelp.h:442
@ IntermediaFault
Definition ActiveHelp.h:28
@ Quartermaster
Definition ActiveHelp.h:440
@ RustysRentals1
Definition ActiveHelp.h:420
@ SimulatorBay2
Definition ActiveHelp.h:423
@ Hardcore1
Definition ActiveHelp.h:424
@ SimulatorBay1
Definition ActiveHelp.h:422
@ Communications
Definition ActiveHelp.h:418
@ MessageOfTheDay
Definition ActiveHelp.h:352
@ TaxiService53
Definition ActiveHelp.h:406
@ Hardcore2
Definition ActiveHelp.h:425
@ WelcomeToChojeir
Definition ActiveHelp.h:439
@ FleetBank1
Definition ActiveHelp.h:421
#define SAFE_RELEASE(value)
#define V(expression)
HRESULT(WINAPI *CUniBuffer::_ScriptApplyDigitSubstitution)(const SCRIPT_DIGITSUBSTITUTE *
SCRIPT_CONTROL SCRIPT_STATE const void DWORD
@ D_COMMUNICATIONS
Definition DialogBase.h:12
@ D_INTERMEDIA
Definition DialogBase.h:9
GameState
Definition GameState.h:4
@ STATUS_LOADING
Definition GameState.h:8
@ STATUS_GAME
Definition GameState.h:9
@ STATUS_CREATE
Definition GameState.h:7
@ STATUS_LOGIN
Definition GameState.h:6
@ STATUS_SPLASH
Definition GameState.h:5
const GUID MYGUID_NULL
Definition Guids.h:3
float RandomFloat()
constexpr auto Clamp(T1 val, T2 min, T3 max)
EventType
Definition Networking.h:37
@ EVENT_SELECT_PAGE
Definition Networking.h:60
@ EVENT_HEADLIGHT_ON
Definition Networking.h:40
@ EVENT_WINDSHIELD_FAULT
Definition Networking.h:68
@ EVENT_BRAKELIGHT_OFF
Definition Networking.h:58
@ EVENT_HORN_STOP
Definition Networking.h:70
@ EVENT_LANDINGGEAR_UP
Definition Networking.h:45
@ EVENT_HORN_START
Definition Networking.h:69
@ EVENT_HEADLIGHT_OFF
Definition Networking.h:41
@ EVENT_SPOILERSETTING
Definition Networking.h:65
@ EVENT_LANDINGGEAR_DOWN
Definition Networking.h:44
@ EVENT_SELECT_TARGET
Definition Networking.h:59
@ EVENT_BRAKELIGHT_ON
Definition Networking.h:57
@ EVENT_DOMELIGHT_ON
Definition Networking.h:46
@ BattleRoyaleParticipant
Definition Networking.h:63
@ EVENT_FLAPSETTING
Definition Networking.h:52
@ EVENT_BAYDOOR_CLOSED
Definition Networking.h:43
@ EVENT_WIPERS
Definition Networking.h:67
@ EVENT_LOGOLIGHT_ON
Definition Networking.h:50
@ BattleRoyaleElimination
Definition Networking.h:64
@ EVENT_LOGOLIGHT_OFF
Definition Networking.h:51
@ EVENT_TRANSPONDER
Definition Networking.h:66
@ EVENT_DOMELIGHT_OFF
Definition Networking.h:47
@ EVENT_POLICELIGHT_OFF
Definition Networking.h:49
@ EVENT_BAYDOOR_OPEN
Definition Networking.h:42
@ EVENT_POLICELIGHT_ON
Definition Networking.h:48
constexpr unsigned char ID_USER_PACKET_CLOUD_WEATHER
Definition Networking.h:17
#define hostC
Definition Networking.h:20
@ CONNECT_CONNECTED
Definition Networking.h:29
@ CONNECT_CONNECTING
Definition Networking.h:28
@ CONNECT_PATCHED
Definition Networking.h:31
#define portC
Definition Networking.h:21
#define rotlimitC
#define MAX_INVPERSHIP
#define TRANSMIT_CHAT_SIZE
@ ID_USER_PACKET_ERROR
Definition ServerTypes.h:27
@ ID_USER_PACKET_LOGO
Definition ServerTypes.h:36
@ ID_USER_PACKET_HELP
Definition ServerTypes.h:33
@ ID_USER_PACKET_CHAT
Definition ServerTypes.h:28
@ ID_USER_PACKET_TELEMETRY
Definition ServerTypes.h:29
@ ID_USER_PACKET_AVATAR
Definition ServerTypes.h:30
@ ID_USER_PACKET_LOGFILE
Definition ServerTypes.h:34
@ ID_USER_PACKET_DEVICE
Definition ServerTypes.h:35
@ ID_USER_PACKET_PATCH
Definition ServerTypes.h:31
@ ID_USER_PACKET_SUPER
Definition ServerTypes.h:32
#define MAX_AVIOPERSHIP
@ W6Manx
Definition ServerTypes.h:84
@ Hangar
Definition ServerTypes.h:90
@ C98
Definition ServerTypes.h:61
@ ControlTower
Definition ServerTypes.h:86
@ C2
Definition ServerTypes.h:66
@ C2A
Definition ServerTypes.h:81
@ T19
Definition ServerTypes.h:87
@ P13
Definition ServerTypes.h:64
@ Apartment
Definition ServerTypes.h:80
@ ARJ_PAX
Definition ServerTypes.h:70
@ E10
Definition ServerTypes.h:63
@ T120
Definition ServerTypes.h:67
@ T27
Definition ServerTypes.h:82
@ E11
Definition ServerTypes.h:68
@ FloatingMan
Definition ServerTypes.h:88
@ SimBay
Definition ServerTypes.h:85
@ DIHV
Definition ServerTypes.h:62
@ A4
Definition ServerTypes.h:65
@ T121
Definition ServerTypes.h:89
@ Estate
Definition ServerTypes.h:91
#define MAX_INVPERPLYR
PacketOrdering
Definition ServerTypes.h:11
@ ORDERING_ERRORS
Definition ServerTypes.h:18
@ ORDERING_TELEMETRY
Definition ServerTypes.h:16
@ ORDERING_NONE
Definition ServerTypes.h:12
@ ORDERING_CHAT
Definition ServerTypes.h:17
#define MAX_ENGINES
#define MAX_WEAPPERSHIP
#define MAX_BAYSPERSHIP
#define MAX_SCAN
@ Passengers
PlotType
@ PlotTypeEnum
@ UserTownship
@ UserAirfield
@ UserFarming
@ UserMining
@ UserRefinery
@ NotZoned
@ NightVision
const RiseMath::Vector3 centerC
@ REF_BUILDING
Definition ServerTypes.h:46
@ REF_DOCKENUMCPOC
Definition ServerTypes.h:53
@ REF_INANOTHER
Definition ServerTypes.h:45
@ REF_ENUMMIN
Definition ServerTypes.h:41
@ REF_APNMODE
Definition ServerTypes.h:42
@ REF_ONGROUND
Definition ServerTypes.h:43
@ REF_ENUMMAX
Definition ServerTypes.h:56
@ REF_WINDOWLESS
Definition ServerTypes.h:50
SOUNDS
Definition Sound.h:23
@ SOUND_RADIOCARRIER4
Definition Sound.h:321
@ SOUND_GROUNDSCRAPELOOP
Definition Sound.h:269
@ SOUND_BACKUP
Definition Sound.h:261
@ SOUND_BOARDING
Definition Sound.h:182
@ SOUND_RADIOCARRIER11
Definition Sound.h:328
@ SOUND_DOCKCHIME
Definition Sound.h:205
@ SOUND_RADIOCARRIER5
Definition Sound.h:322
@ SOUND_FIREWORKEXPLODE1
Definition Sound.h:235
@ SOUND_RADIOCUT1
Definition Sound.h:310
@ SOUND_RADIOCARRIER1
Definition Sound.h:318
@ SOUND_RADIOCARRIER8
Definition Sound.h:325
@ SOUND_RADIOCARRIER2
Definition Sound.h:319
@ SOUND_DEICE
Definition Sound.h:239
@ SOUND_RADIOCARRIER10
Definition Sound.h:327
@ SOUND_BACKUPMAMMOTH
Definition Sound.h:264
@ SOUND_RADIOCARRIER0
Definition Sound.h:317
@ SOUND_ROADNOISELOOP
Definition Sound.h:271
@ SOUND_FIREWORKLAUNCH1
Definition Sound.h:232
@ SOUND_RADIOCARRIER3
Definition Sound.h:320
@ SOUND_RADIOCARRIER7
Definition Sound.h:324
@ SOUND_DOCKANNOUNCE1
Definition Sound.h:192
@ SOUND_RADIOCARRIER6
Definition Sound.h:323
@ SOUND_DOCKEVAC
Definition Sound.h:204
@ SOUND_RADIOCARRIER9
Definition Sound.h:326
scanDb Scanner
Definition Bus.h:484
float StaticAirPressureMb
Definition Bus.h:406
bool RevenuePassengers
Definition Bus.h:478
float EngineThrustOutput[MAX_ENGINES]
Definition Bus.h:54
bool turnByTurnDirty
Definition Bus.h:512
float MapScaleInnerRingKm
Definition Bus.h:490
float assayQuality
Definition Bus.h:495
float PayloadWeightLbs
Definition Bus.h:464
float GroundSpeedKms
Definition Bus.h:179
UINT flapSettingLE
Definition Bus.h:69
float TrailingEdgeFlapsPosition
Definition Bus.h:424
float CabinPressureMb
Definition Bus.h:403
short targetC
Definition Bus.h:480
void ClearTurnByTurn()
Definition Bus.h:517
UINT flapSettingTE
Definition Bus.h:67
bool streetViewConfigured
Definition Bus.h:510
bool ProximityAlert
Definition Bus.h:477
float EngineThrustLever[MAX_ENGINES]
Definition Bus.h:357
std::vector< Snode > nodes
Definition Bus.h:511
double SimulatorTimeOffset
Definition Bus.h:475
float LeadingEdgeFlapsPosition
Definition Bus.h:426
float FlightSpoilerPositionScalar
Definition Bus.h:76
bool AntiIce
Definition Bus.h:392
std::vector< Swaypoint > waypoint
Definition Bus.h:500
float PitchTrimScalar
Definition Bus.h:415
unsigned char turnByTurnRoutingType
Definition Bus.h:514
short station
Definition Bus.h:506
float BattleRoyaleRingKm
Definition Bus.h:532
float SpeedometerKPH
Definition Bus.h:180
SAssayGrid assayGrid
Definition Bus.h:494
bool YawDamperStatus
Definition Bus.h:433
float RadioAltitudeKm
Definition Bus.h:157
size_t turnByTurnExpectedNodes
Definition Bus.h:513
RiseMath::Vector3 BattleRoyaleRingCenter
Definition Bus.h:531
short scanslot[MAX_SCAN]
Definition Bus.h:485
bool FlightFreeze
Definition Bus.h:474
float turnByTurnTotalDistanceMeters
Definition Bus.h:515
float GroundSpoilerPositionScalar
Definition Bus.h:75
std::vector< Message > messages
Definition Bus.h:445
bool ThrustReverserCommand[MAX_ENGINES]
Definition Bus.h:72
unsigned short CargoBays[MAX_BAYSPERSHIP]
Definition Bus.h:465
std::vector< Command > commandStream
Definition Bus.h:442
float turnByTurnTotalTimeSeconds
Definition Bus.h:516
unsigned char channel
Definition chat.h:63
bool Receive(Rendering::RenderDevice *device, int32_t token, const void *bytes, size_t size, uint64_t now)
bool Assign(int32_t group, const char *filename, size_t capacity)
bool Submit(const uint8_t *packet, size_t size)
SoundConfig soundConfigComms
Definition config.h:50
InputConfig inputConfigSteer
Definition config.h:38
InputConfig inputConfigLeftToeBrake
Definition config.h:41
SoundConfig soundConfigLegacy
Definition config.h:51
bool SavePatchDate(int &errorCode, unsigned long &osErrorCode) const
Definition config.cpp:56
InputConfig inputConfigGas
Definition config.h:39
InputConfig inputConfigThrustRight
Definition config.h:36
InputConfig inputConfigLookLateral
Definition config.h:43
InputConfig inputConfigBrake
Definition config.h:40
InputConfig inputConfigWalkLateral
Definition config.h:46
char defaultuser[13]
Definition config.h:21
InputConfig inputConfigRoll
Definition config.h:33
InputConfig inputConfigLookVertical
Definition config.h:44
InputConfig inputConfigWalkVertical
Definition config.h:47
unsigned char language
Definition config.h:16
InputConfig inputConfigThrustLeft
Definition config.h:35
InputConfig inputConfigYaw
Definition config.h:34
InputConfig inputConfigRightToeBrake
Definition config.h:42
InputConfig inputConfigPitch
Definition config.h:32
float scale
Definition config.h:29
char patchdate[24]
Definition config.h:23
InputConfig inputConfigPitchTrim
Definition config.h:45
bool active
Definition DialogBase.h:73
static DialogBase * dialogs[D_ENUMERATION]
Definition DialogBase.h:41
void PopUpDialog()
void RestorePage(std::string screenName)
Definition Displays.cpp:882
void ChangePage(std::string screenName, std::string pageName)
Definition Displays.cpp:750
float FrameElapsedTime
Definition GameClass.h:116
GameState displaystage
Definition GameClass.h:118
std::unique_ptr< Bus > bus
Definition GameClass.h:108
Config config
Definition GameClass.h:100
void LostScannerTarget(const char *msg) const
std::unique_ptr< HMI > GUI
Definition GameClass.h:106
float dpiscale
Definition GameClass.h:130
void UseOrDisuseInventoryItemType(int itemtype, int itemsubtype, int itemId, int vehicleId) const
std::unique_ptr< Sound > sound
Definition GameClass.h:104
std::unique_ptr< Networking > networking
Definition GameClass.h:103
bool vphelp[vphelpC]
Definition GameClass.h:101
void UpdateTrackedResource(const char *name, int status)
std::unique_ptr< Displays > displays
Definition GameClass.h:110
static float GetCpuSpeedMhz()
void RepairVehicle() const
std::unique_ptr< Viewscreen > viewscreen
Definition GameClass.h:107
void ChangeGear(char newGear, bool isInit=false) const
float displayWidth
Definition GameClass.h:131
std::unique_ptr< Logger > logger
Definition GameClass.h:109
float displayHeight
Definition GameClass.h:131
void ToggleFullScreen(bool goFullScreen)
bool isInjected
Definition gui.h:1108
bool immigrationPassed
Definition gui.h:1107
bool GetImmigrationEmail(char(&email)[32])
Definition gui.cpp:4788
void ChangePlayerProperties(SSubscribeData *prop)
Definition gui.cpp:4331
RejoinCountdown rejoinCountdown
Definition gui.h:1103
SPlayerData player[MAX_ONLINEPLAYERS]
Definition gui.h:1093
short txbuffer
Definition gui.h:1100
void AddDiscordChatMessage(const WCHAR *msg)
Definition gui.cpp:4099
void ChannelInvite(char *title, unsigned char whoinvited, unsigned char channel, unsigned char players) const
Definition gui.cpp:4319
bool isSteam
Definition gui.h:1114
void AddSubtitles(std::wstring const &msg) const
Definition gui.cpp:1836
RiseDialog g_HUD
Definition gui.h:1031
void LoadPeopleSounds() const
Definition gui.cpp:1215
std::wstring strings[L_ENUMERATION]
Definition gui.h:1076
InformationDialog * informationDialog
Definition gui.h:1120
void PlayerJoinedChannel(short tab, unsigned char playerindex)
Definition gui.cpp:4028
char referralValid
Definition gui.h:1101
char GetAlignment(int ownerId) const
Definition gui.h:1155
void ReceiveEmailValidation(float token, bool passed, float reason)
Definition gui.cpp:4821
void SexChangeOperation(char newsex, bool randomizeHeightWeight)
Definition gui.cpp:111
unsigned char ourplayerC
Definition gui.h:1094
void SetPlayerAlignment(char *msg, unsigned char playerindex)
Definition gui.cpp:4257
void AddSupportChatMessage(const WCHAR *wmsg)
Definition gui.cpp:4078
char handleValid
Definition gui.h:1101
ImmigrationEmail::State emailValidation
Definition gui.h:1102
void AddPlayer(char *msg, unsigned char playerindex)
Definition gui.cpp:4204
void ChangeChannelOwner(short tab, unsigned char playerindex)
Definition gui.cpp:4066
void PlayerLeftChannel(short tab, unsigned char playerindex)
Definition gui.cpp:4047
void ChangeChannelName(unsigned char channelId, char *title)
Definition gui.cpp:4299
Rendering::ImageBuffer * pBuffer
Definition gui.h:1089
Rendering::RenderFont * g_pFont
Definition gui.h:1052
void PlayerOffline(unsigned char arrayindex)
Definition gui.cpp:3988
std::vector< std::wstring > subtitles
Definition gui.h:1124
short rxbuffer
Definition gui.h:1100
std::vector< std::wstring > motd
Definition gui.h:1073
void AddChatMessage(WCHAR *msg, unsigned char playerindex, unsigned char channel)
Definition gui.cpp:4129
char charnameValid
Definition gui.h:1101
WCHAR loginstr[99]
Definition gui.h:1074
void ResetLoginFields()
Definition gui.cpp:4021
CHATCHANNEL chatchannel[MAX_TAB]
Definition gui.h:1096
void AddSubtitle(const WCHAR *msg) const
Definition gui.cpp:1864
bool IsAdmin
Definition gui.h:1108
Rendering::RenderSprite * g_pTextSprite
Definition gui.h:1051
void AddToast(const WCHAR *message, ActiveHelp activeHelp)
Definition gui.cpp:1303
void SetHelpText(WCHAR *str, int id)
bool PopUpHelp(short helpId, bool allowDismiss=true, bool isLearnMore=false)
void SetMenu(const SPacketMenu &datapacket)
void Log(const char *msg, Level level=Info, int errorCode=0)
Definition Logger.cpp:283
void AddToCallStack(const char *msg)
Definition Logger.cpp:355
void SendPendingCrashReports()
Definition Logger.cpp:221
void ConfirmTraceDelivery(std::uint32_t receipt)
Definition Logger.cpp:265
Level
Definition Logger.h:23
@ Debug
Definition Logger.h:27
@ Info
Definition Logger.h:25
@ Warn
Definition Logger.h:26
@ Fatal
Definition Logger.h:29
@ Error
Definition Logger.h:28
void SendTelemetry(SClientPacketNew *pData) const
void FrameMove(GameState displaystage)
GameClass * game
Definition Networking.h:75
Networking(GameClass *g)
bool patchRequiresRestart
Definition Networking.h:84
RakNet::RakNetStatistics * GetStatistics() const
void SendToServer(void *pData, DWORD dwSize, bool bGuaranteed, PacketOrdering order=ORDERING_NONE) const
std::uint32_t SendTraceFile(const char *fileContents, bool requestReceipt=false) const
int GetPingTime() const
char oldreference[MAX_SCAN]
Definition Networking.h:82
void RequestVerbiage(int helpId) const
unsigned long rcvdbytes
Definition Networking.h:113
char connectstatus
Definition Networking.h:111
RakNet::RakPeerInterface * rakPeer
Definition Networking.h:77
unsigned long patchbytes
Definition Networking.h:112
RakNet::ConnectionAttemptResult Connect() const
uint64_t cloudWeatherLoggedRevision
Definition Networking.h:85
RakNet::Packet * p
Definition Networking.h:79
void SendEvent(EventType eventType, float extent=0.0f) const
CloudWeather::Receiver cloudWeather
Definition Networking.h:90
bool Flush() const
void Trace(const char *msg, Logger::Level severity=Logger::Level::Info) const
bool SendErrorReport(SErrorPacket *pData) const
void SendChatMessage(unsigned char channel, unsigned char player, const WCHAR *message) const
short retryconnect
Definition Networking.h:114
RakNet::SystemAddress serverC
Definition Networking.h:78
void EvaluateRevenuePax() const
void RakNetMessageHandler(RakNet::Packet *packet)
int oldPlayerFrame
Definition Networking.h:81
unsigned char battleRoyaleSequence
Definition Networking.h:83
bool is_set() const
Definition Nullable.h:87
T get() const
Definition Nullable.h:80
INT DrawTextW(RenderSprite *sprite, const wchar_t *text, INT count, RECT *rectangle, DWORD flags, PackedColor color)
virtual void SetEnabled(bool bEnabled)
Definition Controls.h:575
RiseEditBox * GetEditBox(int ID)
Definition Controls.h:196
RiseRadioButton * GetRadioButton(int ID)
Definition Controls.h:184
RiseButton * GetButton(int ID)
Definition Controls.h:176
LPCWSTR GetText()
Definition Controls.h:1269
void SetText(LPCWSTR wszText, bool bSelected=false)
void SetChecked(bool bChecked, bool bClearGroup=true)
Definition Controls.h:800
void SetSexDexterity(char sex)
Definition Camera.h:68
void AddDelayedSound(SOUNDS soundEnum, float delay, float volume=1.0f, float freq=1.0f, bool fromOutside=false)
Definition Sound.cpp:3376
char stationUrls[6][64]
Definition Sound.h:703
void ChangeVolume(SoundConfig *config, float modVolume)
Definition Sound.cpp:551
void Stop(SOUNDS soundEnum) const
Definition Sound.cpp:3397
void PlayCabinAnnouncement(SOUNDS sound_enum)
Definition Sound.cpp:3456
void RemoveLoopingVehicleSound(unsigned char array, SOUNDS soundEnum=SOUND_NONE)
Definition Sound.cpp:3428
float Play(SOUNDS soundEnum, float volume=1.0f)
Definition Sound.cpp:802
void PlayEx(SOUNDS soundEnum, bool loop, float volume=1.0f, float frequencyMod=1.0f, float pan=0.0f, bool restart=true, bool fromOutside=false, bool partOfHull=false)
Definition Sound.cpp:1006
void LegacySoundRequestUniverse(SServerPacket datapacket)
Definition Sound.cpp:2242
bool loopintro
Definition Sound.h:700
void PlayAudioData(unsigned char *data, size_t length)
Definition Sound.cpp:430
ChannelMetrics VehicleMetrics(std::size_t slot, double nowSeconds) const
void ResetVehicle(std::size_t slot, int identity, int reference, int parentSlot, bool identityChanged)
void RemoveVehicle(std::size_t slot)
Acceptance PushVehicle(std::size_t slot, MotionSnapshot snapshot, double receiptSeconds)
short oldRoomIndex
Definition Viewscreen.h:380
Rendering::RenderTexture * m_pddsHullDynamicTexture[MAX_SCAN]
Definition Viewscreen.h:320
std::unique_ptr< waypoints > ptrWaypoints
Definition Viewscreen.h:437
GameClass * gameclass
Definition Viewscreen.h:439
ReentryEnvelope::State reentryState
Definition Viewscreen.h:399
std::unique_ptr< propulsion > ptrPropulsion
Definition Viewscreen.h:432
RiseMath::Vector3 reentryWindward
Definition Viewscreen.h:400
std::unique_ptr< weather > ptrWeather
Definition Viewscreen.h:434
std::unique_ptr< grid > ptrGrid
Definition Viewscreen.h:426
void SetProjectionMatrices()
void LoadVehicleProfile(short t)
CityCampaignLogos cityCampaignLogos
Definition Viewscreen.h:309
static RiseMath::Vector3 CalculateBarycentric(RiseMath::Vector3 *position, RiseMath::Vector3 *gthrust, float *radius)
std::vector< Rendering::RenderTexture * > m_pddsLogos
Definition Viewscreen.h:307
LOCALGRID2 CalculateSRV(short t, short s, VECTOR2SHORT tcp, char cube, SRenderVertex sourcedata)
std::unique_ptr< cockpit > ptrCockpit
Definition Viewscreen.h:435
bool hornBindingDown
Definition Viewscreen.h:413
std::unique_ptr< joystick > ptrJoystick
Definition Viewscreen.h:430
float radioBlackout
Definition Viewscreen.h:104
SCamera * cockpitCamera
Definition Viewscreen.h:138
std::unique_ptr< weapon > ptrWeapon
Definition Viewscreen.h:427
void CheckLogo(unsigned char array, char *logofile)
void ClearCollisionEffects()
void ResetHeadAccelerationEffects(const char *reason, bool waitForTerrain=false)
std::vector< RECT > rooms
Definition Viewscreen.h:106
static bool CheckLayout(unsigned i, LOCALGRID2 localgrid2)
void Load(unsigned char newType) const
Definition cockpit.cpp:216
void RefreshExternalCameras() const
Definition cockpit.cpp:65
bool geometryReady
Definition grid.h:37
void ElevationChanged() const
Definition grid.h:55
bool wholeGridPending
Definition grid.h:40
void ReceiveWholeGrid(const SRenderGrid &datapacket)
Definition grid.cpp:219
char cube
Definition grid.h:45
bool dataReady
Definition grid.h:36
void CalculateInsideArray(short t, short s) const
Definition grid.cpp:1230
void RemoveBuildZone(short ordinal) const
Definition grid.cpp:13
bool makeBuildings
Definition grid.h:42
VECTOR2SHORT tcp
Definition grid.h:44
char dataPending
Definition grid.h:39
std::vector< DIDEVICEINSTANCE > deviceList
Definition joystick.h:29
float airIceAccumulationMm
Definition propulsion.h:85
float holdOverTime
Definition propulsion.h:96
bool initFromDeflect
Definition propulsion.h:80
float groundIceAccumulationMm
Definition propulsion.h:86
float airframeTempCelsius
Definition propulsion.h:84
void InsertUpdateParent(USHORT vehicleId, USHORT parentId)
Definition scanDb.cpp:88
void InsertUpdateModeAC(USHORT vehicleId, SmodeAC modeAC)
Definition scanDb.cpp:26
void InsertUpdateModeX(USHORT vehicleId, SmodeX modeX)
Definition scanDb.cpp:73
Sscan Get(USHORT vehicleId) const
Definition scanDb.cpp:111
void SetCurrentFromServer(int id)
Definition waypoints.cpp:76
void AddOrUpdate(Swaypoint tempwaypoint)
void ResetSession()
Definition waypoints.cpp:12
void FrameMove(float elapsedSeconds)
Definition waypoints.cpp:39
void ProcessPacket(SWeaponPacket datapacket)
Definition weapon.cpp:1046
void ReceiveGridLightning(short u, short v, int seed, int chainedBolts)
Definition weather.cpp:1214
void SetTemperatureCelsius(float prmTemperature)
Definition weather.cpp:869
void SetWindDirectionRadians(float prmWinddir)
Definition weather.cpp:856
void SetWindspeedKms(float prmWindspeed)
Definition weather.cpp:881
void ReceivePlotWeather(const unsigned char *bytes, size_t length)
Definition weather.cpp:1069
void ResetPlotWeatherConnection()
Definition weather.cpp:1008
float gammascreenOverride
Definition weather.h:225
float fuel
Definition globals.cpp:90
Sinteractive interactive
Definition globals.cpp:120
float deathfuel
Definition globals.cpp:91
DeathType dead
Definition globals.cpp:37
char prompt[80]
Definition globals.cpp:62
float g_UniverseTime
Definition globals.cpp:18
FIREWORKS fireworks[fireworksC]
Definition globals.cpp:118
s_network_objects playerships[MAX_SCAN]
Definition globals.cpp:112
float cash
Definition globals.cpp:93
bool g_bEnabled
Definition globals.cpp:96
float deathinhibit
Definition globals.cpp:39
s_universe_object allobjects[maxstarC]
Definition globals.cpp:108
Scockpit ourcockpit
Definition globals.cpp:114
bool g_bGotConclusion
Definition globals.cpp:97
float dockprogress
Definition globals.cpp:32
bool g_bAboveClouds
Definition globals.cpp:16
LOCALGRID2 gridarray[64][64]
Definition globals.cpp:100
float payload
Definition globals.cpp:92
char g_bTextInput
Definition globals.cpp:61
char outgoing[80]
Definition globals.cpp:60
float f_Uphours
Definition globals.cpp:19
bool g_bAugment
Definition globals.cpp:47
#define MaxAcceleration
Definition globals.h:45
#define radiusC
Definition globals.h:87
@ ImNotDeadYet
Definition globals.h:150
@ LifeSupportFailure
Definition globals.h:161
#define INTERIOR_SCALE
Definition globals.h:37
#define fireworksC
Definition globals.h:769
@ L_LOGIN_ALREADYONLINE
Definition gui.h:259
@ L_MESSAGE_RESERVED
Definition gui.h:177
@ L_MESSAGE_VULGARITY
Definition gui.h:178
@ L_MESSAGE_NOTFOUND
Definition gui.h:184
@ L_MESSAGE_CALLSIGN
Definition gui.h:176
@ L_LOGIN_CALLSIGNINCORRECT
Definition gui.h:257
@ L_MESSAGE_DUPLICATE
Definition gui.h:179
@ L_DOCK_TACEVAC
Definition gui.h:446
@ L_MESSAGE_TOOSHORT
Definition gui.h:188
@ L_SPLASH_VALIDATINGINSTALL
Definition gui.h:245
@ L_MESSAGE_NUMBERS
Definition gui.h:182
@ L_MESSAGE_CHARNAME
Definition gui.h:185
@ L_LOGIN_VERSIONTOOOLD
Definition gui.h:260
@ L_MESSAGE_SPACES
Definition gui.h:180
@ L_LOGIN_TOOMANYATTEMPTS
Definition gui.h:258
@ L_LOGIN_VERSIONTOOOLDSTEAM
Definition gui.h:261
@ L_MESSAGE_SYMBOLS
Definition gui.h:181
@ L_LOGIN_PASSWORDINCORRECT
Definition gui.h:256
@ L_DOCK_TAC0
Definition gui.h:434
@ L_MESSAGE_REFERRAL
Definition gui.h:183
#define subtitleCharLimitC
Definition gui.h:26
@ IDC_SIGNATUREHINT
Definition gui.h:744
@ IDC_HEIGHT
Definition gui.h:704
@ IDC_MALE
Definition gui.h:686
@ IDC_FEMALE
Definition gui.h:688
@ IDC_CHARNAME
Definition gui.h:690
@ IDC_HANDLE
Definition gui.h:696
@ IDC_SUGGEST
Definition gui.h:691
constexpr unsigned char AssignmentType
float Quality(float altitudeKm)
HRESULT LoadTextureMemory(RenderDevice *owner, const void *data, UINT bytes, RenderTexture **result, UINT levels=0)
HWND ClientWindow()
HRESULT TraceFailure(const wchar_t *operation, HRESULT code)
Window11 * ClientHost()
RenderDevice * ClientRenderer()
constexpr PackedColor ColorARGB(unsigned a, unsigned r, unsigned g, unsigned b)
const wchar_t * ClientDeviceStats()
auto ToRadian(T value)
Definition ClientMath.h:13
float Vec3Length(const Vector3 *a)
Definition ClientMath.h:95
constexpr auto Min(A first, B second)
Definition ClientMath.h:15
Vector3 * Vec3Add(Vector3 *out, const Vector3 *a, const Vector3 *b)
Definition ClientMath.h:96
float Vec3LengthSq(const Vector3 *a)
Definition ClientMath.h:94
Vector3 * Vec3Normalize(Vector3 *out, const Vector3 *a)
Definition ClientMath.h:103
Vector3 * Vec3Scale(Vector3 *out, const Vector3 *a, float scale)
Definition ClientMath.h:98
constexpr auto Max(A first, B second)
Definition ClientMath.h:16
Matrix * MatrixTranslation(Matrix *out, float x, float y, float z)
Definition ClientMath.h:125
constexpr float HalfPi
Definition ClientMath.h:12
double MonotonicSeconds()
bool HasExactPayloadLength(std::size_t actualBytes, std::size_t expectedBytes)
UploadDiagnostics gUploadDiagnostics
SnapshotSystem gSnapshotSystem
bool ShouldBufferVehicleReference(int reference)
bool NormalizeQuaternion(Quaternion &value)
bool IsFinite(const Vec3 &value)
int ivalues[2]
Definition Command.h:21
std::string name
Definition Command.h:11
bool inuse
Definition globals.h:772
RiseMath::Color color
Definition globals.h:775
short texture
Definition globals.h:773
char type
Definition globals.h:774
RiseMath::Vector3 position
Definition globals.h:776
unsigned char axis
Definition InputConfig.h:14
unsigned char type
Definition globals.h:576
unsigned char subtype
Definition globals.h:576
PlotType type
Definition globals.h:276
long layout3
Definition globals.h:287
long layout4
Definition globals.h:287
long layout2
Definition globals.h:287
unsigned char zone
Definition globals.h:285
short buildzoneOrdinal
Definition globals.h:286
long layout1
Definition globals.h:287
bool powered
Definition globals.h:292
unsigned char type
unsigned char channelInvLookLateral
char channelAxisLookVertical
unsigned char channelInvThrustLeft
unsigned char channelInvGas
unsigned char channelInvYaw
char channelAxisRightToeBrake
unsigned char channelInvLookVertical
unsigned char channelInvThrustRight
WCHAR name[160]
char channelAxisLookLateral
char channelAxisLeftToeBrake
unsigned char channelInvLeftToeBrake
unsigned char channelInvBrake
char channelAxisThrustRight
unsigned char deviceType
unsigned char channelSplitLeftToeBrake
unsigned char channelInvPitch
unsigned char channelSplitGas
unsigned char channelInvRightToeBrake
unsigned char channelSplitYaw
unsigned char channelInvSteer
unsigned char channelInvTurn
unsigned char channelInvPitchTrim
unsigned char forceFeedback
unsigned char channelSplitThrustRight
unsigned char deviceSubtype
unsigned char channelSplitThrustLeft
char channelAxisPitchTrim
unsigned char channelInvRoll
char channelAxisThrustLeft
unsigned char channelSplitRightToeBrake
unsigned char channelInvWalk
unsigned char channelSplitBrake
unsigned char array
unsigned char ship
unsigned char inarray
unsigned char type
unsigned char type
short menuLevel
char email[32]
unsigned char heightCm
unsigned char bldg
char characterName[30]
unsigned char weightKg
unsigned char age
unsigned char voice
char callsign[13]
unsigned char type
VECTOR2SHORT tcp
unsigned char zone
VECTOR2SHORT tcp
SRenderVertex gridarray
SRenderVertex gridarray[64]
VECTOR2SHORT tcp
unsigned char side
unsigned char array
unsigned char type
RiseMath::Vector3 position
unsigned short sourceRevision
unsigned short sequence
unsigned char onlyOne
RiseMath::Quaternion orientation
unsigned char tenthsMs
RiseMath::Vector3 velocity
unsigned char array
unsigned short sampleTimeMs
unsigned char playerBldg
unsigned char groundIceAccumulationMm
bool remoteAssayPower
float orientationx
unsigned char inarray
unsigned char selectedPage
float rollDeflect
float orientationy
char parentReference
short hullTempCelsius
float orientationw
unsigned char bay
float steerDeflect
float orientationz
unsigned char mapZoom
float pitchDeflect
unsigned char vehicleType
unsigned char airIceAccumulationMm
short cabinPressureMb
unsigned char radioChannel
char oldShipData[78]
bool weatherRadarPower
WCHAR text[510]
char weapontype[MAX_WEAPPERSHIP]
char overhead
char avionictype[MAX_AVIOPERSHIP]
unsigned char array
bool polaroid1
Definition globals.h:669
bool remoteAssayPower
Definition globals.h:597
int inventoryItemInUseSubType
Definition globals.h:700
short texturelib
Definition globals.h:602
unsigned char stowageLoadType
Definition globals.h:695
char owner[13]
Definition globals.h:691
int inventoryItemInUseVehicleId
Definition globals.h:701
short ourplyrC
Definition globals.h:682
std::vector< InventoryHelper > vehicleInventory
Definition globals.h:698
int allegiance
Definition globals.h:692
bool remoteAssayEquipped
Definition globals.h:669
float dexterity
Definition globals.h:687
unsigned char stowageDestination
Definition globals.h:695
char character[30]
Definition globals.h:689
float power
Definition globals.h:599
float flapExtent
Definition globals.h:660
std::vector< FlapSetting > flapSettings
Definition globals.h:661
int landingDamageVehicleId
Definition globals.h:606
std::array< LandingLights::ImpactCondition, LandingLights::MaxLights > landingLightImpact
Definition globals.h:608
std::vector< InventoryHelper > personalInventory
Definition globals.h:697
SVesselDC vdat
Definition globals.h:664
char handle[13]
Definition globals.h:690
unsigned char playerWeightKg
Definition globals.h:688
std::array< LandingLights::Condition, LandingLights::MaxLights > landingLightCondition
Definition globals.h:607
std::array< float, LandingLights::MaxLights > landingLightBrightness
Definition globals.h:609
bool radioPower
Definition globals.h:597
bool weatherRadarEquipped
Definition globals.h:669
char gearshift
Definition globals.h:677
float tach
Definition globals.h:676
float flapMaxDegrees
Definition globals.h:714
float scanrange
Definition globals.h:670
float adrenolinBPM
Definition globals.h:741
bool parkingBrake
Definition globals.h:709
char startcycle
Definition globals.h:599
unsigned char hitpoints
Definition globals.h:686
bool wheeled
Definition globals.h:596
unsigned char stowageQuantity
Definition globals.h:695
char bays
Definition globals.h:630
float usage
Definition globals.h:670
bool radioEquipped
Definition globals.h:669
float bmi
Definition globals.h:739
RiseMath::Vector3 chaireye
Definition globals.h:615
int inventoryItemInUseType
Definition globals.h:699
int ownerId
Definition globals.h:693
float maxBPM
Definition globals.h:740
unsigned landingLightMismatchReported
Definition globals.h:610
bool weatherRadarPower
Definition globals.h:597
short type7built
Definition globals.h:796
short type5built
Definition globals.h:796
short type4built
Definition globals.h:796
short type6built
Definition globals.h:796
short type3built
Definition globals.h:796
VECTOR2SHORT tcp
Definition globals.h:786
short type9built
Definition globals.h:796
unsigned char menutype
Definition globals.h:784
short type1built
Definition globals.h:796
short type8built
Definition globals.h:796
float mincoltorun
Definition globals.h:795
short type2built
Definition globals.h:796
float colonistsforbuilding
Definition globals.h:795
long layout1
long layout3
long layout2
long layout4
bool tow
Definition scanDb.h:24
RiseMath::Vector3 location
Definition scanDb.h:20
char reference
Definition scanDb.h:19
unsigned char type
Definition scanDb.h:17
char hullname[23]
Definition scanDb.h:18
bool stolen
Definition scanDb.h:26
bool reposess
Definition scanDb.h:25
int allegiance
Definition scanDb.h:23
int ownerId
Definition scanDb.h:22
char IVR[6]
Definition scanDb.h:16
char owner[13]
Definition scanDb.h:21
unsigned short vehicleId
Definition scanDb.h:15
char load_dest[20]
Definition scanDb.h:33
Nullable< int > pilot
Definition scanDb.h:36
Nullable< float > fuel_tank
Definition scanDb.h:35
Nullable< unsigned short > load_quantity
Definition scanDb.h:32
Nullable< float > weightLbs
Definition scanDb.h:34
Nullable< unsigned char > load_type
Definition scanDb.h:31
RiseMath::Vector2 position
float timeS
float distanceM
int edgeId
char streetName[32]
float speedLimitKph
Definition scanDb.h:47
bool initialized
Definition scanDb.h:48
Sscandata scandata
Definition scanDb.h:49
SmodeAC modeAC
Definition scanDb.h:41
SmodeX modeX
Definition scanDb.h:43
RiseMath::Vector3 barycentric
Definition globals.h:500
RiseMath::Quaternion orientation
Definition globals.h:521
RiseMath::Vector3 acciter
Definition globals.h:504
RiseMath::Vector3 dockingvel
Definition globals.h:500
RiseMath::Vector3 position
Definition globals.h:511
RiseMath::Vector3 positer
Definition globals.h:501
RiseMath::Vector3 accleft
Definition globals.h:504
unsigned short components
Definition globals.h:551
double precisionz
Definition globals.h:512
RiseMath::Vector3 acc
Definition globals.h:504
bool inhibitvisibility
Definition globals.h:528
unsigned char bay
Definition globals.h:510
unsigned char type
Definition globals.h:488
RiseMath::Quaternion orientleft
Definition globals.h:521
bool rainProtectionEnabled
Definition globals.h:532
RiseMath::Vector3 dockoffset
Definition globals.h:511
RiseMath::Vector3 velleft
Definition globals.h:501
unsigned short vehicleId
Definition globals.h:537
s_mesh_component * componentarray
Definition globals.h:552
double precisiony
Definition globals.h:512
RiseMath::Quaternion orientiter
Definition globals.h:521
RiseMath::Vector3 posleft
Definition globals.h:501
RiseMath::Vector3 velocity
Definition globals.h:500
float rollRadPerSec
Definition globals.h:523
WindshieldWipers::Motion wipers
Definition globals.h:535
unsigned short sequence
Definition globals.h:561
double precisionx
Definition globals.h:512
unsigned char inarray
Definition globals.h:509
RiseMath::Vector3 veliter
Definition globals.h:501
char hullname[23]
Definition globals.h:495
RiseMath::Matrix matrixWorld
Definition globals.h:517
RiseMath::Vector3 velocity
Definition globals.h:461
RiseMath::Vector3 position
Definition globals.h:454