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

Adding support for content mods #335

Merged
merged 3 commits into from
Nov 24, 2020
Merged

Adding support for content mods #335

merged 3 commits into from
Nov 24, 2020

Conversation

DanielNoord
Copy link
Collaborator

As mentioned in #332 CM currently breaks upon finding an unknown object/upgrade/achievement.
By adding

if (you == undefined) {
   CM.Sim.InitData();
}

CM will now re-initialize the "database" of objects, upgrades and achievements.
This will still produce an initial error in the console, but will then be resolved.

Furthermore, as noticed by @staticvariablejames we currently called CM.Sim.CopyData with every loop.
This call has been moved outside of the loop.

@DanielNoord DanielNoord merged commit 935ce42 into CookieMonsterTeam:dev Nov 24, 2020
@Aktanusa
Copy link
Collaborator

Aktanusa commented Nov 24, 2020

I'll repeat what I said in Issue #332. CM.Sim.CopyData is inside the loop for a good reason. Unless you undo the changes afterward, the calculation for each building afterward is incorrect. Unless I missed something. Please take a look closely.

For example. me.amount += amount; is called on each object once. The data is not reset after an iteration of the for loop. This means for every building calculation afterwards, there is an extra building added.

Another example: CM.Sim.Win('Click'); (or any other CM.Sim.Win()) is called. That achievement has to be removed for the next iteration or else an extra achievement is there incorrectly.

@DanielNoord
Copy link
Collaborator Author

You are indeed correct. I'm sorry I was too quick to judge.
With #338 I have resolved the problem.

@Aktanusa
Copy link
Collaborator

That's okay. Everyone makes mistakes. If you have a question as to why I did something, don't hesitate to ask! I only by chance noticed this one. I sure didn't go through everything.

@DanielNoord
Copy link
Collaborator Author

Besides this edit we have not really changed anything in the way the calculations work, so all should be fine :)

@Aktanusa
Copy link
Collaborator

Aktanusa commented Nov 24, 2020

I was going to add that another reason why I also take a long time is because everything is kind of delicate. Almost everything is in a certain order for a reason. It's good to know nothing else has been changed much. I did notice some change to CalculateGains and that is also a delicate area. Do be careful =).

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

Successfully merging this pull request may close these issues.

2 participants