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

factorize capacity computations #1080

Merged

Conversation

petchema
Copy link
Collaborator

Factorize capacity computations (player carry capacity, wagon hold
capacity, gold dropping into wagon), using floats to avoid rounding down
bugs.
Code that makes horse, wagon and arrows weightless was also factorized.

Gold dropping message was left as-is to preserve Daggerfall classic
behavior; However, when dropping gold into wagon, a post capacity check
was added: if the wagon cannot accomodate the amount, only the gold that
fits is dropped and a message is displayed.

Bug report https://forums.dfworkshop.net/viewtopic.php?f=24&t=1587

I found another bug while factorizing: gold weight was counted twice in
wagon, because it was handled with a special case when the common case
was sufficient.

Factorize capacity computations (player carry capacity, wagon hold
capacity, gold dropping into wagon), using floats to avoid rounding down
bugs.
Code that makes horse, wagon and arrows weightless was also factorized.

Gold dropping message was left as-is to preserve Daggerfall classic
behavior; However, when dropping gold into wagon, a post capacity check
was added: if the wagon cannot accomodate the amount, only the gold that
fits is dropped and a message is displayed.

Bug report https://forums.dfworkshop.net/viewtopic.php?f=24&t=1587

I found another bug while factorizing: gold weight was counted twice in
wagon, because it was handled with a special case when the common case
was sufficient.
DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this);
messageBox.SetText(String.Format(wagonFullGold, wagonCanHold));
messageBox.ClickAnywhereToClose = true;
messageBox.Show();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe you could use this to shorten this boilerplate code for all the MsgBoxes you added:

DaggerfallUI.MessageBox(text);

@ajrb
Copy link
Collaborator

ajrb commented Dec 11, 2018

Excellent work Pango, looks really good.

@ajrb
Copy link
Collaborator

ajrb commented Dec 11, 2018

Perfect, very happy how you sorted the gold weight out.

@Interkarma
Copy link
Owner

Very clever! Thank you. :)

@Interkarma Interkarma merged commit 042edff into Interkarma:master Dec 11, 2018
@petchema petchema deleted the factorize-capacity-computations branch December 23, 2018 08:53
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.

None yet

3 participants