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

Rework gibbing, refactor damage.h #17243

Merged
merged 5 commits into from Jun 24, 2016

Conversation

Projects
None yet
4 participants
@Coolthulhu
Copy link
Contributor

commented Jun 18, 2016

"NOGIB" flag was passed around in a weird way. Unlike all other effects, it was a damage_instance member. 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::explode and mondeath::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 into projectile.h/.cpp instead.
This was actually the primary reason for this PR, with gib fixes only being necessary because of the NOGIB weirdness.

@illi-kun

This comment has been minimized.

Copy link
Member

commented Jun 19, 2016

Please check Jently bot error:

src/player.cpp:6432:20: error: unused variable 'dealt' [-Werror,-Wunused-variable]
        const auto dealt = deal_damage( nullptr, bp, damage_instance( DT_HEAT, rng( intense, intense * 2 ) ) );
@Coolthulhu

This comment has been minimized.

Copy link
Contributor Author

commented Jun 19, 2016

May possibly fix #17188 since it deals with one possible source of the bug.

@mugling mugling self-assigned this 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.

Copy link
@mugling

mugling Jun 23, 2016

Contributor

why?

This comment has been minimized.

Copy link
@Coolthulhu

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.

Copy link
@mugling

mugling Jun 24, 2016

Contributor

which one out of curiosity?

This comment has been minimized.

Copy link
@Coolthulhu

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.

Copy link
@mugling

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.

speed( 0 ), range( 0 ), drop( nullptr ), custom_explosion( nullptr )
{ }

projectile::~projectile()

This comment has been minimized.

Copy link
@mugling

mugling Jun 23, 2016

Contributor

Why this as opposed to the default destructor?

This comment has been minimized.

Copy link
@BevapDin

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".

#include "explosion.h"
#include "field.h"

projectile::projectile() :

This comment has been minimized.

Copy link
@mugling

mugling Jun 23, 2016

Contributor

Should be specified in the header as default values

This comment has been minimized.

Copy link
@BevapDin

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.

Copy link
@Coolthulhu

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.

Copy link
@mugling

mugling Jun 24, 2016

Contributor

Why?

Reduction in complexity

That said it's impossible to do so as set out in @Coolthulhu's argument

{
}

projectile::projectile( const projectile &other )

This comment has been minimized.

Copy link
@mugling

mugling Jun 23, 2016

Contributor

could (and probably will) be inlined if moved to the header

This comment has been minimized.

Copy link
@Coolthulhu

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.

@mugling

This comment has been minimized.

Copy link
Contributor

commented Jun 24, 2016

src/iuse_actor.cpp:1944:25: error: no member named 'accumulate' in namespace 'std'
@mugling

This comment has been minimized.

Copy link
Contributor

commented Jun 24, 2016

#include <numeric> fixes that

@mugling

This comment has been minimized.

Copy link
Contributor

commented Jun 24, 2016

Same in vehicle.cpp

@mugling

This comment has been minimized.

Copy link
Contributor

commented Jun 24, 2016

Also turret.cpp

@mugling

This comment has been minimized.

Copy link
Contributor

commented Jun 24, 2016

and damage.cpp

@mugling

This comment has been minimized.

Copy link
Contributor

commented Jun 24, 2016

Compiles correctly after those inclusions

@mugling

This comment has been minimized.

Copy link
Contributor

commented Jun 24, 2016

Fixes #17188

@Coolthulhu

This comment has been minimized.

Copy link
Contributor Author

commented Jun 24, 2016

Didn't complain here (clang 3.6.0) or in Jenkins' version of GCC.

Which compiler doesn't like the lack of <numeric>?

@mugling

This comment has been minimized.

Copy link
Contributor

commented Jun 24, 2016

FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
Target: x86_64-unknown-freebsd10.2

@mugling mugling merged commit cab791e into CleverRaven:master Jun 24, 2016

@Coolthulhu Coolthulhu deleted the cataclysmbnteam:damage-projectile-gib branch Jun 29, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.