Project Blue Streak F3(DLL)

EDIT: Urwumpe, you can force a programmer to accept your return value but not force them to do something appropriate with it :P Horses to water, and all that...

You have never gotten an uncaught ReturnValueIgnoredException yet, did you? ;)
 
Thats very esoretic chaps, (I mean over my head), but... either way, thanks for your help, and I'll keep plodding on.

N.

---------- Post added at 15:24 ---------- Previous post was Yesterday at 20:17 ----------

Trying to use this code from the OrbiterWiki/Surveyor tutorial to get the L key to launch the rocket:-

Code:
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BlueStreak::clbkConsumeBufferedKey (DWORD key, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]bool[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] down,[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]char[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] *kstate) {[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (!down) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 0; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//only process keydown events[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (KEYMOD_SHIFT (kstate)) {[/SIZE]
 
[SIZE=2]} [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]else[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] { [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// unmodified keys[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]switch[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (key) {[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]case[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] OAPI_KEY_L: [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Fire mains[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]SetThrusterLevel(th_main, 1);[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 1;[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 0;[/SIZE]
[SIZE=2]} [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//closing brace of BlueStreak class[/COLOR][/SIZE]
[/COLOR][/SIZE]

Getting this error message first:-
Code:
[SIZE=1]1>c:\users\public\orbitersdk\samples\shuttlepb\bluestreak.cpp(236) : error C2601: 'BlueStreak::clbkConsumeBufferedKey' : local function definitions are illegal[/SIZE]

also getting this error message second:-
Code:
[SIZE=1]1> c:\users\public\orbitersdk\samples\shuttlepb\bluestreak.cpp(76): this line contains a '{' which has not yet been matched[/SIZE]

I've rechecked the braces for matching, and I'm sure they all pair up.

Something subtle I'll bet?

All help appreciated.
N.
 
Not really subtle I think... Can you post your whole source code? It fear, you defined the clbkConsumeBufferedKey inside the scope of another function.

Local function definitions are functions inside functions (like local variables are variables only visible inside a function).
 
Can do, subtle for me I'm afraid!:(

Code:
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]
// ==============================================================
// ORBITER MODULE: BlueStreak
// Part of the ORBITER SDK
// Copyright (C) 2002-2004 Martin Schweiger
// All rights reserved
//
// BlueStreak.cpp
// Control module for BlueStreak vessel class
//
// Notes:
// This is an example for a "minimal" vessel implementation which
// only overloads the clbkSetClassCaps method to define vessel
// capabilities and otherwise uses the default VESSEL class
// behaviour.
// ==============================================================
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]#define[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] STRICT
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]#define[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ORBITER_MODULE

[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]#include[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"orbitersdk.h"
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// ==============================================================
// Some vessel parameters
// ==============================================================
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] PB_FUELMASS = 89260; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//750.0;
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] PB_MAXMAINTH = 1334000; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//2*RZ_2 //3e4;
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] PB_ISP = 2433; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// = 248s * g //5e4;
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] VAC_MAIN_ISP = 2796; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// ISP(vac)
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] NML_MAIN_ISP = 2433; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// ISP(sl)
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] P_NML_MAIN_ISP = 101.4e3;
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] PB_MAXHOVERTH = 1.5e4;
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] PB_MAXRCSTH = 2e4; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//2e2;
// Calculate lift coefficient [Cl] as a function of aoa (angle of attack) over -Pi ... Pi
// Implemented here as a piecewise linear function
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] LiftCoeff ([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] aoa)
{
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] nlift = 9;
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]static[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] AOA[nlift] = {-180*RAD,-60*RAD,-30*RAD,-1*RAD,15*RAD,20*RAD,25*RAD,60*RAD,180*RAD};
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]static[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] CL[nlift] = { 0, 0, -0.1, 0, 0.2, 0.25, 0.2, 0, 0};
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]static[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SCL[nlift] = {(CL[1]-CL[0])/(AOA[1]-AOA[0]), (CL[2]-CL[1])/(AOA[2]-AOA[1]),
(CL[3]-CL[2])/(AOA[3]-AOA[2]), (CL[4]-CL[3])/(AOA[4]-AOA[3]),
(CL[5]-CL[4])/(AOA[5]-AOA[4]), (CL[6]-CL[5])/(AOA[6]-AOA[5]),
(CL[7]-CL[6])/(AOA[7]-AOA[6]), (CL[8]-CL[7])/(AOA[8]-AOA[7])};
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] i;
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]for[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (i = 0; i < nlift-1 && AOA[i+1] < aoa; i++);
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] CL[i] + (aoa-AOA[i])*SCL[i];
}
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// ==============================================================
// Shuttle-PB class interface
// ==============================================================
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]class[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BlueStreak: [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] VESSEL2 {
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]:
BlueStreak (OBJHANDLE hVessel, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] flightmodel)
: VESSEL2 (hVessel, flightmodel) {}
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] clbkSetClassCaps (FILEHANDLE cfg);
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] clbkPreStep([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SimT, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SimDT, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Mjd);

[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] clbkConsumeBufferedKey (DWORD key, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]bool[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] down, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]char[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] *kstate);

