Skip to content

Commit 1fd7ff5

Browse files
committed
Automatic merge of T1.5.1-1004-g6fd841761e and 18 pull requests
- Pull request #799 at dfc715e: Consolidated wind simulation - Pull request #839 at d00beb9: First phase of https://blueprints.launchpad.net/or/+spec/additional-cruise-control-parameters - Pull request #876 at f92de76: docs: add source for documents previously on website to source Documentation folder - Pull request #882 at 8f695a4: Blueprint/train car operations UI window - Pull request #885 at 2728d6d: feat: Add notifications to Menu - Pull request #891 at 9a1d6b2: Auto save - Pull request #892 at 1f5ba4c: Signal Function OPP_SIG_ID_TRAINPATH - Pull request #896 at 5866028: First implementation of https://blueprints.launchpad.net/or/+spec/specific-sounds-for-ai-trains - Pull request #900 at c27f32d: DMI updates - Pull request #903 at 3e390b8: Downloading route content (Github, zip) - Pull request #912 at 359cfee: New Triple Valve Features Vol. 2 - Pull request #922 at abe2e52: Autopilot for timetable mode - Pull request #946 at 66f836c: Advanced track sounds - Pull request #949 at d29622b: Oil Burning Locomotive - Pull request #952 at b2af1f5: Investigation - Pulsing graphics part 1 - Pull request #953 at a519452: Fix Lights Crash on Corrupt Shapes - Pull request #954 at 84c2f4b: Add Support for Multiple Track Profiles - Pull request #956 at 6adc5a3: Map settings saved
20 parents 2b02db0 + 6fd8417 + dfc715e + d00beb9 + f92de76 + 8f695a4 + 2728d6d + 9a1d6b2 + 1f5ba4c + 5866028 + c27f32d + 3e390b8 + 359cfee + abe2e52 + 66f836c + d29622b + b2af1f5 + a519452 + 84c2f4b + 6adc5a3 commit 1fd7ff5

File tree

1 file changed

+29
-30
lines changed

1 file changed

+29
-30
lines changed

Source/RunActivity/Viewer3D/Map/MapDataProvider.cs

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -249,46 +249,45 @@ public float GetUnusedYLocation(float startX, float wantY, string name)
249249
var desiredPositionY = (int)(wantY / MapViewer.spacing); // The positionY of the ideal row for the text.
250250
var endX = startX + (name.Length * F.trainFont.Size);
251251

252-
if (endX < 0) // Out of drawing area
252+
if ((endX < 0) || // Out of drawing area
253+
(F.alignedTextY == null))
253254
return noFreeSlotFound;
254255

255256
var positionY = desiredPositionY;
256-
if (F.alignedTextY != null) {
257-
while (positionY >= 0 && positionY < F.alignedTextY.Length)
258-
{
259-
// If the line contains no text yet, put it there
260-
if (F.alignedTextNum[positionY] == 0)
261-
return SaveLabelLocation(startX, endX, positionY);
257+
while (positionY >= 0 && positionY < F.alignedTextY.Length)
258+
{
259+
// If the line contains no text yet, put it there
260+
if (F.alignedTextNum[positionY] == 0)
261+
return SaveLabelLocation(startX, endX, positionY);
262262

263-
var conflict = false;
263+
var conflict = false;
264264

265-
// Check if it intersects with any labels already in this row
266-
for (var col = 0; col < F.alignedTextNum[positionY]; col++)
265+
// Check if it intersects with any labels already in this row
266+
for (var col = 0; col < F.alignedTextNum[positionY]; col++)
267+
{
268+
var v = F.alignedTextY[positionY][col];
269+
//check conflict with a text, v.X is the start of the text, v.Y is the end of the text
270+
if (endX >= v.X && startX <= v.Y)
267271
{
268-
var v = F.alignedTextY[positionY][col];
269-
//check conflict with a text, v.X is the start of the text, v.Y is the end of the text
270-
if (endX >= v.X && startX <= v.Y)
271-
{
272-
conflict = true;
273-
break;
274-
}
272+
conflict = true;
273+
break;
275274
}
275+
}
276276

277-
if (conflict)
278-
{
279-
positionY--; // Try a different row: -1, -2, +2, +1
277+
if (conflict)
278+
{
279+
positionY--; // Try a different row: -1, -2, +2, +1
280280

281-
if (positionY - desiredPositionY <= -2) // Cannot move up (-ve Y), so try to move it down (+ve Y)
282-
positionY = desiredPositionY + 2; // Try +2 then +1
281+
if (positionY - desiredPositionY <= -2) // Cannot move up (-ve Y), so try to move it down (+ve Y)
282+
positionY = desiredPositionY + 2; // Try +2 then +1
283283

284-
if (positionY == desiredPositionY) // Back to original position again
285-
return noFreeSlotFound;
286-
}
287-
else
288-
{
289-
// Check that row has an unused column in its fixed size array
290-
return F.alignedTextNum[positionY] >= F.alignedTextY[positionY].Length ? noFreeSlotFound : SaveLabelLocation(startX, endX, positionY);
291-
}
284+
if (positionY == desiredPositionY) // Back to original position again
285+
return noFreeSlotFound;
286+
}
287+
else
288+
{
289+
// Check that row has an unused column in its fixed size array
290+
return F.alignedTextNum[positionY] >= F.alignedTextY[positionY].Length ? noFreeSlotFound : SaveLabelLocation(startX, endX, positionY);
292291
}
293292
}
294293
return noFreeSlotFound;

0 commit comments

Comments
 (0)