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

EnumerateSpeedLimits in OnToolGUI .... #1149

Merged
merged 4 commits into from
Aug 28, 2021

Conversation

DaEgi01
Copy link
Contributor

@DaEgi01 DaEgi01 commented Aug 25, 2021

  • Removed SpeedUnit.CurrentlyConfigured because that is not a speed unit.
  • Added GlobalConfig.Main.GetDisplaySpeedUnit() method to get SpeedUnit from user config directly.
  • Added SpeedValue.Unlimited() convenience method for better expressing intent.
  • Removed EnumerateSpeedLimits from OnToolGUI in SpeedLimitsTool.
    The values should be generated once and reused since they don't change during runtime.

- Removed SpeedUnit.CurrentlyConfigured because that is not a speed unit.
- Added GlobalConfig.Main.GetDisplaySpeedUnit() method to get SpeedUnit from user config directly.
- Added SpeedValue.Unlimited() convenience method for better expressing intent.
- Removed EnumerateSpeedLimits from OnToolGUI in SpeedLimitsTool.
  The values should be generated once and reused since they don't change during runtime.
@DaEgi01 DaEgi01 added the performance Make it faster! label Aug 25, 2021
@@ -68,6 +68,8 @@ public static SpeedValue FromMph(ushort mph)
public static SpeedValue FromMph(MphValue mph)
=> new SpeedValue(mph.Mph / ApiConstants.SPEED_TO_MPH);

public static SpeedValue Unlimited() => new SpeedValue(0);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we use speed value 20f as Unlimited (1000 km/h). 0f has some different meaning.

Copy link
Contributor Author

@DaEgi01 DaEgi01 Aug 25, 2021

Choose a reason for hiding this comment

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

Check GetPrevious and GetNext and
SpeedLimitsTool:636 before change
allSpeedLimits.Add(new SpeedValue(0)); // add last item: no limit
Unlimited() is basically a replacement for that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

0 is used to display 🚫 in the speed palette
this is not the same as 20f used as unlimited. And i would prefer unlimited constant to be 20f.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so "no limit" is not the same as "unlimited"?
isn't 🚫 the sign for unlimited speed?
I am confused.

Copy link
Collaborator

Choose a reason for hiding this comment

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

0 is texture index for 🚫
20f is used to set the speed limit to Unlimited
you gave name Unlimited to 0f which is wrong
the value 0f in speed palette should be converted to 20f somewhere in the code, that's the confusing moment.

Copy link
Contributor Author

@DaEgi01 DaEgi01 Aug 25, 2021

Choose a reason for hiding this comment

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

so functions like ToKmphPreciseString are wrong too?
can you show me where this 20f is? can't find it.

Copy link
Collaborator

@kvakvs kvakvs Aug 25, 2021

Choose a reason for hiding this comment

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

SpeedLimitManager::MAX_SPEED = 10f * 2f
SpeedLimitManager::ToGameSpeedLimit() and ::IsValidRange()

Copy link
Member

Choose a reason for hiding this comment

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

From the current master branch

image
and also

image

@DaEgi01 DaEgi01 requested a review from kvakvs August 25, 2021 21:53
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.

I can work with this. Merge away!

@DaEgi01 DaEgi01 merged commit a23edf8 into master Aug 28, 2021
@DaEgi01 DaEgi01 deleted the performance/EnumerateSpeedLimits_in_OnToolGUI branch August 28, 2021 05:02
@originalfoo originalfoo added this to the 11.6.0 milestone Dec 23, 2021
@originalfoo originalfoo modified the milestones: 11.6.0, 11.6.1.1, 11.6.1.2 Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Make it faster!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants