summaryrefslogtreecommitdiff
path: root/app/bin/track.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2020-05-27 14:58:13 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2020-05-27 14:58:13 +0200
commit265d6934cd70a60228e7a11cfc000aff73dd4701 (patch)
tree610eb753fea70e7f407e751e22697fc8a1ec04bd /app/bin/track.c
parentbd8c21a35fd05fcbdaa95e4c0b7c94c3b97507b6 (diff)
parent359b557176b9bb2ff1aed2082641eed39c358d0d (diff)
Update upstream source from tag 'upstream/5.1.2a'
Update to upstream version '5.1.2a' with Debian dir 4d0d8239e41bb5de5dc968c2a5c6eb9c140bb2f3
Diffstat (limited to 'app/bin/track.c')
-rw-r--r--app/bin/track.c57
1 files changed, 49 insertions, 8 deletions
diff --git a/app/bin/track.c b/app/bin/track.c
index 22af292..0660d7d 100644
--- a/app/bin/track.c
+++ b/app/bin/track.c
@@ -106,7 +106,7 @@ static int suspendElevUpdates = FALSE;
static track_p * importTrack;
-EXPORT BOOL_T onTrackInSplit;
+EXPORT BOOL_T onTrackInSplit = FALSE;
static BOOL_T inDrawTracks;
@@ -650,8 +650,10 @@ EXPORT EPINX_T PickEndPoint( coOrd p, track_cp trk )
coOrd pos;
if (trk->endCnt <= 0)
return -1;
- if ( onTrackInSplit && trk->endCnt > 2 )
- return TurnoutPickEndPt( p, trk );
+ if ( onTrackInSplit && trk->endCnt > 2 ) {
+ if (GetTrkType(trk) != T_TURNOUT)
+ return TurnoutPickEndPt( p, trk );
+ }
d = FindDistance( p, trk->endPt[0].pos );
inx = 0;
for ( i=1; i<trk->endCnt; i++ ) {
@@ -721,6 +723,22 @@ EXPORT EPINX_T GetEndPtConnectedToMe( track_p trk, track_p me )
return -1;
}
+EXPORT EPINX_T GetNearestEndPtConnectedToMe( track_p trk, track_p me, coOrd pos) {
+ EPINX_T ep, found = -1;
+ DIST_T d = 10000;
+ DIST_T dd;
+ for (ep=0; ep<trk->endCnt; ep++) {
+ if (trk->endPt[ep].track == me) {
+ dd = FindDistance(pos,trk->endPt[ep].pos);
+ if (dd<d) {
+ found = ep;
+ d = dd;
+ }
+ }
+ }
+ return found;
+}
+
EXPORT void SetEndPts( track_p trk, EPINX_T cnt )
{
@@ -761,6 +779,8 @@ EXPORT void MoveTrack( track_p trk, coOrd orig )
EXPORT void RotateTrack( track_p trk, coOrd orig, ANGLE_T angle )
{
EPINX_T ep;
+ if ( trackCmds( trk->type )->rotate == NULL )
+ return;
for (ep=0; ep<trk->endCnt; ep++) {
Rotate( &trk->endPt[ep].pos, orig, angle );
trk->endPt[ep].angle = NormalizeAngle( trk->endPt[ep].angle + angle );
@@ -772,7 +792,7 @@ EXPORT void RotateTrack( track_p trk, coOrd orig, ANGLE_T angle )
EXPORT void RescaleTrack( track_p trk, FLOAT_T ratio, coOrd shift )
{
EPINX_T ep;
- if ( trackCmds( trk->type )->rotate == NULL )
+ if ( trackCmds( trk->type )->rescale == NULL )
return;
for (ep=0; ep<trk->endCnt; ep++) {
trk->endPt[ep].pos.x *= ratio;
@@ -872,6 +892,26 @@ EXPORT BOOL_T RebuildTrackSegs(
return FALSE;
}
+EXPORT BOOL_T ReplayTrackData(
+ track_p trk,
+ void * data,
+ long length)
+{
+ if (trackCmds(trk->type)->replayData)
+ return trackCmds(trk->type)->replayData(trk,data,length);
+ return FALSE;
+}
+
+EXPORT BOOL_T StoreTrackData(
+ track_p trk,
+ void ** data,
+ long * length)
+{
+ if (trackCmds(trk->type)->storeData)
+ return trackCmds(trk->type)->storeData(trk,data,length);
+ return FALSE;
+}
+
/*****************************************************************************
@@ -1676,8 +1716,8 @@ EXPORT void ConnectTracks( track_p trk0, EPINX_T inx0, track_p trk1, EPINX_T inx
LOG( log_track, 3, ( "ConnectTracks( T%d[%d] @ [%0.3f, %0.3f] = T%d[%d] @ [%0.3f %0.3f]\n", trk0->index, inx0, pos0.x, pos0.y, trk1->index, inx1, pos1.x, pos1.y ) )
d = FindDistance( pos0, pos1 );
a = NormalizeAngle( trk0->endPt[inx0].angle -
- trk1->endPt[inx1].angle + (180.0+connectAngle/2.0) );
- if (d > connectDistance || a > connectAngle || logTable(log_endPt).level>=1) {
+ trk1->endPt[inx1].angle + 180.0 );
+ if (d > connectDistance || (a > connectAngle && a < 360.0 - connectAngle) || (log_endPt>0 && logTable(log_endPt).level>=1)) {
#ifndef WINDOWS
LogPrintf( "connectTracks: T%d[%d] T%d[%d] d=%0.3f a=%0.3f\n %d ",
trk0->index, inx0, trk1->index, inx1, d, a, trk0->index );
@@ -1688,7 +1728,8 @@ LOG( log_track, 3, ( "ConnectTracks( T%d[%d] @ [%0.3f, %0.3f] = T%d[%d] @ [%0.3f
PrintEndPt( logFile, trk1, 1 );???*/
LogPrintf("\n");
#endif
- NoticeMessage( MSG_CONNECT_TRK, _("Continue"), NULL, trk0->index, inx0, trk1->index, inx1, d, a );
+ if (d > connectDistance || (a > connectAngle && a < 360.0 - connectAngle))
+ NoticeMessage( MSG_CONNECT_TRK, _("Continue"), NULL, trk0->index, inx0, trk1->index, inx1, d, a );
}
UndoModify( trk0 );
UndoModify( trk1 );
@@ -1888,7 +1929,7 @@ EXPORT BOOL_T TraverseTrack(
return TRUE;
if ( !trvTrk->trk )
return FALSE;
- ep = GetEndPtConnectedToMe( trvTrk->trk, oldTrk );
+ ep = GetNearestEndPtConnectedToMe( trvTrk->trk, oldTrk, trvTrk->pos );
if ( ep != -1 ) {
trvTrk->pos = GetTrkEndPos( trvTrk->trk, ep );
trvTrk->angle = NormalizeAngle( GetTrkEndAngle( trvTrk->trk, ep ) + 180.0 );