Erabior / RouteManager

Mod for Railroader the game that adds basic automation for passenger routes
12 stars 5 forks source link

V2 - Deferred Alpha 2 - Train bypasses station and halts with "no longer has stations selected" & Potential Null Exception #67

Closed Voidheartd closed 7 months ago

Voidheartd commented 7 months ago

Went to test V2.0 Alpha 1 today. Train was at the coal/water in Whittier with full passenger load from Whittier. Toggled all stations (Whittier, Ela, Bryson, Hemingway, Alarka Jct) then enabled route manager. Train backed up some then went correct direction. Everything but Whittier and Ela were unchecked on passengers cars. I saw and fixed so passengers were not lost. I also unchecked Whittier on route list to attempt to avoid it going back there after Ela. Drove right past Whittier to Ela. Stopped at Ela and never continued after exchanging passengers.

When I saw it wasn't going anywhere I turned route manager off and back on. It proceeded to uncheck everything but Whittier (which was still unchecked on the route manager list) on the passenger cars so I gave up and quit to menu at that point. railloader.log

I decided to give it another try, and moved the train up to Whittier station first. Selected all stations again, and enabled route manager. It immediately unchecked all but Whittier and Ela again. Backed up a little, went forward, and completely ignored Whittier again to go to Ela. When it got to Ela it just sat and never moved again. railloader.log

AdamC1228 commented 7 months ago

I will leave this open but I am under the impression that this is related to #54 but also note the presence of a null reference in the dictionary.

I am leaving this marked as under investigation and will likely revisit after Alpha 2 is ready.

AdamC1228 commented 7 months ago

@Voidheartd Please retest with alpha 2 so we can determine if this needs further attention or if resolving the other known issues has resolved this one as well.

Voidheartd commented 7 months ago

The train was at Ela on the way to Bryson when I loaded Alpha 2, so I set the train for Ela through Alarka. The train immediately drove in reverse all the way past Whittier until I set a fusee to stop it from going on to nowhere. I then completely unchecked route mode and all stations and rechecked them all and then route mode. It set my passenger cars to Whittier only and then drove off (forward this time at least) right past Whittier and Ela. I stopped at this point. There seems to be no recognition of stations. railloader.log

AdamC1228 commented 7 months ago

Seems to be a crash thats causing this. I will have to do some debugging. Please set the logs to trace and reproduce in the mean time.


System.NullReferenceException: Object reference not set to an instance of an object
  at RouteManager.v2.core.AutoEngineer+<locomotiveStationStopControl>d__2.MoveNext () [0x00366] in <be72abcf7f7642c89ac91387cec616df>:0 
  at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00026] in <16292a0376dd4a2e8ff79beef190c0a8>:0 
