SDK Question Recompiling the LuaInterpreter error

dgatsoulis

ele2png user
Donator
Joined
Dec 2, 2009
Messages
1,924
Reaction score
340
Points
98
Location
Sparta
I want to add a couple of functions to the LuaInterpreter.dll that suit my needs for a challenge I am creating.

Before adding anything to the source files, I tried to recompile the vanilla ones that come with Orbiter 2010 P1, to see if I have the development environment setup properly.

But I am getting these warnings:

Code:
1>------ Build started: Project: LuaInterpreter, Configuration: Release Win32 ------
1>Copy interpreter header file to SDK include directory
1>        1 file(s) copied.
1>Compiling...
1>Interpreter.cpp
1>.\LuaInterpreter\Interpreter.cpp(243) : warning C4244: '=' : conversion from 'lua_Number' to 'float', possible loss of data
1>.\LuaInterpreter\Interpreter.cpp(246) : warning C4244: '=' : conversion from 'lua_Number' to 'float', possible loss of data
1>.\LuaInterpreter\Interpreter.cpp(249) : warning C4244: '=' : conversion from 'lua_Number' to 'float', possible loss of data
1>.\LuaInterpreter\Interpreter.cpp(252) : warning C4244: '=' : conversion from 'lua_Number' to 'float', possible loss of data
1>Linking...
1>   Creating library ..\..\..\..\Orbiter\LuaInterpreter.lib and object ..\..\..\..\Orbiter\LuaInterpreter.exp
1>Embedding manifest...
1>Build log was saved at "file://d:\Users\jim\Desktop\Orbiter\Orbitersdk\samples\LuaScript\LuaInterpreter\Release\BuildLog.htm"
1>LuaInterpreter - 0 error(s), 4 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

