Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration to Harmony #1060

Merged
merged 21 commits into from
Apr 10, 2021
Merged

Migration to Harmony #1060

merged 21 commits into from
Apr 10, 2021

Conversation

krzychu124
Copy link
Member

@krzychu124 krzychu124 commented Feb 20, 2021

PR goals

- Delete RedirectionFramework from the project in favor of Harmony patching library

- Improve runtime compatibility on Linux and MacOS #817


  • Remove unused reverse redirections
  • Check, test and reuse Kian's work done for migrating most of Vehicle patches (partial migration of VehicleAI.StartPathFind into harmony. #943, major-feature-harmony2-migration)
  • Rewrite reverse redirections to harmony delegates
  • Rewrite leftover RF redirections to either Harmony prefix, postfix or transpiler

Improvements

  • Fixed double patch causing overwriting CarAI redirection by TrolleybusAI redirection resulting in:
    • ignored Individual driving styles
    • ignored penalties for road conditions (studded tires, wet/damaged road)
    • possible incorrect max speed of vehicles

= to be continued =

  • update issues list

Closes #864
Closes #865
Closes #1063

Latest build

You can find it here!

Compatible Node Controller:
https://github.com/kianzarrin/NodeController/releases/tag/V2.2.4

@krzychu124 krzychu124 added enhancement Improve existing feature high priority Affects lots of users technical Tasks that need to be performed in order to improve quality and maintainability COMPATIBILITY Mod (in)compatibility / checker Harmony labels Feb 20, 2021
@krzychu124 krzychu124 added this to the 11.6.0 milestone Feb 20, 2021
@krzychu124 krzychu124 self-assigned this Feb 20, 2021
@kianzarrin
Copy link
Collaborator

kianzarrin commented Feb 21, 2021

Delete RedirectionFramework from the project in favor of Harmony patching library

is this the continuation of my initiative #865 ? might worth saying fixes 865

@krzychu124
Copy link
Member Author

Delete RedirectionFramework from the project in favor of Harmony patching library

is this the continuation of my initiative #865 ? might worth saying fixes 865

Yes, the plan is to fix all issues regards to harmony and finally forget about Redirection Framework.
I'll try transpiling wherever it is possible or prefix patch if TM:PE changes are too big and transpiling doesn't make sense(further altering the result wouldn't be really "patchable").

@kianzarrin
Copy link
Collaborator

that is a load off my shoulders! thanks!

@kianzarrin
Copy link
Collaborator

we could use reverse patch strategy instead of using static global args struct to pass on arguments
https://discord.com/channels/131466550938042369/361891646742462467/778665308948267048
it is more thread-safe.

But that is too complicated ( I can't understand that code) and if it is hard to understand it is hard to maintain. also not sure if it will be compatible if other people also want to patch the same methods.

@krzychu124
Copy link
Member Author

I'll take a look into it. One thing I found is that on Linux Harmony reverse patches tend to cause issues because it seems that mono runtime on linux is way more aggressive when it comes to method inlining.

I'll go for easiest route to remove Redirection Framework first, then I'll explore potential readability/extensibility improvements.

Personally I think it needs to work the same as before, before we will start improving/refactoring that code.

@breakone9r
Copy link

Tested this last night. Seems like a step in the right direction. It solved some of the issues I've been having on Linux.

- Replaced ParkingAI reverse redirections with fast delegates (IPassengerCarAIConnection)
- Removed unused redirections from CustomCarAI(will be replaced anyways)
- Migrated more than half of all redirection to Harmony (10 types left)
@zubozrout
Copy link

I've only played for a few hours but tried using TM:PE and loaded the game 4 times and so far so good. This work is awesome, thank you @krzychu124.

@krzychu124
Copy link
Member Author

Pretty much everything was migrated, removed obsolete RedirectionFramework submodule.
I'll try to figure out why sometimes TM:PE patch is slightly different than stock code. Usually changes were necessary due to additional features. I need to revisit those Kian's questions in linked issues.

Mod still works, Linux users should finally use the mod without any weird crashes or issues.
I haven't found any regression when it comes to functionality, but performance tests are welcomed.

@krzychu124 krzychu124 added the code cleanup Refactor code, remove old code, improve maintainability label Mar 11, 2021
@krzychu124 krzychu124 changed the base branch from master to testing March 11, 2021 01:23
Copy link
Collaborator

@kvakvs kvakvs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice
Only style comments and struct construction (not sure if a performance warning or not)

TLM/TLM/Custom/PathFinding/CustomPathManager.cs Outdated Show resolved Hide resolved
TLM/TLM/Manager/Impl/AdvancedParkingManager.cs Outdated Show resolved Hide resolved
TLM/TLM/Manager/Impl/AdvancedParkingManager.cs Outdated Show resolved Hide resolved
TLM/TLM/Manager/Impl/AdvancedParkingManager.cs Outdated Show resolved Hide resolved
TLM/TLM/Manager/Impl/AdvancedParkingManager.cs Outdated Show resolved Hide resolved
TLM/TLM/Manager/Impl/ExtPathManager.cs Outdated Show resolved Hide resolved
TLM/TLM/Patch/_TransportLineAI/StartPathFindPatch.cs Outdated Show resolved Hide resolved
@kianzarrin
Copy link
Collaborator

kianzarrin commented Mar 29, 2021

Closes #865

I am not sure if this closes #865 because, we have introduced a lot of prefixes that return false.

I am not sure if it is possible to add prefix/postfix and run through the original code or how important is it to do so.

TLM/TLM/Manager/Impl/ExtPathManager.cs Outdated Show resolved Hide resolved
TLM/TLM/Manager/Impl/ExtPathManager.cs Outdated Show resolved Hide resolved
TLM/TLM/Manager/Impl/ExtPathManager.cs Outdated Show resolved Hide resolved
TLM/TLM/Manager/Impl/ExtPathManager.cs Outdated Show resolved Hide resolved
@krzychu124 krzychu124 merged commit 9f7bb61 into testing Apr 10, 2021
@kianzarrin
Copy link
Collaborator

@krzychu124 is testing branch equivalent to major-feature-branch-harmony ?

@kianzarrin
Copy link
Collaborator

when are you merging to master?

@krzychu124
Copy link
Member Author

I'll wait for your changes and merge master to testing then merge testing back to master and release/testing
The goal is to have master for continuous work(sort of changes container) and release/testing for workshop releases (always working version)

@krzychu124 krzychu124 deleted the improvement/full-harmony-migration branch April 11, 2021 19:12
@DaEgi01
Copy link
Contributor

DaEgi01 commented Apr 12, 2021

so testing = labs?

@krzychu124
Copy link
Member Author

Hmm, maybe "new labs", but I'll remove that branch once merged with master, so there will be master (aka development) and release/test and release/stable for easier change tracking.

@flarn2006
Copy link

I'm getting a crash when I try to toggle traffic lights for a junction while editing an intersection in the asset editor. I haven't tried it without Traffic Manager, or even with Traffic Manager on any release other than the one from this thread, but I just thought I'd mention it because it is a part of the game that I'd expect Traffic Manager to have interactions with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code cleanup Refactor code, remove old code, improve maintainability COMPATIBILITY Mod (in)compatibility / checker enhancement Improve existing feature Harmony high priority Affects lots of users technical Tasks that need to be performed in order to improve quality and maintainability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use Harmony 2 instead of Redirection Framework patch spawn/despawn vehicle using new harmony
7 participants