Elvas Tower: New route load error in menu since rev #1769 - Elvas Tower

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

New route load error in menu since rev #1769 Rate Topic: -----

#1 User is offline   BB25187 

  • Fireman
  • Group: Status: Active Member
  • Posts: 138
  • Joined: 09-December 12
  • Gender:Male
  • Simulator:OpenRails MSTS
  • Country:

Posted 05 October 2013 - 08:53 AM

Hi all,

Since revision 1769, I have noticed new errors in the route menu:

http://img268.imageshack.us/img268/1306/1tn6.jpg

Those erros were not raised with revision #1768. They are caused by routes which are "stored" using TrainStore. Thus the folder is present, but it does not contain a TRK file. I don't know if this change was made on purpose, but I don't think that those errors are very useful. This can be fixed by adding a few more conditions in the file Source\ORTS\Menu\Routes.cs. The code of the GetRoutes method is as follows:

        public static List<Route> GetRoutes(Folder folder)
        {
            var routes = new List<Route>();
            var directory = System.IO.Path.Combine(folder.Path, "ROUTES");
            if (Directory.Exists(directory))
            {
                foreach (var routeDirectory in Directory.GetDirectories(directory))
                {
                    try
                    {
                        routes.Add(new Route(routeDirectory));
                    }
                    catch { }
                }
            }
            return routes;
        }


It can be replaced by:

        public static List<Route> GetRoutes(Folder folder)
        {
            var routes = new List<Route>();
            var directory = System.IO.Path.Combine(folder.Path, "ROUTES");
            if (Directory.Exists(directory))
            {
                foreach (var routeDirectory in Directory.GetDirectories(directory))
                {
                    // Test if route can be loaded before adding it to the menu!
                    Route route_seen = new Route(routeDirectory);
                    if (route_seen != null && route_seen.Name != null && 
                        !route_seen.Name.Contains("<load error:") &&
                        !route_seen.Name.Contains("<missing:"))
                    {
                        try
                        {
                            routes.Add(route_seen);
                        }
                        catch { }
                    }
                }
            }
            return routes;
        }


I can log a bug and provide a SVN patch if you think it is useful.

Regards
Vincent

#2 User is offline   PA1930 

  • Foreman Of Engines
  • Group: Status: Contributing Member
  • Posts: 782
  • Joined: 16-December 12
  • Gender:Male
  • Simulator:-
  • Country:

Posted 05 October 2013 - 09:38 AM

I also noticed this recently. A fix for this should be nice. :sweatingbullets:

#3 User is online   James Ross 

  • Open Rails Developer
  • Group: Status: Elite Member
  • Posts: 5,491
  • Joined: 30-June 10
  • Gender:Not Telling
  • Simulator:Open Rails
  • Country:

Posted 06 October 2013 - 09:25 AM

View PostBB25187, on 05 October 2013 - 08:53 AM, said:

Those erros were not raised with revision #1768. They are caused by routes which are "stored" using TrainStore. Thus the folder is present, but it does not contain a TRK file. I don't know if this change was made on purpose, but I don't think that those errors are very useful.


The change was intentional, in so much as all problems with loading the info about a route directory are shown. An exception can be made for TrainStore "stored" routes if the exact nature of its modifications can be documented. I do not want to hide genuine errors with routes if at all possible.

View PostBB25187, on 05 October 2013 - 08:53 AM, said:

                    // Test if route can be loaded before adding it to the menu!
                    Route route_seen = new Route(routeDirectory);
                    if (route_seen != null && route_seen.Name != null && 
                        !route_seen.Name.Contains("<load error:") &&
                        !route_seen.Name.Contains("<missing:"))


Really, this isn't the way to do it. The constructor for Route should throw an exception if the route is stored and the existing code you copied will do the right thing.

#4 User is offline   BB25187 

  • Fireman
  • Group: Status: Active Member
  • Posts: 138
  • Joined: 09-December 12
  • Gender:Male
  • Simulator:OpenRails MSTS
  • Country:

