Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign upRework gibbing, refactor damage.h #17243
Conversation
Coolthulhu
added some commits
Jun 18, 2016
This comment has been minimized.
This comment has been minimized.
|
Please check Jently bot error:
|
Coolthulhu
added some commits
Jun 19, 2016
This comment has been minimized.
This comment has been minimized.
|
May possibly fix #17188 since it deals with one possible source of the bug. |
mugling
self-assigned this
Jun 23, 2016
mugling
reviewed
Jun 23, 2016
| @@ -304,7 +304,7 @@ bool gun_actor::call( monster &z ) const | |||
| if( z.friendly ) { | |||
| int max_range = 0; | |||
| for( const auto &e : ranges ) { | |||
| max_range = std::max( { max_range, e.first.first, e.first.second } ); | |||
| max_range = std::max( std::max( max_range, e.first.first ), e.first.second ); | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Coolthulhu
Jun 24, 2016
Author
Contributor
It requires an extra header. It was cleaner to break it up than to include a header just for 3 way max.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Coolthulhu
Jun 24, 2016
Author
Contributor
I think it was <algorithm>. I assume it uses accumulate internally.
http://www.cplusplus.com/reference/algorithm/max/ says max requires algorithm, but they only use the 2 value one. We may have a forward declaration of the 2 argument max somewhere, possibly in the compiler itself.
This comment has been minimized.
This comment has been minimized.
mugling
Jun 24, 2016
Contributor
I'm torn on that. It's not a lightweight header but I suspect we have a build error waiting to happen there given the right combination of platform and compiler.
mugling
reviewed
Jun 23, 2016
| speed( 0 ), range( 0 ), drop( nullptr ), custom_explosion( nullptr ) | ||
| { } | ||
|
|
||
| projectile::~projectile() |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
BevapDin
Jun 24, 2016
Contributor
This could indeed be defaulted, as in projectile::~projectile() = default;. But it has to stay in the cpp file, not the header. If it was in the header, the header would have to include "item.h" as well to allow destroying the item inside of the unique_ptr. The current code allows using this class without having to include "item.h".
mugling
reviewed
Jun 23, 2016
| #include "explosion.h" | ||
| #include "field.h" | ||
|
|
||
| projectile::projectile() : |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
BevapDin
Jun 24, 2016
Contributor
Why? It's just as good here and will result in the same code anyway. And putting it in the header exposes an implementation detail - it's nobodies business what the initial value of private members is.
This comment has been minimized.
This comment has been minimized.
Coolthulhu
Jun 24, 2016
Author
Contributor
Pretty sure pushing it to header would make it necessary to expose the item part of the unique_ptr<item>.
Since damage.h is all over the place, it shouldn't require item.h.
This comment has been minimized.
This comment has been minimized.
mugling
Jun 24, 2016
Contributor
Why?
Reduction in complexity
That said it's impossible to do so as set out in @Coolthulhu's argument
mugling
reviewed
Jun 23, 2016
| { | ||
| } | ||
|
|
||
| projectile::projectile( const projectile &other ) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Coolthulhu
Jun 24, 2016
Author
Contributor
The operator= operates on an item&, meaning it couldn't be pulled up to the header. Inlining a constructor that will then still expand into a function won't help with performance, especially if the compiler realizes the operator= is in the same compilation unit.
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
Same in |
This comment has been minimized.
This comment has been minimized.
|
Also |
This comment has been minimized.
This comment has been minimized.
|
and |
This comment has been minimized.
This comment has been minimized.
|
Compiles correctly after those inclusions |
This comment has been minimized.
This comment has been minimized.
|
Fixes #17188 |
This comment has been minimized.
This comment has been minimized.
|
Didn't complain here (clang 3.6.0) or in Jenkins' version of GCC. Which compiler doesn't like the lack of |
This comment has been minimized.
This comment has been minimized.
|
Coolthulhu commentedJun 18, 2016
"NOGIB" flag was passed around in a weird way. Unlike all other effects, it was a
damage_instancemember. It was also the only usage of said member. Made it use ammo effects instead, since it's much cleaner and more standard.Critter gibbing was happening in 2 places:
monster::explodeandmondeath::normal. This allowed weirdness like monster gibbing and yet leaving a corpse. Now monster can only gib if it leaves no corpse.Finally, refactored
damage.h. It is included all over the place and in headers and will be included even more, so it should be as tiny as possible. Moved projectile-related stuff intoprojectile.h/.cppinstead.This was actually the primary reason for this PR, with gib fixes only being necessary because of the NOGIB weirdness.