@@ -107,37 +107,14 @@ public RouteData(string routePath, MessageDelegate messageDelegate)
107
107
//sigcfgFile = null; // default initialization
108
108
}
109
109
110
- // read the activity location events and store them in the TrackDB.TrItemTable
110
+ // read the activity location events and add them to the TrackDB.TrItemTable
111
111
112
112
ActivityNames . Clear ( ) ;
113
113
var directory = System . IO . Path . Combine ( routePath , "ACTIVITIES" ) ;
114
114
if ( System . IO . Directory . Exists ( directory ) )
115
115
{
116
- // counting
117
- int cnt = 0 ;
118
-
119
- foreach ( var file in Directory . GetFiles ( directory , "*.act" ) )
120
- {
121
- try
122
- {
123
- var activityFile = new ActivityFile ( file ) ;
124
- Events events = activityFile . Tr_Activity . Tr_Activity_File . Events ;
125
- if ( events != null )
126
- {
127
- for ( int i = 0 ; i < events . EventList . Count ; i ++ )
128
- {
129
- if ( events . EventList [ i ] . GetType ( ) == typeof ( EventCategoryLocation ) )
130
- {
131
- cnt ++ ;
132
- }
133
- }
134
- }
135
- }
136
- catch { }
137
- }
138
-
139
- // adding
140
- uint index = 0 ;
116
+ int index = TrackDB . TrItemTable . Length ;
117
+ List < TrItem > eventItems = new List < TrItem > ( ) ;
141
118
foreach ( var file in Directory . GetFiles ( directory , "*.act" ) )
142
119
{
143
120
try
@@ -157,8 +134,8 @@ public RouteData(string routePath, MessageDelegate messageDelegate)
157
134
eventCategoryLocation . Outcomes . DisplayMessage ,
158
135
eventCategoryLocation . TileX , eventCategoryLocation . TileZ ,
159
136
eventCategoryLocation . X , 0 , eventCategoryLocation . Z ,
160
- index ) ;
161
- TrackDB . TrItemTable [ index ] = eventItem ;
137
+ ( uint ) index ) ;
138
+ eventItems . Add ( eventItem ) ;
162
139
index ++ ;
163
140
found = true ;
164
141
}
@@ -168,9 +145,18 @@ public RouteData(string routePath, MessageDelegate messageDelegate)
168
145
ActivityNames . Add ( activityFile . Tr_Activity . Tr_Activity_Header . Name ) ;
169
146
}
170
147
}
171
- catch { }
148
+ catch { /* just ignore activity files with problems */ }
172
149
}
173
150
151
+ // extend the track items array and append the event items
152
+ if ( eventItems . Count > 0 )
153
+ {
154
+ int oldSize = TrackDB . TrItemTable . Length ;
155
+ Array . Resize < TrItem > ( ref TrackDB . TrItemTable , index ) ;
156
+ int newSize = TrackDB . TrItemTable . Length ;
157
+ int eventSize = eventItems . Count ;
158
+ for ( int toIdx = oldSize , fromIdx = 0 ; toIdx < newSize && fromIdx < eventSize ; toIdx ++ , fromIdx ++ ) { TrackDB . TrItemTable [ toIdx ] = eventItems [ fromIdx ] ; }
159
+ }
174
160
}
175
161
}
176
162
0 commit comments