THRUSTER_HANDLE th_main, th_PackA, th_PackB, th_Pack[2] ;
};
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// ==============================================================
// Overloaded callback functions
// ==============================================================
// --------------------------------------------------------------
// Set the capabilities of the vessel class
// --------------------------------------------------------------
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BlueStreak::clbkSetClassCaps (FILEHANDLE cfg)
{

THRUSTER_HANDLE th_hover, th_rcs[14], th_group[4] ;
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// physical specs
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]SetSize (20);
SetEmptyMass (7168);[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Dry Mass(6168kg) + Payload(1000kg)// Propellant Mass(89260kg)
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]SetCW (0.3, 0.3, 0.6, 0.9);
SetWingAspect (0.7);
SetWingEffectiveness (2.5);
SetCrossSections (_V(10.5,15.0,5.8));
SetRotDrag (_V(0.6,0.6,0.35));
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (GetFlightModel() >= 1) {
SetPitchMomentScale (1e-4);
SetBankMomentScale (1e-4);
}
SetPMI (_V(86.26,86.52,1.33));[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// ShuttlePB values(_V(2.28,2.31,0.79));
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]SetTrimScale (0.05);
SetCameraOffset (_V(0,0.8,0));
SetLiftCoeffFunc (LiftCoeff);
SetDockParams (_V(0,1.3,-1), _V(0,1,0), _V(0,0,-1));

[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//SetTouchdownPoints (_V(0,-1.5,2), _V(-1,-1.5,-1.5), _V(1,-1.5,-1.5));
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]SetTouchdownPoints (_V(0,-1.524,0), _V(-1.32,-0.762,0), _V(1.32,-0.762,0)); 
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//Blue Streak radius = 1.524m. 1.32 and 0.762 are cos(),sin() of this radius for equally spaced touchdown points 
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// propellant resources
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]PROPELLANT_HANDLE hpr = CreatePropellantResource (PB_FUELMASS);