they correspond to these lines of code (which I haven't touched) in the Interpreter.cpp file (bold):

Code:
COLOUR4 Interpreter::lua_torgba (lua_State *L, int idx)
{
	COLOUR4 col = {0,0,0,0};
	lua_getfield (L, idx, "r");
	[B]if (lua_isnumber(L,-1)) col.r = lua_tonumber (L, -1);[/B]
	lua_pop (L,1);
	lua_getfield (L, idx, "g");
	[B]if (lua_isnumber(L,-1)) col.g = lua_tonumber (L, -1);[/B]
	lua_pop (L,1);
	lua_getfield (L, idx, "b");
	[B]if (lua_isnumber(L,-1)) col.b = lua_tonumber (L, -1);[/B]
	lua_pop (L,1);
	lua_getfield (L, idx, "a");
	[B]if (lua_isnumber(L,-1)) col.a = lua_tonumber (L, -1);[/B]
	lua_pop (L,1);
	return col;
}

When I run a scripted scenario with the recompiled dll (In the D3D9 client), I see no problems during the simulation, but when I exit I get this msg:

Untitled-1_zpsdxwqsp1t.jpg


And here are the contents of the log:
Code:
**** Orbiter.log
Build Aug 30 2010 [v.100830]
Timer precision: 6.98413e-008 sec
Found 0 joystick(s)
Module AscensionUltraConfigurator.dll  [Build 140705, API 100830]
Module AtlantisConfig.dll .... [Build 100830, API 100830]
Module AtmConfig.dll ......... [Build 100830, API 100830]
Module DGConfigurator.dll .... [Build 100830, API 100830]
Module TransX.dll ............ [Build 140205, API 100830]
Module TransX2.dll ........... [Build 140202, API 100830]
Module InterMFD55.dll ........ [Build 100826, API 100704]
---------------------------------------------------------------
>>> WARNING: Obsolete API function used: oapiRegisterMFDMode
At least one active module is accessing an obsolete interface function.
Addons which rely on obsolete functions may not be compatible with
future versions of Orbiter.
---------------------------------------------------------------
Module BurnTimeMFD.dll ....... [Build 140205, API 100830]
Module AeroBrakeMFD.dll ...... [Build ******, API 100830]
Module ExtMFD.dll ............ [Build 100830, API 100830]
Module ScnEditor.dll ......... [Build 100830, API 100830]
Module D3D9Client.dll ........ [Build 130712, API 100830]
Module OrbiterSound.dll ...... [Build 121120, API 100830]
Module baseland.dll .......... [Build 120512, API 100830]

**** Creating simulation session
D3D9Client: [DirectX 9 Initialized]
D3D9Client: Sytem has XNA math support
D3D9Client: [3DDevice Initialized]
D3D9Client: [Compiling Effects for Shader Model 3.0]
D3D9Client: [Loading Stars]
D3D9Client: [Loading Constellations]
D3D9Client: [D3D9Client Initialized]
Module Sun.dll ............... [Build 100830, API 100830]
VSOP87(E) Sun: Precision 1e-006, Terms 554/6634
Module Mercury.dll ........... [Build 100830, API 100830]
VSOP87(B) Mercury: Precision 1e-005, Terms 167/7123
Module Venus.dll ............. [Build 100830, API 100830]
Module VenusAtm2006.dll ...... [Build 100830, API 100830]
VSOP87(B) Venus: Precision 1e-005, Terms 79/1710
Module Earth.dll ............. [Build 100830, API 100830]
Module EarthAtmJ71G.dll ...... [Build 100830, API 100830]
VSOP87(B) Earth: Precision 1e-008, Terms 2564/2564
Module Moon.dll .............. [Build 100830, API 100830]
ELP82: Precision 1e-005, Terms 116/829
Module Mars.dll .............. [Build 100830, API 100830]
Module MarsAtm2006.dll ....... [Build 100830, API 100830]
VSOP87(B) Mars: Precision 1e-005, Terms 405/6400
Module Phobos.dll ............ [Build ******, API 060425]
Module Deimos.dll ............ [Build ******, API 060425]
Module Galsat.dll ............ [Build 100217, API 100215]
Module Jupiter.dll ........... [Build 100830, API 100830]
VSOP87(B) Jupiter: Precision 1e-006, Terms 1624/3625
Module Io.dll ................ [Build 100217, API 100215]
Module Europa.dll ............ [Build 100217, API 100215]
Module Ganymede.dll .......... [Build 100217, API 100215]
Module Callisto.dll .......... [Build 100217, API 100215]
Module Satsat.dll ............ [Build 100215, API 100212]
Module Saturn.dll ............ [Build 100830, API 100830]
VSOP87(B) Saturn: Precision 1e-006, Terms 2904/6365
Module Mimas.dll ............. [Build 100215, API 100212]
SATSAT Mimas: Terms 113
Module Enceladus.dll ......... [Build 100215, API 100212]
SATSAT Enceladus: Terms 33
Module Tethys.dll ............ [Build 100215, API 100212]
SATSAT Tethys: Terms 101
Module Dione.dll ............. [Build 100215, API 100212]
SATSAT Dione: Terms 59
Module Rhea.dll .............. [Build 100215, API 100212]
SATSAT Rhea: Terms 68
Module Titan.dll ............. [Build 100215, API 100212]
SATSAT Titan: Terms 100
Module Iapetus.dll ........... [Build 100215, API 100212]
SATSAT Iapetus: Terms 605
Module Uranus.dll ............ [Build 100830, API 100830]
VSOP87(B) Uranus: Precision 1e-006, Terms 1827/5269
Module Miranda.dll ........... [Build ******, API 060425]
Module Ariel.dll ............. [Build ******, API 060425]
Module Umbriel.dll ........... [Build ******, API 060425]
Module Titania.dll ........... [Build ******, API 060425]
Module Oberon.dll ............ [Build ******, API 060425]
Module Neptune.dll ........... [Build 100830, API 100830]
VSOP87(B) Neptune: Precision 1e-006, Terms 391/2024
Finished initialising world
Module DeltaGliderIV.dll ..... [Build 140107, API 100830]
Finished initialising status
Finished initialising camera
Finished initialising panels
---------------------------------------------------------------
>>> ERROR: Could not load vessel module: AscensionUltra
>>> [Vessel::LoadModule | .\Vessel.cpp | 5442]
---------------------------------------------------------------
Finished setting up render state
Module LuaInline.dll ......... [Build 100830, API 100830]
D3D9Client: [Scene Initialized]
Orbiter Version 100830
D3D9Client Build [Jul 12 2013]
Exception Code=0xC0000005, Address=0x77B56626
EAX=0x00000000 EBX=0x466D0001 ECX=0x00000137 EDX=0x00000000 ESI=0x09871570 EDI=0x466D0000 EBP=0x009FF7AC ESP=0x009FF778 EIP=0x77B56626
D:\Windows\system32\ntdll.dll EntryPoint=0x00000000, Base=0x77AF0000, Size=1212416
GraphicsClient::RenderWndProc(hWnd=0x16081C, uMsg=2, wParam=0, lParam=0)
!!! Abnormal Program Termination !!!

with the Inline client, I get this when I exit Orbiter:
Untitled-3_zpslbefgeer.jpg

with these "problem details"
Code:
Problem signature:
  Problem Event Name:	APPCRASH
  Application Name:	orbiter.exe
  Application Version:	0.0.0.0
  Application Timestamp:	4c7b0d0d
  Fault Module Name:	ntdll.dll
  Fault Module Version:	6.0.6002.18541
  Fault Module Timestamp:	4ec3e3d5
  Exception Code:	c0000005
  Exception Offset:	00066626
  OS Version:	6.0.6002.2.2.0.256.1
  Locale ID:	1033
  Additional Information 1:	fd00
  Additional Information 2:	ea6f5fe8924aaa756324d57f87834160
  Additional Information 3:	fd00
  Additional Information 4:	ea6f5fe8924aaa756324d57f87834160

Read our privacy statement:
  http://go.microsoft.com/fwlink/?linkid=50163&clcid=0x0409

And these contents on Orbiter.log
Code:
**** Orbiter.log
Build Aug 30 2010 [v.100830]
Timer precision: 6.98413e-008 sec
Found 0 joystick(s)
Devices enumerated: 6
Devices accepted: 5
==> RGB Emulation
==> Direct3D HAL
==> Direct3D T&L HAL
==> Direct3D HAL (NVIDIA GeForce GT 620)
==> Direct3D T&L HAL (NVIDIA GeForce GT 620)
Module AscensionUltraConfigurator.dll  [Build 140705, API 100830]
Module AtlantisConfig.dll .... [Build 100830, API 100830]
Module AtmConfig.dll ......... [Build 100830, API 100830]
Module DGConfigurator.dll .... [Build 100830, API 100830]
Module TransX.dll ............ [Build 140205, API 100830]
Module TransX2.dll ........... [Build 140202, API 100830]
Module InterMFD55.dll ........ [Build 100826, API 100704]
---------------------------------------------------------------
>>> WARNING: Obsolete API function used: oapiRegisterMFDMode
At least one active module is accessing an obsolete interface function.
Addons which rely on obsolete functions may not be compatible with
future versions of Orbiter.
---------------------------------------------------------------
Module AeroBrakeMFD.dll ...... [Build ******, API 100830]
Module BurnTimeMFD.dll ....... [Build 140205, API 100830]
Module OrbiterSound.dll ...... [Build 121120, API 100830]
Module ExtMFD.dll ............ [Build 100830, API 100830]
Module ScnEditor.dll ......... [Build 100830, API 100830]
Module CameraMFD.dll [API v.060425]
Module videnie.dll ........... [Build 110912, API 100830]
Module SlaveMFD.dll .......... [Build 140309, API 100830]

**** Creating simulation session
DirectDraw interface OK
Direct3D interface OK
Graphics: Viewport: Window 1274 x 694 x 32
Graphics: Hardware T&L capability: Yes
Graphics: Z-buffer depth: 32 bit
Graphics: Active lights supported: 8
Loading 15382 records from star database
Module Sun.dll ............... [Build 100830, API 100830]
VSOP87(E) Sun: Precision 1e-006, Terms 554/6634
Module Mercury.dll ........... [Build 100830, API 100830]
VSOP87(B) Mercury: Precision 1e-005, Terms 167/7123
Module Venus.dll ............. [Build 100830, API 100830]
Module VenusAtm2006.dll ...... [Build 100830, API 100830]
VSOP87(B) Venus: Precision 1e-005, Terms 79/1710
Module Earth.dll ............. [Build 100830, API 100830]
Module EarthAtmJ71G.dll ...... [Build 100830, API 100830]
VSOP87(B) Earth: Precision 1e-008, Terms 2564/2564
Module Moon.dll .............. [Build 100830, API 100830]
ELP82: Precision 1e-005, Terms 116/829
Module Mars.dll .............. [Build 100830, API 100830]
Module MarsAtm2006.dll ....... [Build 100830, API 100830]
VSOP87(B) Mars: Precision 1e-005, Terms 405/6400
Module Phobos.dll ............ [Build ******, API 060425]
Module Deimos.dll ............ [Build ******, API 060425]
Module Galsat.dll ............ [Build 100217, API 100215]
Module Jupiter.dll ........... [Build 100830, API 100830]
VSOP87(B) Jupiter: Precision 1e-006, Terms 1624/3625
Module Io.dll ................ [Build 100217, API 100215]
Module Europa.dll ............ [Build 100217, API 100215]
Module Ganymede.dll .......... [Build 100217, API 100215]
Module Callisto.dll .......... [Build 100217, API 100215]
Module Satsat.dll ............ [Build 100215, API 100212]
Module Saturn.dll ............ [Build 100830, API 100830]
VSOP87(B) Saturn: Precision 1e-006, Terms 2904/6365
Module Mimas.dll ............. [Build 100215, API 100212]
SATSAT Mimas: Terms 113
Module Enceladus.dll ......... [Build 100215, API 100212]
SATSAT Enceladus: Terms 33
Module Tethys.dll ............ [Build 100215, API 100212]
SATSAT Tethys: Terms 101
Module Dione.dll ............. [Build 100215, API 100212]
SATSAT Dione: Terms 59
Module Rhea.dll .............. [Build 100215, API 100212]
SATSAT Rhea: Terms 68
Module Titan.dll ............. [Build 100215, API 100212]
SATSAT Titan: Terms 100
Module Iapetus.dll ........... [Build 100215, API 100212]
SATSAT Iapetus: Terms 605
Module Uranus.dll ............ [Build 100830, API 100830]
VSOP87(B) Uranus: Precision 1e-006, Terms 1827/5269
Module Miranda.dll ........... [Build ******, API 060425]
Module Ariel.dll ............. [Build ******, API 060425]
Module Umbriel.dll ........... [Build ******, API 060425]
Module Titania.dll ........... [Build ******, API 060425]
Module Oberon.dll ............ [Build ******, API 060425]
Module Neptune.dll ........... [Build 100830, API 100830]
VSOP87(B) Neptune: Precision 1e-006, Terms 391/2024
Finished initialising world
Module DeltaGliderIV.dll ..... [Build 140107, API 100830]
Finished initialising status
Finished initialising camera
Finished initialising panels
---------------------------------------------------------------
>>> ERROR: Could not load vessel module: AscensionUltra
>>> [Vessel::LoadModule | .\Vessel.cpp | 5442]
---------------------------------------------------------------
Finished setting up render state
Module LuaInline.dll ......... [Build 100830, API 100830]

At first I thought it was the AscensionUltra creating a problem, but I've also tested it on a clean installation with the same results.

Any ideas on how to fix this? I am mainly interested in the D3D9 client, since my aged PC gets a much better frame-rate.
 
Last edited:

jedidia

shoemaker without legs
Addon Developer
Joined
Mar 19, 2008
Messages
10,874
Reaction score
2,129
Points
203
Location
between the planets
The warnings are pretty straightforward: Number is of type double, and you are implicitly casting it to float. The compiler is warning you that there is a loss in precision of which you might not be aware.

So, the compiler is merely telling you that it cannot clearly deduct if that was your intent. This won't lead to problems, unless you really do need the double precision and weren't aware that you are casting to float.
If you don't need the precision and it was your full intent to cast to float, you can leave the warnings. Or, if you prefer your code to compile without warning, you can cast explicitly:

Code:
if (lua_isnumber(L,-1)) col.r = (float) lua_tonumber (L, -1);

In this case the compiler knows that you are fully aware of what you're doing and will not throw a warning.

I don't know where the error on exit comes from, but I'd consider it impossible that it's got anything to do with this.
 
Last edited:

martins

Orbiter Founder
Orbiter Founder
Joined
Mar 31, 2008
Messages
2,448
Reaction score
462
Points
83
Website
orbit.medphys.ucl.ac.uk
Did you try to compile the entire Lua subsystem, or just LuaInterpreter? From your logfile I see that LuaInline still has the original build date. This could be a problem, since the dependent modules (LuaInline, LuaMFD and LuaConsole) call routines in LuaInterpreter, so they may have gone out of sync.

It's best to recompile the entire subsystem. Just load the LuaScript solution file and rebuild. LuaInterpreter should already be registered as a dependency for the other modules.

If that doesn't help, you could build debug versions of the Lua modules and try to figure out if you can locate the problem. Since it occurs on exit, a good starting point would be the destructors of the various Lua modules.

Also make sure that your recompiled LuaInterpreter.dll and LuaInline.dll modules actually end up in the Orbiter root directory. I can't remember if the project files do that automatically, or if you have to copy the files by hand. LuaMFD.dll and LuaConsole.dll on the other hand should end up in Modules/Plugin.

Does Lua actually work with your recompiled LuaInterpreter.dll? It's curious that problems should only arise on exit.
 

dgatsoulis

ele2png user
Donator
Joined
Dec 2, 2009
Messages
1,924
Reaction score
340
Points
98
Location
Sparta
Thanks for replying martin.
I recompiled just the interpreter; I'll try recompiling the whole project and see how that works.
Lua works fine with just the recompiled LuaInterpreter.dll. No problems during the simulation, just the problem on exit.

---------- Post added at 22:57 ---------- Previous post was at 22:02 ----------

Before compiling the whole project, I tried just the LuaInline and the LuaInterpreter. The problem on exit is gone. Everything seems to be working properly.
Just to be on the safe side, I'll also recompile the whole project, after I've added a couple of things in the interpreter, that I need for a challenge I am making.

NonsphericalGravityEnabled() and oapiOpenMFD (mode, mfd)

What I want to do, is to check whether the NonsphericalGravity is enabled on scenario start and to be able to turn off the left and right MFDs via the script.

Thanks for the help!
:tiphat:
 
Top