diff --git a/src/ai/basictasks/directsuicidetask.cpp b/src/ai/basictasks/directsuicidetask.cpp index 8504d7b8..d73067da 100644 --- a/src/ai/basictasks/directsuicidetask.cpp +++ b/src/ai/basictasks/directsuicidetask.cpp @@ -10,12 +10,12 @@ DirectSuicideTask::DirectSuicideTask(BoardComputer* boardComputer, WorldObject* target) : AiTask(boardComputer), - m_target(target ? target->handle() : Handle()) + m_target(target ? makeHandle(target) : Handle()) { } void DirectSuicideTask::setTarget(WorldObject* target) { - m_target = (target ? target->handle() : Handle()); + m_target = (target ? makeHandle(target) : Handle()); } void DirectSuicideTask::update(float deltaSec) { diff --git a/src/ai/grouptasks/defendareatask.cpp b/src/ai/grouptasks/defendareatask.cpp index f0692f80..9c6164ea 100644 --- a/src/ai/grouptasks/defendareatask.cpp +++ b/src/ai/grouptasks/defendareatask.cpp @@ -47,7 +47,7 @@ void DefendAreaTask::update(float deltaSec) { updatePatrol(); } } - + // update called by the leader himself } } @@ -77,7 +77,7 @@ bool DefendAreaTask::isEnemyInRange() { if (ship) { Faction& enemyFaction = ship->character()->faction(); if (enemyFaction.relationTo(m_squad.leader()->character()->faction()).type() == FactionRelationType::Enemy) { - m_enemies.push_back(worldObject->handle()); + m_enemies.push_back(makeHandle(worldObject)); } else { continue; } diff --git a/src/camera/camerafollowhelper.cpp b/src/camera/camerafollowhelper.cpp index 5f78936d..0671a51e 100644 --- a/src/camera/camerafollowhelper.cpp +++ b/src/camera/camerafollowhelper.cpp @@ -18,7 +18,7 @@ WorldObject* CameraFollowHelper::target() { } void CameraFollowHelper::setTarget(WorldObject* target) { - m_target = target->handle(); + m_target = makeHandle(target); } glm::vec3 CameraFollowHelper::followPosition() { diff --git a/src/equipment/weapons/rocket.cpp b/src/equipment/weapons/rocket.cpp index 483f2d86..52073693 100644 --- a/src/equipment/weapons/rocket.cpp +++ b/src/equipment/weapons/rocket.cpp @@ -65,7 +65,7 @@ WorldObject* Rocket::target() { void Rocket::setTarget(WorldObject* targetObject) { if (targetObject) { - m_targetHandle = targetObject->handle(); + m_targetHandle = makeHandle(targetObject); m_aiTask.reset(new DirectSuicideTask(&m_boardComputer, targetObject)); } else { m_targetHandle = Handle(); diff --git a/src/equipment/weapons/splitrocket.cpp b/src/equipment/weapons/splitrocket.cpp index 4187e8b6..45717f52 100644 --- a/src/equipment/weapons/splitrocket.cpp +++ b/src/equipment/weapons/splitrocket.cpp @@ -38,7 +38,7 @@ SplitRocket::SplitRocket(): void SplitRocket::setTarget(WorldObject* targetObject) { if (targetObject) { - m_targetHandle = targetObject->handle(); + m_targetHandle = makeHandle(targetObject); m_aiTask.reset(new SplitRocketTask(this, &m_boardComputer, targetObject)); } else { m_targetHandle = Handle(nullptr); diff --git a/src/events/aabbenteredpoll.cpp b/src/events/aabbenteredpoll.cpp index b709380d..16670242 100644 --- a/src/events/aabbenteredpoll.cpp +++ b/src/events/aabbenteredpoll.cpp @@ -7,7 +7,7 @@ AABBEnteredPoll::AABBEnteredPoll(WorldObject* worldObject, const AABB& aabb, const Callback& callback): EventPoll(callback), - m_worldObject(worldObject->handle()), + m_worldObject(makeHandle(worldObject)), m_aabb(aabb), m_entered(false) { diff --git a/src/events/aitaskfinishedpoll.cpp b/src/events/aitaskfinishedpoll.cpp index e4e0ced8..4d46d51b 100644 --- a/src/events/aitaskfinishedpoll.cpp +++ b/src/events/aitaskfinishedpoll.cpp @@ -5,7 +5,7 @@ AiTaskFinishedPoll::AiTaskFinishedPoll(AiTask* aitask, const Callback& callback): EventPoll(callback), - m_aiTask(aitask->handle()) + m_aiTask(makeHandle(aitask)) { } diff --git a/src/events/worldobjectdestroyedpoll.cpp b/src/events/worldobjectdestroyedpoll.cpp index 3b454e02..ecfbf8f4 100644 --- a/src/events/worldobjectdestroyedpoll.cpp +++ b/src/events/worldobjectdestroyedpoll.cpp @@ -5,7 +5,7 @@ WorldObjectDestroyedPoll::WorldObjectDestroyedPoll(WorldObject* worldObject, const Callback& callback): EventPoll(callback), - m_worldObject(worldObject->handle()) + m_worldObject(makeHandle(worldObject)) { } diff --git a/src/player.cpp b/src/player.cpp index c50cb036..40c29291 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -44,7 +44,7 @@ Ship* Player::ship() { } void Player::setShip(Ship* ship) { - m_ship = ship->handle(); + m_ship = makeHandle(ship); m_ship->character()->setFaction(World::instance()->factionMatrix().playerFaction()); m_ship->info().setShowOnHud(false); m_cameraDolly->followWorldObject(ship); diff --git a/src/scripting/bindings/aibindings.cpp b/src/scripting/bindings/aibindings.cpp index 0cab2146..42d82835 100644 --- a/src/scripting/bindings/aibindings.cpp +++ b/src/scripting/bindings/aibindings.cpp @@ -162,10 +162,11 @@ int AiBindings::apiAddFightTaskTarget(apikey key, apikey worldObjectKey) { } WorldObject* worldObject = m_scriptEngine.get(worldObjectKey); - if (!worldObject) { return -1; } - + if (!worldObject){ + return -1; + } - fightTask->addTarget(worldObject->handle()); + fightTask->addTarget(makeHandle(worldObject)); return 0; } diff --git a/src/scripting/scriptcallbackimpl.inl b/src/scripting/scriptcallbackimpl.inl index bbba5d8f..5ab5f0b2 100644 --- a/src/scripting/scriptcallbackimpl.inl +++ b/src/scripting/scriptcallbackimpl.inl @@ -15,7 +15,7 @@ void callHelper(ScriptCallbackImpl* callback, const std::string& functi template ScriptCallbackImpl::ScriptCallbackImpl(Script& script, const std::string& function, Args... args): - m_script(script.handle