[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//Debug
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] clbkPreStep([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SimT, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SimDT, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Mjd);

[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//th_main = CreateThruster (_V(0,0,-4.35), _V(0,0,1), PB_MAXMAINTH, hpr, VAC_MAIN_ISP, NML_MAIN_ISP, P_NML_MAIN_ISP);// original th_main.
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]
th_Pack[0] = CreateThruster (_V(-0.762,0,0), _V(0,0,1), PB_MAXMAINTH/2, hpr, VAC_MAIN_ISP, NML_MAIN_ISP, P_NML_MAIN_ISP);
th_Pack[1] = CreateThruster (_V(0.762,0,0), _V(0,0,1), PB_MAXMAINTH/2, hpr, VAC_MAIN_ISP, NML_MAIN_ISP, P_NML_MAIN_ISP);

[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//th_PackGroup[0] = th_PackA;
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//th_PackGroup[1] = th_PackB;
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]
th_main = CreateThrusterGroup (th_Pack, 2, THGROUP_MAIN);

[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//CreateThrusterGroup (&th_PackB, 1, THGROUP_MAIN);
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]AddExhaust (th_Pack[0], 8, 1, _V(-0.762,0,-1), _V(0,0,-1));
AddExhaust (th_Pack[1], 8, 1, _V(0.762,0,-1), _V(0,0,-1));

[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//double ISP = GetThrusterIsp(th_main);
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FuelRate = GetFuelRate();
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// ***************** thruster definitions *******************
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]PARTICLESTREAMSPEC contrail_main = {
0, 5.0, 16, 200, 0.15, 1.0, 5, 3.0, PARTICLESTREAMSPEC::DIFFUSE,
PARTICLESTREAMSPEC::LVL_PSQRT, 0, 2,
PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
};
PARTICLESTREAMSPEC contrail_hover = {
0, 5.0, 8, 200, 0.15, 1.0, 5, 3.0, PARTICLESTREAMSPEC::DIFFUSE,
PARTICLESTREAMSPEC::LVL_PSQRT, 0, 2,
PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
};
PARTICLESTREAMSPEC exhaust_main = {
0, 2.0, 20, 200, 0.05, 0.1, 8, 1.0, PARTICLESTREAMSPEC::EMISSIVE,
PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
};
PARTICLESTREAMSPEC exhaust_hover = {
0, 2.0, 10, 200, 0.05, 0.05, 8, 1.0, PARTICLESTREAMSPEC::EMISSIVE,
PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
};

th_hover = CreateThruster (_V(0,-1.5,0), _V(0,1,0), PB_MAXHOVERTH, hpr, PB_ISP);
CreateThrusterGroup (&th_hover, 1, THGROUP_HOVER);

AddExhaust (th_hover, 8, 1, _V(0,-1.5,1), _V(0,-1,0));
AddExhaust (th_hover, 8, 1, _V(0,-1.5,-1), _V(0,-1,0));
AddExhaustStream (th_hover, _V(0,-3, 1), &contrail_hover);
AddExhaustStream (th_hover, _V(0,-3,-1), &contrail_hover);
AddExhaustStream (th_main, _V(0,0.3,-10), &contrail_main);
AddExhaustStream (th_hover, _V(0,-2, 1), &exhaust_hover);
AddExhaustStream (th_hover, _V(0,-2,-1), &exhaust_hover);
AddExhaustStream (th_main, _V(0,0.3,-5), &exhaust_main);
th_rcs[ 0] = CreateThruster (_V( 1,0, 3), _V(0, 1,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[ 1] = CreateThruster (_V( 1,0, 3), _V(0,-1,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[ 2] = CreateThruster (_V(-1,0, 3), _V(0, 1,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[ 3] = CreateThruster (_V(-1,0, 3), _V(0,-1,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[ 4] = CreateThruster (_V( 1,0,-3), _V(0, 1,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[ 5] = CreateThruster (_V( 1,0,-3), _V(0,-1,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[ 6] = CreateThruster (_V(-1,0,-3), _V(0, 1,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[ 7] = CreateThruster (_V(-1,0,-3), _V(0,-1,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[ 8] = CreateThruster (_V( 1,0, 3), _V(-1,0,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[ 9] = CreateThruster (_V(-1,0, 3), _V( 1,0,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[10] = CreateThruster (_V( 1,0,-3), _V(-1,0,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[11] = CreateThruster (_V(-1,0,-3), _V( 1,0,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[12] = CreateThruster (_V( 0,0,-3), _V(0,0, 1), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[13] = CreateThruster (_V( 0,0, 3), _V(0,0,-1), PB_MAXRCSTH, hpr, PB_ISP);
th_group[0] = th_rcs[0];
th_group[1] = th_rcs[2];
th_group[2] = th_rcs[5];
th_group[3] = th_rcs[7];
CreateThrusterGroup (th_group, 4, THGROUP_ATT_PITCHUP);
th_group[0] = th_rcs[1];
th_group[1] = th_rcs[3];
th_group[2] = th_rcs[4];
th_group[3] = th_rcs[6];
CreateThrusterGroup (th_group, 4, THGROUP_ATT_PITCHDOWN);
th_group[0] = th_rcs[0];
th_group[1] = th_rcs[4];
th_group[2] = th_rcs[3];
th_group[3] = th_rcs[7];
CreateThrusterGroup (th_group, 4, THGROUP_ATT_BANKLEFT);
th_group[0] = th_rcs[1];
th_group[1] = th_rcs[5];
th_group[2] = th_rcs[2];
th_group[3] = th_rcs[6];
CreateThrusterGroup (th_group, 4, THGROUP_ATT_BANKRIGHT);
th_group[0] = th_rcs[0];
th_group[1] = th_rcs[4];
th_group[2] = th_rcs[2];
th_group[3] = th_rcs[6];
CreateThrusterGroup (th_group, 4, THGROUP_ATT_UP);
th_group[0] = th_rcs[1];
th_group[1] = th_rcs[5];
th_group[2] = th_rcs[3];
th_group[3] = th_rcs[7];
CreateThrusterGroup (th_group, 4, THGROUP_ATT_DOWN);
th_group[0] = th_rcs[8];
th_group[1] = th_rcs[11];
CreateThrusterGroup (th_group, 2, THGROUP_ATT_YAWLEFT);
th_group[0] = th_rcs[9];
th_group[1] = th_rcs[10];
CreateThrusterGroup (th_group, 2, THGROUP_ATT_YAWRIGHT);
th_group[0] = th_rcs[8];
th_group[1] = th_rcs[10];
CreateThrusterGroup (th_group, 2, THGROUP_ATT_LEFT);
th_group[0] = th_rcs[9];
th_group[1] = th_rcs[11];
CreateThrusterGroup (th_group, 2, THGROUP_ATT_RIGHT);
CreateThrusterGroup (th_rcs+12, 1, THGROUP_ATT_FORWARD);
CreateThrusterGroup (th_rcs+13, 1, THGROUP_ATT_BACK);
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// visual specs
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]AddMesh ([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"BlueStreak"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);

[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BlueStreak::clbkConsumeBufferedKey (DWORD key, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]bool[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] down,[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]char[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] *kstate) {
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (!down) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 0; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//only process keydown events
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (KEYMOD_SHIFT (kstate)) {

} [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]else[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] { [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// unmodified keys
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]switch[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (key) {
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]case[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] OAPI_KEY_L: [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Fire mains
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]SetThrusterLevel(th_main, 1);
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 1;
}
}
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 0;
} [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//closing brace of BlueStreak class

// ==============================================================
// API callback interface
// ==============================================================
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BlueStreak::clbkPreStep([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SimT, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SimDT, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Mjd){

[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Mass = GetMass(); [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//Launch Mass = 96428kg 
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FuelMass = GetFuelMass();[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Launch Fuel Mass 89260kg
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//double ISP = GetThrusterIsp(th_main);
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FuelRate = GetFuelRate();
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Force = PB_MAXMAINTH; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// = 1334000 KN
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Acceleration=Force/Mass;[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Launch acceleration = 1334000/96428 = 13.83m/s/s
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]

sprintf(oapiDebugString(), [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"SimT %0.1f FuelRate %0.1f Mass %0.1f "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] , SimT, FuelRate, Mass);

}
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// --------------------------------------------------------------
// Vessel initialisation
// --------------------------------------------------------------
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]DLLCLBK VESSEL *ovcInit (OBJHANDLE hvessel, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] flightmodel)
{
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BlueStreak (hvessel, flightmodel);
}
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// --------------------------------------------------------------
// Vessel cleanup
// --------------------------------------------------------------
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]DLLCLBK [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ovcExit (VESSEL *vessel)
{
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (vessel) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]delete[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (BlueStreak*)vessel;
}
[/SIZE]
 
Yes, I was right. You have "int BlueStreak::clbkConsumeBufferedKey(...." already before the function clbkSetClassCaps is over (by the terminating }).

Do you use VisualStudio 2008 Express? I think the express version also has the very nice function you can find under "Edit->Advanced->Format". Just select a part or the whole source code and activate this function, and it indents the source code for making it easier to read.

I would say, when I am at home and not wasting some productivity at work, I will give you a quick introduction into how to organize your source code in the most clean way (which is then not always optimal for larger compiler runs blablablabla... I prefer readability over short compiler runs).
 
Thanks, Urwumpe, I'll have a go with that.
N.

---------- Post added at 17:43 ---------- Previous post was at 16:14 ----------

Put the clbkConsumeBufferedKey outside the class, and added a missing }, I think they were unmatched? between return1; and return 0; .

Code:
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// ==============================================================
// ORBITER MODULE: BlueStreak
// Part of the ORBITER SDK
// Copyright (C) 2002-2004 Martin Schweiger
// All rights reserved
//
// BlueStreak.cpp
// Control module for BlueStreak vessel class
//
// Notes:
// This is an example for a "minimal" vessel implementation which
// only overloads the clbkSetClassCaps method to define vessel
// capabilities and otherwise uses the default VESSEL class
// behaviour.
// ==============================================================
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]#define[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] STRICT[/COLOR]
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]#define[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] ORBITER_MODULE[/COLOR]
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]#include[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"orbitersdk.h"
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// ==============================================================
// Some vessel parameters
// ==============================================================
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PB_FUELMASS = 89260; [/COLOR][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//750.0;
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PB_MAXMAINTH = 1334000; [/COLOR][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//2*RZ_2 //3e4;
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PB_ISP = 2433; [/COLOR][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// = 248s * g //5e4;
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] VAC_MAIN_ISP = 2796; [/COLOR][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// ISP(vac)
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] NML_MAIN_ISP = 2433; [/COLOR][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// ISP(sl)
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] P_NML_MAIN_ISP = 101.4e3;[/COLOR]
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PB_MAXHOVERTH = 1.5e4;[/COLOR]
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PB_MAXRCSTH = 2e4; [/COLOR][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//2e2;
// Calculate lift coefficient [Cl] as a function of aoa (angle of attack) over -Pi ... Pi
// Implemented here as a piecewise linear function
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] LiftCoeff ([/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] aoa)[/COLOR]
{
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] nlift = 9;
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]static[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] AOA[nlift] = {-180*RAD,-60*RAD,-30*RAD,-1*RAD,15*RAD,20*RAD,25*RAD,60*RAD,180*RAD};
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]static[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] CL[nlift] = { 0, 0, -0.1, 0, 0.2, 0.25, 0.2, 0, 0};
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]static[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SCL[nlift] = {(CL[1]-CL[0])/(AOA[1]-AOA[0]), (CL[2]-CL[1])/(AOA[2]-AOA[1]),
(CL[3]-CL[2])/(AOA[3]-AOA[2]), (CL[4]-CL[3])/(AOA[4]-AOA[3]),
(CL[5]-CL[4])/(AOA[5]-AOA[4]), (CL[6]-CL[5])/(AOA[6]-AOA[5]),
(CL[7]-CL[6])/(AOA[7]-AOA[6]), (CL[8]-CL[7])/(AOA[8]-AOA[7])};
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] i;
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]for[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (i = 0; i < nlift-1 && AOA[i+1] < aoa; i++);
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] CL[i] + (aoa-AOA[i])*SCL[i];

}
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// ==============================================================
// Shuttle-PB class interface
// ==============================================================
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]class[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] BlueStreak: [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] VESSEL2 {[/COLOR]
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000]:[/COLOR]
BlueStreak (OBJHANDLE hVessel, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] flightmodel)
: VESSEL2 (hVessel, flightmodel) {}
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] clbkSetClassCaps (FILEHANDLE cfg);
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] clbkPreStep([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SimT, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SimDT, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Mjd);
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] clbkConsumeBufferedKey (DWORD key, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]bool[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] down, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]char[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] *kstate);
THRUSTER_HANDLE th_main, th_PackA, th_PackB, th_Pack[2] ;
}; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//Closing brace of class interface
// ==============================================================
// Overloaded callback functions
// ==============================================================
// --------------------------------------------------------------
// Set the capabilities of the vessel class
// --------------------------------------------------------------
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] BlueStreak::clbkSetClassCaps (FILEHANDLE cfg)[/COLOR]
{
THRUSTER_HANDLE th_hover, th_rcs[14], th_group[4] ;
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// physical specs
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]SetSize (20);
SetEmptyMass (7168);[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Dry Mass(6168kg) + Payload(1000kg)// Propellant Mass(89260kg)
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]SetCW (0.3, 0.3, 0.6, 0.9);
SetWingAspect (0.7);
SetWingEffectiveness (2.5);
SetCrossSections (_V(10.5,15.0,5.8));
SetRotDrag (_V(0.6,0.6,0.35));
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (GetFlightModel() >= 1) {
SetPitchMomentScale (1e-4);
SetBankMomentScale (1e-4);
}
SetPMI (_V(86.26,86.52,1.33));[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// ShuttlePB values(_V(2.28,2.31,0.79));
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]SetTrimScale (0.05);
SetCameraOffset (_V(0,0.8,0));
SetLiftCoeffFunc (LiftCoeff);
SetDockParams (_V(0,1.3,-1), _V(0,1,0), _V(0,0,-1));
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//SetTouchdownPoints (_V(0,-1.5,2), _V(-1,-1.5,-1.5), _V(1,-1.5,-1.5));
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]SetTouchdownPoints (_V(0,-1.524,0), _V(-1.32,-0.762,0), _V(1.32,-0.762,0)); 
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//Blue Streak radius = 1.524m. 1.32 and 0.762 are cos(),sin() of this radius for equally spaced touchdown points 
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// propellant resources
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]PROPELLANT_HANDLE hpr = CreatePropellantResource (PB_FUELMASS);
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//Debug
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] clbkPreStep([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SimT, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SimDT, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Mjd);
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//th_main = CreateThruster (_V(0,0,-4.35), _V(0,0,1), PB_MAXMAINTH, hpr, VAC_MAIN_ISP, NML_MAIN_ISP, P_NML_MAIN_ISP);// original th_main.
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]th_Pack[0] = CreateThruster (_V(-0.762,0,0), _V(0,0,1), PB_MAXMAINTH/2, hpr, VAC_MAIN_ISP, NML_MAIN_ISP, P_NML_MAIN_ISP);
th_Pack[1] = CreateThruster (_V(0.762,0,0), _V(0,0,1), PB_MAXMAINTH/2, hpr, VAC_MAIN_ISP, NML_MAIN_ISP, P_NML_MAIN_ISP);
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//th_PackGroup[0] = th_PackA;
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//th_PackGroup[1] = th_PackB;
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]th_main = CreateThrusterGroup (th_Pack, 2, THGROUP_MAIN);
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//CreateThrusterGroup (&th_PackB, 1, THGROUP_MAIN);
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]AddExhaust (th_Pack[0], 8, 1, _V(-0.762,0,-1), _V(0,0,-1));
AddExhaust (th_Pack[1], 8, 1, _V(0.762,0,-1), _V(0,0,-1));
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//double ISP = GetThrusterIsp(th_main);
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FuelRate = GetFuelRate();
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// ***************** thruster definitions *******************
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]PARTICLESTREAMSPEC contrail_main = {
0, 5.0, 16, 200, 0.15, 1.0, 5, 3.0, PARTICLESTREAMSPEC::DIFFUSE,
PARTICLESTREAMSPEC::LVL_PSQRT, 0, 2,
PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
};
PARTICLESTREAMSPEC contrail_hover = {
0, 5.0, 8, 200, 0.15, 1.0, 5, 3.0, PARTICLESTREAMSPEC::DIFFUSE,
PARTICLESTREAMSPEC::LVL_PSQRT, 0, 2,
PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
};
PARTICLESTREAMSPEC exhaust_main = {
0, 2.0, 20, 200, 0.05, 0.1, 8, 1.0, PARTICLESTREAMSPEC::EMISSIVE,
PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
};
PARTICLESTREAMSPEC exhaust_hover = {
0, 2.0, 10, 200, 0.05, 0.05, 8, 1.0, PARTICLESTREAMSPEC::EMISSIVE,
PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
};


th_hover = CreateThruster (_V(0,-1.5,0), _V(0,1,0), PB_MAXHOVERTH, hpr, PB_ISP);
CreateThrusterGroup (&th_hover, 1, THGROUP_HOVER);
AddExhaust (th_hover, 8, 1, _V(0,-1.5,1), _V(0,-1,0));
AddExhaust (th_hover, 8, 1, _V(0,-1.5,-1), _V(0,-1,0));
AddExhaustStream (th_hover, _V(0,-3, 1), &contrail_hover);
AddExhaustStream (th_hover, _V(0,-3,-1), &contrail_hover);
AddExhaustStream (th_main, _V(0,0.3,-10), &contrail_main);
AddExhaustStream (th_hover, _V(0,-2, 1), &exhaust_hover);
AddExhaustStream (th_hover, _V(0,-2,-1), &exhaust_hover);
AddExhaustStream (th_main, _V(0,0.3,-5), &exhaust_main);
th_rcs[ 0] = CreateThruster (_V( 1,0, 3), _V(0, 1,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[ 1] = CreateThruster (_V( 1,0, 3), _V(0,-1,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[ 2] = CreateThruster (_V(-1,0, 3), _V(0, 1,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[ 3] = CreateThruster (_V(-1,0, 3), _V(0,-1,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[ 4] = CreateThruster (_V( 1,0,-3), _V(0, 1,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[ 5] = CreateThruster (_V( 1,0,-3), _V(0,-1,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[ 6] = CreateThruster (_V(-1,0,-3), _V(0, 1,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[ 7] = CreateThruster (_V(-1,0,-3), _V(0,-1,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[ 8] = CreateThruster (_V( 1,0, 3), _V(-1,0,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[ 9] = CreateThruster (_V(-1,0, 3), _V( 1,0,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[10] = CreateThruster (_V( 1,0,-3), _V(-1,0,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[11] = CreateThruster (_V(-1,0,-3), _V( 1,0,0), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[12] = CreateThruster (_V( 0,0,-3), _V(0,0, 1), PB_MAXRCSTH, hpr, PB_ISP);
th_rcs[13] = CreateThruster (_V( 0,0, 3), _V(0,0,-1), PB_MAXRCSTH, hpr, PB_ISP);
th_group[0] = th_rcs[0];
th_group[1] = th_rcs[2];
th_group[2] = th_rcs[5];
th_group[3] = th_rcs[7];
CreateThrusterGroup (th_group, 4, THGROUP_ATT_PITCHUP);
th_group[0] = th_rcs[1];
th_group[1] = th_rcs[3];
th_group[2] = th_rcs[4];
th_group[3] = th_rcs[6];
CreateThrusterGroup (th_group, 4, THGROUP_ATT_PITCHDOWN);
th_group[0] = th_rcs[0];
th_group[1] = th_rcs[4];
th_group[2] = th_rcs[3];
th_group[3] = th_rcs[7];
CreateThrusterGroup (th_group, 4, THGROUP_ATT_BANKLEFT);
th_group[0] = th_rcs[1];
th_group[1] = th_rcs[5];
th_group[2] = th_rcs[2];
th_group[3] = th_rcs[6];
CreateThrusterGroup (th_group, 4, THGROUP_ATT_BANKRIGHT);
th_group[0] = th_rcs[0];
th_group[1] = th_rcs[4];
th_group[2] = th_rcs[2];
th_group[3] = th_rcs[6];
CreateThrusterGroup (th_group, 4, THGROUP_ATT_UP);
th_group[0] = th_rcs[1];
th_group[1] = th_rcs[5];
th_group[2] = th_rcs[3];
th_group[3] = th_rcs[7];
CreateThrusterGroup (th_group, 4, THGROUP_ATT_DOWN);
th_group[0] = th_rcs[8];
th_group[1] = th_rcs[11];
CreateThrusterGroup (th_group, 2, THGROUP_ATT_YAWLEFT);
th_group[0] = th_rcs[9];
th_group[1] = th_rcs[10];
CreateThrusterGroup (th_group, 2, THGROUP_ATT_YAWRIGHT);
th_group[0] = th_rcs[8];
th_group[1] = th_rcs[10];
CreateThrusterGroup (th_group, 2, THGROUP_ATT_LEFT);
th_group[0] = th_rcs[9];
th_group[1] = th_rcs[11];
CreateThrusterGroup (th_group, 2, THGROUP_ATT_RIGHT);
CreateThrusterGroup (th_rcs+12, 1, THGROUP_ATT_FORWARD);
CreateThrusterGroup (th_rcs+13, 1, THGROUP_ATT_BACK);
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// visual specs
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]AddMesh ([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"BlueStreak"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
}[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//closing brace of BlueStreak class
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BlueStreak::clbkConsumeBufferedKey (DWORD key, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]bool[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] down,[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]char[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] *kstate) {
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (!down) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 0; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//only process keydown events
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (KEYMOD_SHIFT (kstate)){
} [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]else[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] { [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// unmodified keys
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]switch[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (key) {
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]case[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] OAPI_KEY_L: [/COLOR][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Fire mains
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]SetThrusterLevel(th_main, 1);
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 1;
}
}
}
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 0; 
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// ==============================================================
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// API callback interface
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// ==============================================================
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BlueStreak::clbkPreStep([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SimT, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SimDT, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Mjd){
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Mass = GetMass(); [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//Launch Mass = 96428kg 
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FuelMass = GetFuelMass();[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Launch Fuel Mass 89260kg
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//double ISP = GetThrusterIsp(th_main);
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] FuelRate = GetFuelRate();
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Force = PB_MAXMAINTH; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// = 1334000 KN
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Acceleration=Force/Mass;[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Launch acceleration = 1334000/96428 = 13.83m/s/s

[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]sprintf(oapiDebugString(), [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"SimT %0.1f FuelRate %0.1f Mass %0.1f "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] , SimT, FuelRate, Mass);
}
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// --------------------------------------------------------------
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Vessel initialisation
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// --------------------------------------------------------------
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]DLLCLBK VESSEL *ovcInit (OBJHANDLE hvessel, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] flightmodel)
{
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BlueStreak (hvessel, flightmodel);
}
[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// --------------------------------------------------------------
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Vessel cleanup
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// --------------------------------------------------------------
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]DLLCLBK [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ovcExit (VESSEL *vessel)
{
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (vessel) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]delete[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (BlueStreak*)vessel;
}
[/SIZE][/COLOR][/SIZE][/COLOR][/SIZE]

Just get this error now:-
Code:
[SIZE=1]
1>c:\users\public\orbitersdk\samples\shuttlepb\bluestreak.cpp(251) : error C2059: syntax error : 'return'
[/SIZE]

N.
 
Yes. because return is a statement which has to be part of the function. You have drawn the border of the scope just in front of it.

Which makes no sense, if you think about it.

Each { } is one scope - a region of visibility in the program. If you define a variable, it is only visible inside the scope and the scopes inside it AND only to instructions following the definition.

The statement return allows you to leave a function and return a so-called return value from the function. In this case, the return value is of the type int, because the function is defined as "int BlueStreak::clbkConsumeBufferedKey".

Of course, it makes no sense to place a return statement outside the function, which function should it leave? Inside a function, you can have as many return statements as you like, but only the first in the program flow is executed. You can thus use return statements for quickly ending a function.

In a function starting with "BlueStreak::" you can not only see all elements defined in the function or outside the function and in front of it, but also all elements defined inside the scope of class BlueStreak: public VESSEL2 {... };
 
Should have put the missing brace here:-
Code:
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BlueStreak::clbkConsumeBufferedKey (DWORD key, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]bool[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] down,[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]char[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] *kstate)[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (!down) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 0; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//only process keydown events[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (KEYMOD_SHIFT (kstate)){[/SIZE]
[SIZE=2]} [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]else[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] { [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// unmodified keys[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]switch[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (key) {[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]case[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] OAPI_KEY_L: [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Fire mains[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]SetThrusterLevel(th_main, 1);[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 1;[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 0;[/SIZE]
[SIZE=2]}[/SIZE]

This compiles and links, and as long as you don't press the "l" key it functions normally. CTD if I press "l" key.

N.

Just read your last Urwumpe, after sending this.

Many thanks for that, I'll have read.

N.

---------- Post added at 20:07 ---------- Previous post was at 18:12 ----------

Changin to this works, with no CTD:-
Code:
[SIZE=2]SetThrusterLevel(th_hover, 1);
[/SIZE]

I guess making the th_main using two thrusters isn't working in this mode?

N.
 
Last edited:
th_main itself is no "THRUSTER_HANDLE" variable, but actually a "THRUSTER_HANDLE*", a pointer in the memory to the variable th_main[0].

You could of course prevent this bug by either writing

"th_main[0]" or "*th_main" (both mean the same) and "th_main[1]" or if you like to be really confused: "*(th_main + 1)"
 
I couldn't get any of those to compile without errors, it seems happy with this.

Code:
[SIZE=2]
}[/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//closing brace of BlueStreak class
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BlueStreak::clbkConsumeBufferedKey (DWORD key, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]bool[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] down,[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]char[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] *kstate)
{
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (!down) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 0; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//only process keydown events
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (KEYMOD_SHIFT (kstate))
{
} [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]else[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] { [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// unmodified keys
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]switch[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (key) { [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]case[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] OAPI_KEY_L: [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Fire mains
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]SetThrusterLevel(th_Pack[0], 1);
SetThrusterLevel(th_Pack[1], 1);
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 1;
}
}
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 0;
}
[/SIZE]
The "l" key now fires both engines ok. I thought from that code, "L" key was needed? dosen't the use of "l" conflict with the LVL autopilot mode?

N.
 
The "l" key now fires both engines ok. I thought from that code, "L" key was needed? dosen't the use of "l" conflict with the LVL autopilot mode?
It won't conflict per-se. By returning "1" when you process the key, this tells Orbiter not to process its internal key shortcuts so the LVL auto-pilot won't activate (or toggle its state, I can't remember which). Of course, you could also return 0 which would mean your mains would fire and the LVL auto-pilot would also activate but that would be poor form.

If you want shift-L to fire the engines you want to re-arrange the code a little. The code that fires the engines is currently outside of the scope where KEYMOD_SHIFT(kstate)==true. Try this (and with some indenting this time ;), styles vary but this is how I usually do mine):

Code:
[SIZE=2]
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BlueStreak::clbkConsumeBufferedKey (DWORD key, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]bool[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] down,[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]char[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] *kstate)
{[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]
  if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (!down) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 0; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//only process keydown events
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]
  if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (KEYMOD_SHIFT (kstate))
  {
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]    switch[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (key) { [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]case[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] OAPI_KEY_L: [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Fire mains[/COLOR][/SIZE][/COLOR][/SIZE]
    [SIZE=2]SetThrusterLevel(th_Pack[0], 1);
    SetThrusterLevel(th_Pack[1], 1);[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]
    return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 1;[/SIZE][SIZE=2]
  }
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 0;
}
[/SIZE]
 
Thanks for that tb, if it dosen't conflict, I'll leave it.
Just to clarify, whilstever your vessel has the focus, the user will not be able to activate the LVL autopilot using the "l" shortcut. I would see that as a conflict if your vessel has need of the LVL auto-pilot (I'm not sure in your case).

Don't know why the indenting disapeared, here's how it is at the moment:-
http://i89.photobucket.com/albums/k207/Notebook_04/Indenting.jpg

I used Urwumpe's suggestion in #45 above regarding the formatting.
Ah, OK. IIRC, if you put the
Code:
 tags into to your post before you paste the text in, vBulletin won't parse out the leading whitespace.
 
A side note, since we are giving you all this coding advice anyway :P. It is bad form to do this:
[code]if (myThing)
  { // do nothing }
else
  { // do something }
Much better to do:
Code:
if (!myThing)
  { // do something }

For one, it is more efficient to write, but it also makes your code more readable which is important for when it comes to hunting down bugs (and, as you have found out, you will have them :P). If you Google around you will find plenty of code "style guides" - take them all with a grain of salt (they are often written by fanatics with nothing better to do than tell the world how good their style is - mine is the best of course :P) but you should be able to skim the basics off them and develop your own style. As long as you use something that is self-consistent and not too complicated you will be OK.
 
Thanks again tb, I'm putting all these comments in a text file with the project. I can't remember stuff like I used too...

N.
 
Another week, another question...

Exploring the VECTOR3 and _V(x,y,z) in Orbiter, got this to work:-

Code:
[SIZE=2][COLOR=#0000ff]
[SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BlueStreak::clbkPreStep([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SimT, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SimDT, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Mjd){[/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//double totalPropellantRate = GetTotalPropellantFlowrate(); // Blue Streak average 554kg/s[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//double totalPropellantMass = GetTotalPropellantMass(); // Launch Fuel Mass 89260kg[/COLOR][/SIZE]
[/COLOR][/SIZE]
[SIZE=2]GetThrusterDir(th_main, thDir);[/SIZE]
[SIZE=2]thDir = (_V(127,126,125));[/SIZE]
[SIZE=2]sprintf(oapiDebugString(), [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"SimT %0.1f thDir %0.1f "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] , SimT, thDir);[/SIZE]
[SIZE=2]}[/SIZE]

Just getting some data from Orbiter, changing it and trying to dispaly it, nothing usefull.
How do I display the whole (x,y,z) in the debug string?
At the moment, it shows
"thDir 127.0"
so its getting the first value.

Many thanks, N.
 
How do I display the whole (x,y,z) in the debug string?

by accessing the components of the vector. You have two valid ways to do so:

1. printf("...%lf %lf %lf ...", thDir.x, thDir.y, thDir.z);

2. printf("...%lf %lf %lf ...", thDir.data[0], thDir.data[1], thDir.data[2]);

As you can see, you need to break the vector structure down into the data types, the printf function knows, to get ahead. Note: Other structures and unions have different variables inside them, and need to get broken into their components differently.

C++ allows creating custom stream operators for custom data types, but this functionality is not directly used by Orbiters SDK and using the STL classes of C++ together with orbiter requires some annoying conversions, especially annoying since Orbiters API often does not set read-only input zero-terminated character strings to const (constant), so you can directly copy a C++ string (std::string) into the API functions.
 
How do I display the whole (x,y,z) in the debug string?
I will digress a little before giving you the answer, mainly because the VECTOR3 type is a simple example of an interesting type - the union. Here is the definition of the VECTOR3 type from OrbiterAPI.h:
Code:
typedef union {      // 3 vector
    double data[3];
    struct { double x, y, z; };
} VECTOR3;
A union is a data type with members like a class except that all the members share the same memory space. In the case of VECTOR3 this is fairly straight-forward and it looks like this in memory (32-bit system shown, the 'x's represent the actual data):
Code:
[FONT=Courier New]|address        |address+2      |address+4      |
|double(8 bytes)|double(8 bytes)|[/FONT][FONT=Courier New]double(8 bytes)|[/FONT]
[FONT=Courier New]|xxxxxxxxxxxxxxx|[/FONT][FONT=Courier New]xxxxxxxxxxxxxxx|[/FONT][FONT=Courier New]xxxxxxxxxxxxxxx|[/FONT]
Notice that there is only space for three doubles in memory, whereas six are declared. This because the data member and struct member are stored in the same piece of memory. What this means is that you can then access the same piece of data in different ways. The syntax for accessing union members is just like accessing struct or class members so thDir.data[0] returns the same value as thDir.x since they are both referencing the same piece of memory, ie, the first 8 bytes.

So, the short answer to your question (bearing in mind the above explanation) is:
Code:
[FONT=Courier New]sprintf(oapiDebugString(), "SimT %0.1f thDir %0.1f:%0.1f:%0.1f" , SimT, thDir.x, thDir.y, thDir.z);[/FONT]
*OR*
Code:
[FONT=Courier New]sprintf(oapiDebugString(), "SimT %0.1f thDir %0.1f:%0.1f:%0.1f" , SimT, thDir.data[0], thDir.data[1], thDir.data[2]);[/FONT]
But you could also do operations like this (just an example of syntax, it is not meant to do anything useful):
Code:
[FONT=Courier New]for (i=0;i<3;i++) thDir.data[i] /= someArray[i];[/FONT]
which is more elegant than this code which would have the same effect:
Code:
[FONT=Courier New]thDir.x /= someArray[0];
thDir.y /= someArray[1][/FONT];
thDir.z /= someArray[2];


---------- Post added at 22:50 ---------- Previous post was at 22:30 ----------

C++ allows creating custom stream operators for custom data types, but this functionality is not directly used by Orbiters SDK and using the STL classes of C++ together with orbiter requires some annoying conversions, especially annoying since Orbiters API often does not set read-only input zero-terminated character strings to const (constant), so you can directly copy a C++ string (std::string) into the API functions.
I was not aware of such a stream operator for std::string. Are you saying this is valid code (I've never tried it like this):
Code:
int someFunc(const char *s)
{
  return strlen(s);
}

std::string myString="Hello World";
someFunc(myString);
I would normally do:
Code:
someFunc(myString.c_str())
 
As always chaps, thanks for the replies.
I'l wander off, think, and have a gogitate...

N.
 
I was not aware of such a stream operator for std::string. Are you saying this is valid code (I've never tried it like this):
Code:
int someFunc(const char *s)
{
  return strlen(s);
}

std::string myString="Hello World";
someFunc(myString);
I would normally do:
Code:
someFunc(myString.c_str())

No, i mean actually something else.

In orbiter, the functions are often defined as:

Code:
int someFunc(char* s) {
return strlen(s);
}

meaning that you can't throw string::c_str() at it as it returns a const char*.
 
have a gogitate...
I haven't seen that word before, what is it? A portmanteau of Google and cogitate, ie, a hard think augmented by Google? :P

No, i mean actually something else.

In orbiter, the functions are often defined as:

Code:
int someFunc(char* s) {
return strlen(s);
}
meaning that you can't throw string::c_str() at it as it returns a const char*.
Thanks for clearing that up.
 
Back
Top