1
0
mirror of synced 2024-11-05 02:59:16 +00:00

Fixed SimConnect reference not being held causing immediate disconnects

Fixed allRunning / partiallyRunning being swapped in engines.lua
This commit is contained in:
Mark van Renswoude 2017-06-11 20:06:55 +02:00
parent e279ed30d0
commit ed7f2f38b0
2 changed files with 14 additions and 3 deletions

View File

@ -112,9 +112,9 @@ RegisterFunction(
elseif runningCount == 0 then
SetState(context, 'allOff')
elseif runningCount == data.engineCount then
SetState(context, 'partiallyRunning')
else
SetState(context, 'allRunning')
else
SetState(context, 'partiallyRunning')
end
else
SetState(context, 'noEngines')

View File

@ -71,9 +71,11 @@ type
TFSXLEDFunctionWorker = class(TCustomLuaLEDFunctionWorker)
private
FDefinitions: TList<TFSXDefinition>;
FSimConnect: IFSXSimConnect;
protected
property Definitions: TList<TFSXDefinition> read FDefinitions;
protected
function GetSimConnect: IFSXSimConnect;
procedure AddDefinition(ADefinition: IFSXSimConnectDefinition; ADataHandler: IFSXSimConnectDataHandler);
procedure HandleData(AData: Pointer); virtual; abstract;
@ -434,13 +436,22 @@ begin
end;
function TFSXLEDFunctionWorker.GetSimConnect: IFSXSimConnect;
begin
if not Assigned(FSimConnect) then
FSimConnect := (Provider as TFSXLEDFunctionProvider).GetSimConnect;
Result := FSimConnect;
end;
procedure TFSXLEDFunctionWorker.AddDefinition(ADefinition: IFSXSimConnectDefinition; ADataHandler: IFSXSimConnectDataHandler);
var
definition: TFSXDefinition;
begin
definition.DataHandler := ADataHandler;
definition.ID := (Provider as TFSXLEDFunctionProvider).GetSimConnect.AddDefinition(ADefinition, ADataHandler);
definition.ID := GetSimConnect.AddDefinition(ADefinition, ADataHandler);
Definitions.Add(definition);
end;