I was told not to have global variables and given an example. Ifollowed it and now I get this error:only const static integral data members can be initialized inside a class or struct
on lines 50-85

#define STRICT
#define ORBITER_MODULE
#define ENG                 1    
#define START                 2    
#define STOP                 3    

#include <orbitersdk.h>
#include <cstdio>
#include <cmath>
#include <string>
#include "OrbiterSoundSDK3.h"

#include <stdio.h>
 



// ==============================================================
// Shuttle-PB class interface
// ==============================================================

class Chariot: public VESSEL2 {
public:
    Chariot (OBJHANDLE hVessel, int flightmodel);
    //    : VESSEL2 (hVessel, flightmodel) {}
    void clbkSetClassCaps (FILEHANDLE cfg);
    void DefineAnimations(void);
    void clbkPostCreation (void);
    void clbkPreStep (double simt, double simdt, double mjd);
    void clbkPostStep (double simt, double simdt, double mjd);
    int  clbkConsumeBufferedKey (DWORD key, bool down, char *kstate);

private:
double i = 0;
double i2 = 0.5;
double i2l = 0.5;
double i2r = 0.5;
double i3 = 0;
double t1 = 1;
double i4 = 0;
double i5 = 0;
double i6 = 0;
double st = 0;
double pld = 0;
double cen = 0;
double fb = 0;
double sign = 0;
double pit2 = 200;
double sp = 190;
int start = 0;
double i8 = 0;
double main_on = 0;
double retro_on = 0;
THRUSTER_HANDLE th_main;
THRUSTER_HANDLE th_retro;
THRUSTER_HANDLE th_rcs[4], th_group[2];
UINT animactive6;
UINT animactive5;
UINT animactive7;
UINT animactive8;
UINT animactive9;
UINT animactive10;
int MySoundID;    
double canopy = 0;
double lfdoor = 0;
double lrdoor = 0;
double rfdoor = 0;
double rrdoor = 0;
double rhatch = 0;   
UINT anim_wheel;
UINT anim_wheelleft;
UINT anim_wheelright;
UINT anim_wheelleftrev;
UINT anim_wheelrightrev;
UINT anim_leverleft;
UINT anim_leverright;
UINT anim_lfdoor;
UINT anim_dome;
UINT anim_lrdoor;
UINT anim_rfdoor;
UINT anim_rrdoor;
UINT anim_rhatch;
 
};

Chariot::Chariot (OBJHANDLE hVessel, int flightmodel)
        : VESSEL2 (hVessel, flightmodel)
{
    
    DefineAnimations ();
}

Recommended Answers

All 2 Replies

imsorryicantunderstandwhatyourquestionisbecauseitlookslikethis

Try rearranging your post without the LaTex tags

Although, with reference to the subject line - look at the private members in your class (Of which there are far, far too many... if i were you, the first thing i'd do would be to look at a way to cut them down.. such as an array)

You can't directly assign a value to a data member in the class, you need to initialise them in the class constructor instead.

I fixed it. I was told not to have global variables. And send an example

Now I need to see hwta is going on with this:

// --------------------------------------------------------------
// Vessel cleanup
// --------------------------------------------------------------
DLLCLBK void ovcExit (VESSEL *vessel)
{
    if (vessel) delete (Chariot*)vessel;
}
void Chariot::clbkPreStep (double simt, double simdt, double mjd)
{
sprintf(oapiDebugString(),"start %2.2f", start );   
   
if (0==start){
   
    SetThrusterGroupLevel (THGROUP_MAIN, 0);
    SetThrusterGroupLevel (THGROUP_RETRO, 0);
    SetThrusterGroupLevel  (THGROUP_ATT_YAWLEFT, 0);
    SetThrusterGroupLevel (THGROUP_ATT_YAWRIGHT, 0);  
}
}

What happens is event though start =1 the sprintf shows it is 0 and the set thrusterlevel part doesn't work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.