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

Vehicle Functions: Update daily #2182

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

duncanspumpkin
Copy link
Contributor

There is some horrible branches in this code. I can't see an easy way to rework it to not be as horrible whilst still matching vanilla logic.

@duncanspumpkin duncanspumpkin force-pushed the updateDaily branch 2 times, most recently from 184202f to a7859fc Compare November 10, 2023 21:31
Copy link
Member

@AaronVanGeffen AaronVanGeffen left a comment

Choose a reason for hiding this comment

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

Comments with respect to code style aside, have you run any replay tests for this yet?

@AaronVanGeffen
Copy link
Member

What's still needed for this PR?

void removeEntityFromThought(AiThought& thought, EntityId id)
{
auto iter = std::find(std::begin(thought.var_66), std::end(thought.var_66), id);
if (iter == std::end(thought.var_66))
Copy link
Contributor

Choose a reason for hiding this comment

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

can we name var_66?

// Original would copy the value from var_66 + 2 which
// would mean it would copy currency var_76 if var_44 was 7
// I don't think that is possible but lets just add an assert.
assert(thought.var_44 < 7);
Copy link
Contributor

Choose a reason for hiding this comment

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

similarly can we name var_44?

crashedTimeout = Math::Bound::add(crashedTimeout, 1U);
if (!CompanyManager::isPlayerCompany(owner))
{
if (crashedTimeout > 14 && var_60 != 0xFF)
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add a constant for the 14, and can we rename var_60?

Copy link
Contributor

@LeftofZen LeftofZen left a comment

Choose a reason for hiding this comment

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

Multiple minor code changes requested. Branch also has merge conflicts

@duncanspumpkin
Copy link
Contributor Author

There is some sort of divergence in this. I've narrowed it down to the loop at L312 or the minReliabilityCount but i can't tell what ive done wrong. I didn't implement it exactly as per the assembly as it looked like there were some easy simplifications.

@@ -312,7 +312,7 @@ namespace OpenLoco::Vehicles
reliabilityFactor /= 16;

auto& prng = gPrng1();
int32_t randVal = (prng.randNext(65535) * reliabilityFactor / 2) / 65536;
int32_t randVal = (prng.randNext(65535) * (reliabilityFactor / 2)) / 65536;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this fix causes replays to diverge as its used by create vehicle as well but i checked and it is how it is meant to work so will record new masters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants