CitiesSkylinesMods / TMPE

Cities: Skylines Traffic Manager: President Edition
https://steamcommunity.com/sharedfiles/filedetails/?id=1637663252
MIT License
576 stars 85 forks source link

V11 - Could not load type 'TrafficManager.Traffic.Data.VehicleState' from assembly 'TrafficManager` #649

Closed SevenQM closed 4 years ago

SevenQM commented 4 years ago

Solution

Unsubscribe / remove the following mods:

  • CSUR_TMPE_Laneconnector_Fix
  • Advanced Junction Rule

Describe the problem

After the V11 update, I entered the game as before, and an error message popped up。 Could not load type 'TrafficManager.Traffic.Data.VehicleState' from assembly 'TrafficManager, Version=1.0.7026.40416, Culture=neutral, PublicKeyToken=null'. [System.TypeLoadException]

Details: No details

I subscribed to the V11LABS version. No other subscriptions. There is no problem returning 10.20. Find solution: subscribe to V11 and subscribe to 10.20, the problem will only disappear when V11 is enabled

Steps to reproduce

  1. This error is caused by V11 update, no other modules are added

Log files

Savegame?

https://steamcommunity.com/sharedfiles/filedetails/?id=1988175689

Screenshots?

Notes or questions?

TMPE.log output_log.txt

krzychu124 commented 4 years ago

@SevenQM as I explained in comments on workshop item , it's the other mod which is dependent on TM:PE.

I suspect it's CSUR_TMPE_Laneconnector_Fix (it's obsolete, according to github page) or more likely Advanced Junction Rule Disable both for now if you want to use v11 version and just wait for update. We can do nothing from our side.

Tagging @pcfantasy

pcfantasy commented 4 years ago

@SevenQM

Both CSUR_TMPE_Laneconnector_Fix and Advanced Junction Rule is obsolete.

CSUR_TMPE_Laneconnector_Fix is never published and it is for CSUR beta3. please use CSUR ToolBox in steam.

Advanced Junction Rule is removed from steam. Please delete it.

originalfoo commented 4 years ago

@pcfantasy Can we incorporate that code (now in the CSUR ToolBox) direct in to TMPE? I assume it's to deal with lane connector issues on nodeless junctions? We have same issue for RWY (Railway) nodeless tracks and a few other networks too...

pcfantasy commented 4 years ago

@aubergine10

Yes, in CheckSegmentsTurningAngle, TMPE will check

if (turningAngle < 1f) { // balabala........................... float dirDotProd = sourceDirection.x targetDirection.x + sourceDirection.z targetDirection.z; return dirDotProd < turningAngle; }

if turningAngle < 1f and dirDotProd > turningAngle; then return false to prevent some lane connectors.

Sometimes for some reasons, asset owner will create some roads which turningAngle is not 1f. So I just return true for all CSUR roads to allow all lane connectors.

pcfantasy commented 4 years ago

@aubergine10

Add codes https://github.com/citiesskylines-csur/CSURToolBox/blob/master/CustomAI/NewLaneConnectorTool.cs

originalfoo commented 4 years ago

@kianzarrin Could you incorporate that in to the stuff you're doing with lane connectors?

kianzarrin commented 4 years ago

@aubergine10 That review is already getting too big and out of hand. I added fix for lane curves on the top of the ModeLaneMarker and SegmentLaneMarker stuff.

why not to do this in a separate pull request. It is not conflicting with my code.

kianzarrin commented 4 years ago

I am on this. I will also fix CSUR toolbox.

EDIT: WAIT IF CSUR wants to be compatible with previous TMPE versions it should check version string right? what version should it check? tagging @aubergine10

kianzarrin commented 4 years ago

Actually Ill just check for existence of : public static bool IsCSUR(NetInfo asset) using reflection or something.

PS: who ever wrote this code has a really wide screan!

                    Loader.Detours.Add(new Loader.Detour(Assembly.Load("TrafficManager").GetType("TrafficManager.UI.SubTools.LaneConnectorTool").GetMethod("CheckSegmentsTurningAngle", BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(ushort), typeof(NetSegment).MakeByRefType(), typeof(bool), typeof(ushort), typeof(NetSegment).MakeByRefType(), typeof(bool) }, null),
                                           typeof(NewLaneConnectorTool).GetMethod("CheckSegmentsTurningAngle", BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(ushort), typeof(NetSegment).MakeByRefType(), typeof(bool), typeof(ushort), typeof(NetSegment).MakeByRefType(), typeof(bool) }, null)));
pcfantasy commented 4 years ago

@kianzarrin

I suggest to return true for all roads.

Why do we need to check turningAngle to allow lane connector for road, only railway need this I think,

kianzarrin commented 4 years ago

@pcfantasy Sometimes for some reasons, asset owner will create some roads which turningAngle is not 1f. So I just return true for all CSUR roads to allow all lane connectors.

Can you please give me an example outside of CSUR?

