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

Small cosmetic wind adjustments #2834

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

weluvgoatz
Copy link
Member

This PR makes the wind particles point in the proper direction now, as well as putting wind on a layer behind others so that you can actually grab other objects in the editor when there's wind in the level.

@@ -39,6 +39,8 @@ class SpriteParticle final : public GameObject
int drawing_layer = LAYER_OBJECTS-1, bool notimeout = false, Color color = Color::WHITE);
~SpriteParticle() override;

SpritePtr& get_sprite() { return sprite; }
Copy link
Member

Choose a reason for hiding this comment

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

Why is this a SpritePtr reference?

Copy link
Member Author

Choose a reason for hiding this comment

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

Why not?

Copy link
Member

Choose a reason for hiding this comment

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

You can make this const if you return SpritePtr (which is std::unique_ptr<Sprite>) instead of SpritePtr&. It doesn't change anything.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe Sprite& get_sprite() { return *sprite; } would be better?

Copy link
Member Author

Choose a reason for hiding this comment

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

You can make this const if you return SpritePtr (which is std::unique_ptr<Sprite>) instead of SpritePtr&. It doesn't change anything.

Doing it this way creates many errors.

Copy link
Member

Choose a reason for hiding this comment

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

"creates many errors"...WHAT errors?

Copy link
Member

Choose a reason for hiding this comment

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

It's a unique_ptr, so copy issues I'd assume.

Copy link
Member Author

Choose a reason for hiding this comment

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

Many copies of this:
"error C2280: 'std::unique_ptr<Sprite,std::default_delete>::unique_ptr(const std::unique_ptr<Sprite,std::default_delete> &)': attempting to reference a deleted function"

Copy link
Member

Choose a reason for hiding this comment

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

Or maybe return a SpritePtrinstance by using std::unique_ptr::get()

@tobbi
Copy link
Member

tobbi commented Mar 18, 2024

This will fail if sprite ever is NULL (null dereference).

@tobbi
Copy link
Member

tobbi commented Mar 18, 2024

@mrkubax10 Were you so certain that sprite could never be null that you deref'ed it without checking?

@mrkubax10
Copy link
Member

If you return a pointer instead it will fail in other place.

@tobbi
Copy link
Member

tobbi commented Mar 18, 2024

Not when there's suitable null checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants