Code problem

Bj

Addon Developer
Addon Developer
Donator
Joined
Oct 16, 2007
Messages
1,886
Reaction score
11
Points
0
Location
USA-WA
Website
www.orbiter-forum.com
Now this is a weird problem, and I have ran the dubugger to pinpoint where the problem lays.

I get a orbiter CTD

when I run a scenario with the ISS in it and it crashed;

here is the scenario;

Code:
BEGIN_SHIPS
ISS:ProjectAlpha_ISS
  STATUS Orbiting Earth
  RPOS -3384712.85 5742762.34 -964973.82
  RVEL 6502.924 3449.258 -2233.552
  AROT 30.00 -0.00 50.00
  IDS 0:588 100 1:586 100 2:584 100 3:582 100 4:580 100
  NAVFREQ 0 0
  XPDR 466
END
testing:ShuttleA
  STATUS Landed Earth
  POS -80.6745314 28.5187120
  HEADING 100.01
  PRPLEVEL 0:0.997 1:1.000
  NAVFREQ 0 0
  XPDR 0
  PODANGLE 0.0000 0.0000
  DOCKSTATE 0 0.0000
  AIRLOCK 0 0.0000
  GEAR 0 0.0000
  PAYLOAD MASS 0.0 0
END
h:ShuttleA
  STATUS Landed Earth
  POS -80.6745310 28.5185520
  HEADING 100.01
  PRPLEVEL 0:1.000 1:1.000
  NAVFREQ 0 0
  XPDR 0
  PODANGLE 0.0000 0.0000
  DOCKSTATE 0 0.0000
  AIRLOCK 0 0.0000
  GEAR 0 0.0000
  PAYLOAD MASS 0.0 0
END
h2:ShuttleA
  STATUS Landed Earth
  POS -80.6745310 28.5183920
  HEADING 100.01
  PRPLEVEL 0:1.000 1:1.000
  NAVFREQ 0 0
  XPDR 0
  PODANGLE 0.0000 0.0000
  DOCKSTATE 0 0.0000
  AIRLOCK 0 0.0000
  GEAR 0 0.0000
  PAYLOAD MASS 4.8 0
END
Now when I run a scenario like;

Code:
BEGIN_SHIPS
ISS:ProjectAlpha_ISS
  STATUS Orbiting Earth
  RPOS -4400141.21 -4110744.11 -3038014.74
  RVEL 3927.893 662.267 -6572.756
  AROT 30.00 -0.00 50.00
  IDS 0:588 100 1:586 100 2:584 100 3:582 100 4:580 100
  NAVFREQ 0 0
  XPDR 466
END
Mir
  STATUS Orbiting Earth
  RPOS -3978121.93 -327101.07 -5348055.66
  RVEL 6206.306 -281.024 -4594.695
  AROT 0.00 -45.00 90.00
  IDS 0:540 100 1:542 100 2:544 100
  XPDR 482
END
Luna-OB1:Wheel
  STATUS Orbiting Moon
  RPOS 1180222.60 -1901467.59 -19.07
  RVEL 1257.568 780.556 0.010
  AROT 0.00 0.00 -123.77
  VROT 0.00 0.00 10.00
  IDS 0:560 100 1:564 100
  XPDR 494
END
GL-01:DeltaGlider
  STATUS Landed Earth
  BASE Cape Canaveral:1
  POS -80.6758964 28.5227640
  HEADING 150.00
  PRPLEVEL 0:1.000 1:1.000
  NAVFREQ 402 94 0 0
  XPDR 0
  GEAR 1 1.0000
END
SH-02:ShuttleA
  STATUS Landed Earth
  BASE Cape Canaveral:5
  POS -80.6745292 28.5197208
  HEADING 100.00
  PRPLEVEL 0:1.000 1:1.000
  NAVFREQ 0 0
  XPDR 0
  PODANGLE 0.0000 0.0000
  DOCKSTATE 0 0.0000
  AIRLOCK 0 0.0000
  GEAR 0 0.0000
  PAYLOAD MASS 0.0 0
END
I don't have a CTD.


So here is basically what I have;

OBJHANDLE hVessel; //Declared in .h

DLLCLBK void opcPostStep(double simt, double simdt, double mjd)
{


VESSEL * v = NULL;
VECTOR3 ofs = _V(0,0,0);

VECTOR3 Accel;
double maxG = 5;
double TmaxG = 20;


int cnter = oapiGetVesselCount();
int Counter = 0;

while ( Counter < cnter)
{
Counter++;


if (oapiGetVesselByIndex(Counter) == NULL) {break;}
else{
hVessel = oapiGetVesselByIndex(Counter);
}

v = oapiGetVesselInterface(hVessel); //here is problem with ISS
}
It stops on the line;
v = oapiGetVesselInterface(hVessel);

when I ran the debugger up to the above line, it said;

Code:
Unhandled exception at 0x004acb59 in orbiter.exe: 0xC0000005: Access violation reading location 0x00000004.
Anyone have any ideas?


-----Post Added-----


I was playing with scenarios and this works;
Code:
BEGIN_SHIPS
GL-01:DeltaGlider
  STATUS Landed Earth
  BASE Cape Canaveral:1
  POS -80.6758964 28.5227640
  HEADING 150.00
  PRPLEVEL 0:1.000 1:1.000
  NAVFREQ 402 94 0 0
  XPDR 0
  GEAR 1 1.0000
END
END_SHIPS
...and this doesn't

test:ShuttleA
STATUS Landed Earth
POS -80.6745314 28.5187120
HEADING 100.01
PRPLEVEL 0:0.997 1:1.000
NAVFREQ 0 0
XPDR 0
PODANGLE 0.0000 0.0000
DOCKSTATE 0 0.0000
AIRLOCK 0 0.0000
GEAR 0 0.0000
PAYLOAD MASS 0.0 0
END
Edit;

In the disassembly it breaks on this line;

013A3068 83 C4 04 add esp,4

-----Post Added-----

Thanks for everyone's help :P But I found the issue, I still don't know why it would work for one vessel, and not for the other, but I fixed it, it was a simple mistake. :chair:
 
Last edited:
Thanks for everyone's help :P But I found the issue, I still don't know why it would work for one vessel, and not for the other, but I fixed it, it was a simple mistake. :chair:
You didn't say what the mistake was, but I did see that you had a out-of-bounds problem in your loop. Was that it, because if not, you should fix that too ;)
 
Back
Top