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
Conversation
src/object_properties.cpp
Outdated
@@ -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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
Shouldn't it be "maximum"? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay for me
While you're at it, could you please also make max. health settable? (this would fix #2246) |
22bb9e6
to
dc2314b
Compare
src/object_properties.cpp
Outdated
glow = readS8(is); | ||
|
||
if (is.good()) { | ||
glow = readS8(is); |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
There was a problem hiding this 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);
@rubenwardy exceptions are slow when triggered, the catching is slow, if not triggered there is no overhead |
* Customizeable maximal breath for players
* Customizeable maximal breath for players
Implements requested feature of #1972.