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

Customizeable max breath for players #6411

Merged
merged 2 commits into from Sep 15, 2017

Conversation

SmallJoker
Copy link
Member

Implements requested feature of #1972.

@SmallJoker SmallJoker added @ Script API Feature ✨ PRs that add or enhance a feature labels Sep 13, 2017
@@ -153,4 +155,6 @@ void ObjectProperties::deSerialize(std::istream &is)
infotext = deSerializeString(is);
wield_item = deSerializeString(is);
can_zoom = readU8(is);
if (is.good())
breath_max = readU16(is);
Copy link
Member Author

Choose a reason for hiding this comment

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

@nerzhul Is try/catch preferred or is it fine this way?

Copy link
Member

Choose a reason for hiding this comment

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

both ways are good, try catch is easier to use else we will need if (is.good()) on each new read

@C1ffisme
Copy link

Shouldn't it be "maximum"?

@nerzhul nerzhul changed the title Customizeable maximal breath for players Customizeable max breath for players Sep 13, 2017
Copy link
Member

@nerzhul nerzhul left a comment

Choose a reason for hiding this comment

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

Okay for me

@Wuzzy2
Copy link
Contributor

Wuzzy2 commented Sep 13, 2017

While you're at it, could you please also make max. health settable? (this would fix #2246)
Or would that be way too different?

@SmallJoker
Copy link
Member Author

@Wuzzy2 HTTP 303: #6287

Rebasing..

glow = readS8(is);

if (is.good()) {
glow = readS8(is);
Copy link
Member

Choose a reason for hiding this comment

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

why adding glow to the is.good ?

Copy link
Member Author

Choose a reason for hiding this comment

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

glow was added yesterday, where this check was forgotten. I'm moving both into a try/catch to ensure there are no errors. Indeed, is.good is really not suited for these compatibility checks.

Copy link
Member

@rubenwardy rubenwardy left a comment

Choose a reason for hiding this comment

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

Lua code looks good. The C++ does too, however I haven't looked and made sure it's correct.

Exceptions are quite slow, I'm not sure it's worth using it here. Maybe do:

#define GOOD_ELSE_RETURN(is) if (!(is).good()) return

GOOD_ELSE_RETURN(is);
glow = readS8(is);
GOOD_ELSE_RETURN(is);
breath_max = readU16(is);

@nerzhul
Copy link
Member

nerzhul commented Sep 15, 2017

@rubenwardy exceptions are slow when triggered, the catching is slow, if not triggered there is no overhead

@nerzhul nerzhul merged commit edbc533 into minetest:master Sep 15, 2017
@SmallJoker SmallJoker deleted the custom_breath_max branch December 14, 2017 16:00
osjc pushed a commit to osjc/minetest that referenced this pull request Jan 11, 2019
* Customizeable maximal breath for players
osjc pushed a commit to osjc/minetest that referenced this pull request Jan 23, 2019
* Customizeable maximal breath for players
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants