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

Cache LHT and RHT shortcut values? #1274

Closed
originalfoo opened this issue Jan 5, 2022 · 6 comments
Closed

Cache LHT and RHT shortcut values? #1274

originalfoo opened this issue Jan 5, 2022 · 6 comments
Labels
low priority Issue with low priority of work technical Tasks that need to be performed in order to improve quality and maintainability

Comments

@originalfoo
Copy link
Member

In Shorcuts.cs we have the following:

internal static bool LHT => Singleton<SimulationManager>.instance.m_metaData.m_invertTraffic == SimulationMetaData.MetaBool.True;
internal static bool RHT => !LHT;

After PR #1273 is merged (assuming it is), the entire codebase will be using those shortcuts, rather than the cumbersome:

Singleton<SimulationManager>.instance.m_metaData.m_invertTraffic == SimulationMetaData.MetaBool.True; // or .False

However, it seems we're going to be calling LHT and RHT huge numbers of times, particularly when overlays are active ...I think?

Would there be any merit to caching the value?

LHT => _lht;
RHT => _rht;

The value can be changed in-game via mods - currently TM:PE is completely unaware of such change.... To keep the cached value fresh, we could maybe detect changes to .m_invertTraffic . Benefit here is that TM:PE will now know if user or a mod changes which side traffic drives on in-game.

That could further develop in to handling such change:

  1. Pause simulation
  2. Clear all traffic (rather than lengthy repath)
  3. Clear any broken traffic customisations
  4. Let user know they should save under new filename, exit to desktop, then reload city, and that most of their customsiations are toast
@originalfoo originalfoo added low priority Issue with low priority of work technical Tasks that need to be performed in order to improve quality and maintainability labels Jan 5, 2022
@kianzarrin
Copy link
Collaborator

I don't agree with this. we don't need to cache LHT. as far as I can tell it is not used in critical part of the code.

In asset editor ppl change LHT/RHT to test their city but it can happen in game too. Obviously previous TMPE rules will not work well but new rules should.

We don't need to maintain multiple code paths for asset/map editor VS game (ppl might want their roads in game too).

@originalfoo
Copy link
Member Author

Ok, I agree about no need to cache.

But if there's change between LHT/RHT are there adverse effects if user doesn't manually clear down the customisations?

If we start seeing proliferation of TMPE customised assets/maps in workshop, and user has their traffic on other side of road, what's going to happen?

@kianzarrin
Copy link
Collaborator

I suspect it will not work out very well! in any case this is another issue.

@originalfoo
Copy link
Member Author

Pls create another issue that describes the LHT/RHT issue in better detail. At the very least we need to make asset/map creators aware of the potential issues should user play with traffic driving on other side.

@kianzarrin
Copy link
Collaborator

maybe it should be part of the persistency issue?

@originalfoo
Copy link
Member Author

yup, if possible that would be awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
low priority Issue with low priority of work technical Tasks that need to be performed in order to improve quality and maintainability
Projects
None yet
Development

No branches or pull requests

2 participants