1
2
3#include "../Modules/OrbitState.h"
4#include "../Rendering/ClientMath.h"
5#include "../Modules/OrbitEntryAudio.h"
6#include <cstdlib>
7#include <climits>
8#include <iostream>
9#include <vector>
10
13 struct Afcs {
27};
28struct {
bool groundvehicle=
false, isSimulator=
false;
int reference=-1, vehicleId=1; }
playerships[1];
29struct {
float power=1;
bool spaceCapable=
true; }
ourcockpit;
31struct Sound { std::vector<int> played;
void Play(
int id) { played.push_back(
id); } } sound;
36 bool TurnOffDOR(
bool preserveGuidance=
false)
const;
39};
40#include "DorDisconnectProduction.generated.h"
41
42int checks=0;
43void Check(bool ok, const char* message) {
44 ++checks;
45 if(!ok) { std::cerr<<"FAIL: "<<message<<'\n'; std::exit(1); }
46}
49
50
51 for(float power:{1.f,.5f,0.f}) for(bool simulator:{false,true})
61 sound.played.clear();
62 Check(game.
TurnOffDOR(
true),
"active DOR disconnects");
67 Check(sound.played==std::vector<int>{SOUND_APCAVALRY},"one existing disconnect sound");
68 for(
int i=0;i<100;++i) Check(!game.
TurnOffDOR(),
"repeated off is silent");
69 Check(sound.played.size()==1&&bus.
orbit.
guidance.
status==reason,
"no repeat or lost reason");
71 Check(game.
TurnOffDOR(),
"manual takeover re-arms sound");
73 }
75 for(const auto* reason:{L"DOR: DEPARTURE COAST UNSAFE",L"DOR: NO CLEAR CORRECTION",
76 L"DOR: FINAL ORBIT UNSAFE",L"DOR: CORRECTION MARGIN LOST",L"DOR: COAST CLEARANCE LOST"}) {
77 bus.
AFCS.
DorOn=
true; sound.played.clear();
81 Check(game.
TurnOffDOR(
true),
"clearance abort disconnects");
83 for(
auto thrust:bus.
EngineThrustLever) Check(thrust==0,
"clearance abort stops engine commands");
84 Check(sound.played==std::vector<int>{SOUND_APCAVALRY},"clearance abort sounds once");
85 Check(!game.
TurnOffDOR(
true)&&sound.played.size()==1,
"clearance abort cannot replay sound");
86 }
88 TvmCycle(&game,true);
89 Check(bus.
AFCS.
DorOn&&sound.played.empty(),
"key repeat does not disengage");
90 TvmCycle(&game,false);
92 Check(sound.played==std::vector<int>{SOUND_APCAVALRY},"TVM hand-off plays once");
93
95 Check(sound.played.size()==1,"no stale sound on power restoration");
98 Check(game.
TurnOffDOR(),
"entry speed hold can be cancelled after DOR handoff");
101 Check(sound.played==std::vector<int>{SOUND_APCAVALRY},"speed-hold cancel sounds once");
102 Check(!game.
TurnOffDOR()&&sound.played.size()==1,
"repeated speed-hold cancel is silent");
103 for(auto throttle:{EntryThrottleLeft,EntryThrottleRight}) {
106 for(int value=101;value<=140;++value) throttle(&game,value);
108 throttle(&game,141);
109 Check(!bus.
AFCS.
AutothrottleEngaged&&sound.played.size()==sounds+1,
"slow cumulative throttle movement cancels once");
110 throttle(&game,142);Check(sound.played.size()==sounds+1,"subsequent manual movement is silent");
111 }
116 for(
bool simulator:{
false,
true})
for(
float power:{0.f,1.f})
for(
int reference:{
REF_ONGROUND,-1,9})
121 const auto sounds=sound.played.size();
122 DorCycle(&game,false);
124 Check(bus.
orbit.
guidance.
status==L
"DOR: PLAN ONLY / ATM HANDOFF",
"surface preview explains refusal");
125 Check(sound.played.size()==sounds+1&&sound.played.back()==
SOUND_APCAVALRY,
"refused PLAN ONLY engagement sounds once");
127 "refusal never enables DOR or disrupts existing controls");
128 for(int repeat=0;repeat<10;++repeat) DorCycle(&game,true);
129 Check(sound.played.size()==sounds+1&&!bus.
AFCS.
DorOn,
"held key cannot repeat the refusal sound or engage DOR");
130 }
135 DorCycle(&game,false);
136 Check(bus.
AFCS.
DorOn&&!bus.
AFCS.
TvmOn,
"DOR key permits a ground RENDEZVOUS ascent leg");
138 DorCycle(&game,
false);Check(!bus.
AFCS.
DorOn,
"second key press cancels ground mission");
139 std::cout<<"PASS: "<<checks<<" DOR disconnect checks\n";
140}
float EngineThrustLever[MAX_ENGINES]
void AddCommand(const Command &command, bool onlyOne)
bool ThrustReverserCommand[MAX_ENGINES]
std::unique_ptr< Bus > bus
std::unique_ptr< Sound > sound
bool TurnOffDOR(bool preserveGuidance=false) const
std::unique_ptr< Logger > logger
void AutopilotDisconnect() const
void AddToCallStack(const char *msg)
float Play(SOUNDS soundEnum, float volume=1.0f)
s_network_objects playerships[MAX_SCAN]
float DesiredHeadingRadians
VerticalModes
so I guess we allow them to fly until they get to x degrees off
enum Bus::Afcs::LateralModes CurrentLateralMode
float DesiredClosingSpeed
enum Bus::Afcs::VerticalModes CurrentVerticalMode