[02:03:16.37 INF Assembly-CSharp] Found car:  at distance 50.0```
Voidheartd commented 7 months ago

Set logs to trace and ran it through the same scenario starting at Ela and finishing after it ran past Whittier and Ela. railloader.log

AdamC1228 commented 7 months ago

According to your logs here is what happened (please correct where applicable)

  1. Train was at Ella station in the platform
  2. Stations Ella, Bryson, HemingWay, and Alarka Jct were selected
  3. Route Mode was Enabled
  4. Stations got copied to coaches
  5. Train loaded / unloaded at platform
  6. Internal Mod Crash Occurs
Voidheartd commented 7 months ago

That is correct, except for 5. The train does not ever stop at a station. It appears to immediately take off in one direction or another and just keep going.

AdamC1228 commented 7 months ago

That is correct, except for 5. The train does not ever stop at a station. It appears to immediately take off in one direction or another and just keep going.

I am showing that it processed a load / unload at Ela station and a crash following that shortly thereafter. I setup my game and ran a few tests but I'm just not getting the parameters aligned right. Are you able to record yourself reproducing this exact issue so I can setup an identical scenario?

[03:28:06.73 INF RouteManager] 2024-01-07 03:28:06Z - Dispatcher_V2.0.0.3 - DEB: Loco NRR 2 consist empty for current stop
[03:28:06.77 INF RouteManager] 2024-01-07 03:28:06Z - Dispatcher_V2.0.0.3 - DEB: Loco NRR 2 all passengers boarded
[03:28:06.77 INF RouteManager] 2024-01-07 03:28:06Z - Dispatcher_V2.0.0.3 - VER: passengers maximum capacity is 60
[03:28:06.77 INF RouteManager] 2024-01-07 03:28:06Z - Dispatcher_V2.0.0.3 - VER: Locomotive NRR 2 consist has finished loading and unloading at Ela Station
[03:28:06.77 INF RouteManager] 2024-01-07 03:28:06Z - Dispatcher_V2.0.0.3 - TRA: ENTERED FUNCTION: locoLowFuelCheck
[03:28:06.77 INF RouteManager] 2024-01-07 03:28:06Z - Dispatcher_V2.0.0.3 - TRA: ENTERED FUNCTION: compareAgainstMinVal
[03:28:06.77 INF RouteManager] 2024-01-07 03:28:06Z - Dispatcher_V2.0.0.3 - TRA: ENTERED FUNCTION: compareAgainstMinVal
[03:28:06.77 INF RouteManager] 2024-01-07 03:28:06Z - Dispatcher_V2.0.0.3 - TRA: EXITING FUNCTION: compareAgainstMinVal
[03:28:06.77 INF RouteManager] 2024-01-07 03:28:06Z - Dispatcher_V2.0.0.3 - TRA: EXITING FUNCTION: locoLowFuelCheck
[03:28:06.77 ERR Unity] An uncaught exception occured.
System.NullReferenceException: Object reference not set to an instance of an object
  at RouteManager.v2.core.AutoEngineer+<locomotiveStationStopControl>d__2.MoveNext () [0x00366] in <be72abcf7f7642c89ac91387cec616df>:0 
  at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00026] in <16292a0376dd4a2e8ff79beef190c0a8>:0 

The game appears to be crashing after the fuel check but before the next debug statement.

                 if(wasCurrentStopServed(locomotive) && checkFuelQuantities(locomotive))
                    LocoTelem.clearedForDeparture[locomotive] = true;

                //Loco now clear for station departure. 
                if (LocoTelem.clearedForDeparture[locomotive])
                {
                    //Store previous station
                    if(!LocoTelem.previousDestinations[locomotive].Contains(LocoTelem.currentDestination[locomotive]))
                        LocoTelem.previousDestinations[locomotive].Add(LocoTelem.currentDestination[locomotive]);

                    //Notate we are cleared for departure
                    Logger.LogToDebug(String.Format("Locomotive {0} is cleared for departure. Determining next station", locomotive.DisplayName));
Voidheartd commented 7 months ago

If it loads at Ela, it is only the first time when it is already parked there. Once it has left Ela it never stops at a station

Voidheartd commented 7 months ago

Uploaded what happens, with the travel between Whitter and Ela cut out https://youtu.be/CboNKPRWW0E

armyf35 commented 7 months ago

@Voidheartd can you try with the loco facing the opposite direction, rest of the consist shouldn’t matter. Ultimately the goal is for the loco to head towards the east (Sylva) end of the map when told to go forward and towards Andrew’s or Alarka when in reverse

Voidheartd commented 7 months ago

That did allow the train to drive to Ela before stopping and doing nothing else. Why does it have to face that way to work now?

armyf35 commented 7 months ago

https://github.com/Erabior/RouteManager/issues/65#issuecomment-1879599414

The east/west thing is a bug that looks to be fixed later. Not sure about what is causing it to just stop at Ela though… any chance you could upload the save/log from your most recent test and I’ll see if I can find something.

Voidheartd commented 7 months ago

The train backs up, goes forward, backs up again, and then finally goes forward to Ela (started to the west of the Ela station). railloader.log

armyf35 commented 7 months ago

Nothing is jumping out to me so far...

Can you upload the Player.log file and the $SAVENAME.shortsave, I want to see if I can reproduce it more easily.

If you open the help menu and then choose the log folder button it should open the location with those two. The log file will be right there, the save will be inside the Saves folder (You will probably need to zip the save to upload).

Voidheartd commented 7 months ago

save file.zip Player-prev.log

armyf35 commented 7 months ago

One last question... did you modify the config ini file? If so what values did you set?

armyf35 commented 7 months ago

I seem to be able to reproduce the issue by changing my min coal or water levels to a higher value that triggers the min fuel warning. Specifically this section is causing the error https://github.com/Erabior/RouteManager/blob/57dd30c727bb0f31f99b3d5cf2042ff811f04c2f/v2/core/AutoEngineer.cs#L359-L374 An element in LocoTelem.previousDestinations[locomotive] has no DisplayName property if set to default and causes the error.

Voidheartd commented 7 months ago

I only changed the log level to trace, no other changes.

AdamC1228 commented 7 months ago

Appears fixed in the PR by armyf35. Please retest when Alpha 3 is made available.

AdamC1228 commented 7 months ago

@Voidheartd Were you able to confirm any improvements with Alpha 3 (HF1)?

Voidheartd commented 7 months ago

The other issues that came up when testing newer versions have resolved, but I think there are still issues with reenabling the AI. I need to try out interrupting and resuming the AI at different points to simulate stopping for refueling etc.

Voidheartd commented 7 months ago

Removed erroneous comments, dll was wrong version.

Voidheartd commented 7 months ago

On the actual v2-dev as of the merge of #86. Each log file is with fresh start of game.

Train was located at Whittier with passengers loaded. Selected stations Ela, Bryson, Hemingway, and Alarka Jct. Everything but Ela was unchecked on the cars. railloader.log

Next, I repeated the above, except for also checking Whittier on route manager. Train departed Whittier normally. Train was then stopped outside Whitter by going to manual, and then route manager was turned back on. Train returned to Whittier and then was able to depart normally for Ela. Not great behavior but not dumping passengers. railloader.log

I then tried including Whittier again, letting the train get out of Whittier station and stopping manually, but this time unchecking Whittier as a destination before enabling route manager again. The destination was determined to be Bryson, and Ela was unchecked on the cars. railloader.log

Based on this testing there doesn't seem to be a good way to pause and resume route manager that doesn't involve the train driving back to the closest station first (could cause train to proceed afterward in the wrong direction potentially at middle stations? will test later). Including the save that was being used in case it is helpful. save.zip

AdamC1228 commented 7 months ago

Split pausing complaints into separate issue for better tracking.