API Question Quick Question re: VS2015 setup.

slaver0110

Member
Joined
Mar 21, 2011
Messages
72
Reaction score
2
Points
6
I had to do a full reinstall of VisualStudio2015 Community last night, and now I'm getting crashes out of vessel compiles that worked before.

I'm pretty sure I've botched the setup for VS2015 to work with the OrbiterSDK, as I'm getting debug and odd compile files in my Modules directory, and my guess is that because of that things aren't compiling properly.

The vessel I've been working on now crashes Orbiter every time I use the RCS, even though the code is the backup from before I reinstalled VS2015.

the procedure I use for setting up a new project is:
Code:
1.  Start up new project, empty, DLL.
2.  Right-click the project name in PropertyManager and add vessel.props.
3.  Right-click Debug in PropertyManager and add debug.props.
4.  Verify orbiter.root is correct.
5.  Right-click project-name --> Properties -->  Debugging.
6.  Set "Command" to Orbiter.exe and "Working Directory" to the Orbiter root dir.
7.  Make sure Character Set is "Multi-byte".
8.  In Project Properties --> General, set "Output Dir" to Orbiter\Modules\
9.  In Prokect Properties --> Linker --> General, verify output file as Orbiter\Modules\<projectname>.dll
10.  compile as debug, then release afterwards.
I'm thinking that there's something I've missed in the setup.
I've tried compiling into a fresh Orbiter2016 install (just in case), but with the same result.
I found ADSWNJ's setup https://www.orbiter-forum.com/showthread.php?t=34971&highlight=property+sheet but I'm still getting crashes.
Is there something in my setup that I have wrong here?
Thanks in advance, and Cheers!!:cheers:
 

kuddel

Donator
Donator
Joined
Apr 1, 2008
Messages
2,064
Reaction score
507
Points
113
Have you tried to clean your project directory from *all* temporary files?

As some of those files/directories are hidden, it's easiest to re-create a clean directory
- rename old directory (e.g. myProject_old)
- create clean directory (e.g. myProject)
- copy _only_ the needed files (*.cpp,*.h;*.sln;*.vcxproj;*.rc)
- open solution, compile and debug

Sometimes those "caches" produce very strange results...
 

slaver0110

Member
Joined
Mar 21, 2011
Messages
72
Reaction score
2
Points
6
Have you tried to clean your project directory from *all* temporary files?
Sometimes those "caches" produce very strange results...

Gave this a shot, but still getting a crash.
I'm using the SDK from the Orbiter2016 zip file, so I'm reasonably sure that it isn't the problem.
Still thinking that there's something I've missed in the IDE setup.

I'll keep trying.
Cheers!!
 

slaver0110

Member
Joined
Mar 21, 2011
Messages
72
Reaction score
2
Points
6
Thanks for that, Kuddel. I really appreciate your taking the time to help. However, no dice there.

I don't mind saying that it's somewhat frustrating. I've been testing builds in a fresh Orbiter2016 install (just in case it was another addon that was the culprit), but everytime I build now, Orbiter crashes straight to desktop as soon as I use the RCS.

