Skip to content

Commit 4a5484e

Browse files
committed
Fixed static consists without a lead locomotive not appearing in Map window
1 parent 9b0470a commit 4a5484e

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

Source/RunActivity/Viewer3D/Map/MapForm.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ private void DrawTrains(Graphics g, PointF scaledA, PointF scaledB)
497497

498498
selectedTrainList.Clear();
499499

500-
if (simulator.TimetableMode)
500+
/*if (simulator.TimetableMode)
501501
{
502502
// Add the player's train...
503503
if (simulator.PlayerLocomotive.Train is AITrain)
@@ -508,10 +508,10 @@ private void DrawTrains(Graphics g, PointF scaledA, PointF scaledB)
508508
selectedTrainList.Add(train);
509509
}
510510
else
511-
{
511+
{*/
512512
foreach (var train in simulator.Trains)
513513
selectedTrainList.Add(train);
514-
}
514+
/*}*/
515515

516516
foreach (var train in selectedTrainList)
517517
{
@@ -533,7 +533,7 @@ private void DrawTrains(Graphics g, PointF scaledA, PointF scaledB)
533533

534534
// Skip trains with no loco
535535
if (locoCar == null)
536-
continue;
536+
locoCar = train.Cars[0];
537537
}
538538
else
539539
continue;
@@ -544,8 +544,7 @@ private void DrawTrains(Graphics g, PointF scaledA, PointF scaledB)
544544
float y = mapCanvas.Height - (((loc.TileZ * 2048) + loc.Location.Z - subY) * yScale);
545545

546546
// If train out of view then skip it.
547-
if (x < -margin2
548-
|| y < -margin2)
547+
if (x < -margin2 || y < -margin2)
549548
continue;
550549

551550
DrawTrainPath(train, subX, subY, pathPen, g, scaledA, scaledB, pDist, mDist);
@@ -574,7 +573,7 @@ private void DrawTrains(Graphics g, PointF scaledA, PointF scaledB)
574573
Y = -25 + mapCanvas.Height - (((worldPos.TileZ * 2048) - subY + worldPos.Location.Z) * yScale)
575574
};
576575
if (showTrainLabelsCheckbox.Checked)
577-
DrawTrainLabels(g, train, trainName, locoCar, scaledTrain);
576+
DrawTrainLabels(g, train, trainName, scaledTrain);
578577
}
579578
}
580579

@@ -603,7 +602,7 @@ private void DrawCar(Graphics g, Train train, TrainCar car, TrainCar locoCar, fl
603602
if (x < -margin || y < -margin)
604603
return;
605604

606-
t.Move(-car.CarLengthM + (1 / xScale)); // Move from front of car to rear less 1 pixel to create a visible gap
605+
t.Move(-car.CarLengthM + (2 / xScale)); // Move from front of car to rear less 1 pixel to create a visible gap // TODO: investigate `(1 / xScale)` ==> `(2 / xScale)` car gap consequences
607606
scaledTrain.X = x; scaledTrain.Y = y;
608607
}
609608
else // Draw the train as 2 boxes of fixed size
@@ -673,19 +672,19 @@ private void SetTrainColor(Train t, TrainCar locoCar, TrainCar car)
673672

674673
if (t.TrainType == Train.TRAINTYPE.STATIC || (t.TrainType == Train.TRAINTYPE.AI && t.GetAIMovementState() == AITrain.AI_MOVEMENT_STATE.AI_STATIC))
675674
{
676-
trainPen.Color = Color.FromArgb(83, 237, 214);
675+
trainPen.Color = car is MSTSLocomotive ? Color.FromArgb(19, 185, 160) : Color.FromArgb(83, 237, 214);
677676
}
678677

679678
// Draw player train with loco in red
680679
if (t.TrainType == Train.TRAINTYPE.PLAYER && car == locoCar)
681680
trainPen.Color = Color.Red;
682681
}
683682

684-
private void DrawTrainLabels(Graphics g, Train t, string trainName, TrainCar firstCar, PointF scaledTrain)
683+
private void DrawTrainLabels(Graphics g, Train t, string trainName, PointF scaledTrain)
685684
{
686-
WorldPosition worldPos = firstCar.WorldPosition;
685+
/*WorldPosition worldPos = firstCar.WorldPosition;
687686
scaledTrain.X = ((worldPos.TileX * 2048) - subX + worldPos.Location.X) * xScale;
688-
scaledTrain.Y = -25 + mapCanvas.Height - (((worldPos.TileZ * 2048) - subY + worldPos.Location.Z) * yScale);
687+
scaledTrain.Y = -25 + mapCanvas.Height - (((worldPos.TileZ * 2048) - subY + worldPos.Location.Z) * yScale);*/
689688
if (showActiveTrainsRadio.Checked)
690689
{
691690
if (t is AITrain && MapDataProvider.IsActiveTrain(t as AITrain))

0 commit comments

Comments
 (0)