From: Mikko Rasa Date: Sun, 4 Dec 2022 21:25:40 +0000 (+0200) Subject: Change Owned's constructor to take a pointer to the parent X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=a5be9fabc4c8fb153f2176dfce93874d699f32a0;p=libs%2Fgame.git Change Owned's constructor to take a pointer to the parent This avoids some awkwardness with overload resolution --- diff --git a/examples/bassteroids/source/asteroid.cpp b/examples/bassteroids/source/asteroid.cpp index cb7f954..01b7605 100644 --- a/examples/bassteroids/source/asteroid.cpp +++ b/examples/bassteroids/source/asteroid.cpp @@ -5,5 +5,5 @@ using namespace Msp; Asteroid::Asteroid(Game::Handle p, const AsteroidSetup &s): Hittable(p, s.hittable, s.physical), setup(s), - mesh(*this, setup.mesh) + mesh(this, setup.mesh) { } diff --git a/examples/bassteroids/source/bullet.cpp b/examples/bassteroids/source/bullet.cpp index e26b408..f1bc56b 100644 --- a/examples/bassteroids/source/bullet.cpp +++ b/examples/bassteroids/source/bullet.cpp @@ -4,5 +4,5 @@ using namespace Msp; Bullet::Bullet(Game::Handle p, const Setup &s, const Game::TransformValues &tv): Hittable(p, s.hittable, s.physical, tv), - mesh(*this, s.mesh) + mesh(this, s.mesh) { } diff --git a/examples/bassteroids/source/hittable.cpp b/examples/bassteroids/source/hittable.cpp index 08355f1..5ce5eee 100644 --- a/examples/bassteroids/source/hittable.cpp +++ b/examples/bassteroids/source/hittable.cpp @@ -6,7 +6,7 @@ Hittable::Hittable(Game::Handle p, const Setup &setup, const Physi PhysicalEntity(p, ps, tv) { if(!setup.immortal) - hits = Game::Owned(*this, setup.hits); + hits = Game::Owned(this, setup.hits); if(setup.damaging) - damage = Game::Owned(*this, setup.damage); + damage = Game::Owned(this, setup.damage); } diff --git a/examples/bassteroids/source/physicalentity.cpp b/examples/bassteroids/source/physicalentity.cpp index 85ff0bd..83b3ee2 100644 --- a/examples/bassteroids/source/physicalentity.cpp +++ b/examples/bassteroids/source/physicalentity.cpp @@ -4,8 +4,8 @@ using namespace Msp; PhysicalEntity::PhysicalEntity(Game::Handle p, const Setup &s, const Game::TransformValues &tv): Entity(p, tv), - collider(*this, s.collider) + collider(this, s.collider) { if(!s.fixture) - body = Game::Owned(*this, s.body); + body = Game::Owned(this, s.body); } diff --git a/examples/bassteroids/source/playfield.cpp b/examples/bassteroids/source/playfield.cpp index 8c6cc6c..49eca3b 100644 --- a/examples/bassteroids/source/playfield.cpp +++ b/examples/bassteroids/source/playfield.cpp @@ -15,5 +15,5 @@ Playfield::Playfield(Game::Handle p, const Setup &s): Playfield::Border::Border(Playfield &f, LinAl::Vector p, LinAl::Vector s): setup{ .fixture=true, .body={}, .collider={ .type=ColliderType::BOX, .size=s }}, - entity(f, setup, compose(p, 0.0f)) + entity(&f, setup, compose(p, 0.0f)) { } diff --git a/examples/bassteroids/source/ship.cpp b/examples/bassteroids/source/ship.cpp index 8a4b71d..b9db831 100644 --- a/examples/bassteroids/source/ship.cpp +++ b/examples/bassteroids/source/ship.cpp @@ -5,5 +5,5 @@ using namespace Msp; Ship::Ship(Game::Handle p, const Setup &s): PhysicalEntity(p, s.physical), setup(s), - mesh(*this, s.mesh) + mesh(this, s.mesh) { } diff --git a/source/game/entity.cpp b/source/game/entity.cpp index 8f56f67..3c507a3 100644 --- a/source/game/entity.cpp +++ b/source/game/entity.cpp @@ -13,7 +13,7 @@ Entity::Entity(Handle p, TransformTag): Entity::Entity(Handle p, const TransformValues &tv): parent(p), - transform(*this) + transform(this) { transform->set_values(tv); } diff --git a/source/game/owned.h b/source/game/owned.h index d6f9f17..76a7552 100644 --- a/source/game/owned.h +++ b/source/game/owned.h @@ -22,11 +22,7 @@ public: Owned(Handle

, Args &&...); template - Owned(Owned

&p, Args &&... a): Owned(static_cast &>(p), std::forward(a)...) { } - - template - requires(!std::is_const_v

) - Owned(P &parent, Args &&... args): Owned(Handle

::from_object(&parent), std::forward(args)...) { } + Owned(P *parent, Args &&... args): Owned(Handle

::from_object(parent), std::forward(args)...) { } Owned(Owned &&other): Handle(other) { other.ptr = nullptr; } Owned &operator=(Owned &&other);