Elvas Tower: Patch for Cab Views without Cab Controls - Elvas Tower

Jump to content

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

Patch for Cab Views without Cab Controls Rate Topic: -----

#1 User is offline   hytek1999 

  • Apprentice
  • Group: Status: Switchman
  • Posts: 19
  • Joined: 16-October 12
  • Gender:Male
  • Simulator:MSTS; ORTS
  • Country:

Posted 18 October 2013 - 07:42 PM

I noticed that the latest build is crashing when I try to run the Burrinjuck Railway Route with it's default locomotive. It looks like that cab view does not have any cab controls.

Here is a simple fix I created for dealing with cab views that do not have cab controls.

Index: MSTSLocomotive.cs
===================================================================
--- MSTSLocomotive.cs	(revision 1820)
+++ MSTSLocomotive.cs	(working copy)
@@ -2996,57 +2996,60 @@
                     var controlSortIndex = 1;  // Controls are drawn atop the cabview and in order they appear in the CVF file.
                     // This allows the segments of moving-scale meters to be hidden by covers (e.g. TGV-A)
                     CabViewControlRenderersList.Add(new List<CabViewControlRenderer>());
-                    foreach (CabViewControl cvc in cabView.CVFFile.CabViewControls)
+                    if (cabView.CVFFile.CabViewControls != null)
                     {
-                        controlSortIndex++;
-                        CVCDial dial = cvc as CVCDial;
-                        if (dial != null)
+                        foreach (CabViewControl cvc in cabView.CVFFile.CabViewControls)
                         {
-                            CabViewDialRenderer cvcr = new CabViewDialRenderer(viewer, car, dial, _Shader);
-                            cvcr.SortIndex = controlSortIndex;
-                            CabViewControlRenderersList[i].Add(cvcr);
-                            continue;
+                            controlSortIndex++;
+                            CVCDial dial = cvc as CVCDial;
+                            if (dial != null)
+                            {
+                                CabViewDialRenderer cvcr = new CabViewDialRenderer(viewer, car, dial, _Shader);
+                                cvcr.SortIndex = controlSortIndex;
+                                CabViewControlRenderersList[i].Add(cvcr);
+                                continue;
+                            }
+                            CVCGauge gauge = cvc as CVCGauge;
+                            if (gauge != null)
+                            {
+                                CabViewGaugeRenderer cvgr = new CabViewGaugeRenderer(viewer, car, gauge, _Shader);
+                                cvgr.SortIndex = controlSortIndex;
+                                CabViewControlRenderersList[i].Add(cvgr);
+                                continue;
+                            }
+                            CVCSignal asp = cvc as CVCSignal;
+                            if (asp != null)
+                            {
+                                CabViewDiscreteRenderer aspr = new CabViewDiscreteRenderer(viewer, car, asp, _Shader);
+                                aspr.SortIndex = controlSortIndex;
+                                CabViewControlRenderersList[i].Add(aspr);
+                                continue;
+                            }
+                            CVCMultiStateDisplay multi = cvc as CVCMultiStateDisplay;
+                            if (multi != null)
+                            {
+                                CabViewDiscreteRenderer mspr = new CabViewDiscreteRenderer(viewer, car, multi, _Shader);
+                                mspr.SortIndex = controlSortIndex;
+                                CabViewControlRenderersList[i].Add(mspr);
+                                continue;
+                            }
+                            CVCDiscrete disc = cvc as CVCDiscrete;
+                            if (disc != null)
+                            {
+                                CabViewDiscreteRenderer cvdr = new CabViewDiscreteRenderer(viewer, car, disc, _Shader);
+                                cvdr.SortIndex = controlSortIndex;
+                                CabViewControlRenderersList[i].Add(cvdr);
+                                continue;
+                            }
+                            CVCDigital digital = cvc as CVCDigital;
+                            if (digital != null)
+                            {
+                                CabViewDigitalRenderer cvdr = new CabViewDigitalRenderer(viewer, car, digital, _Shader);
+                                cvdr.SortIndex = controlSortIndex;
+                                CabViewControlRenderersList[i].Add(cvdr);
+                                continue;
+                            }
                         }
-                        CVCGauge gauge = cvc as CVCGauge;
-                        if (gauge != null)
-                        {
-                            CabViewGaugeRenderer cvgr = new CabViewGaugeRenderer(viewer, car, gauge, _Shader);
-                            cvgr.SortIndex = controlSortIndex;
-                            CabViewControlRenderersList[i].Add(cvgr);
-                            continue;
-                        }
-                        CVCSignal asp = cvc as CVCSignal;
-                        if (asp != null)
-                        {
-                            CabViewDiscreteRenderer aspr = new CabViewDiscreteRenderer(viewer, car, asp, _Shader);
-                            aspr.SortIndex = controlSortIndex;
-                            CabViewControlRenderersList[i].Add(aspr);
-                            continue;
-                        }
-                        CVCMultiStateDisplay multi = cvc as CVCMultiStateDisplay;
-                        if (multi != null)
-                        {
-                            CabViewDiscreteRenderer mspr = new CabViewDiscreteRenderer(viewer, car, multi, _Shader);
-                            mspr.SortIndex = controlSortIndex;
-                            CabViewControlRenderersList[i].Add(mspr);
-                            continue;
-                        }
-                        CVCDiscrete disc = cvc as CVCDiscrete;
-                        if (disc != null)
-                        {
-                            CabViewDiscreteRenderer cvdr = new CabViewDiscreteRenderer(viewer, car, disc, _Shader);
-                            cvdr.SortIndex = controlSortIndex;
-                            CabViewControlRenderersList[i].Add(cvdr);
-                            continue;
-                        }
-                        CVCDigital digital = cvc as CVCDigital;
-                        if (digital != null)
-                        {
-                            CabViewDigitalRenderer cvdr = new CabViewDigitalRenderer(viewer, car, digital, _Shader);
-                            cvdr.SortIndex = controlSortIndex;
-                            CabViewControlRenderersList[i].Add(cvdr);
-                            continue;
-                        }
                     }
                 }
                 i++;


#2 User is offline   hytek1999 

  • Apprentice
  • Group: Status: Switchman
  • Posts: 19
  • Joined: 16-October 12
  • Gender:Male
  • Simulator:MSTS; ORTS
  • Country:

Posted 18 October 2013 - 07:54 PM

Actually, I apologize. The author of the content posted his own fix.

#3 User is offline   captain_bazza 

  • Chairman, Board of Directors
  • PipPipPipPipPipPipPipPipPipPipPip
  • Group: ET Admin
  • Posts: 13,927
  • Joined: 21-February 06
  • Gender:Male
  • Location:Way, way, way, South
  • Simulator:MSTS & OR
  • Country:

Posted 18 October 2013 - 07:57 PM

Is that the 0-4-0T, JACK?

Cheers Bazza

#4 User is offline   hytek1999 

  • Apprentice
  • Group: Status: Switchman
  • Posts: 19
  • Joined: 16-October 12
  • Gender:Male
  • Simulator:MSTS; ORTS
  • Country:

Posted 19 October 2013 - 12:29 PM

 captain_bazza, on 18 October 2013 - 07:57 PM, said:

Is that the 0-4-0T, JACK?

Cheers Bazza


Yep. That's the one. It may not be a bad patch for the devs to add, just to keep it compatible with simple cab views.

#5 User is offline   captain_bazza 

  • Chairman, Board of Directors
  • PipPipPipPipPipPipPipPipPipPipPip
  • Group: ET Admin
  • Posts: 13,927
  • Joined: 21-February 06
  • Gender:Male
  • Location:Way, way, way, South
  • Simulator:MSTS & OR
  • Country:

Posted 19 October 2013 - 09:23 PM

I need to contact Peter, I don't think he has my new email addy.

Thanks for the headsup.

Cheers Bazza

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