@@ -47,6 +47,10 @@ public float CenterOffsetComponent
4747 {
4848 get => VerticalTransfer ? CenterOffset . Y : CenterOffset . X ;
4949 }
50+ public float OffsetDiff
51+ {
52+ get => RemotelyControlled ? 2.8f : 1.4f ;
53+ }
5054 // Dynamic data
5155 public bool Forward ; // forward motion on
5256 public bool Reverse ; // reverse motion on
@@ -172,6 +176,18 @@ protected void InitializeOffsetsAndTrackNodes()
172176 /// Returns the Y angle to be compared.
173177 /// </summary>
174178 public override void ComputeTarget ( bool isForward )
179+ {
180+ if ( ! Continuous ) return ;
181+ if ( MultiPlayer . MPManager . IsMultiPlayer ( ) )
182+ {
183+ SubMessCode = SubMessageCode . GoToTarget ;
184+ MultiPlayer . MPManager . Notify ( new MultiPlayer . MSGMovingTbl ( Simulator . ActiveMovingTableIndex , Orts . MultiPlayer . MPManager . GetUserName ( ) , SubMessCode , isForward , OffsetPos ) . ToString ( ) ) ;
185+ }
186+ RemotelyControlled = false ;
187+ GeneralComputeTarget ( isForward ) ;
188+ }
189+
190+ public void GeneralComputeTarget ( bool isForward )
175191 {
176192 if ( ! Continuous ) return ;
177193 Continuous = false ;
@@ -180,7 +196,6 @@ public override void ComputeTarget(bool isForward)
180196 Reverse = ! isForward ;
181197 if ( Forward )
182198 {
183- var offsetDiff = 1.4f ;
184199 Connected = false ;
185200 if ( Offsets . Count <= 0 )
186201 {
@@ -194,7 +209,7 @@ public override void ComputeTarget(bool isForward)
194209 if ( MyTrackNodesIndex [ iOffset ] != - 1 && MyTrVectorSectionsIndex [ iOffset ] != - 1 )
195210 {
196211 var thisOffsetDiff = Offsets [ iOffset ] - OffsetPos ;
197- if ( thisOffsetDiff < offsetDiff && thisOffsetDiff >= 0 )
212+ if ( thisOffsetDiff < OffsetDiff && thisOffsetDiff >= 0 )
198213 {
199214 ConnectedTarget = iOffset ;
200215 break ;
@@ -211,7 +226,6 @@ public override void ComputeTarget(bool isForward)
211226 }
212227 else if ( Reverse )
213228 {
214- var offsetDiff = - 1.4f ;
215229 Connected = false ;
216230 if ( Offsets . Count <= 0 )
217231 {
@@ -225,7 +239,7 @@ public override void ComputeTarget(bool isForward)
225239 if ( MyTrackNodesIndex [ iOffset ] != - 1 && MyTrVectorSectionsIndex [ iOffset ] != - 1 )
226240 {
227241 var thisOffsetDiff = Offsets [ iOffset ] - OffsetPos ;
228- if ( thisOffsetDiff > offsetDiff && thisOffsetDiff <= 0 )
242+ if ( thisOffsetDiff > - OffsetDiff && thisOffsetDiff <= 0 )
229243 {
230244 ConnectedTarget = iOffset ;
231245 break ;
@@ -241,6 +255,7 @@ public override void ComputeTarget(bool isForward)
241255 }
242256
243257 }
258+ RemotelyControlled = false ;
244259 return ;
245260 }
246261
@@ -250,6 +265,28 @@ public override void ComputeTarget(bool isForward)
250265 /// </summary>
251266 ///
252267 public override void StartContinuous ( bool isForward )
268+ {
269+ if ( TrainsOnMovingTable . Count == 1 && TrainsOnMovingTable [ 0 ] . FrontOnBoard && TrainsOnMovingTable [ 0 ] . BackOnBoard )
270+ {
271+ // Preparing for rotation
272+ var train = TrainsOnMovingTable [ 0 ] . Train ;
273+ if ( Math . Abs ( train . SpeedMpS ) > 0.1 || ( train . LeadLocomotiveIndex != - 1 && ( train . LeadLocomotive . ThrottlePercent >= 1 || train . TrainType != Train . TRAINTYPE . REMOTE && ! ( train . LeadLocomotive . Direction == Direction . N
274+ || Math . Abs ( train . MUReverserPercent ) <= 1 ) ) ) || ( train . ControlMode != Train . TRAIN_CONTROL . MANUAL && train . ControlMode != Train . TRAIN_CONTROL . TURNTABLE &&
275+ train . ControlMode != Train . TRAIN_CONTROL . EXPLORER && train . ControlMode != Train . TRAIN_CONTROL . UNDEFINED ) )
276+ {
277+ if ( SendNotifications ) Simulator . Confirmer . Warning ( Simulator . Catalog . GetStringFmt ( "Rotation can't start: check throttle, speed, direction and control mode" ) ) ;
278+ return ;
279+ }
280+ }
281+ if ( MultiPlayer . MPManager . IsMultiPlayer ( ) )
282+ {
283+ SubMessCode = SubMessageCode . StartingContinuous ;
284+ MultiPlayer . MPManager . Notify ( new MultiPlayer . MSGMovingTbl ( Simulator . ActiveMovingTableIndex , Orts . MultiPlayer . MPManager . GetUserName ( ) , SubMessCode , isForward , OffsetPos ) . ToString ( ) ) ;
285+ }
286+ GeneralStartContinuous ( isForward ) ;
287+ }
288+
289+ public void GeneralStartContinuous ( bool isForward )
253290 {
254291 if ( TrainsOnMovingTable . Count > 1 || ( TrainsOnMovingTable . Count == 1 && TrainsOnMovingTable [ 0 ] . FrontOnBoard ^ TrainsOnMovingTable [ 0 ] . BackOnBoard ) )
255292 {
@@ -263,13 +300,6 @@ public override void StartContinuous(bool isForward)
263300 {
264301 // Preparing for transfer
265302 var train = TrainsOnMovingTable [ 0 ] . Train ;
266- if ( Math . Abs ( train . SpeedMpS ) > 0.1 || ( train . LeadLocomotiveIndex != - 1 && ( train . LeadLocomotive . ThrottlePercent >= 1 || ! ( train . LeadLocomotive . Direction == Direction . N
267- || Math . Abs ( train . MUReverserPercent ) <= 1 ) ) ) || ( train . ControlMode != Train . TRAIN_CONTROL . MANUAL && train . ControlMode != Train . TRAIN_CONTROL . TURNTABLE &&
268- train . ControlMode != Train . TRAIN_CONTROL . EXPLORER && train . ControlMode != Train . TRAIN_CONTROL . UNDEFINED ) )
269- {
270- Simulator . Confirmer . Warning ( Simulator . Catalog . GetStringFmt ( "Transfer can't start: check throttle, speed, direction and control mode" ) ) ;
271- return ;
272- }
273303 if ( train . ControlMode == Train . TRAIN_CONTROL . MANUAL || train . ControlMode == Train . TRAIN_CONTROL . EXPLORER || train . ControlMode == Train . TRAIN_CONTROL . UNDEFINED )
274304 {
275305 SaveConnected = Connected ^ ! MyTrackNodesOrientation [ ConnectedTrackEnd ] ;
0 commit comments