pcfantasy commented 4 years ago

@victoriacity

Can you help explain something about turningAngle?

victoriacity commented 4 years ago

maxTurningAngle < 90 degrees is necessary for implementing continuous median toggled by traffic lights. For example, when traffic lights are turned off for a T-junction of CSUR roads, the median and markings on the straight road is not broken so that one does not have to plop medians and markings manually to achieve such effect as in vanilla roads.

Specifically, the continuous median is a direct connect node triggered by a connect group (e.g., WideTram and NarrowTram), and most CSUR roads have connect group originally designed for trains and at-grade tram intersections. This leads to the need of setting an acute maxTurningAngle for continuous medians, because the maxTurningAngle is the maximum angle by which the game tries to create direct connect nodes.

Screenshot 251

In vanilla roads, the maxTurningAngle is 90°. This allows for making rail transit networks above or on the road turn at an intersection. In the screenshot above the turning angle of monorail is exactly 90° in the left and slightly larger than 90° in the right. Because the maxTurningAngle is 90°, the monorail is connected through a direct connect road only in the left.

Screenshot 250

Therefore, if the maxTurningAngle=90 is used for continuous median (right road in the above screenshot), one obtains a similar effect as is expected for a monorail/tram intersection. However, in this case the desired effect is the median of the branched road comes to an end right before the intersection (left road in the above screenshot), and this has to be achieved by setting maxTurningAngle < 90. In CSUR roads, we set maxTurningAngle=75 (maxTurningAngleCos=0.2588) to allow for some flexibility in the intersection angle.

Outside of CSUR, the earliest road assets implementing continuous median also have maxTurningAngle < 90, for example: https://steamcommunity.com/sharedfiles/filedetails/?id=1300747514 https://steamcommunity.com/sharedfiles/filedetails/?id=1327917624 https://steamcommunity.com/sharedfiles/filedetails/?id=1319965985

kianzarrin commented 4 years ago

In the situation bellow its possible to select the monorail lanemarker even though it does not go anywhere. (EDIT: original TMPE code)

Screenshot (434)

Screenshot (433)

kianzarrin commented 4 years ago

OK I fixed the issue of the max turning angle. it only applies to tracks now: Screenshot (435) Screenshot (437)

kianzarrin commented 4 years ago

To solve https://github.com/krzychu124/Cities-Skylines-Traffic-Manager-President-Edition/issues/649#issuecomment-583843474 I made exception for unconnected tracks: Screenshot (439) Screenshot (440)

kianzarrin commented 4 years ago

The TMPE side is fixed(shortly will put a pull request) the CSUR should not patch TMPE if the fix is present. One way to do this is to check for TMPE version:

TrafficManagerMod::public const string VERSION = "11.0";

Can I rely on this to be VERSION >= 11.1 EDIT: I am not intending to do string comparison. i will convert it to number first.

pcfantasy commented 4 years ago

@kianzarrin

OK,I will update this too.

originalfoo commented 4 years ago

I think the VERSION needs to be string due to CO API (IUserMod) - could be wrong, been ages since I checked. And we often have versions with -beta1 etc in them.

We could add a separate property to the TrafficManagerMod with some sort of numeric version number?

originalfoo commented 4 years ago

Just realised VERSION isn't part of IUserMod so we can change it to any format we want

@kianzarrin Change it to number but provide some way to include string bolt ons in the stuff that gets shown to user (eg. 11.1-beta1 or 11.0-hotfix)

kianzarrin commented 4 years ago

@aubergine10

Just realised VERSION isn't part of IUserMod so we can change it to any format we want @kianzarrin Change it to number but provide some way to include string bolt ons in the stuff that gets shown to user (eg. 11.1-beta1 or 11.0-hotfix)

I prefer to use Version class.

// usage example
new Version(11.1,blah,blah)
version.ToString(2) //major and minor only
version1 > version2 // it has internal comparison

And I will get Version from AssemblyInfo.cs:

       public static string VersionString => ModVersion.ToString(2);
       public static Version ModVersion => typeof(TrafficManagerMod).Assembly.GetName().Version;

Hopefully no one has used TrafficManagerMod::VERSION externally.

kianzarrin commented 4 years ago

I fixed this issue: The images bellow are produced while CSUR did not patch TMPE. Screenshot (445)

Screenshot (444)

also the log includes:

No need to defer LaneConnectorTool::CheckSegmentsTurningAngle calls

which means new version of TMPE was detected and was not patched.

kianzarrin commented 4 years ago

detecting median is not part of this issue but rather its part of #243 Screenshot (448)

originalfoo commented 4 years ago

A beta is being pushed to LABS page that does not yet contian CSUR fix. The beta will be versioned 11.1.0 (note: build value)

The CSUR update will be in next beta, version 11.1.1. For more details see #687

originalfoo commented 4 years ago

@SevenQM Please let us know if the issue is fixed or not.