If I do a Debug build and then a Release build, it seems to work just fine, until I close Orbiter and restart the same scenario; after which I get a CTD upon using the RCS (there's no other propulsion on that vessel).

Strange part is, it's the same code that worked before, copypasted into the IDE.
With every build, I'm getting .exp .iobj .ipdb .lib and .pdb files in the Modules directory, which tells me that I've really botched the IDE setup.

I'm thinking that I'll need my hand held on this one...:shrug:

Again, I thank you for the help thus far.
Cheers!!
 

kuddel

Donator
Donator
Joined
Apr 1, 2008
Messages
2,064
Reaction score
507
Points
113
...yeah it can be frustrating sometimes.
But for the .exp .iobj .ipdb .lib and .pdb files in the Modules directory, it looks like a project file issue.
But with an otherwise unchanged project, it might also be a Visual Studio "global" setting that differs now. Is there any "global" Macros, or path setup settings that apply to all projects/solutions in Visual Studio 2015?

If you don't mind, you could send me the project (ZIP) and i can try what it does here.

Nevertheless, I have to go to bed. :zzz:
good night from here
 

slaver0110

Member
Joined
Mar 21, 2011
Messages
72
Reaction score
2
Points
6
Might not be VS2015 after all

Ok, found out something interesting that has me even more perplexed than when I started...

After I compile the vessel code, and start the Orbiter scenario that tests it, it works as it should: RCS works fine, everything looks perfect.

...until I close Orbiter and and open it again with the same scenario...
On the second run, any use of the RCS crashes Orbiter straight to desktop. If I recompile the vessel, again it works only on the first scenario run, and when I leave Orbiter and restart the scenario, the RCS CTD's.

Fresh Orbiter2016 install. No other addons. No other vessels in the scenario.
Just as an experiment, I tried the vessel in a clean O2010 install, same result; CTD on the second run.

I'm left thinking that it isn't the IDE setup at all...

Tug1 code:
Code:
#define STRICT
#define ORBITER_MODULE

#include "orbitersdk.h"
#include "Tug1.h"

Tug1::Tug1(OBJHANDLE hVessel, int flightmodel) : VESSEL3(hVessel, flightmodel) 
{
	hpr = CreatePropellantResource(T1_FUELMASS);
	SURFHANDLE exhaust = oapiRegisterExhaustTexture("Dragon_atrcs");	
}
Tug1::~Tug1() {}

void Tug1::clbkSetClassCaps(FILEHANDLE cfg)
{
	SetSize(T1_SIZE);
	SetEmptyMass(T1_EMPTYMASS);
	SetPMI(T1_PMI);
	SetCrossSections(T1_CS);
	SetRotDrag(T1_RD);

	// RCS RIGHT
	th_rcs[0] = CreateThruster(_V(1.8, 0, 0), _V(-1, 0, 0), T1_MAXRCSTH, hpr, T1_ISP); AddExhaust(th_rcs[0], 1.0, 0.05, exhaust);
	th_rcs[1] = CreateThruster(_V(1.8, 0, 0), _V(0, 0, -1), T1_MAXRCSTH, hpr, T1_ISP); AddExhaust(th_rcs[1], 1.0, 0.05, exhaust);
	th_rcs[2] = CreateThruster(_V(1.8, 0, 0), _V(0, 0, 1), T1_MAXRCSTH, hpr, T1_ISP); AddExhaust(th_rcs[2], 1.0, 0.05, exhaust);
	th_rcs[3] = CreateThruster(_V(1.8, 0, 0), _V(0, 1, 0), T1_MAXRCSTH, hpr, T1_ISP); AddExhaust(th_rcs[3], 1.0, 0.05, exhaust);
	th_rcs[4] = CreateThruster(_V(1.8, 0, 0), _V(0, -1, 0), T1_MAXRCSTH, hpr, T1_ISP); AddExhaust(th_rcs[4], 1.0, 0.05, exhaust);
	// RCS LEFT
	th_rcs[5] = CreateThruster(_V(-1.8, 0, 0), _V(1, 0, 0), T1_MAXRCSTH, hpr, T1_ISP); AddExhaust(th_rcs[5], 1.0, 0.05, exhaust);
	th_rcs[6] = CreateThruster(_V(-1.8, 0, 0), _V(0, 0, -1), T1_MAXRCSTH, hpr, T1_ISP); AddExhaust(th_rcs[6], 1.0, 0.05, exhaust);
	th_rcs[7] = CreateThruster(_V(-1.8, 0, 0), _V(0, 0, 1), T1_MAXRCSTH, hpr, T1_ISP); AddExhaust(th_rcs[7], 1.0, 0.05, exhaust);
	th_rcs[8] = CreateThruster(_V(-1.8, 0, 0), _V(0, 1, 0), T1_MAXRCSTH, hpr, T1_ISP); AddExhaust(th_rcs[8], 1.0, 0.05, exhaust);
	th_rcs[9] = CreateThruster(_V(-1.8, 0, 0), _V(0, -1, 0), T1_MAXRCSTH, hpr, T1_ISP); AddExhaust(th_rcs[9], 1.0, 0.05, exhaust);
	// PHANTOM RCS TOP
	th_rcs[10] = CreateThruster(_V(0.0, 2.0, 0.0), _V(0, 0, 1), T1_MAXRCSTH, hpr, T1_ISP); AddExhaust(th_rcs[10], 1.0, 0.05, exhaust);
	th_rcs[11] = CreateThruster(_V(0.0, 2.0, 0.0), _V(0, 0, -1), T1_MAXRCSTH, hpr, T1_ISP); AddExhaust(th_rcs[11], 1.0, 0.05, exhaust);
	// PHANTOM RCS BOTTOM
	th_rcs[12] = CreateThruster(_V(0.0, -2.0, 0.0), _V(0, 0, 1), T1_MAXRCSTH, hpr, T1_ISP); AddExhaust(th_rcs[12], 1.0, 0.05, exhaust);
	th_rcs[13] = CreateThruster(_V(0.0, -2.0, 0.0), _V(0, 0, -1), T1_MAXRCSTH, hpr, T1_ISP); AddExhaust(th_rcs[13], 1.0, 0.05, exhaust);
	// POD RCS
	th_pod_up = CreateThruster(_V(0.0, 0.0, -7.5), _V(0, -1, 0), T1_PODRCSTH, hpr, T1_ISP); AddExhaust(th_pod_up, 4.0, 0.2, exhaust);
	th_pod_down = CreateThruster(_V(0.0, 0.0, -7.5), _V(0, 1, 0), T1_PODRCSTH, hpr, T1_ISP); AddExhaust(th_pod_down, 4.0, 0.2, exhaust);
	th_pod_left = CreateThruster(_V(0.0, 0.0, -7.5), _V(1, 0, 0), T1_PODRCSTH, hpr, T1_ISP); AddExhaust(th_pod_left, 4.0, 0.2, exhaust);
	th_pod_right = CreateThruster(_V(0.0, 0.0, -7.5), _V(-1, 0, 0), T1_PODRCSTH, hpr, T1_ISP); AddExhaust(th_pod_right, 4.0, 0.2, exhaust);

	th_group[0] = th_rcs[11];	th_group[1] = th_rcs[12];
	CreateThrusterGroup(th_group, 2, THGROUP_ATT_PITCHUP);

	th_group[0] = th_rcs[10];	th_group[1] = th_rcs[13];
	CreateThrusterGroup(th_group, 2, THGROUP_ATT_PITCHDOWN);

	th_group[0] = th_rcs[9];	th_group[1] = th_rcs[3];
	CreateThrusterGroup(th_group, 2, THGROUP_ATT_BANKLEFT);

	th_group[0] = th_rcs[4];	th_group[1] = th_rcs[8];
	CreateThrusterGroup(th_group, 2, THGROUP_ATT_BANKRIGHT);

	th_group[0] = th_rcs[3];	th_group[1] = th_rcs[8];
	CreateThrusterGroup(th_group, 2, THGROUP_ATT_UP);

	th_group[0] = th_rcs[4];	th_group[1] = th_rcs[9];
	CreateThrusterGroup(th_group, 2, THGROUP_ATT_DOWN);

	th_group[0] = th_rcs[2];	th_group[1] = th_rcs[6];
	CreateThrusterGroup(th_group, 2, THGROUP_ATT_YAWLEFT);

	th_group[0] = th_rcs[1];	th_group[1] = th_rcs[7];
	CreateThrusterGroup(th_group, 2, THGROUP_ATT_YAWRIGHT);

	th_group[0] = th_rcs[0];
	CreateThrusterGroup(th_group, 1, THGROUP_ATT_LEFT);

	th_group[0] = th_rcs[5];
	CreateThrusterGroup(th_group, 1, THGROUP_ATT_RIGHT);

	th_group[0] = th_rcs[2];	th_group[1] = th_rcs[7];
	CreateThrusterGroup(th_group, 2, THGROUP_ATT_FORWARD);

	th_group[0] = th_rcs[1];	th_group[1] = th_rcs[6];
	CreateThrusterGroup(th_group, 2, THGROUP_ATT_BACK);

	CreateDock(_V(0.0, 0.0, 1.7), _V(0, 0, 1), _V(0, 1, 0));
	SetCameraOffset(_V(0, 0.8, 0));
	AddMesh("Tug1");
}

void Tug1::changePodFlag()
{
	if (PodFlag == 0) { PodFlag = 1; }
	else if (PodFlag == 1) { PodFlag = 0; }
}

void Tug1::changePodThrust(int t)
{
	if (t == 0 && PodThrust < 0.0) PodThrust = 0.0;
	if (t == 1 && PodThrust > 1.0) PodThrust = 1.0;
	if (t == 0) PodThrust -= 0.05;
	if (t == 1) PodThrust += 0.05;
}

bool Tug1::clbkDrawHUD(int mode, const HUDPAINTSPEC *hps, oapi::Sketchpad *skp)
{
	if (oapiGetHUDMode() == HUD_DOCKING)
	{
		iPodThrust = (float)PodThrust * 100;

		sprintf_s(buffer, "POD FLAG: %.0f", PodFlag);
		txt = buffer;
		skp->Text(100, 300, txt.c_str(), (int)txt.length());

		sprintf_s(buffer, "POD THRUST: %.0f", iPodThrust);
		txt = buffer;
		skp->Text(100, 350, txt.c_str(), (int)txt.length());
	}
	return true;
}

int Tug1::clbkConsumeBufferedKey(DWORD key, bool down, char *kstate)
{
	if (!down)
	{
		SetThrusterLevel(th_pod_down, 0.0);
		SetThrusterLevel(th_pod_up, 0.0);
		SetThrusterLevel(th_pod_left, 0.0);
		SetThrusterLevel(th_pod_right, 0.0);
		return 1;
	}
	if (KEYMOD_SHIFT(kstate)) {}
	else
	{
		switch (key)
		{
		case OAPI_KEY_L:
			changePodFlag(); return 1;
		case OAPI_KEY_COMMA:
			changePodThrust(0); return 1;
		case OAPI_KEY_PERIOD:
			changePodThrust(1); return 1;
		case OAPI_KEY_NUMPAD8:
			if (PodFlag == 1) { SetThrusterLevel(th_pod_down, PodThrust); }  break;
		case OAPI_KEY_NUMPAD2:
			if (PodFlag == 1) { SetThrusterLevel(th_pod_up, PodThrust); }  break;
		case OAPI_KEY_NUMPAD3:
			if (PodFlag == 1) { SetThrusterLevel(th_pod_right, PodThrust); }  break;
		case OAPI_KEY_NUMPAD1:
			if (PodFlag == 1) { SetThrusterLevel(th_pod_left, PodThrust); }  break;
		}
	}
	return 0;
}

DLLCLBK VESSEL *ovcInit(OBJHANDLE hvessel, int flightmodel)
{
	return new Tug1(hvessel, flightmodel);
}

DLLCLBK void ovcExit(VESSEL *vessel)
{
	if (vessel) delete (Tug1*)vessel;
}

Tug1.h
Code:
#ifndef TUG1_H
#define TUG1_H

class Tug1 : public VESSEL3
{
public:
	Tug1(OBJHANDLE hVessel, int flightmodel);
	~Tug1();
	void clbkSetClassCaps(FILEHANDLE cfg);
	void clbkPostStep(double simt, double simdt, double mjd);
	void clbkPreStep(double simt, double simdt, double mjd);
	bool Tug1::clbkDrawHUD(int mode, const HUDPAINTSPEC *hps, oapi::Sketchpad *skp);
	THRUSTER_HANDLE th_rcs[14], th_pod_up, th_pod_down, th_pod_left, th_pod_right, th_group[12];
	PROPELLANT_HANDLE hpr;
	SURFHANDLE exhaust;
	int clbkConsumeBufferedKey(DWORD key, bool down, char *kstate);
	virtual void changePodFlag();
	void changePodThrust(int);
	double PodFlag = 0;
	double PodThrust = 0.5;
	float iPodThrust;
	std::string txt;
	char buffer[256];
private:
	const double T1_SIZE = 4.5;					// mean radius [m]
	const VECTOR3 T1_CS = { 4.0,4.0,18.0 };		// x,y,z cross sections [m^2]
	const VECTOR3 T1_PMI = { 2.28,2.31,0.79 };	// principal moments of inertia (mass-normalised) [m^2]
	const VECTOR3 T1_RD = { 0.025,0.025,0.02 };	// {0.05,0.1,0.05};  // rotation drag coefficients
	const double  T1_EMPTYMASS = 1805.0;        // empty vessel mass [kg]
	const double  T1_FUELMASS = 50.0;           // max fuel mass [kg]
	const double  T1_ISP = 5e4;					// fuel-specific impulse [m/s]
	const double  T1_MAXRCSTH = 35;				// Reaction Control System Thrust
	const double  T1_PODRCSTH = 150;
};

#endif // !TUG1_H

I wondered if a pointer was being left hanging, but I don't see one...:shrug:
 
Last edited:
Top