Posted 06 October 2013 - 11:17 AM

Hi,

Thanks for your reply. If this was done on purpose, then OK, the code does the right thing!

View PostJames Ross, on 06 October 2013 - 09:25 AM, said:

An exception can be made for TrainStore "stored" routes if the exact nature of its modifications can be documented. I do not want to hide genuine errors with routes if at all possible.


The folder of a fully stored route:
- Does not contain a TRK file
- Has empty ACTIVITIES and SERVICES sub-folders
Besides this, it is similar to a legal non-stored route.

View PostJames Ross, on 06 October 2013 - 09:25 AM, said:

Really, this isn't the way to do it. The constructor for Route should throw an exception if the route is stored and the existing code you copied will do the right thing.


I agree that those errors could make sense. The point is that dumping them in the menu is annoying, especially for the stored routes. I am wondering if they wouldn't be better reported in a log file (the usual log file is not yet created when running the start menu), as any other errors and warnings?
This is the reason why I will use my modified code until further modifications: even if it is not safe in any conditions, it better meets my personal expectations.

Note that I made quick tests with an unmodified revision #1799:
- If the TRK file is present and totally empty, then an error is reported
- If the TRK file is present and only contains the route ID and route name, or if it only contains the SIMISA@@@@@@@@@@JINX0r0t______ header, then no error is dumped at all, and the route is hidden in the menu.
So, even with the current checks, the behavior is not always consistent, and some corruptions in the installation of the route may not be reported as errors...

Regards

#5 User is offline   roeter 

  • Vice President
  • Group: Status: Elite Member
  • Posts: 2,426
  • Joined: 25-October 11
  • Gender:Male
  • Country:

Posted 06 October 2013 - 01:02 PM

What doesn't help in this is that all the load errors are listed first, before any valid route entries.
If the list order could be changed such that the valid routes are on top, the information on load errors could be usefull but would not be such a nuisance. This could be achieved by just starting the error lines with a character that comes after normal letters, instead of the one used now which comes before. Curly braces ({ }) instead of (< >) would do the trick nicely.

Regards,

Rob Roeterdink

#6 User is online   James Ross 

  • Open Rails Developer
  • Group: Status: Elite Member
  • Posts: 5,491
  • Joined: 30-June 10
  • Gender:Not Telling
  • Simulator:Open Rails
  • Country:

Posted 07 October 2013 - 12:54 PM

I have updated the logic in X.1804 so that it should hide stored routes (those with no TRK file at all).

View PostBB25187, on 06 October 2013 - 11:17 AM, said:

Note that I made quick tests with an unmodified revision #1799:
- If the TRK file is present and totally empty, then an error is reported
- If the TRK file is present and only contains the route ID and route name, or if it only contains the SIMISA@@@@@@@@@@JINX0r0t______ header, then no error is dumped at all, and the route is hidden in the menu.
So, even with the current checks, the behavior is not always consistent, and some corruptions in the installation of the route may not be reported as errors...


I could not reproduce your second issue at all; in all cases I tried, the route either appeared normally with a name, or as a <load error>. If you can still reproduce it with X.1804, please attach the TRK file and I'll investigate.

View Postroeter, on 06 October 2013 - 01:02 PM, said:

What doesn't help in this is that all the load errors are listed first, before any valid route entries.


As with log errors, I prefer to keep visibility high while the certainty is low. Now that stored routes should be properly hidden, I would be interested in any genuine errors that remain.

#7 User is offline   BB25187 

  • Fireman
  • Group: Status: Active Member
  • Posts: 138
  • Joined: 09-December 12
  • Gender:Male
  • Simulator:OpenRails MSTS
  • Country:

Posted 26 December 2013 - 06:15 AM

Hi James,

I hadn't much time during the past months to participate to the forum.
Thanks for the fix. Everything works fine now!

Regards

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users