Changeset 108 for trunk


Ignore:
Timestamp:
Oct 4, 2022, 4:31:22 PM (2 years ago)
Author:
chronos
Message:
  • Fixed: Exception in calculating grabbed train direction.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UEngine.pas

    r107 r108  
    187187    CarriageCountVisible: Boolean;
    188188    TerminalCountVisible: Boolean;
    189     GrabbedTrainLastTrackPosition: TTrackPosition;
     189    LastGrabbedTrainTrackPosition: TTrackPosition;
    190190    GrabbedTrainDirection: Integer;
     191    LastGrabbedTrain: TMetroTrain;
    191192    function GetServedDaysCount: Integer;
    192193    procedure ResizeView(Force: Boolean);
     
    27422743      Angle := Vector.GetAngle;
    27432744
    2744       if TrackPosition.GetTrackPosition >
    2745         GrabbedTrainLastTrackPosition.GetTrackPosition then
    2746           GrabbedTrainDirection := 1
    2747       else
    2748       if TrackPosition.GetTrackPosition <
    2749         GrabbedTrainLastTrackPosition.GetTrackPosition then
    2750         GrabbedTrainDirection := -1;
    2751 
    2752       GrabbedTrainLastTrackPosition := TrackPosition;
     2745      if Assigned(LastGrabbedTrain) then begin
     2746        if TrackPosition.GetTrackPosition >
     2747          LastGrabbedTrainTrackPosition.GetTrackPosition then
     2748            GrabbedTrainDirection := 1
     2749        else
     2750        if TrackPosition.GetTrackPosition <
     2751          LastGrabbedTrainTrackPosition.GetTrackPosition then
     2752          GrabbedTrainDirection := -1;
     2753      end else GrabbedTrainDirection := 1;
     2754
     2755      LastGrabbedTrain := SelectedTrain;
     2756      LastGrabbedTrainTrackPosition := TrackPosition;
    27532757    end;
    27542758    FocusedTrack.Free;
     
    30033007        end;
    30043008        FocusedTrack.Free;
     3009
     3010        LastGrabbedTrain := nil;
    30053011      end;
    30063012
Note: See TracChangeset for help on using the changeset viewer.